My progress on real RISC-V hardware

I managed to get PCI configuration space access and PCI bus enumeration working.

pci_controller_init()
hostCtrlType: sifive
  reg[0]: (0xe00000000, 0x100000000)
  reg[1]: (0xdf0000000, 0x10000000)
  reg[2]: (0x100d0000, 0x1000)
  configRegs: (0x60070000, 0x10000)
  dbiRegs: (0xe00000000, 0x100000000)
  interrupt-map:
    bus: 0, dev: 0, fn: 0, childIrq: 1, parentIrq: (10, 57)
    bus: 0, dev: 0, fn: 0, childIrq: 2, parentIrq: (10, 58)
    bus: 0, dev: 0, fn: 0, childIrq: 3, parentIrq: (10, 59)
    bus: 0, dev: 0, fn: 0, childIrq: 4, parentIrq: (10, 60)
  ranges:
    IOPORT (0x81000000): child: 60080000, parent: 60080000, len: 10000
    MMIO32 (0x82000000): child: 60090000, parent: 60090000, len: ff70000
    MMIO32 (0x82000000): child: 70000000, parent: 70000000, len: 1000000
    MMIO64 (0xc3000000): child: 2000000000, parent: 2000000000, len: 2000000000
ATU:
  0: base: 0x70000000, limit: 0x70ffffff, target: 0x70000000, ctrl1: 0x0, ctrl2: 0x80000000
  1: base: 0x60080000, limit: 0x6008ffff, target: 0x60080000, ctrl1: 0x2, ctrl2: 0x80000000
AllocRegs()
AllocRegsForDevice(bus: 0, device: 0, function: 0)
  vendorID: 0xf15e
  deviceID: 0x00
  headerType: bridge
  primaryBus: 0
  secondaryBus: 1
  subordinateBus: 7
  bar[0]: MMIO64, adr: 0x70000000, size: 0x100000
  rom_bar: adr: 0x70100000, size: 0x10000
  intLine: 57
  intPin: INTA#
AllocRegsForDevice(bus: 1, device: 0, function: 0)
  vendorID: 0x1b21
  deviceID: 0x2824
  headerType: bridge
  primaryBus: 1
  secondaryBus: 2
  subordinateBus: 7
  bar[0]: MMIO32, adr: 0x0, size: 0x0
  bar[1]: MMIO32, adr: 0x0, size: 0x0
  rom_bar: adr: 0x0, size: 0x0
  intLine: 57
  intPin: INTA#
AllocRegsForDevice(bus: 2, device: 0, function: 0)
  vendorID: 0x1b21
  deviceID: 0x2824
  headerType: bridge
  primaryBus: 2
  secondaryBus: 3
  subordinateBus: 3
  bar[0]: MMIO32, adr: 0x0, size: 0x0
  bar[1]: MMIO32, adr: 0x0, size: 0x0
  rom_bar: adr: 0x0, size: 0x0
  intLine: 57
  intPin: INTA#
AllocRegsForDevice(bus: 2, device: 2, function: 0)
  vendorID: 0x1b21
  deviceID: 0x2824
  headerType: bridge
  primaryBus: 2
  secondaryBus: 4
  subordinateBus: 4
  bar[0]: MMIO32, adr: 0x0, size: 0x0
  bar[1]: MMIO32, adr: 0x0, size: 0x0
  rom_bar: adr: 0x0, size: 0x0
  intLine: 57
  intPin: INTA#
AllocRegsForDevice(bus: 2, device: 3, function: 0)
  vendorID: 0x1b21
  deviceID: 0x2824
  headerType: bridge
  primaryBus: 2
  secondaryBus: 5
  subordinateBus: 5
  bar[0]: MMIO32, adr: 0x0, size: 0x0
  bar[1]: MMIO32, adr: 0x0, size: 0x0
  rom_bar: adr: 0x0, size: 0x0
  intLine: 57
  intPin: INTA#
AllocRegsForDevice(bus: 2, device: 4, function: 0)
  vendorID: 0x1b21
  deviceID: 0x2824
  headerType: bridge
  primaryBus: 2
  secondaryBus: 6
  subordinateBus: 6
  bar[0]: MMIO32, adr: 0x0, size: 0x0
  bar[1]: MMIO32, adr: 0x0, size: 0x0
  rom_bar: adr: 0x0, size: 0x0
  intLine: 57
  intPin: INTA#
