FreeNOS
Data Structures | Macros | Typedefs

The ATA (Advanced Technology Attachment) driver provides a block I/O storage device. More...

Data Structures

struct  IdentifyData
 IDENTIFY data presentation. More...
 
struct  ATADrive
 Represents a Drive on the ATA bus. More...
 
class  ATAController
 AT Attachment (ATA) Host Controller Device. More...
 

Macros

#define IDENTIFY_TEXT_SWAP(field, size)
 Swap ASCII bytes from IDENTIFY. More...
 

Typedefs

typedef struct IdentifyData IdentifyData
 IDENTIFY data presentation. More...
 
typedef struct ATADrive ATADrive
 Represents a Drive on the ATA bus. More...
 

ATA I/O Bases.

#define ATA_BASE_CMD0   0x1f0
 First ATA Bus Command I/O Base. More...
 
#define ATA_BASE_CMD1   0x170
 Second ATA Bus Command I/O Base. More...
 
#define ATA_BASE_CTL0   0x3f6
 First ATA Bus Control I/O Base. More...
 
#define ATA_BASE_CTL1   0x376
 Second ATA Bus Control I/O Base. More...
 

ATA Command Registers.

See also
http://wiki.osdev.org/ATA_PIO_Mode#Registers
#define ATA_REG_DATA   0
 Data port. More...
 
#define ATA_REG_ERROR   1
 Features and Error info. More...
 
#define ATA_REG_COUNT   2
 Sector Count. More...
 
#define ATA_REG_ADDR0   3
 Partial Disk Sector address. More...
 
#define ATA_REG_ADDR1   4
 Partial Disk Sector address. More...
 
#define ATA_REG_ADDR2   5
 Partial Disk Sector address. More...
 
#define ATA_REG_SELECT   6
 Drive Select bit, Flag bits, Extra address bits. More...
 
#define ATA_REG_CMD   7
 Command port and Regular Status port. More...
 
#define ATA_REG_STATUS   7
 Regular Status port. More...
 

ATA Status Registers.

#define ATA_STATUS_ERROR   0x01
 Error flag (when set). More...
 
#define ATA_STATUS_DATA   0x08
 Drive data ready for transfer. More...
 
#define ATA_STATUS_BUSY   0x80
 Drive is preparing to accept or send data. More...
 

ATA Control Registers.

See also
http://wiki.osdev.org/ATA_PIO_Mode#Device_Control_Register_.2F_Alternate_Status
#define ATA_REG_RESET   0x4
 Software Reset. More...
 
#define ATA_REG_INTR   0x2
 Interrupt Disable. More...
 

ATA Device Selector Flags.

#define ATA_SEL_MASTER   0xa0
 Master Drive in Legacy mode. More...
 
#define ATA_SEL_MASTER_28   0xe0
 Master Drive in 28-bit LBA mode. More...
 
#define ATA_SEL_MASTER_48   0x40
 Master Drive in 48-bit LBA mode. More...
 

ATA Commands.

#define ATA_CMD_IDENTIFY   0xec
 Identifies an ATA device, if any. More...
 
#define ATA_CMD_READ   0x20
 Reads sectors from an ATA device. More...
 

Detailed Description

The ATA (Advanced Technology Attachment) driver provides a block I/O storage device.

Macro Definition Documentation

◆ ATA_BASE_CMD0

#define ATA_BASE_CMD0   0x1f0

First ATA Bus Command I/O Base.

Definition at line 39 of file ATAController.h.

◆ ATA_BASE_CMD1

#define ATA_BASE_CMD1   0x170

Second ATA Bus Command I/O Base.

Definition at line 42 of file ATAController.h.

◆ ATA_BASE_CTL0

#define ATA_BASE_CTL0   0x3f6

First ATA Bus Control I/O Base.

Definition at line 45 of file ATAController.h.

◆ ATA_BASE_CTL1

#define ATA_BASE_CTL1   0x376

Second ATA Bus Control I/O Base.

Definition at line 48 of file ATAController.h.

◆ ATA_CMD_IDENTIFY

#define ATA_CMD_IDENTIFY   0xec

Identifies an ATA device, if any.

Definition at line 190 of file ATAController.h.

◆ ATA_CMD_READ

#define ATA_CMD_READ   0x20

