diff --git a/dev/ahci.c b/dev/ahci.c index 5fdd606..1e48591 100644 --- a/dev/ahci.c +++ b/dev/ahci.c @@ -20,6 +20,9 @@ static int ahci_port_type(hbaport_t *port) if (det != HBA_PORT_DET_PRESENT) return AHCI_DEV_NULL; + if(port->clb_low == 0 && port->clb_high == 0) + return AHCI_DEV_NULL; + switch (port->sig) { case SATA_SIG_ATAPI: return AHCI_DEV_SATAPI; diff --git a/include/dev/ahci.h b/include/dev/ahci.h index ecffea1..af25710 100644 --- a/include/dev/ahci.h +++ b/include/dev/ahci.h @@ -236,8 +236,11 @@ struct hba_cmd_tbl { typedef volatile struct { /* 0x00 */ - paddr_t clb; - paddr_t fb; + paddr32_t clb_low; + paddr32_t clb_high; + + paddr32_t fb_low; + paddr32_t fb_high; /* 0x10 */ uint32_t is; @@ -286,7 +289,7 @@ typedef volatile struct { uint8_t reserved[0x74]; /* 0xA0 */ - char vendor[0x60]; + uint8_t vendor[0x60]; /* 0x100 */ hbaport_t ports[32]; diff --git a/include/kernel/acpi.h b/include/kernel/acpi.h index 3ff8879..4f01ae5 100644 --- a/include/kernel/acpi.h +++ b/include/kernel/acpi.h @@ -31,9 +31,22 @@ struct rsdt { uint32_t sdt[]; } PACKED; +struct mcfg { + struct acpi_sdt_header h; + uint64_t reserved; + struct { + uint64_t base_addr; + uint16_t seg_group; + uint8_t start_bus; + uint8_t end_bus; + uint32_t reserved; + } PACKED cfg[]; +} PACKED; + void acpi_init(); extern struct madt *__madt; +extern struct mcfg *__mcfg; #endif /* __ASM__ */ #endif /* _ACPI_H_ */ diff --git a/init/acpi.c b/init/acpi.c index 096db7d..cefc108 100644 --- a/init/acpi.c +++ b/init/acpi.c @@ -12,6 +12,7 @@ struct limine_rsdp_request rsdp_req = { .id = LIMINE_RSDP_REQUEST, .revision = 0 static struct rsdp *rsdp = NULL; struct madt *__madt = NULL; +struct mcfg *__mcfg = NULL; static void rsdt_parse(struct rsdt *rsdt) { @@ -30,6 +31,10 @@ static void rsdt_parse(struct rsdt *rsdt) __madt = (struct madt *)h; } + if(!(memcmp(h->signature, "MCFG", 4))) { + __mcfg = (struct mcfg *)h; + } + #ifdef KDEBUG char buf[8] = { 0 }; memcpy(buf, h->signature, 4);