AllocRegsForDevice(bus: 2, device: 8, function: 0)
  vendorID: 0x1b21
  deviceID: 0x2824
  headerType: bridge
  primaryBus: 2
  secondaryBus: 7
  subordinateBus: 7
  bar[0]: MMIO32, adr: 0x0, size: 0x0
  bar[1]: MMIO32, adr: 0x0, size: 0x0
  rom_bar: adr: 0x0, size: 0x0
  intLine: 57
  intPin: INTA#
AllocRegsForDevice(bus: 4, device: 0, function: 0)
  vendorID: 0x1b21
  deviceID: 0x1142
  headerType: generic
  bar[0]: MMIO64, adr: 0x70200000, size: 0x8000
  bar[2]: MMIO32, adr: 0x0, size: 0x0
  bar[3]: MMIO32, adr: 0x0, size: 0x0
  bar[4]: MMIO32, adr: 0x0, size: 0x0
  bar[5]: MMIO32, adr: 0x0, size: 0x0
  rom_bar: adr: 0x0, size: 0x0
  intLine: 57
  intPin: INTA#
AllocRegsForDevice(bus: 6, device: 0, function: 0)
  vendorID: 0x1987
  deviceID: 0x5013
  headerType: generic
  bar[0]: MMIO64, adr: 0x70300000, size: 0x4000
  bar[2]: MMIO32, adr: 0x0, size: 0x0
  bar[3]: MMIO32, adr: 0x0, size: 0x0
  bar[4]: MMIO32, adr: 0x0, size: 0x0
  bar[5]: MMIO32, adr: 0x0, size: 0x0
  rom_bar: adr: 0x0, size: 0x0
  intLine: 57
  intPin: INTA#
AllocRegsForDevice(bus: 7, device: 0, function: 0)
  vendorID: 0x1002
  deviceID: 0x683f
  headerType: ?(128)
  bar[0]: MMIO64, adr: 0x2000000000, size: 0x10000000
  bar[2]: MMIO64, adr: 0x70400000, size: 0x40000
  bar[4]: IOPORT, adr: 0x60080000, size: 0x100
  bar[5]: MMIO32, adr: 0x0, size: 0x0
  rom_bar: adr: 0x70440000, size: 0x20000
  intLine: 57
  intPin: INTA#
