Data Fields
ata_lba Union Reference

An ATA Logical Block Address. More...

#include <ata.h>

Data Fields

uint64_t native
 LBA as a 64-bit integer in native-endian order. More...
struct {
   uint8_t   low_cur
   uint8_t   mid_cur
   uint8_t   high_cur
   uint8_t   low_prev
   uint8_t   mid_prev
   uint8_t   high_prev
   uint16_t   pad
 ATA registers. More...

Detailed Description

An ATA Logical Block Address.

ATA controllers have three byte-wide registers for specifying the block address: LBA Low, LBA Mid and LBA High. This allows for a 24-bit address. Some devices support the "48-bit address feature set" (LBA48), in which case each of these byte-wide registers is actually a two-entry FIFO, and the "previous" byte pushed into the FIFO is used as the corresponding high-order byte. So, to set up the 48-bit address 0x123456abcdef, you would issue

0x56 -> LBA Low register
0xef -> LBA Low register
0x34 -> LBA Mid register
0xcd -> LBA Mid register
0x12 -> LBA High register
0xab -> LBA High register

This structure encapsulates this information by providing a single 64-bit integer in native byte order, unioned with bytes named so that the sequence becomes

low_prev  -> LBA Low register
low_cur   -> LBA Low register
mid_prev  -> LBA Mid register
mid_cur   -> LBA Mid register
high_prev -> LBA High register
high_cur  -> LBA High register

Just to complicate matters further, in non-LBA48 mode it is possible to have a 28-bit address, in which case bits 27:24 must be written into the low four bits of the Device register.

Definition at line 49 of file ata.h.

Field Documentation

◆ native

uint64_t ata_lba::native

LBA as a 64-bit integer in native-endian order.

Definition at line 51 of file ata.h.

◆ low_cur

uint8_t ata_lba::low_cur

Definition at line 55 of file ata.h.

◆ mid_cur

uint8_t ata_lba::mid_cur

Definition at line 56 of file ata.h.

◆ high_cur

uint8_t ata_lba::high_cur

Definition at line 57 of file ata.h.

◆ low_prev

uint8_t ata_lba::low_prev

Definition at line 58 of file ata.h.

◆ mid_prev

uint8_t ata_lba::mid_prev

Definition at line 59 of file ata.h.

◆ high_prev

uint8_t ata_lba::high_prev

Definition at line 60 of file ata.h.

◆ pad

uint16_t ata_lba::pad

Definition at line 61 of file ata.h.

◆ bytes

struct { ... } ata_lba::bytes

ATA registers.

The documentation for this union was generated from the following file: