Retro Rocket Kernel BASIC-Powered Operating System

Data Structures | Macros | Enumerations | Functions
ata.h File Reference
`#include <stdint.h>`

## Data Structures
struct | channel
struct | ide_device

## Macros
#define | ATA_SR_BSY 0x80
#define | ATA_SR_DRDY 0x40
#define | ATA_SR_DF 0x20
#define | ATA_SR_DSC 0x10
#define | ATA_SR_DRQ 0x08
#define | ATA_SR_CORR 0x04
#define | ATA_SR_IDX 0x02
#define | ATA_SR_ERR 0x01
#define | ATA_ER_BBK 0x80
#define | ATA_ER_UNC 0x40
#define | ATA_ER_MC 0x20
#define | ATA_ER_IDNF 0x10
#define | ATA_ER_MCR 0x08
#define | ATA_ER_ABRT 0x04
#define | ATA_ER_TK0NF 0x02
#define | ATA_ER_AMNF 0x01
#define | ATA_CMD_READ_PIO 0x20
#define | ATA_CMD_READ_PIO_EXT 0x24
#define | ATA_CMD_READ_DMA 0xC8
#define | ATA_CMD_READ_DMA_EXT 0x25
#define | ATA_CMD_WRITE_PIO 0x30
#define | ATA_CMD_WRITE_PIO_EXT 0x34
#define | ATA_CMD_WRITE_DMA 0xCA
#define | ATA_CMD_WRITE_DMA_EXT 0x35
#define | ATA_CMD_CACHE_FLUSH 0xE7
#define | ATA_CMD_CACHE_FLUSH_EXT 0xEA
#define | ATA_CMD_PACKET 0xA0
#define | ATA_CMD_IDENTIFY_PACKET 0xA1
#define | ATA_CMD_IDENTIFY 0xEC
#define | ATAPI_CMD_READ 0xA8
#define | ATAPI_CMD_EJECT 0x1B
#define | ATA_IDENT_DEVICETYPE 0
#define | ATA_IDENT_CYLINDERS 2
#define | ATA_IDENT_HEADS 6
#define | ATA_IDENT_SECTORS 12
#define | ATA_IDENT_SERIAL 20
#define | ATA_IDENT_MODEL 54
#define | ATA_IDENT_CAPABILITIES 98
#define | ATA_IDENT_FIELDVALID 106
#define | ATA_IDENT_MAX_LBA 120
#define | ATA_IDENT_COMMANDSETS 164
#define | ATA_IDENT_MAX_LBA_EXT 200
#define | ATA_MASTER 0x00
#define | ATA_SLAVE 0x01
#define | IDE_ATA 0x00
#define | IDE_ATAPI 0x01
#define | ATA_REG_DATA 0x00
#define | ATA_REG_ERROR 0x01
#define | ATA_REG_FEATURES 0x01
#define | ATA_REG_SECCOUNT0 0x02
#define | ATA_REG_LBA0 0x03
#define | ATA_REG_LBA1 0x04
#define | ATA_REG_LBA2 0x05
#define | ATA_REG_HDDEVSEL 0x06
#define | ATA_REG_COMMAND 0x07
#define | ATA_REG_STATUS 0x07
#define | ATA_REG_SECCOUNT1 0x08
#define | ATA_REG_LBA3 0x09
#define | ATA_REG_LBA4 0x0A
#define | ATA_REG_LBA5 0x0B
#define | ATA_REG_CONTROL 0x0C
#define | ATA_REG_ALTSTATUS 0x0C
#define | ATA_REG_DEVADDRESS 0x0D
#define | ATA_PRIMARY 0x00
#define | ATA_SECONDARY 0x01
#define | ATA_READ 0x00
#define | ATA_WRITE 0x01

## Enumerations
enum | ata_poll_error_code { ATA_POLL_NO_ERROR = 0 , ATA_POLL_DEVICE_FAULT = 1 , ATA_POLL_GENRAL_ERROR = 2 , ATA_POLL_DRQ_NOT_SET = 3 , ATA_POLL_TIMEOUT = 4 }

