-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathxthdc.h
61 lines (51 loc) · 1.34 KB
/
xthdc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef _XTHDC_H
#define _XTHDC_H
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <limits.h>
#include "io.h"
#include "fe2010.h"
/* Hard disk C/H/S always set to 20MB Western Digital 93024-X */
#define DISK_CYLINDERS 615
#define DISK_HEADS 4
#define DISK_SECTORS 17
#define DISK_SECTOR_SIZE 512
#define DISK_SIZE (DISK_CYLINDERS * \
DISK_HEADS * \
DISK_SECTORS * \
DISK_SECTOR_SIZE)
typedef enum {
XTHDC_STATE_IDLE,
XTHDC_STATE_COMMAND,
XTHDC_STATE_COMMAND_PARAM_1,
XTHDC_STATE_COMMAND_PARAM_2,
XTHDC_STATE_COMMAND_PARAM_3,
XTHDC_STATE_COMMAND_PARAM_4,
XTHDC_STATE_COMMAND_PARAM_5,
XTHDC_STATE_INITIALIZE_DRIVE,
XTHDC_STATE_READ_SECTOR,
XTHDC_STATE_STATUS,
} xthdc_state_t;
typedef struct xthdc_s {
xthdc_state_t state;
uint8_t status;
uint8_t mask;
uint8_t config;
uint8_t command[6];
uint8_t command_status;
uint8_t drive;
uint16_t cylinder;
uint8_t head;
uint8_t sector;
uint16_t byte_no;
bool loaded;
char loaded_filename[PATH_MAX];
uint8_t data[DISK_SIZE];
fe2010_t* fe2010;
} xthdc_t;
void xthdc_init(xthdc_t *xthdc, io_t *io, fe2010_t *fe2010);
void xthdc_trace_dump(FILE *fh);
int xthdc_image_load(xthdc_t *xthdc, const char *filename);
int xthdc_image_save(xthdc_t *xthdc, const char *filename);
#endif /* _XTHDC_H */