MicrOS
harddisk_pio_mode_header.h
Go to the documentation of this file.
1 #ifndef HARDDISK_PIO_MODE_HEADER
2 #define HARDDISK_PIO_MODE_HEADER
3 
4 #include <stdint.h>
5 
6 // This OS currently use LBA 48bit for handling hard disks.
7 
8 // Ports
9 
11 
12 #define HARDDISK_ATA_PRIMARY_BUS_IO_PORT 0x1F0
13 
15 
16 #define HARDDISK_ATA_PRIMARY_BUS_CONTROL_PORT 0x3F6
17 
19 
20 #define HARDDISK_ATA_SECONDARY_BUS_IO_PORT 0x170
21 
23 
24 #define HARDDISK_ATA_SECONDARY_BUS_CONTROL_PORT 0x376
25 
26 // Registers offsets
27 
29 
32 #define HARDDISK_IO_DATA_REGISTER_OFFSET 0
33 
35 
38 #define HARDDISK_IO_ERROR_REGISTER_OFFSET 1
39 
41 
44 #define HARDDISK_FEATURES_REGISTER_OFFSET 1
45 
47 
50 #define HARDDISK_IO_SECTOR_COUNT_REGISTER_OFFSET 2
51 
53 
56 #define HARDDISK_IO_SECTOR_NUMBER_REGISTER_OFFSET 3
57 
59 
62 #define HARDDISK_IO_CYLINDER_LOW_REGISTER_OFFSET 4
63 
65 
68 #define HARDDISK_IO_CYLINDER_HIGH_REGISTER_OFFSET 5
69 
71 
74 #define HARDDISK_IO_DRIVE_HEAD_REGISTER_OFFSET 6
75 
77 
80 #define HARDDISK_IO_STATUS_REGISTER_OFFSET 7
81 
83 
86 #define HARDDISK_IO_COMMAND_REGISTER_OFFSET 7
87 
89 
92 #define HARDDISK_CONTROL_ALTERNATE_STATUS_REGISTER_OFFSET 0
93 
95 
98 #define HARDDISK_CONTROL_DEVICE_CONTROL_REGISTER_OFFSET 0
99 
101 
104 #define HARDDISK_CONTROL_DEVICE_ADDRESS_REGISTER_OFFSET 1
105 
106 // Structs
107 
109 
111 {
113  uint8_t unused;
117  uint8_t track_zero_not_found : 1;
119  uint8_t aborted_command : 1;
121  uint8_t media_change_request : 1;
123  uint8_t id_not_found : 1;
125  uint8_t media_changed : 1;
129  uint8_t bad_block_detected : 1;
131 
133 
135 {
139  uint16_t value;
141 
143 
145 {
149  uint8_t drive_number : 1;
151  uint8_t always_set_field_1 : 1;
153  uint8_t uses_lba : 1;
155  uint8_t always_set_field_2 : 1;
157 
159 
161 {
165  uint8_t value;
166 
168 
170 
176 {
178  uint8_t error_occurred : 1;
180  uint8_t index : 1;
182  uint8_t corrected_data : 1;
184  uint8_t drive_ready : 1;
188  uint8_t drive_fault_error : 1;
190  uint8_t ready : 1;
192  uint8_t busy : 1;
194 
196 
202 {
206  uint8_t value;
208 
210 
216 {
218  uint8_t always_clear_field_1 : 1;
222  uint8_t software_reset : 1;
224  uint8_t reserved_field_4 : 1;
226  uint8_t reserved_field_3 : 1;
228  uint8_t reserved_field_2 : 1;
230  uint8_t reserved_field_1 : 1;
232  uint8_t high_order_byte_read : 1;
234 
236 
242 {
246  uint8_t value;
248 
250 
252 {
254  uint8_t select_drive_0 : 1;
256  uint8_t select_drive_1 : 1;
258  uint8_t selected_head : 1;
260  uint8_t write_gate : 1;
264 
266 
268 {
272  uint8_t value;
274 
275 #endif
uint16_t value
Value of this union.
Definition: harddisk_pio_mode_header.h:139
uint8_t value
Value of this union.
Definition: harddisk_pio_mode_header.h:206
uint8_t busy
Indicates the drive is preparing to send/receive data (wait for it to clear). In case of &#39;hang&#39; (it n...
Definition: harddisk_pio_mode_header.h:192
Hard disk I/O based Error Register.
Definition: harddisk_pio_mode_header.h:134
uint8_t index
Index. Always set to zero. (short: IDX).
Definition: harddisk_pio_mode_header.h:180
uint8_t value
Value of this union.
Definition: harddisk_pio_mode_header.h:246
uint8_t drive_number
Selects the drive number (short: DRV).
Definition: harddisk_pio_mode_header.h:149
uint8_t stop_sending_interrupts
Set this to stop the current device from sending interrupts (short: nIEN).
Definition: harddisk_pio_mode_header.h:220
uint8_t drive_fault_error
Drive Fault Error (does not set ERR). (short: DF).
Definition: harddisk_pio_mode_header.h:188
uint8_t value
Value of this union.
Definition: harddisk_pio_mode_header.h:272
uint8_t id_not_found
ID not found (short: IDNF).
Definition: harddisk_pio_mode_header.h:123
uint8_t select_drive_1
Drive 1 select. Clears when drive 1 selected (short: DS1).
Definition: harddisk_pio_mode_header.h:256
uint8_t overlapped_mode_service_request
Overlapped Mode Service Request. (short: SRV).
Definition: harddisk_pio_mode_header.h:186
uint8_t media_changed
Media changed (short: MC).
Definition: harddisk_pio_mode_header.h:125
uint8_t uses_lba
Uses CHS addressing if clear or LBA addressing if set (short: LBA).
Definition: harddisk_pio_mode_header.h:153
harddisk_control_device_control_register_fields fields
Fields of this union.
Definition: harddisk_pio_mode_header.h:244
uint8_t select_drive_0
Drive 0 select. Clears when drive 0 selected (short: DS0).
Definition: harddisk_pio_mode_header.h:254
uint8_t always_set_field_2
Always set.
Definition: harddisk_pio_mode_header.h:155
uint8_t error_occurred
Indicates an error occurred. Send a new command to clear it (or nuke it with a Software Reset)...
Definition: harddisk_pio_mode_header.h:178
uint8_t corrected_data
Corrected data. Always set to zero. (short: CORR).
Definition: harddisk_pio_mode_header.h:182
uint8_t high_order_byte_read
Set this to read back the High Order Byte of the last LBA48 value sent to an IO port (short: HOB)...
Definition: harddisk_pio_mode_header.h:232
uint8_t unused
Unused.
Definition: harddisk_pio_mode_header.h:113
Hard disk I/O based Drive / Head Register.
Definition: harddisk_pio_mode_header.h:160
uint8_t reserved_field_4
Reserved, set to zero.
Definition: harddisk_pio_mode_header.h:224
uint8_t always_clear_field_1
Always set to zero.
Definition: harddisk_pio_mode_header.h:218
uint8_t drive_ready
Set when the drive has PIO data to transfer, or is ready to accept PIO data. (short: DRQ)...
Definition: harddisk_pio_mode_header.h:184
uint8_t media_change_request
Media change request (short: MCR).
Definition: harddisk_pio_mode_header.h:121
uint8_t aborted_command
Aborted command (short: ABRT).
Definition: harddisk_pio_mode_header.h:119
Hard disk Control based Drive Address Register.
Definition: harddisk_pio_mode_header.h:267
uint8_t always_set_field_1
Always set.
Definition: harddisk_pio_mode_header.h:151
uint8_t reserved_field_3
Reserved, set to zero.
Definition: harddisk_pio_mode_header.h:226
Hard disk Control based Device Control Register.
Definition: harddisk_pio_mode_header.h:215
uint8_t address_mark_not_found
Address mark not found (short: AMNF).
Definition: harddisk_pio_mode_header.h:115
uint8_t software_reset
Set, then clear (after 5us), this to do a "Software Reset" on all ATA drives on a bus...
Definition: harddisk_pio_mode_header.h:222
uint8_t write_gate
Write gate; goes low while writing to the drive is in progress (short: WTG).
Definition: harddisk_pio_mode_header.h:260
uint8_t reserved_for_floppy_controllers
Reserved for compatibility with floppy drive controllers which may use this bit.
Definition: harddisk_pio_mode_header.h:262
uint8_t selected_head
One&#39;s compliment representation of the currently selected head (short: HS0 - HS3).
Definition: harddisk_pio_mode_header.h:258
harddisk_control_drive_address_register_fields fields
Fields of this union.
Definition: harddisk_pio_mode_header.h:270
harddisk_io_error_register_fields fields
Fields of this union.
Definition: harddisk_pio_mode_header.h:137
uint8_t reserved_field_1
Reserved, set to zero.
Definition: harddisk_pio_mode_header.h:230
Hard disk Control based Drive Address Register.
Definition: harddisk_pio_mode_header.h:251
Hard disk I/O or Control based Status Register.
Definition: harddisk_pio_mode_header.h:201
uint8_t ready
Bit is clear when drive is spun down, or after an error. Set otherwise. (short: RDY).
Definition: harddisk_pio_mode_header.h:190
uint8_t bad_block_detected
Bad Block detected (short: BBK).
Definition: harddisk_pio_mode_header.h:129
Hard disk I/O based Error Register.
Definition: harddisk_pio_mode_header.h:110
harddisk_io_drive_head_register_fields fields
Fields of this union.
Definition: harddisk_pio_mode_header.h:163
uint8_t chs_head_lba_block_number
In CHS addressing, bits 0 to 3 of the head. In LBA addressing, bits 24 to 27 of the block number...
Definition: harddisk_pio_mode_header.h:147
uint8_t track_zero_not_found
Track zero not found (short: TKZNF).
Definition: harddisk_pio_mode_header.h:117
Hard disk Control based Device Control Register.
Definition: harddisk_pio_mode_header.h:241
uint8_t reserved_field_2
Reserved, set to zero.
Definition: harddisk_pio_mode_header.h:228
uint8_t value
Value of this union.
Definition: harddisk_pio_mode_header.h:165
harddisk_io_control_status_register_fields fields
Fields of this union.
Definition: harddisk_pio_mode_header.h:204
Hard disk I/O based Drive / Head Register.
Definition: harddisk_pio_mode_header.h:144
uint8_t uncorrectable_data_error
Uncorrectable data error (short: UNC).
Definition: harddisk_pio_mode_header.h:127
Hard disk I/O or Control based Status Register.
Definition: harddisk_pio_mode_header.h:175