## Functions
uint8_t | ide_read (uint8_t channel, uint8_t reg)
void | ide_write (uint8_t channel, uint8_t reg, uint8_t data)
void | init_ide ()
void | ide_irq (uint8_t isr, uint64_t error, uint64_t irq, void *opaque)
int | ide_read_sectors (uint8_t drive, uint16_t numsects, uint64_t lba, uint64_t buffer_address)
int | ide_write_sectors (uint8_t drive, uint16_t numsects, uint64_t lba, uint64_t buffer_address)
int | ide_atapi_eject (uint8_t drive)

## Detailed Description

Author
  Craig Edwards (craig.nosp@m.edwa.nosp@m.rds@b.nosp@m.rain.nosp@m.box.c.nosp@m.c)

Copyright
  Copyright (c) 2012-2023

## Macro Definition Documentation

## ◆ ATA_CMD_CACHE_FLUSH

#define ATA_CMD_CACHE_FLUSH 0xE7

## ◆ ATA_CMD_CACHE_FLUSH_EXT

#define ATA_CMD_CACHE_FLUSH_EXT 0xEA

## ◆ ATA_CMD_IDENTIFY

#define ATA_CMD_IDENTIFY 0xEC

## ◆ ATA_CMD_IDENTIFY_PACKET

#define ATA_CMD_IDENTIFY_PACKET 0xA1

## ◆ ATA_CMD_PACKET

#define ATA_CMD_PACKET 0xA0

## ◆ ATA_CMD_READ_DMA

#define ATA_CMD_READ_DMA 0xC8

## ◆ ATA_CMD_READ_DMA_EXT

#define ATA_CMD_READ_DMA_EXT 0x25

## ◆ ATA_CMD_READ_PIO

#define ATA_CMD_READ_PIO 0x20

## ◆ ATA_CMD_READ_PIO_EXT

#define ATA_CMD_READ_PIO_EXT 0x24

## ◆ ATA_CMD_WRITE_DMA

#define ATA_CMD_WRITE_DMA 0xCA

## ◆ ATA_CMD_WRITE_DMA_EXT

#define ATA_CMD_WRITE_DMA_EXT 0x35

## ◆ ATA_CMD_WRITE_PIO

#define ATA_CMD_WRITE_PIO 0x30

## ◆ ATA_CMD_WRITE_PIO_EXT

#define ATA_CMD_WRITE_PIO_EXT 0x34

## ◆ ATA_ER_ABRT

#define ATA_ER_ABRT 0x04

## ◆ ATA_ER_AMNF

#define ATA_ER_AMNF 0x01

## ◆ ATA_ER_BBK

#define ATA_ER_BBK 0x80

## ◆ ATA_ER_IDNF

#define ATA_ER_IDNF 0x10

## ◆ ATA_ER_MC

#define ATA_ER_MC 0x20

## ◆ ATA_ER_MCR

#define ATA_ER_MCR 0x08

## ◆ ATA_ER_TK0NF

#define ATA_ER_TK0NF 0x02

## ◆ ATA_ER_UNC

#define ATA_ER_UNC 0x40

## ◆ ATA_IDENT_CAPABILITIES

#define ATA_IDENT_CAPABILITIES 98

## ◆ ATA_IDENT_COMMANDSETS

#define ATA_IDENT_COMMANDSETS 164

## ◆ ATA_IDENT_CYLINDERS

#define ATA_IDENT_CYLINDERS 2

## ◆ ATA_IDENT_DEVICETYPE

#define ATA_IDENT_DEVICETYPE 0

## ◆ ATA_IDENT_FIELDVALID

#define ATA_IDENT_FIELDVALID 106

## ◆ ATA_IDENT_HEADS

#define ATA_IDENT_HEADS 6

## ◆ ATA_IDENT_MAX_LBA

#define ATA_IDENT_MAX_LBA 120

## ◆ ATA_IDENT_MAX_LBA_EXT

#define ATA_IDENT_MAX_LBA_EXT 200

## ◆ ATA_IDENT_MODEL

#define ATA_IDENT_MODEL 54

## ◆ ATA_IDENT_SECTORS

#define ATA_IDENT_SECTORS 12

## ◆ ATA_IDENT_SERIAL

#define ATA_IDENT_SERIAL 20

## ◆ ATA_MASTER

#define ATA_MASTER 0x00

## ◆ ATA_PRIMARY

#define ATA_PRIMARY 0x00

## ◆ ATA_READ

#define ATA_READ 0x00

## ◆ ATA_REG_ALTSTATUS

