diff options
-rw-r--r-- | board-js2x/slof/pci-device_1002_515e.fs | 19 | ||||
-rw-r--r-- | slof/fs/pci-config-bridge.fs | 19 |
2 files changed, 25 insertions, 13 deletions
diff --git a/board-js2x/slof/pci-device_1002_515e.fs b/board-js2x/slof/pci-device_1002_515e.fs index 5cd692b..84561c4 100644 --- a/board-js2x/slof/pci-device_1002_515e.fs +++ b/board-js2x/slof/pci-device_1002_515e.fs @@ -32,15 +32,12 @@ my-space pci-set-irq-line -1 value regs-addr false value is_installed -: >rn [ 18 config-l@ -10 and ] LITERAL + ; -: rn! >rn rl!-le ; -: rn@ >rn rl@-le ; -: reg-rl@ rn@ ; -: reg-rl! rn! ; -: map-in " map-in" $call-parent ; -: map-out " map-out" $call-parent ; -: pc@ ( offset -- byte ) >rn rb@ ; -: pc! ( byte offset -- ) >rn rb! ; +: reg-rl@ regs-addr + rl@-le ; +: reg-rl! regs-addr + rl!-le ; +: map-in " map-in" $call-parent ; +: map-out " map-out" $call-parent ; +: pc@ ( offset -- byte ) regs-addr + rb@ ; +: pc! ( byte offset -- ) regs-addr + rb! ; 0 value phys_low 0 value phys_mid @@ -206,8 +203,8 @@ dup l@ swap la1+ ; : andorset ( reg and or -- ) - 2 pick regs-addr + dup rn@ - 3 pick AND 2 pick OR swap rn! 3drop + 2 pick dup reg-rl@ + 3 pick AND 2 pick OR swap reg-rl! 3drop ; : INIT1 diff --git a/slof/fs/pci-config-bridge.fs b/slof/fs/pci-config-bridge.fs index e1fe92b..82e263d 100644 --- a/slof/fs/pci-config-bridge.fs +++ b/slof/fs/pci-config-bridge.fs @@ -56,9 +56,24 @@ THEN \ FI ; -: map-in ( phys.lo ... phys.hi size -- virt ) +: map-in ( phys.lo phys.mid phys.hi size -- virt ) \ ." map-in called: " .s cr - 2drop drop + \ Ignore the size, phys.lo and phys.mid, get BAR from config space + drop nip nip ( phys.hi ) + \ Sanity check whether config address is in expected range: + dup FF AND 10 28 WITHIN NOT IF + cr ." phys.hi = " . cr + ABORT" map-in with illegal config space address" + THEN + 00FFFFFF AND \ Need only bus-dev-fn+register bits + dup config-l@ ( phys.hi' bar.lo ) + dup 7 AND 4 = IF \ Is it a 64-bit BAR? + swap 4 + config-l@ lxjoin \ Add upper part of 64-bit BAR + ELSE + nip + THEN + F NOT AND \ Clear indicator bits + \ TODO: Use translate-address here! ; : map-out ( virt size -- ) |