From 9504a2adab92f5acdb08252ad02610b1d73f144b Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Thu, 7 Sep 2023 12:53:04 -0400 Subject: [PATCH] Set alignment of XSDT table pointers to 4 instead of 8 --- src/hulk/acpi.d | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/hulk/acpi.d b/src/hulk/acpi.d index 2c3c1d3..ace3428 100644 --- a/src/hulk/acpi.d +++ b/src/hulk/acpi.d @@ -28,8 +28,8 @@ struct Acpi static struct Xsdt { XsdtHeader header; - uint _pad; - ulong[0] tables; + /* Table pointers are not ulong-aligned! They begin at offset 36. */ + align(4) ulong[1] tables; } static struct MadtHeader @@ -73,16 +73,16 @@ struct Acpi ulong address = xsdt.tables[i]; Hurl.identity_map_range(address, 4u, 0u); uint signature = *cast(const(uint) *)address; - if (signature == APIC_SIGNATURE) - { - parse_apic_table(address); - } Klog.writefln("Found ACPI table %08x (%c%c%c%c)", signature, signature & 0xFFu, (signature >> 8u) & 0xFFu, (signature >> 16u) & 0xFFu, (signature >> 24u) & 0xFFu); + if (signature == APIC_SIGNATURE) + { + parse_apic_table(address); + } } } @@ -100,8 +100,8 @@ struct Acpi if (madt_entry.type == 5u) { /* Found a 64-bit Local APIC Address Override entry. */ - memcpy(cast(void *)&apic_address, cast(const(void) *)madt_entry + 4u, 8u); Klog.writefln("Found 64-bit APIC address: 0x%x", apic_address); + memcpy(cast(void *)&apic_address, cast(const(void) *)madt_entry + 4u, 8u); } } }