AHCI data structures
Posted: Wed Dec 08, 2021 5:34 am
So I'm rewriting my AHCI driver in a more readable way. This time instead of blindly trusting tutorials/wikis/articles I'd wanted to deeply understand what exactly each piece of code does to abstract it in a more pleasant way. I've been reading the AHCI specs in search of explanations about what each bit in the data structures means but as I stumbled upon the FIS structures I couldn't find any good explanation. The wiki provides a struct to use but it, just like the specs, does not go in deep for each field.
This is the struct I'm presented with. While some fields are self-explanatory to me (like fis_type, lba*, count*) some others have cryptic names and I can't find anywhere what their value means.
For example, in my old code, I used to set some arbitrary values to the fields pmport, c and device without really knowing the meaning.
Do you have some kind of table or know somewhere I can read about these structures?
Code: Select all
typedef struct fis_reg_h2d
{
// DWORD 0
uint8_t fis_type; // FIS_TYPE_REG_H2D
uint8_t pmport : 4; // Port multiplier
uint8_t reserved0 : 3;
uint8_t c : 1; // 1: Command, 0: Control
uint8_t command; // Command register
uint8_t featurel; // Feature register, 7:0
// DWORD 1
uint8_t lba0; // LBA low register, 7:0
uint8_t lba1; // LBA mid register, 15:8
uint8_t lba2; // LBA high register, 23:16
uint8_t device; // Device register
// DWORD 2
uint8_t lba3; // LBA register, 31:24
uint8_t lba4; // LBA register, 39:32
uint8_t lba5; // LBA register, 47:40
uint8_t featureh; // Feature register, 15:8
// DWORD 3
uint8_t countl; // Count register, 7:0
uint8_t counth; // Count register, 15:8
uint8_t icc; // Isochronous command completion
uint8_t control; // Control register
// DWORD 4
uint8_t reserved1[4];
} __attribute__ ((packed)) fis_reg_h2d_t;
For example, in my old code, I used to set some arbitrary values to the fields pmport, c and device without really knowing the meaning.
Do you have some kind of table or know somewhere I can read about these structures?