#include <IOKit/ata/IOATATypes.h>
IOKit/ata/IOATATypes.h Kernel.framework 22 macros · 18 enums · 3 structs · 3 typedefs
@header IOATAtypes.h
@discussion contains various definitions and constants for use in the IOATAFamily and clients. Header Doc is incomplete at this point, but file is heavily commented.
property strings
#define kATADevPropertyKey "ata device type" #define kATATypeATAString "ata" #define kATATypeATAPIString "atapi" #define kATATypeUnknownString "unknown" #define kATAVendorPropertyKey "device model" #define kATARevisionPropertyKey "device revision" #define kATASerialNumPropertyKey "device serial" #define kATAUnitNumberKey "unit number" #define kATASocketKey "socket type" #define kATAInternalSocketString "internal" #define kATAPCCardSocketString "pccard" #define kATAInternalSATAString "serial-ata" #define kATASATABayString "sata-bay" #define kATAInternalSATA2 "serial-ata-2" #define kATASATA2BayString "sata-2-bay" #define kATAUnkownSocketString "unknown" #define kATANotifyOnChangeKey "media-notify" allows for porting to non-memory-mapped IO systems, such as x86.
for such a platform, create a class and overload the assignment operators
so that the correct IO operation is performed and define the type for that architecture port.
#define IOATARegPtr8 volatile UInt8 * #define IOATARegPtr16 volatile UInt16 * #define IOATARegPtr32 volatile UInt32 * underlying type unsigned int
kUnknownSocket 0 kInternalATASocket 1 kMediaBaySocket 2 kPCCardSocket 3 kInternalSATA 4 kSATABay 5 kInternalSATA2 6 kSATA2Bay 7
underlying type unsigned int
kUnknownATADeviceType 0 kATADeviceType 1 kATAPIDeviceType 2
enum for bits 5 and 6 of word zero of
the identify packet device info data.
shift word-0 5-bits left, mask 0x03 and these enums apply.
underlying type unsigned int
kATAPIDRQSlow 0 kATAPIIRQPacket 1 kATAPIDRQFast 16 kATAPIUnknown 17
underlying type int
kATAInvalidDeviceID -1 kATADevice0DeviceID 0 aka, Primary. Device 0 is the correct terminology kATADevice1DeviceID 1 aka, Secondary. Device 1 is the correct terminology
underlying type unsigned int
Task file definition *** Error Register ***
underlying type unsigned int
bATABadBlock 7 bit number of bad block error bit bATAUncorrectable 6 bit number of uncorrectable error bit bATAMediaChanged 5 bit number of media changed indicator bATAIDNotFound 4 bit number of ID not found error bit bATAMediaChangeReq 3 bit number of media changed request bATACommandAborted 2 bit number of command abort bit bATATrack0NotFound 1 bit number of track not found bATAAddressNotFound 0 bit number of address mark not found mATABadBlock 128 Bad Block Detected mATAUncorrectable 64 Uncorrectable Data Error mATAMediaChanged 32 Media Changed Indicator (for removable) mATAIDNotFound 16 ID Not Found mATAMediaChangeReq 8 Media Change Requested (NOT IMPLEMENTED) mATACommandAborted 4 Aborted Command mATATrack0NotFound 2 Track 0 Not Found mATAAddressNotFound 1 Address Mark Not Found
Task file definition *** Features register ***
underlying type unsigned int
bATAPIuseDMA 0 bit number of useDMA bit (ATAPI) mATAPIuseDMA 1
Task file definition *** ataTFSDH Register ***
underlying type unsigned int
mATAHeadNumber 15 Head Number (bits 0-3) mATASectorSize 160 bit 7=1; bit 5 = 01 (512 sector size) <DP4> mATADriveSelect 16 Drive (0 = primary, 1 = secondary) mATALBASelect 64 LBA mode bit (0 = chs, 1 = LBA)
Task file definition *** Status Register ***
underlying type unsigned int
bATABusy 7 bit number of BSY bit bATADriveReady 6 bit number of drive ready bit bATAWriteFault 5 bit number of write fault bit bATASeekComplete 4 bit number of seek complete bit bATADataRequest 3 bit number of data request bit bATADataCorrected 2 bit number of data corrected bit bATAIndex 1 bit number of index mark bATAError 0 bit number of error bit mATABusy 128 Unit is busy mATADriveReady 64 Unit is ready mATAWriteFault 32 Unit has a write fault condition mATASeekComplete 16 Unit seek complete mATADataRequest 8 Unit data request mATADataCorrected 4 Data corrected mATAIndex 2 Index mark - NOT USED mATAError 1 Error condition - see error register
Task file definition *** Device Control Register ***
underlying type unsigned int
bATADCROne 3 bit number of always one bit bATADCRReset 2 bit number of reset bit bATADCRnIntEnable 1 bit number of interrupt disable mATADCROne 8 always one bit mATADCRReset 4 Reset (1 = reset) mATADCRnIntEnable 2 Interrupt Disable(0 = enabled)
'ataRegMask' field of the ataRegAccess definition
underlying type unsigned int
bATAAltSDevCValid 14 bit number of alternate status/device cntrl valid bit bATAStatusCmdValid 7 bit number of status/command valid bit bATASDHValid 6 bit number of ataTFSDH valid bit bATACylinderHiValid 5 bit number of cylinder high valid bit bATACylinderLoValid 4 bit number of cylinder low valid bit bATASectorNumValid 3 bit number of sector number valid bit bATASectorCntValid 2 bit number of sector count valid bit bATAErrFeaturesValid 1 bit number of error/features valid bit bATADataValid 0 bit number of data valid bit mATAAltSDevCValid 16384 alternate status/device control valid mATAStatusCmdValid 128 status/command valid mATASDHValid 64 ataTFSDH valid mATACylinderHiValid 32 cylinder high valid mATACylinderLoValid 16 cylinder low valid mATASectorNumValid 8 sector number valid mATASectorCntValid 4 sector count valid mATAErrFeaturesValid 2 error/features valid mATADataValid 1 data valid
underlying type unsigned int
bATAFlagQuiesce 20 bATAFlagNoIRQ 19 bit Number of no IRQ protocol flag bATAFlag48BitLBA 18 bATAFlagDMAQueued 17 bATAFlagOverlapped 16 bATAFlagUseConfigSpeed 15 bit number of use configured speed flag bATAFlagByteSwap 14 bit number of byte swap flag bATAFlagIORead 13 bit number of I/O read flag bATAFlagIOWrite 12 bit number of I/O write flag bATAFlagTFAccessResult 8 bit number of get register results on command completion. bATAFlagUseDMA 7 bit number of use DMA flag bATAFlagProtocolATAPI 5 bit number of ATAPI protocol bATAFlagImmediate 1 bit number of immediate flag bATAFlagTFAccess 0 bit number of TF access mATAFlagQuiesce 1048576 mATAFlagUseNoIRQ 524288 Special purpose! Avoid using! No-IRQ, polled synchronous protocol valid only for PIO commands mATAFlag48BitLBA 262144 Use 48 bit extended LBA protocol on this command. Requires support from the controller. mATAFlagDMAQueued 131072 Use tagged dma queuing protocol on this command. Requires support from the controller. mATAFlagOverlapped 65536 Use overllaped protocol on this command. Requires support from the controller. mATAFlagUseConfigSpeed 32768 Use the configured interface speed = true. False = use default PIO (slow) speed. valid only for PIO commands mATAFlagByteSwap 16384 Swap data bytes (read - after; write - before) mATAFlagIORead 8192 Read (in) operation mATAFlagIOWrite 4096 Write (out) operation mATAFlagTFAccessResult 256 get contents of TaskFile registers indicated in TFMask on command completion, even if no error mATAFlagUseDMA 128 mATAFlagProtocolATAPI 32 ATAPI protocol indicator mATAFlagImmediate 2 Put command at head of queue mATAFlagTFAccess 1 Return Taskfile on error status
The Function codes sent to controllers
underlying type unsigned int
kATANoOp 0 kATAFnExecIO 1 Execute ATA I/O kATAPIFnExecIO 2 ATAPI I/O kATAFnRegAccess 3 Register Access kATAFnQFlush 4 I/O Queue flush requests for your unit number kATAFnBusReset 5 Reset ATA bus
The ATA Event codes
sent when calling the device driver's event handler
underlying type unsigned int
kATANullEvent 0 Just kidding -- nothing happened kATAOnlineEvent 1 An ATA device has come online kATAOfflineEvent 2 An ATA device has gone offline kATARemovedEvent 3 An ATA device has been removed from the bus kATAResetEvent 4 Someone gave a hard reset to the drive kATAOfflineRequest 5 Someone requesting to offline the drive kATAEjectRequest 6 Someone requesting to eject the drive kATAPIResetEvent 7 Someone gave a ATAPI reset to the drive kATAReservedEvent 128 RESERVED
underlying type unsigned int
kSOFTRESET 8 ATAPI Soft Reset command kPACKET 160 ATAPI Packet command kID_DRIVE 161 ATAPI Identify drive command
ATA Command Opcode definition
underlying type unsigned int
kATAcmdWORetry 1 Without I/O retry option kATAcmdNOP 0 NOP operation - media detect kATAcmdRecal 16 Recalibrate command kATAcmdRead 32 Read command kATAcmdReadLong 34 Read Long command kATAcmdReadExtended 36 Read Extended (with retries) kATAcmdReadDMAExtended 37 Read DMA Extended (with retries) kATAcmdWrite 48 Write command kATAcmdWriteLong 50 Write Long kATAcmdWriteExtended 52 Write Extended (with retries) kATAcmdWriteDMAExtended 53 Write DMA Extended (with retries) kATAcmdWriteVerify 60 Write verify kATAcmdReadVerify 64 Read Verify command kATAcmdFormatTrack 80 Format Track command kATAcmdSeek 112 Seek command kATAcmdDiagnostic 144 Drive Diagnostic command kATAcmdInitDrive 145 Init drive parameters command kATAcmdReadMultiple 196 Read multiple kATAcmdWriteMultiple 197 Write multiple kATAcmdSetRWMultiple 198 Set Multiple for Read/Write Multiple kATAcmdReadDMA 200 Read DMA (with retries) kATAcmdWriteDMA 202 Write DMA (with retries) kATAcmdMCAcknowledge 219 Acknowledge media change - removable kATAcmdDoorLock 222 Door lock kATAcmdDoorUnlock 223 Door unlock kATAcmdStandbyImmed 224 Standby Immediate kATAcmdIdleImmed 225 Idle Immediate kATAcmdStandby 226 Standby kATAcmdIdle 227 Idle kATAcmdReadBuffer 228 Read sector buffer command kATAcmdCheckPowerMode 229 Check power mode command <04/04/94> kATAcmdSleep 230 Sleep kATAcmdFlushCache 231 Flush Cache kATAcmdWriteBuffer 232 Write sector buffer command kATAcmdWriteSame 233 Write same data to multiple sectors kATAcmdFlushCacheExtended 234 Flush Cache Extended kATAcmdDriveIdentify 236 Identify Drive command kATAcmdMediaEject 237 Media Eject kATAcmdSetFeatures 239 Set Features
Set feature command opcodes
underlying type unsigned int
kATAEnableWriteCache 2 Enable write cache kATASetTransferMode 3 Set transfer mode kATAEnableAPM 5 Enable Advanced Power Management kATASetPIOMode 8 PIO Flow Control Tx Mode bit kATADisableWriteCache 130 disable write cache kATAEnableReadAhead 170 Read look-ahead enable
task file for ata
size 7, align 1
UInt8 ataTFFeatures <-> Error(R) or ataTFFeatures(W) register image UInt8 ataTFCount <-> Sector count/remaining UInt8 ataTFSector <-> Sector start/finish UInt8 ataTFCylLo <-> ataTFCylLo UInt8 ataTFCylHigh <-> ataTFCylHigh UInt8 ataTFSDH <-> ataTFSDH register image UInt8 ataTFCommand <-> Status(R) or Command(W) register image
typedef struct ataTaskFile ataTaskFile; size 12, align 2
ataTaskFile taskFile UInt16 ataDataRegister <-> Data register. UInt8 ataAltSDevCReg <->: Alternate status(R) or Device Control(W) register image
typedef struct ataRegisterImage ataRegisterImage; size 18, align 2
UInt16 atapiPacketSize Size of command packet in bytes UInt16 [8]atapiCommandByte The command packet itself
typedef struct ATAPICmdPacket ATAPICmdPacket; Error and result codes: TBD
underlying type int
kATAErrUnknownType -1 kATANoErr 0 kATAQueueEmpty 1 kATAUnknownOpcode 2 kATATimeoutErr 3 kATAInvalidDevID 4 kATAErrDevBusy 5 kATAModeNotSupported 6 kATADevIntNoCmd 7 kATADeviceError 8 kATADMAErr 9
Generated 2026-09-08 from the headers of one specific machine (macOS 26.4.1, SDK 26.4, arm64) — not official documentation. About & caveats