Move MCFG ACPI table processing from ACPI to PCI
This commit is contained in:
1 parent
e32282f6f0
commit
f5c6a35cef
2 files changed
+42
-43
No files matched your search
+36
-3
@@ -29,6 +29,38 @@ struct Pci
|
||||
/** XHCI controller device type. */
|
||||
enum XHCI_CONTROLLER = Type(0x0Cu, 0x03u, 0x30u);
|
||||
|
||||
/**
|
||||
* MCFG ACPI table structure.
|
||||
*/
|
||||
static struct MCFG
|
||||
{
|
||||
/* PCI Segment Group Memory Area Descriptor. */
|
||||
static struct SGMADesc
|
||||
{
|
||||
uint[2] base_address_a;
|
||||
ushort pci_segment_group_number;
|
||||
ubyte start_pci_bus_number;
|
||||
ubyte end_pci_bus_number;
|
||||
uint _reserved;
|
||||
|
||||
public @property ulong base_address() const
|
||||
{
|
||||
return base_address_a[0] | (cast(ulong)base_address_a[1] << 32);
|
||||
}
|
||||
}
|
||||
static assert(SGMADesc.sizeof == 16);
|
||||
static assert(SGMADesc.alignof == 4);
|
||||
|
||||
Acpi.Header header;
|
||||
uint[2] _reserved;
|
||||
SGMADesc[0] sgma_descs;
|
||||
|
||||
size_t n_sgma_descs()
|
||||
{
|
||||
return (header.length - MCFG.sgma_descs.offsetof) / MCFG.SGMADesc.sizeof;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* PCI device address (bus number, device number, function number).
|
||||
*/
|
||||
@@ -385,11 +417,12 @@ struct Pci
|
||||
|
||||
public static void initialize()
|
||||
{
|
||||
Klog.writefln("\a3Initializing PCI Bus");
|
||||
size_t n_sgma_descs = Acpi.mcfg.n_sgma_descs;
|
||||
Klog.writefln("\a3Initializing PCI");
|
||||
MCFG * mcfg = cast(MCFG *)Acpi.get_table("MCFG");
|
||||
size_t n_sgma_descs = mcfg.n_sgma_descs;
|
||||
for (size_t i = 0u; i < n_sgma_descs; i++)
|
||||
{
|
||||
Acpi.MCFG.SGMADesc * sgma_desc = &Acpi.mcfg.sgma_descs[i];
|
||||
MCFG.SGMADesc * sgma_desc = &mcfg.sgma_descs[i];
|
||||
ulong base_address = sgma_desc.base_address;
|
||||
uint start_pci_bus = sgma_desc.start_pci_bus_number;
|
||||
uint end_pci_bus = sgma_desc.end_pci_bus_number;
|
||||
|
||||
Reference in new issue
Block a user