Use Acpi.Header in ACPI table structures
This commit is contained in:
parent
6514af8e94
commit
e088f942d1
@ -18,7 +18,7 @@ struct Acpi
|
|||||||
enum uint MCFG_SIGNATURE = signature("MCFG");
|
enum uint MCFG_SIGNATURE = signature("MCFG");
|
||||||
enum uint XSDT_SIGNATURE = signature("XSDT");
|
enum uint XSDT_SIGNATURE = signature("XSDT");
|
||||||
|
|
||||||
static align(4) struct XsdtHeader
|
static align(4) struct Header
|
||||||
{
|
{
|
||||||
uint signature;
|
uint signature;
|
||||||
uint length;
|
uint length;
|
||||||
@ -31,35 +31,27 @@ struct Acpi
|
|||||||
uint creator_revision;
|
uint creator_revision;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct Xsdt
|
static struct XSDT
|
||||||
{
|
{
|
||||||
XsdtHeader header;
|
Header header;
|
||||||
/* Table pointers are not ulong-aligned! They begin at offset 36. */
|
/* Table pointers are not ulong-aligned! They begin at offset 36. */
|
||||||
align(4) ulong[1] tables;
|
align(4) ulong[1] tables;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct MadtHeader
|
static struct MADT
|
||||||
{
|
{
|
||||||
uint signature;
|
static struct Entry
|
||||||
uint length;
|
|
||||||
ubyte revision;
|
|
||||||
ubyte checksum;
|
|
||||||
char[6] oemid;
|
|
||||||
ulong oemtableid;
|
|
||||||
uint oem_revision;
|
|
||||||
uint creator_id;
|
|
||||||
uint creator_revision;
|
|
||||||
uint local_apic_address;
|
|
||||||
uint flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct MadtEntry
|
|
||||||
{
|
{
|
||||||
ubyte type;
|
ubyte type;
|
||||||
ubyte length;
|
ubyte length;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct MCFGTable
|
Header header;
|
||||||
|
uint local_apic_address;
|
||||||
|
uint flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct MCFG
|
||||||
{
|
{
|
||||||
/* PCI Segment Group Memory Area Descriptor. */
|
/* PCI Segment Group Memory Area Descriptor. */
|
||||||
static struct SGMADesc
|
static struct SGMADesc
|
||||||
@ -78,15 +70,7 @@ struct Acpi
|
|||||||
static assert(SGMADesc.sizeof == 16);
|
static assert(SGMADesc.sizeof == 16);
|
||||||
static assert(SGMADesc.alignof == 4);
|
static assert(SGMADesc.alignof == 4);
|
||||||
|
|
||||||
uint signature;
|
Header header;
|
||||||
uint length;
|
|
||||||
ubyte revision;
|
|
||||||
ubyte checksum;
|
|
||||||
char[6] oemid;
|
|
||||||
ulong oemtableid;
|
|
||||||
uint oem_revision;
|
|
||||||
uint creator_id;
|
|
||||||
uint creator_revision;
|
|
||||||
uint[2] _reserved;
|
uint[2] _reserved;
|
||||||
SGMADesc[0] sgma_descs;
|
SGMADesc[0] sgma_descs;
|
||||||
}
|
}
|
||||||
@ -96,8 +80,8 @@ struct Acpi
|
|||||||
public static void initialize(ulong acpi_xsdt_phys)
|
public static void initialize(ulong acpi_xsdt_phys)
|
||||||
{
|
{
|
||||||
/* Map the XSDT header. */
|
/* Map the XSDT header. */
|
||||||
Hurl.identity_map_range(acpi_xsdt_phys, Xsdt.sizeof, 0u);
|
Hurl.identity_map_range(acpi_xsdt_phys, XSDT.sizeof, 0u);
|
||||||
const(Xsdt) * xsdt = cast(const(Xsdt) *)acpi_xsdt_phys;
|
const(XSDT) * xsdt = cast(const(XSDT) *)acpi_xsdt_phys;
|
||||||
if (xsdt.header.signature != XSDT_SIGNATURE)
|
if (xsdt.header.signature != XSDT_SIGNATURE)
|
||||||
{
|
{
|
||||||
Klog.writef("XSDT signature invalid\n");
|
Klog.writef("XSDT signature invalid\n");
|
||||||
@ -130,15 +114,15 @@ struct Acpi
|
|||||||
|
|
||||||
private static parse_apic_table(ulong address)
|
private static parse_apic_table(ulong address)
|
||||||
{
|
{
|
||||||
const(MadtHeader) * madt_header = cast(const(MadtHeader) *)address;
|
const(MADT) * madt = cast(const(MADT) *)address;
|
||||||
Hurl.identity_map_range(address, madt_header.length, 0u);
|
Hurl.identity_map_range(address, madt.header.length, 0u);
|
||||||
apic_address = madt_header.local_apic_address;
|
apic_address = madt.local_apic_address;
|
||||||
Klog.writefln("Found 32-bit APIC address: 0x%x", 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(MADT.Entry) * madt_entry = cast(const(MADT.Entry) *)(address + MADT.sizeof);
|
||||||
while (madt_entry < madt_end)
|
while (madt_entry < madt_end)
|
||||||
{
|
{
|
||||||
madt_entry = cast(const(MadtEntry) *)(cast(size_t)madt_entry + madt_entry.length);
|
madt_entry = cast(const(MADT.Entry) *)(cast(size_t)madt_entry + madt_entry.length);
|
||||||
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. */
|
||||||
@ -150,18 +134,19 @@ struct Acpi
|
|||||||
|
|
||||||
private static parse_mcfg_table(ulong address)
|
private static parse_mcfg_table(ulong address)
|
||||||
{
|
{
|
||||||
const(MCFGTable) * mcfg_table = cast(const(MCFGTable) *)address;
|
const(MCFG) * mcfg = cast(const(MCFG) *)address;
|
||||||
Hurl.identity_map_range(address, mcfg_table.length, 0u);
|
Hurl.identity_map_range(address, mcfg.header.length, 0u);
|
||||||
Klog.writefln("MCFG length = %u", mcfg_table.length);
|
Klog.writefln("MCFG length = %u", mcfg.header.length);
|
||||||
size_t n_sgma_descs = (mcfg_table.length - MCFGTable.sgma_descs.offsetof) / MCFGTable.SGMADesc.sizeof;
|
size_t n_sgma_descs = (mcfg.header.length - MCFG.sgma_descs.offsetof) / MCFG.SGMADesc.sizeof;
|
||||||
Klog.writefln("# SGMA descriptors = %u", (mcfg_table.length - MCFGTable.sgma_descs.offsetof) / MCFGTable.SGMADesc.sizeof);
|
Klog.writefln("# SGMA descriptors = %u", (mcfg.header.length - MCFG.sgma_descs.offsetof) / MCFG.SGMADesc.sizeof);
|
||||||
for (size_t i = 0; i < n_sgma_descs; i++)
|
for (size_t i = 0; i < n_sgma_descs; i++)
|
||||||
{
|
{
|
||||||
Klog.writefln("SGMA %u: SG %u; Bus %u-%u; addr %p",
|
Klog.writefln("SGMA %u: SG %u; Bus %u-%u; addr %p",
|
||||||
i, mcfg_table.sgma_descs[i].pci_segment_group_number,
|
i,
|
||||||
mcfg_table.sgma_descs[i].start_pci_bus_number,
|
mcfg.sgma_descs[i].pci_segment_group_number,
|
||||||
mcfg_table.sgma_descs[i].end_pci_bus_number,
|
mcfg.sgma_descs[i].start_pci_bus_number,
|
||||||
mcfg_table.sgma_descs[i].base_address);
|
mcfg.sgma_descs[i].end_pci_bus_number,
|
||||||
|
mcfg.sgma_descs[i].base_address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user