]> git.sesse.net Git - pistorm/blob - platforms/amiga/gayle-ide/ide.h
Merge pull request #6 from shanshe/wip-crap
[pistorm] / platforms / amiga / gayle-ide / ide.h
1 #include <stdint.h>
2
3 #define ACME_ROADRUNNER         1       /* 504MB classic IDE drive */
4 #define ACME_COYOTE             2       /* 20MB early IDE drive */
5 #define ACME_NEMESIS            3       /* 20MB LBA capable drive */
6 #define ACME_ULTRASONICUS       4       /* 40MB LBA capable drive */
7 #define ACME_ACCELLERATTI       5       /* 128MB LBA capable drive */
8 #define ACME_ZIPPIBUS           6       /* 256MB LBA capable drive */
9
10 #define MAX_DRIVE_TYPE          6
11
12 #define         ide_data        0
13 #define         ide_error_r     1
14 #define         ide_feature_w   1
15 #define         ide_sec_count   2
16 #define         ide_sec_num     3
17 #define         ide_lba_low     3
18 #define         ide_cyl_low     4
19 #define         ide_lba_mid     4
20 #define         ide_cyl_hi      5
21 #define         ide_lba_hi      5
22 #define         ide_dev_head 6
23 #define         ide_lba_top     6
24 #define         ide_status_r    7
25 #define         ide_command_w   7
26 #define         ide_altst_r     8
27 #define         ide_devctrl_w   8
28 #define         ide_data_latch  9
29
30 struct ide_taskfile {
31   uint16_t data;
32   uint8_t error;
33   uint8_t feature;
34   uint8_t count;
35   uint8_t status;
36   uint8_t command;
37   uint8_t devctrl;
38   struct ide_drive *drive;
39 };
40
41 struct ide_drive {
42   struct ide_controller *controller;
43   struct ide_taskfile taskfile;
44   unsigned int present:1, intrq:1, failed:1, lba:1, eightbit:1;
45   uint16_t cylinders;
46   uint8_t heads, sectors;
47   uint8_t data[512];
48   uint16_t identify[256];
49   uint8_t *dptr;
50   int state;
51   int fd;
52   off_t offset;
53   int length;
54   uint8_t header_present;
55 };
56
57 struct ide_controller {
58   struct ide_drive drive[2];
59   int selected;
60   const char *name;
61   uint16_t data_latch;
62   uint8_t lba1;
63   uint8_t lba2;
64   uint8_t lba3;
65   uint8_t lba4;
66 };
67
68 //extern ide_controller idectrl;
69 extern const uint8_t ide_magic[9];
70
71 void ide_reset_begin(struct ide_controller *c);
72 uint8_t ide_read8(struct ide_controller *c, uint8_t r);
73 void ide_write8(struct ide_controller *c, uint8_t r, uint8_t v);
74 uint16_t ide_read16(struct ide_controller *c, uint8_t r);
75 void ide_write16(struct ide_controller *c, uint8_t r, uint16_t v);
76 uint8_t ide_read_latched(struct ide_controller *c, uint8_t r);
77 void ide_write_latched(struct ide_controller *c, uint8_t r, uint8_t v);
78
79 struct ide_controller *ide_allocate(const char *name);
80 int ide_attach(struct ide_controller *c, int drive, int fd);
81 int ide_attach_hdf(struct ide_controller *c, int drive, int fd);
82 int ide_make_ident(uint16_t c, uint8_t h, uint8_t s, char *name, uint16_t *target);
83 void ide_detach(struct ide_drive *d);
84 void ide_free(struct ide_controller *c);
85
86 int ide_make_drive(uint8_t type, int fd);