On Mon, 22 Jul 2019, BALATON Zoltan wrote:
SLOF reads the BAR address from card config space with config-l@ using the addr.hi part only then translates it either from assigned-addresses or or parent's ranges property (but I could not get the details of this).
I can't do the same in OpenBIOS because BAR seems to be unassigned if I read config reg from map-in and trying to get address from assigned-adresses also look strange for io regions:
I think we need something like this:
: pci-map-in ( addr.lo addr.mid addr.hi size -- virt ) \ Ignore everything but addr.hi and find assigned addr for BAR drop nip nip " assigned-addresses" active-package get-package-property 0= if begin decode-phys ( bar prop prop-len phys.lo phys.mid phys.hi ) dup 6 pick = if 2drop -rot decode-int drop decode-int drop 2drop ( bar addr.lo ) \ Now translate addr.lo, FIXME this is wrong \ maybe we should look at parent's ranges instead? over 18 rshift 3 and 1 = if " reg" active-package parent get-package-property 0= if ( bar addr.lo prop prop-len reg.addr reg.size ) decode-int -rot decode-int 3drop + then then nip exit else 3drop \ no match, try next then \ Drop the size as we don't need it decode-int drop decode-int drop dup 0= until 3drop -1 \ not found else drop -1 \ could not find assigned-addresses then ;
which returns the correct values for the case I looked at but likely not the proper way to do this and I don't know why for example only io range needs adding an offset. This also has assumptions about node being direct child of a pci bus so probably won't work with bridges. Also how to add this to be a method of the /pci node (without going through a C function that I could do but seems ugly).
I'm still interested if anyone knows how all this should work so instead of putting together pieces from here and there we actually know where we are going.
Regards, BALATON Zoltan