Reads sectors from an ATA device.

Definition at line 193 of file ATAController.h.

◆ ATA_REG_ADDR0

#define ATA_REG_ADDR0   3

Partial Disk Sector address.

This register is CHS, LBA28 and LBA48 specific.

Definition at line 82 of file ATAController.h.

◆ ATA_REG_ADDR1

#define ATA_REG_ADDR1   4

Partial Disk Sector address.

Definition at line 87 of file ATAController.h.

◆ ATA_REG_ADDR2

#define ATA_REG_ADDR2   5

Partial Disk Sector address.

Definition at line 92 of file ATAController.h.

◆ ATA_REG_CMD

#define ATA_REG_CMD   7

Command port and Regular Status port.

Used to write commands and read status.

Definition at line 103 of file ATAController.h.

◆ ATA_REG_COUNT

#define ATA_REG_COUNT   2

Sector Count.

Number of sectors to read or write (0 = special value).

Definition at line 76 of file ATAController.h.

◆ ATA_REG_DATA

#define ATA_REG_DATA   0

Data port.

Read and write PIO data bytes on this port.

Definition at line 64 of file ATAController.h.

◆ ATA_REG_ERROR

#define ATA_REG_ERROR   1

Features and Error info.

Mostly used with ATAPI.

Definition at line 70 of file ATAController.h.

◆ ATA_REG_INTR

#define ATA_REG_INTR   0x2

Interrupt Disable.

Set this to stop the current device from sending interrupts.

Definition at line 160 of file ATAController.h.

◆ ATA_REG_RESET

#define ATA_REG_RESET   0x4

Software Reset.

Set this to reset all ATA drives on a bus, if one is misbehaving.

Definition at line 154 of file ATAController.h.

◆ ATA_REG_SELECT

#define ATA_REG_SELECT   6

Drive Select bit, Flag bits, Extra address bits.

Definition at line 97 of file ATAController.h.

◆ ATA_REG_STATUS

#define ATA_REG_STATUS   7

Regular Status port.

This is the same register as the command register.

See also
ATA_REG_CMD

Definition at line 110 of file ATAController.h.

◆ ATA_SEL_MASTER

#define ATA_SEL_MASTER   0xa0

Master Drive in Legacy mode.

Definition at line 172 of file ATAController.h.

◆ ATA_SEL_MASTER_28

#define ATA_SEL_MASTER_28   0xe0

Master Drive in 28-bit LBA mode.

Definition at line 175 of file ATAController.h.

◆ ATA_SEL_MASTER_48

#define ATA_SEL_MASTER_48   0x40

Master Drive in 48-bit LBA mode.

Definition at line 178 of file ATAController.h.

◆ ATA_STATUS_BUSY

#define ATA_STATUS_BUSY   0x80

Drive is preparing to accept or send data.

Wait until this bit clears. If it never clears, do a Software Reset. Technically, when BSY is set, the other bits in the Status bytes are meaningless.

Definition at line 138 of file ATAController.h.

◆ ATA_STATUS_DATA

#define ATA_STATUS_DATA   0x08

Drive data ready for transfer.

Set when the drive has PIO data to transfer, or is ready to accept PIO data.

Definition at line 131 of file ATAController.h.

◆ ATA_STATUS_ERROR

#define ATA_STATUS_ERROR   0x01

Error flag (when set).

Send a new command to clear it (or nuke it with a Software Reset).

Definition at line 125 of file ATAController.h.

◆ IDENTIFY_TEXT_SWAP

#define IDENTIFY_TEXT_SWAP (   field,
  size 
)
Value:
\
({ \
u8 tmp; \
\
for (int i = 0; i < (size); i+=2) \
{ \
tmp = (field)[i]; \
(field)[i] = (field)[i+1]; \
(field)[i+1] = tmp; \
} \
})

Swap ASCII bytes from IDENTIFY.

This macro is needed to swap ASCII bytes in the IDENTIFY result buffer, because IDENTIFY returns 256 little-endian words.

Definition at line 206 of file ATAController.h.

Typedef Documentation

◆ ATADrive

typedef struct ATADrive ATADrive

Represents a Drive on the ATA bus.

◆ IdentifyData

typedef struct IdentifyData IdentifyData

IDENTIFY data presentation.