The decode-unit and encode-unit methods should be static methods which can be called without an active instance. But decode-unit has to insert the bus number in phys.hi which is available when the device node is created. Instead of trying to get the bus-range property of the current device, which fails if this method is called from a different package, store the bus number in the device when it is created and add a small forth wrapper to add the bus number so the C function does not need to care about it.
Signed-off-by: BALATON Zoltan balaton@eik.bme.hu --- NOTE: There should be a way to do the feval in last hunk within is-pci-bus so that line would not be needed here and could be put in pci.fs instead but I couldn't figure out how to put a colon definition within another so it's only evaluated when the outer one is executed. Does somebody with forth knowledge have an idea?
drivers/pci.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/pci.c b/drivers/pci.c index 55b959c..a50dc11 100644 --- a/drivers/pci.c +++ b/drivers/pci.c @@ -182,7 +182,6 @@ ob_pci_decode_unit(int *idx) ucell hi, mid, lo; const char *arg = pop_fstr_copy(); int dev, fn, reg, ss, n, p, t; - int bus, len; char *ptr;
PCI_DPRINTF("ob_pci_decode_unit idx=%p\n", idx); @@ -274,9 +273,7 @@ ob_pci_decode_unit(int *idx) } free((char*)arg);
- bus = get_int_property(get_cur_dev(), "bus-range", &len); - - hi = n | p | t | (ss << 24) | (bus << 16) | (dev << 11) | (fn << 8) | reg; + hi = n | p | t | (ss << 24) | (dev << 11) | (fn << 8) | reg;
PUSH(lo); PUSH(mid); @@ -412,7 +409,7 @@ ob_pci_bus_map_in(int *idx) }
NODE_METHODS(ob_pci_bus_node) = { - { "decode-unit", ob_pci_decode_unit }, + { "pci-decode-unit", ob_pci_decode_unit }, { "encode-unit", ob_pci_encode_unit }, { "pci-map-in", ob_pci_bus_map_in }, }; @@ -427,7 +424,7 @@ ob_pci_bridge_map_in(int *idx) }
NODE_METHODS(ob_pci_bridge_node) = { - { "decode-unit", ob_pci_decode_unit }, + { "pci-decode-unit", ob_pci_decode_unit }, { "encode-unit", ob_pci_encode_unit }, { "pci-map-in", ob_pci_bridge_map_in }, }; @@ -1773,6 +1770,8 @@ static phandle_t ob_configure_pci_device(const char* parent_path, BIND_NODE_METHODS(phandle, ob_pci_bus_node); } fword("is-pci-bus"); + PUSH(*bus_num); + feval(": decode-unit pci-decode-unit lbsplit nip ( bus-num ) literal swap bljoin ;"); break; }