acpi: show APIC address found

This commit is contained in:
Josh Holtrop 2022-10-18 12:55:41 -04:00
parent 72b83b0c3c
commit dba58b2277

View File

@ -3,7 +3,6 @@
*/ */
module hulk.acpi; module hulk.acpi;
import hulk.klog;
import hulk.hurl; import hulk.hurl;
import hulk.klog; import hulk.klog;
import hos.memory; import hos.memory;
@ -54,7 +53,7 @@ struct acpi
ubyte length; ubyte length;
} }
private static ulong apic_address; public static __gshared ulong apic_address;
public static void initialize(ulong acpi_xsdt_phys) public static void initialize(ulong acpi_xsdt_phys)
{ {
@ -86,6 +85,7 @@ struct acpi
const(MadtHeader) * madt_header = cast(const(MadtHeader) *)address; const(MadtHeader) * madt_header = cast(const(MadtHeader) *)address;
Hurl.map_range(address, madt_header.length, 0u); Hurl.map_range(address, madt_header.length, 0u);
apic_address = madt_header.local_apic_address; apic_address = madt_header.local_apic_address;
klog.writefln("Found 32-bit APIC address: 0x%x", apic_address);
const(void) * madt_end = cast(const(void) *)(address + madt_header.length); const(void) * madt_end = cast(const(void) *)(address + madt_header.length);
const(MadtEntry) * madt_entry = cast(const(MadtEntry) *)(address + 0x2Cu); const(MadtEntry) * madt_entry = cast(const(MadtEntry) *)(address + 0x2Cu);
while (madt_entry < madt_end) while (madt_entry < madt_end)
@ -95,6 +95,7 @@ struct acpi
{ {
/* 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); memcpy(cast(void *)&apic_address, cast(const(void) *)madt_entry + 4u, 8u);
klog.writefln("Found 64-bit APIC address: 0x%x", apic_address);
} }
} }
} }