On Sat, 20 Jul 2019, BALATON Zoltan wrote:
On Sat, 20 Jul 2019, BALATON Zoltan wrote:
0 > "/pci@f2000000/ATY" open-dev to my-self
ob_pci_bar_map_in idx=1fc5ac54 ob_pci_map: ba=0x82000000 size=16384 ob_pci_map: after decode flags=0x0 space_code=0x2 mask=0xf pci_bus_addr_to_host_addr: space=0x2 ba=0x82000000 ob_pci_map: phys=0x82000000 size=16384 ob_pci_bar_map_in idx=1fc5ac54 ob_pci_map: ba=0x81000000 size=16777216 ob_pci_map: after decode flags=0x0 space_code=0x2 mask=0xf pci_bus_addr_to_host_addr: space=0x2 ba=0x81000000 ob_pci_map: phys=0x81000000 size=16777216
ok 0 > my-unit ok 3 > . 7800 ok 2 > . 0 ok 1 > . 0 ok 0 > my-space . 0 ok
^ this is still wrong, should be 7800
0 > my-address . . 0 0 ok 0 > my-address h# 1000014 h# 7800 + h# 100 ok 4 > .s <4> 0 0 1007814 100 ok 4 > " map-in" $call-parent
ob_pci_bar_map_in idx=1fc5ac54 ob_pci_map: ba=0x00000000 size=256 ob_pci_map: after decode flags=0x0 space_code=0x2 mask=0xf pci_bus_addr_to_host_addr: space=0x2 ba=0x00000000 ob_pci_map: phys=0x00000000 size=256
ok
So the base address already looks wrong in the first line of ob_pci_map. Does the ob_pci_bar_map_in() function decode its parameters correctly?
/* ( pci-addr.lo pci-addr.mid pci-addr.hi size -- virt ) */
static void ob_pci_bus_map_in(int *idx) { uint32_t ba; ucell size; ucell virt;
PCI_DPRINTF("ob_pci_bar_map_in idx=%p\n", idx); size = POP(); POP(); POP(); ba = POP(); virt = ob_pci_map(ba, size); PUSH(virt);
}
Shouldn't this be
size = POP(); ba = POP(); POP(); POP();
above?
Or maybe not because it looks correct for BARs as above at the top of this message. So why does this function ignore the pci-addr.hi which is the only non-0 in this call or should it try to map config space of the card for ba=0?
This pci_decode_pci_addr() function looks suspicious:
https://github.com/openbios/openbios/blob/master/drivers/pci.c#L156
it's called from ob_pci_map():
https://github.com/openbios/openbios/blob/master/drivers/pci.c#L373
It only expects IO or MMIO space and instead of finding what space is requested from pci-addr.hi it only looks at pci-addr.lo to decide. I think this is probably not how this should work. OK, the comment near ob_pci_map() says it's for mapping PCI MMIO or IO so it was probably not meant to allow access to config space but the map-in word seems to allow that as well. So what's the recommended way here? Which of these functions should be changed to add support for config space or should that be handled in ob_pci_bus_map_in already?
Regards, BALATON Zoltan