Set alignment of XSDT table pointers to 4 instead of 8

This commit is contained in:
Josh Holtrop 2023-09-07 12:53:04 -04:00
parent 22c9891c4f
commit 459d5c36aa

View File

@ -12,7 +12,7 @@ struct Acpi
enum uint APIC_SIGNATURE = 0x43495041u; enum uint APIC_SIGNATURE = 0x43495041u;
enum uint XSDT_SIGNATURE = 0x54445358u; enum uint XSDT_SIGNATURE = 0x54445358u;
static struct XsdtHeader static align(4) struct XsdtHeader
{ {
uint signature; uint signature;
uint length; uint length;
@ -28,8 +28,8 @@ struct Acpi
static struct Xsdt static struct Xsdt
{ {
XsdtHeader header; XsdtHeader header;
uint _pad; /* Table pointers are not ulong-aligned! They begin at offset 36. */
ulong[0] tables; align(4) ulong[1] tables;
} }
static struct MadtHeader static struct MadtHeader
@ -73,16 +73,16 @@ struct Acpi
ulong address = xsdt.tables[i]; ulong address = xsdt.tables[i];
Hurl.identity_map_range(address, 4u, 0u); Hurl.identity_map_range(address, 4u, 0u);
uint signature = *cast(const(uint) *)address; uint signature = *cast(const(uint) *)address;
if (signature == APIC_SIGNATURE)
{
parse_apic_table(address);
}
Klog.writefln("Found ACPI table %08x (%c%c%c%c)", Klog.writefln("Found ACPI table %08x (%c%c%c%c)",
signature, signature,
signature & 0xFFu, signature & 0xFFu,
(signature >> 8u) & 0xFFu, (signature >> 8u) & 0xFFu,
(signature >> 16u) & 0xFFu, (signature >> 16u) & 0xFFu,
(signature >> 24u) & 0xFFu); (signature >> 24u) & 0xFFu);
if (signature == APIC_SIGNATURE)
{
parse_apic_table(address);
}
} }
} }
@ -100,8 +100,8 @@ struct Acpi
if (madt_entry.type == 5u) if (madt_entry.type == 5u)
{ {
/* Found a 64-bit Local APIC Address Override entry. */ /* 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); Klog.writefln("Found 64-bit APIC address: 0x%x", apic_address);
memcpy(cast(void *)&apic_address, cast(const(void) *)madt_entry + 4u, 8u);
} }
} }
} }