Newer
Older
tree-os / src / kernel / drivers / pci / hardDrive / sataController.c
#include <_stdio.h>
#include <hardDrive.h>

// information source:
// https://www.intel.com/content/dam/www/public/us/en/documents/technical-specifications/serial-ata-ahci-spec-rev1_3.pdf

typedef struct {
    uint32_t hostCapabilities, globalHostControl, interruptStatus,
        implementedPorts, version, cccCtl, cccPts, enclosureManagementLocation,
        enclosureManagementControl, hostCapabilitiesExtended, handoffStatus;
} HbaMemoryRegisters;

void initializeSataController(PciDevice *pciDevice, ListElement **drives) {
    if (pciDevice->programmingInterface != 1) {
        // todo
        return;
    }
    HbaMemoryRegisters *registers = (HbaMemoryRegisters *)pciDevice->bar5;
    printf("hostCapabilities: %x\nimplementedPorts: %x\nversion: %x\n",
           registers->hostCapabilities, registers->implementedPorts,
           registers->version);
}