PCI: FixupDevices: checking bus 1 behind f15e:0000
PCI: FixupDevices: checking bus 2 behind 1b21:2824
PCI: FixupDevices: checking bus 3 behind 1b21:2824
PCI: FixupDevices: checking bus 4 behind 1b21:2824
PCI: FixupDevices: checking bus 5 behind 1b21:2824
PCI: FixupDevices: checking bus 6 behind 1b21:2824
PCI: FixupDevices: checking bus 7 behind 1b21:2824
PCI: dom 0, bus 0, dev  0, func 0, changed PCI bridge control from 0x0000 to 0x0003
PCI: dom 0, bus 1, dev  0, func 0, changed PCI bridge control from 0x0008 to 0x000b
PCI: dom 0, bus 2, dev  0, func 0, changed PCI bridge control from 0x0000 to 0x0003
PCI: dom 0, bus 2, dev  2, func 0, changed PCI bridge control from 0x0000 to 0x0003
PCI: dom 0, bus 2, dev  3, func 0, changed PCI bridge control from 0x0000 to 0x0003
PCI: dom 0, bus 2, dev  4, func 0, changed PCI bridge control from 0x0000 to 0x0003
PCI: dom 0, bus 2, dev  8, func 0, changed PCI bridge control from 0x0008 to 0x000b
PCI: [dom 0, bus  0] bus   0, device  0, function  0: vendor f15e, device 0000, revision 00
PCI:   class_base 06, class_function 04, class_api 00
PCI:   line_size 08, latency 00, header_type 01, BIST 00
PCI:   subsystem_id 0000, subsystem_vendor_id 0040
PCI:   primary_bus 00, secondary_bus 01, subordinate_bus 07, secondary_latency 00
PCI:   I/O window 0000-0fff
PCI:   memory window 70200000-704fffff
PCI:   prefetchable memory window 0000002000000000-000000200fffffff
PCI:   bridge_control 0003, secondary_status 0000
PCI:   interrupt_line 39, interrupt_pin 01
PCI:   ROM base host 70100000, pci 70100000, size ??
PCI:   base reg 0: host 70000000, pci 70000000, size 00100000, flags 04
PCI:   base reg 1: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   Capabilities: PM, MSI, PCIe
PCI:   Extended capabilities: Advanced Error Reporting, Secondary PCIe, Vendor Unique
PCI: [dom 0, bus  1] bus   1, device  0, function  0: vendor 1b21, device 2824, revision 01
PCI:   class_base 06, class_function 04, class_api 00
PCI:   line_size 08, latency 00, header_type 01, BIST 00
PCI:   subsystem_id 0000, subsystem_vendor_id 0040
PCI:   primary_bus 01, secondary_bus 02, subordinate_bus 07, secondary_latency 00
PCI:   I/O window 60080000-60080fff
PCI:   memory window 70200000-704fffff
PCI:   prefetchable memory window 0000002000000000-000000200fffffff
PCI:   bridge_control 000b, secondary_status 0000
PCI:   interrupt_line 39, interrupt_pin 01
PCI:   ROM base host 00000000, pci 00000000, size ??
PCI:   base reg 0: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   base reg 1: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   Capabilities: PM, MSI, PCIe, subvendor
PCI:   Extended capabilities: Advanced Error Reporting, Power Budgeting, Latency Tolerance Reporting, Multicast, Secondary PCIe, Vendor Unique
PCI: [dom 0, bus  2] bus   2, device  0, function  0: vendor 1b21, device 2824, revision 01
PCI:   class_base 06, class_function 04, class_api 00
PCI:   line_size 08, latency 00, header_type 01, BIST 00
PCI:   subsystem_id 0000, subsystem_vendor_id 0040
PCI:   primary_bus 02, secondary_bus 03, subordinate_bus 03, secondary_latency 00
PCI:   I/O window 60080000-6007ffff
PCI:   memory window 70200000-701fffff
PCI:   prefetchable memory window 0000002000000000-0000001fffffffff
PCI:   bridge_control 0003, secondary_status 0000
PCI:   interrupt_line 39, interrupt_pin 01
PCI:   ROM base host 00000000, pci 00000000, size ??
PCI:   base reg 0: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   base reg 1: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   Capabilities: PM, MSI, PCIe, subvendor
PCI:   Extended capabilities: Advanced Error Reporting, Power Budgeting, Latency Tolerance Reporting, Multicast, Secondary PCIe, Vendor Unique
PCI: [dom 0, bus  2] bus   2, device  2, function  0: vendor 1b21, device 2824, revision 01
PCI:   class_base 06, class_function 04, class_api 00
PCI:   line_size 08, latency 00, header_type 01, BIST 00
PCI:   subsystem_id 0000, subsystem_vendor_id 0040
PCI:   primary_bus 02, secondary_bus 04, subordinate_bus 04, secondary_latency 00
PCI:   I/O window 60080000-6007ffff
PCI:   memory window 70200000-702fffff
PCI:   prefetchable memory window 0000002000000000-0000001fffffffff
PCI:   bridge_control 0003, secondary_status 0000
PCI:   interrupt_line 39, interrupt_pin 01
PCI:   ROM base host 00000000, pci 00000000, size ??
PCI:   base reg 0: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   base reg 1: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   Capabilities: PM, MSI, PCIe, subvendor
PCI:   Extended capabilities: Advanced Error Reporting, Power Budgeting, Latency Tolerance Reporting, Multicast, Secondary PCIe, Vendor Unique
PCI: [dom 0, bus  4] bus   3, device  0, function  0: vendor 1b21, device 1142, revision 00
PCI:   class_base 0c, class_function 03, class_api 30
PCI:   line_size 08, latency 00, header_type 00, BIST 00
PCI:   ROM base host 00000000, pci 00000000, size 00000000
PCI:   cardbus_CIS 00000000, subsystem_id 1142, subsystem_vendor_id 1b21
PCI:   interrupt_line 39, interrupt_pin 01, min_grant 00, max_latency 00
PCI:   base reg 0: host 70200000, pci 70200000, size 00008000, flags 04
PCI:   base reg 1: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   base reg 2: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   base reg 3: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   base reg 4: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   base reg 5: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   Capabilities: MSI, MSI-X, PM, PCIe
PCI:   Extended capabilities: Virtual Channel
PCI: [dom 0, bus  2] bus   2, device  3, function  0: vendor 1b21, device 2824, revision 01
PCI:   class_base 06, class_function 04, class_api 00
PCI:   line_size 08, latency 00, header_type 01, BIST 00
PCI:   subsystem_id 0000, subsystem_vendor_id 0040
PCI:   primary_bus 02, secondary_bus 05, subordinate_bus 05, secondary_latency 00
PCI:   I/O window 60080000-6007ffff
PCI:   memory window 70300000-702fffff
PCI:   prefetchable memory window 0000002000000000-0000001fffffffff
PCI:   bridge_control 0003, secondary_status 0000
PCI:   interrupt_line 39, interrupt_pin 01
PCI:   ROM base host 00000000, pci 00000000, size ??
PCI:   base reg 0: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   base reg 1: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   Capabilities: PM, MSI, PCIe, subvendor
PCI:   Extended capabilities: Advanced Error Reporting, Power Budgeting, Latency Tolerance Reporting, Multicast, Secondary PCIe, Vendor Unique
PCI: [dom 0, bus  2] bus   2, device  4, function  0: vendor 1b21, device 2824, revision 01
PCI:   class_base 06, class_function 04, class_api 00
PCI:   line_size 08, latency 00, header_type 01, BIST 00
PCI:   subsystem_id 0000, subsystem_vendor_id 0040
PCI:   primary_bus 02, secondary_bus 06, subordinate_bus 06, secondary_latency 00
PCI:   I/O window 60080000-6007ffff
PCI:   memory window 70300000-703fffff
PCI:   prefetchable memory window 0000002000000000-0000001fffffffff
PCI:   bridge_control 0003, secondary_status 0000
PCI:   interrupt_line 39, interrupt_pin 01
PCI:   ROM base host 00000000, pci 00000000, size ??
PCI:   base reg 0: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   base reg 1: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   Capabilities: PM, MSI, PCIe, subvendor
PCI:   Extended capabilities: Advanced Error Reporting, Power Budgeting, Latency Tolerance Reporting, Multicast, Secondary PCIe, Vendor Unique
PCI: [dom 0, bus  6] bus   4, device  0, function  0: vendor 1987, device 5013, revision 01
PCI:   class_base 01, class_function 08, class_api 02
PCI:   line_size 08, latency 00, header_type 00, BIST 00
PCI:   ROM base host 00000000, pci 00000000, size 00000000
PCI:   cardbus_CIS 00000000, subsystem_id 5013, subsystem_vendor_id 1987
PCI:   interrupt_line 39, interrupt_pin 01, min_grant 00, max_latency 00
PCI:   base reg 0: host 70300000, pci 70300000, size 00004000, flags 04
PCI:   base reg 1: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   base reg 2: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   base reg 3: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   base reg 4: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   base reg 5: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   Capabilities: PCIe, MSI-X, MSI, PM
PCI:   Extended capabilities: Latency Tolerance Reporting, L1 Power Management Substates, Advanced Error Reporting, Secondary PCIe
PCI: [dom 0, bus  2] bus   2, device  8, function  0: vendor 1b21, device 2824, revision 01
PCI:   class_base 06, class_function 04, class_api 00
PCI:   line_size 08, latency 00, header_type 01, BIST 00
PCI:   subsystem_id 0000, subsystem_vendor_id 0040
PCI:   primary_bus 02, secondary_bus 07, subordinate_bus 07, secondary_latency 00
PCI:   I/O window 60080000-60080fff
PCI:   memory window 70400000-704fffff
PCI:   prefetchable memory window 0000002000000000-000000200fffffff
PCI:   bridge_control 000b, secondary_status 0000
PCI:   interrupt_line 39, interrupt_pin 01
PCI:   ROM base host 00000000, pci 00000000, size ??
PCI:   base reg 0: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   base reg 1: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   Capabilities: PM, MSI, PCIe, subvendor
PCI:   Extended capabilities: Advanced Error Reporting, Power Budgeting, Latency Tolerance Reporting, Multicast, Secondary PCIe, Vendor Unique
PCI: [dom 0, bus  7] bus   5, device  0, function  0: vendor 1002, device 683f, revision 87
PCI:   class_base 03, class_function 00, class_api 00
PCI:   line_size 08, latency 00, header_type 80, BIST 00
PCI:   ROM base host 70440000, pci 70440000, size 00020000
PCI:   cardbus_CIS 00000000, subsystem_id 7250, subsystem_vendor_id 1787
PCI:   interrupt_line 39, interrupt_pin 01, min_grant 00, max_latency 00
PCI:   base reg 0: host 00000000, pci 00000000, size 10000000, flags 0c
PCI:   base reg 1: host 00000020, pci 00000020, size 00000000, flags 00
PCI:   base reg 2: host 70400000, pci 70400000, size 00040000, flags 04
PCI:   base reg 3: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   base reg 4: host 00000000, pci 60080000, size 00000100, flags 01
PCI:   base reg 5: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   Capabilities: vendspec, PM, PCIe, MSI
PCI:   Extended capabilities: Vendor Unique, Advanced Error Reporting, Resizable Bar, Secondary PCIe
PCI: [dom 0, bus  7] bus   5, device  0, function  1: vendor 1002, device aab0, revision 00
PCI:   class_base 04, class_function 03, class_api 00
PCI:   line_size 08, latency 00, header_type 80, BIST 00
PCI:   ROM base host 00000000, pci 00000000, size 00000000
PCI:   cardbus_CIS 00000000, subsystem_id aab0, subsystem_vendor_id 1787
PCI:   interrupt_line ff, interrupt_pin 02, min_grant 00, max_latency 00
PCI:   base reg 0: host 70460000, pci 70460000, size 00004000, flags 04
PCI:   base reg 1: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   base reg 2: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   base reg 3: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   base reg 4: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   base reg 5: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   Capabilities: vendspec, PM, PCIe, MSI
PCI:   Extended capabilities: Vendor Unique, Advanced Error Reporting
PCI: [dom 0, bus  7] bus   5, device  0, function  2: vendor 1002, device ad18, revision 00
PCI:   class_base 04, class_function 80, class_api 00
PCI:   line_size 08, latency 00, header_type 80, BIST 00
PCI:   ROM base host 00000000, pci 00000000, size 00000000
PCI:   cardbus_CIS 00000000, subsystem_id ad18, subsystem_vendor_id 1787
PCI:   interrupt_line ff, interrupt_pin 03, min_grant 00, max_latency 00
PCI:   base reg 0: host 70464000, pci 70464000, size 00000080, flags 04
PCI:   base reg 1: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   base reg 2: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   base reg 3: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   base reg 4: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   base reg 5: host 00000000, pci 00000000, size 00000000, flags 00
PCI:   Capabilities: vendspec, PM, PCIe, MSI
PCI:   Extended capabilities: Vendor Unique, Advanced Error Reporting

