- toc = lxcalloc(1, sizeof(acpi_context));
- assert_msg(toc, "Fail to create ACPI context");
+ ctx = lxcalloc(1, sizeof(acpi_context));
+ assert_msg(ctx, "Fail to create ACPI context");
size_t entry_n = (rsdt->header.length - sizeof(acpi_sdthdr_t)) >> 2;
for (size_t i = 0; i < entry_n; i++) {
acpi_sdthdr_t* sdthdr = ((acpi_apic_t**)&(rsdt->entry))[i];
switch (sdthdr->signature) {
case ACPI_MADT_SIG:
size_t entry_n = (rsdt->header.length - sizeof(acpi_sdthdr_t)) >> 2;
for (size_t i = 0; i < entry_n; i++) {
acpi_sdthdr_t* sdthdr = ((acpi_apic_t**)&(rsdt->entry))[i];
switch (sdthdr->signature) {
case ACPI_MADT_SIG:
- madt_parse((acpi_madt_t*)sdthdr, toc);
+ madt_parse((acpi_madt_t*)sdthdr, ctx);
+ break;
+ case ACPI_FADT_SIG:
+ // FADT just a plain structure, no need to parse.
+ ctx->fadt = *(acpi_fadt_t*)sdthdr;
- kprintf(KINFO "OEM: %s\n", toc->oem_id);
- kprintf(KINFO "IOAPIC address: %p\n", toc->madt.ioapic->ioapic_addr);
- kprintf(KINFO "APIC address: %p\n", toc->madt.apic_addr);
+ kprintf(KINFO "OEM: %s\n", ctx->oem_id);
+ kprintf(KINFO "IOAPIC address: %p\n", ctx->madt.ioapic->ioapic_addr);
+ kprintf(KINFO "APIC address: %p\n", ctx->madt.apic_addr);
#else
// You know what, I just search the entire 1MiB for Celestia's sake.
uint8_t* mem_start = 0x4000;
#else
// You know what, I just search the entire 1MiB for Celestia's sake.
uint8_t* mem_start = 0x4000;
- for (size_t j = 0; j < 0x100000; j += 16) {
- uint32_t sig_low = *((uint32_t*)(mem_start + j));
+ for (; mem_start < 0x100000; mem_start += 16) {
+ uint32_t sig_low = *((uint32_t*)(mem_start));
+ // XXX: do we need to compare this as well?