2 * Copyright 2002/03, Thomas Kurschel. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 #ifndef __ATA_TYPES_H__
6 #define __ATA_TYPES_H__
10 #include <lendian_bitfield.h>
14 // contains the command block interpreted under different conditions with
15 // first byte being first command register, second byte second command register
16 // etc.; for lba48, registers must be written twice, therefore there
17 // are twice as many bytes as registers - the first eight bytes are those
18 // that must be written first, the second eight bytes are those that
19 // must be written second.
59 uint8 byte_count_8_15
;
79 cmd_or_data
: 1, // 1 - cmd, 0 - data
80 input_or_output
: 1, // 0 - input (to device), 1 - output
86 uint8 byte_count_8_15
;
106 B_LBITFIELD8_4( // only <tag> is defined for write
107 cmd_or_data
: 1, // 1 - cmd, 0 - data
108 input_or_output
: 1, // 0 - input (to device), 1 - output
125 uint8 sector_count_0_7
;
138 uint8 sector_count_8_15
;
145 uint8 sector_count_0_7
;
147 cmd_or_data
: 1, // 1 - cmd, 0 - data
148 input_or_output
: 1, // 0 - input (to device), 1 - output
163 uint8 sector_count_8_15
;
192 typedef union ata_task_file ata_task_file
;
194 // content of "mode" field
200 // mask for ata_task_file fields to be written
202 ATA_MASK_FEATURES
= 0x01,
203 ATA_MASK_SECTOR_COUNT
= 0x02,
206 ATA_MASK_SECTOR_NUMBER
= 0x04,
207 ATA_MASK_CYLINDER_LOW
= 0x08,
208 ATA_MASK_CYLINDER_HIGH
= 0x10,
211 ATA_MASK_LBA_LOW
= 0x04,
212 ATA_MASK_LBA_MID
= 0x08,
213 ATA_MASK_LBA_HIGH
= 0x10,
216 ATA_MASK_BYTE_COUNT
= 0x18,
218 // packet and dma queued result
219 ATA_MASK_ERROR
= 0x01,
220 ATA_MASK_INTERRUPT_REASON
= 0x02,
222 ATA_MASK_DEVICE_HEAD
= 0x20,
223 ATA_MASK_COMMAND
= 0x40,
225 ATA_MASK_STATUS
= 0x40,
227 // for 48 bits, the following flags tell which registers to load twice
228 ATA_MASK_FEATURES_48
= 0x80 | ATA_MASK_FEATURES
,
229 ATA_MASK_SECTOR_COUNT_48
= 0x100 | ATA_MASK_SECTOR_COUNT
,
230 ATA_MASK_LBA_LOW_48
= 0x200 | ATA_MASK_LBA_LOW
,
231 ATA_MASK_LBA_MID_48
= 0x400 | ATA_MASK_LBA_MID
,
232 ATA_MASK_LBA_HIGH_48
= 0x800 | ATA_MASK_LBA_HIGH
,
239 ATA_STATUS_ERROR
= 0x01, // error
240 ATA_STATUS_INDEX
= 0x02, // obsolete
241 ATA_STATUS_CORR
= 0x04, // obsolete
242 ATA_STATUS_DATA_REQUEST
= 0x08, // data request
243 ATA_STATUS_DSC
= 0x10, // reserved
244 ATA_STATUS_SERVICE
= 0x10, // ready to service device
245 ATA_STATUS_DWF
= 0x20, // reserved
246 ATA_STATUS_DMA
= 0x20, // reserved
247 ATA_STATUS_DMA_READY
= 0x20, // packet: DMA ready
248 ATA_STATUS_DEVICE_FAULT
= 0x20, // device fault
249 ATA_STATUS_DEVICE_READY
= 0x40, // device ready
250 ATA_STATUS_BUSY
= 0x80 // busy
253 // device control register (ATA command block)
255 // bit 0 must be zero
256 ATA_DEVICE_CONTROL_DISABLE_INTS
= 0x02, // disable INTRQ
257 ATA_DEVICE_CONTROL_SOFT_RESET
= 0x04, // software device reset
258 ATA_DEVICE_CONTROL_BIT3
= 0x08, // obsolete. Must always be set
259 // bits inbetween are reserved
260 ATA_DEVICE_CONTROL_HIGH_ORDER_BYTE
= 0x80 // read high order byte
264 // error register - most bits are command specific
267 ATA_ERROR_ABORTED
= 0x04, // command aborted
269 // used for Ultra DMA modes
270 ATA_ERROR_INTERFACE_CRC
= 0x80, // interface CRC error
272 // used by reading data transfers
273 ATA_ERROR_UNCORRECTABLE
= 0x40, // uncorrectable data error
274 // used by writing data transfers
275 ATA_ERROR_WRITE_PROTECTED
= 0x40, // media write protect
277 // used by all data transfer commands
278 ATA_ERROR_MEDIUM_CHANGED
= 0x20, // medium changed
279 ATA_ERROR_INVALID_ADDRESS
= 0x10, // invalid CHS address
280 ATA_ERROR_MEDIA_CHANGE_REQUESTED
= 0x08, // media change requested
281 ATA_ERROR_NO_MEDIA
= 0x02, // no media
286 typedef struct ata_channel_info
*ata_channel_cookie
;
288 #endif /* __ATA_TYPES_H__ */