setos

拙OS
Log | Files | Refs | LICENSE

commit 342a21e17ee7c78454f593cda204808267787a6c
parent d01500acafae1b78f57e7b9af67c60098ffab5cd
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Sat, 20 Apr 2024 08:57:01 +0900

 add comment on MMIO base

Diffstat:
Msys/src/kernel/main.c | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sys/src/kernel/main.c b/sys/src/kernel/main.c @@ -61,7 +61,7 @@ kernel_main(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop) for (int i = 0; i < num_pci_dev; i++) { if (pci_dev[i].base_class == 0xc && pci_dev[i].sub_class == 0x3 && pci_dev[i].prog == 0x30) { - uintptr pci_config_base = &pci_dev[i]; + uintptr pci_config_base = (uintptr) &pci_dev[i]; PCICap *cap = (PCICap *) (pci_config_base + pci_dev[i].capabilities_pointer); for (;; cap = (PCICap *) (pci_config_base + cap->next_pointer)) { switch (cap->capability_id) { @@ -84,7 +84,10 @@ kernel_main(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop) break; } } - uintptr xhc_base = ((uintptr) pci_dev[i].t0.base_address_register[1]) << 32 | pci_dev[i].t0.base_address_register[0]&0xfffffff0; + // TODO: find the following calculation in some specification. + // only article found is osdev's page: + // osdev.org/PCI#Address_and_size_of_the_BAR + uintptr xhc_base = ((uintptr) pci_dev[i].t0.base_address_register[1]) << 32 | (pci_dev[i].t0.base_address_register[0]&0xfffffff0); cons_printf(&con0, "xhc_base: %x\n", xhc_base); xhc_capability_registers *xhccr = (xhc_capability_registers *) xhc_base; xhc_operational_registers *xhcor = (xhc_operational_registers *) (xhc_base + xhccr->CAPLENGTH); @@ -93,6 +96,7 @@ kernel_main(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop) cons_printf(&con0, "CAPLENGTH: %x\n", xhccr->CAPLENGTH); cons_printf(&con0, "HCIVERSION: %x\n", xhccr->HCIVERSION); cons_printf(&con0, "HCSPARAMS1: %x\n", xhccr->HCSPARAMS1); + cons_printf(&con0, "HCCPARAMS1: %x\n", xhccr->HCCPARAMS1); cons_printf(&con0, "USBCMD: %x\n", xhcor->USBCMD); cons_printf(&con0, "USBSTS: %x\n", xhcor->USBSTS); cons_printf(&con0, "FLADJ: %x\n", pci_dev[i].reg[0x21]);