#define ATA_REG_ALTSTATUS 0x0C

## ◆ ATA_REG_COMMAND

#define ATA_REG_COMMAND 0x07

## ◆ ATA_REG_CONTROL

#define ATA_REG_CONTROL 0x0C

## ◆ ATA_REG_DATA

#define ATA_REG_DATA 0x00

## ◆ ATA_REG_DEVADDRESS

#define ATA_REG_DEVADDRESS 0x0D

## ◆ ATA_REG_ERROR

#define ATA_REG_ERROR 0x01

## ◆ ATA_REG_FEATURES

#define ATA_REG_FEATURES 0x01

## ◆ ATA_REG_HDDEVSEL

#define ATA_REG_HDDEVSEL 0x06

## ◆ ATA_REG_LBA0

#define ATA_REG_LBA0 0x03

## ◆ ATA_REG_LBA1

#define ATA_REG_LBA1 0x04

## ◆ ATA_REG_LBA2

#define ATA_REG_LBA2 0x05

## ◆ ATA_REG_LBA3

#define ATA_REG_LBA3 0x09

## ◆ ATA_REG_LBA4

#define ATA_REG_LBA4 0x0A

## ◆ ATA_REG_LBA5

#define ATA_REG_LBA5 0x0B

## ◆ ATA_REG_SECCOUNT0

#define ATA_REG_SECCOUNT0 0x02

## ◆ ATA_REG_SECCOUNT1

#define ATA_REG_SECCOUNT1 0x08

## ◆ ATA_REG_STATUS

#define ATA_REG_STATUS 0x07

## ◆ ATA_SECONDARY

#define ATA_SECONDARY 0x01

## ◆ ATA_SLAVE

#define ATA_SLAVE 0x01

## ◆ ATA_SR_BSY

#define ATA_SR_BSY 0x80

## ◆ ATA_SR_CORR

#define ATA_SR_CORR 0x04

## ◆ ATA_SR_DF

#define ATA_SR_DF 0x20

## ◆ ATA_SR_DRDY

#define ATA_SR_DRDY 0x40

## ◆ ATA_SR_DRQ

#define ATA_SR_DRQ 0x08

## ◆ ATA_SR_DSC

#define ATA_SR_DSC 0x10

## ◆ ATA_SR_ERR

#define ATA_SR_ERR 0x01

## ◆ ATA_SR_IDX

#define ATA_SR_IDX 0x02

## ◆ ATA_WRITE

#define ATA_WRITE 0x01

## ◆ ATAPI_CMD_EJECT

#define ATAPI_CMD_EJECT 0x1B

## ◆ ATAPI_CMD_READ

#define ATAPI_CMD_READ 0xA8

## ◆ IDE_ATA

#define IDE_ATA 0x00

## ◆ IDE_ATAPI

#define IDE_ATAPI 0x01

## Enumeration Type Documentation

## ◆ ata_poll_error_code

enum ata_poll_error_code

Enumerator
ATA_POLL_NO_ERROR |
ATA_POLL_DEVICE_FAULT |
ATA_POLL_GENRAL_ERROR |
ATA_POLL_DRQ_NOT_SET |
ATA_POLL_TIMEOUT |

## Function Documentation

## ◆ ide_atapi_eject()

int ide_atapi_eject | ( | uint8_t | drive | ) |

## ◆ ide_irq()

void ide_irq | ( | uint8_t | isr,
|  | uint64_t | error,
|  | uint64_t | irq,
|  | void * | opaque
| ) |  |

## ◆ ide_read()

uint8_t ide_read | ( | uint8_t | channel,
|  | uint8_t | reg
| ) |  |

## ◆ ide_read_sectors()

int ide_read_sectors | ( | uint8_t | drive,
|  | uint16_t | numsects,
|  | uint64_t | lba,
|  | uint64_t | buffer_address
| ) |  |

## ◆ ide_write()

void ide_write | ( | uint8_t | channel,
|  | uint8_t | reg,
|  | uint8_t | data
| ) |  |

## ◆ ide_write_sectors()

int ide_write_sectors | ( | uint8_t | drive,
|  | uint16_t | numsects,
|  | uint64_t | lba,
|  | uint64_t | buffer_address
| ) |  |

## ◆ init_ide()

void init_ide | ( |  | ) |