Determine XHCI controller addresses
This commit is contained in:
parent
459d5c36aa
commit
f3f45445b3
@ -60,6 +60,8 @@ struct Pci
|
|||||||
{
|
{
|
||||||
map_memory_regions();
|
map_memory_regions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spawn_device_instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void map_memory_regions()
|
private void map_memory_regions()
|
||||||
|
@ -10,6 +10,7 @@ module hulk.usb.xhci;
|
|||||||
|
|
||||||
import hulk.pci;
|
import hulk.pci;
|
||||||
import hulk.hurl.a1;
|
import hulk.hurl.a1;
|
||||||
|
import hulk.klog;
|
||||||
|
|
||||||
struct XHCI
|
struct XHCI
|
||||||
{
|
{
|
||||||
@ -74,8 +75,22 @@ struct XHCI
|
|||||||
}
|
}
|
||||||
static assert(DoorbellRegister.sizeof == 4u);
|
static assert(DoorbellRegister.sizeof == 4u);
|
||||||
|
|
||||||
|
private CapabilityRegisters * m_capability_registers;
|
||||||
|
private OperationalRegisters * m_operational_registers;
|
||||||
|
private PortRegisters * m_port_registers;
|
||||||
|
private RuntimeRegisters * m_runtime_registers;
|
||||||
|
private DoorbellRegister * m_doorbell_registers;
|
||||||
|
|
||||||
void initialize(Pci.Device * pci_device)
|
void initialize(Pci.Device * pci_device)
|
||||||
{
|
{
|
||||||
|
void * base_address = pci_device.memory_ranges[0].address;
|
||||||
|
Klog.writefln("Found XHCI controller at address %x", base_address);
|
||||||
|
m_capability_registers = cast(CapabilityRegisters *)base_address;
|
||||||
|
m_operational_registers = cast(OperationalRegisters *)(base_address + m_capability_registers.capability_length);
|
||||||
|
/* TODO: confirm if 0x400 offset is from m_operation_registers or base_address. */
|
||||||
|
m_port_registers = cast(PortRegisters *)(cast(void *)m_operational_registers + 0x400);
|
||||||
|
m_runtime_registers = cast(RuntimeRegisters *)(base_address + m_capability_registers.rts_offset);
|
||||||
|
m_doorbell_registers = cast(DoorbellRegister *)(base_address + m_capability_registers.doorbell_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void build(Pci.Device * pci_device)
|
static void build(Pci.Device * pci_device)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user