Map ACPI tables as disable cache + no execute

This commit is contained in:
Josh Holtrop 2023-09-17 09:12:20 -04:00
parent 10d7e7f0c6
commit f79b0098c5

View File

@ -116,7 +116,7 @@ struct Acpi
public static void initialize(ulong acpi_xsdt_phys)
{
/* Map the XSDT header. */
Hurl.identity_map_range(acpi_xsdt_phys, PAGE_SIZE, 0u);
map_table(acpi_xsdt_phys, PAGE_SIZE);
const(XSDT) * xsdt = cast(const(XSDT) *)acpi_xsdt_phys;
if (xsdt.header.signature != XSDT_SIGNATURE)
{
@ -126,18 +126,18 @@ struct Acpi
/* Map the entire XSDT. */
if (xsdt.header.length > PAGE_SIZE)
{
Hurl.identity_map_range(acpi_xsdt_phys, xsdt.header.length, 0u);
map_table(acpi_xsdt_phys, xsdt.header.length);
}
size_t n_entries = (xsdt.header.length - xsdt.header.sizeof) / xsdt.tables[0].sizeof;
for (size_t i = 0u; i < n_entries; i++)
{
ulong address = xsdt.tables[i];
Hurl.identity_map_range(address, PAGE_SIZE, 0u);
map_table(address, PAGE_SIZE);
const(Header) * header = cast(const(Header) *)address;
uint length = header.length;
if (length > PAGE_SIZE)
{
Hurl.identity_map_range(address, length, 0u);
map_table(address, length);
}
uint signature = header.signature;
Klog.writefln("Found ACPI table %08x (%c%c%c%c)",
@ -156,4 +156,9 @@ struct Acpi
}
}
}
private static void map_table(ulong address, ulong length)
{
Hurl.identity_map_range(address, length, PT_DISABLE_CACHE | PT_NO_EXECUTE);
}
}