XHCI controller and NVMe disk are recognized, but currently not working properly because of not working PCI interrupts.

usb xhci: failed to get pci x86 module
usb xhci -1: interface version: 0x0100
usb xhci -1: structural parameters: 1:0x04000840 2:0x000000f1 3:0x00000000
usb xhci -1: capability parameters: 0x0200e081
INIT: main: done... begin idle loop on cpu 0
arch_thread_init_kthread_stack(0xffffffc006aab000(xhci event thread))
arch_thread_init_kthread_stack(0xffffffc006aaa500(xhci finish thread))
arch_int_enable_io_interrupt(57)
usb xhci -1: starting XHCI host controller
usb xhci -1: successfully started the controller
module: Search for bus_managers/pci/x86/v1 failed.
usb uhci: failed to get pci x86 module
usb uhci: no devices found
module: Search for bus_managers/pci/x86/v1 failed.
usb ohci: failed to get pci x86 module
usb ohci: no devices found
module: Search for bus_managers/pci/x86/v1 failed.
usb ehci: failed to get pci x86 module
usb ehci: no devices found
arch_thread_init_kthread_stack(0xffffffc006aaaa80(usb explore))
usb hub 2: port 0: new device connected
usb error control pipe 7: timeout waiting for queued request to complete
usb xhci 0: cancel queued transfers (1) for pipe 0xffffffc00096ede8 (0)
usb xhci 0: transfer error on slot 1 endpoint 1: Stopped
usb error xhci 0: TRB 0x81671020 was not found in the endpoint!
usb error xhci 0: failed to get the device descriptor: Operation timed out
usb hub 2: port 0 was warm reset
nvme_disk: attached to NVMe device "SPCC M.2 PCIe SSD (7EF607140B6800005305)"
nvme_disk:      maximum transfer size: 262144
nvme_disk:      qpair count: 8
nvme_disk: timed out waiting for interrupt!

NVMe driver even managed to read something with not working interrupts:

[  0] partition type: 5b193300-fc78-40cd-8002-e86c45580b47
      unique id: caa86a79-eb57-4306-ae66-61ba1975c038
      start block: 34
      end block: 2081
      size: 0.999 MB
      attributes: 0
      name: primary
[  1] partition type: 2e54b353-1271-4842-806f-e436d6af6985
      unique id: 5c2ddb18-ceaa-4389-aeba-6838e33cc54c
      start block: 2082
      end block: 10273
      size: 3.999 MB
      attributes: 0
      name: primary
[  2] partition type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
      unique id: 912a9078-3af3-4e50-8d29-c544030e486e
      start block: 16384
      end block: 282623
      size: 129.999 MB
      attributes: 4
      name: boot
[  3] partition type: 0fc63daf-8483-4772-8e79-3d69d8477de4
      unique id: 2a34702b-93d3-44ff-8129-9c68a8e94119
      start block: 286720
      end block: 249204735
      size: 121541.999 MB
      attributes: 0
      name: root
32 Likes