Move MCFG ACPI table processing from ACPI to PCI
This commit is contained in:
parent
e32282f6f0
commit
f5c6a35cef
@ -15,7 +15,6 @@ struct Acpi
|
|||||||
*/
|
*/
|
||||||
private static __gshared List!Header tables;
|
private static __gshared List!Header tables;
|
||||||
|
|
||||||
enum uint MCFG_SIGNATURE = signature("MCFG");
|
|
||||||
enum uint XSDT_SIGNATURE = signature("XSDT");
|
enum uint XSDT_SIGNATURE = signature("XSDT");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,37 +44,9 @@ struct Acpi
|
|||||||
}
|
}
|
||||||
static assert(XSDT.tables.offsetof == 36);
|
static assert(XSDT.tables.offsetof == 36);
|
||||||
|
|
||||||
static struct MCFG
|
/**
|
||||||
{
|
* Initialize ACPI.
|
||||||
/* 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);
|
|
||||||
|
|
||||||
Header header;
|
|
||||||
uint[2] _reserved;
|
|
||||||
SGMADesc[0] sgma_descs;
|
|
||||||
|
|
||||||
size_t n_sgma_descs()
|
|
||||||
{
|
|
||||||
return (header.length - MCFG.sgma_descs.offsetof) / MCFG.SGMADesc.sizeof;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public __gshared MCFG * mcfg;
|
|
||||||
|
|
||||||
public static void initialize(ulong acpi_xsdt_phys)
|
public static void initialize(ulong acpi_xsdt_phys)
|
||||||
{
|
{
|
||||||
Klog.writefln("\a3Initializing ACPI");
|
Klog.writefln("\a3Initializing ACPI");
|
||||||
@ -112,14 +83,6 @@ struct Acpi
|
|||||||
(signature >> 16u) & 0xFFu,
|
(signature >> 16u) & 0xFFu,
|
||||||
(signature >> 24u) & 0xFFu,
|
(signature >> 24u) & 0xFFu,
|
||||||
address);
|
address);
|
||||||
if (signature == MCFG_SIGNATURE)
|
|
||||||
{
|
|
||||||
mcfg = cast(MCFG *)address;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (mcfg == null)
|
|
||||||
{
|
|
||||||
Klog.fatal_error("MCFG table not found");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,6 +106,9 @@ struct Acpi
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map an ACPI table.
|
||||||
|
*/
|
||||||
private static void map_table(ulong address, ulong length)
|
private static void map_table(ulong address, ulong length)
|
||||||
{
|
{
|
||||||
Hurl.identity_map_range(address, length, PT_WRITABLE | PT_DISABLE_CACHE | PT_NO_EXECUTE);
|
Hurl.identity_map_range(address, length, PT_WRITABLE | PT_DISABLE_CACHE | PT_NO_EXECUTE);
|
||||||
|
@ -29,6 +29,38 @@ struct Pci
|
|||||||
/** XHCI controller device type. */
|
/** XHCI controller device type. */
|
||||||
enum XHCI_CONTROLLER = Type(0x0Cu, 0x03u, 0x30u);
|
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).
|
* PCI device address (bus number, device number, function number).
|
||||||
*/
|
*/
|
||||||
@ -385,11 +417,12 @@ struct Pci
|
|||||||
|
|
||||||
public static void initialize()
|
public static void initialize()
|
||||||
{
|
{
|
||||||
Klog.writefln("\a3Initializing PCI Bus");
|
Klog.writefln("\a3Initializing PCI");
|
||||||
size_t n_sgma_descs = Acpi.mcfg.n_sgma_descs;
|
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++)
|
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;
|
ulong base_address = sgma_desc.base_address;
|
||||||
uint start_pci_bus = sgma_desc.start_pci_bus_number;
|
uint start_pci_bus = sgma_desc.start_pci_bus_number;
|
||||||
uint end_pci_bus = sgma_desc.end_pci_bus_number;
|
uint end_pci_bus = sgma_desc.end_pci_bus_number;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user