aboutsummaryrefslogtreecommitdiff
path: root/board-qemu/slof
diff options
context:
space:
mode:
authorAlexey Kardashevskiy <aik@ozlabs.ru>2018-04-06 12:28:23 +1000
committerAlexey Kardashevskiy <aik@ozlabs.ru>2018-09-07 13:18:50 +1000
commitb752674383846af8045a38f8f32604574fb54471 (patch)
tree35b5607ba5e6fc6beae5d669927995935169042e /board-qemu/slof
parent6e4b4adb893d16bdec05f777bf92a18b4ec2aa09 (diff)
downloadSLOF-b752674383846af8045a38f8f32604574fb54471.zip
SLOF-b752674383846af8045a38f8f32604574fb54471.tar.gz
SLOF-b752674383846af8045a38f8f32604574fb54471.tar.bz2
fdt: Factor out code to replace a phandle in place
We generate a fake XICS phandle in QEMU and SLOF replaces that phandle with the real one (i.e. SLOF's node address) in interrupt-parent and interrupt-map properties. These properties are handled differently - the interrupt-map is fixed in place while interrupt-parent is decoded+encoded+set as a property. This changes interrupt-parent fixing code to do what the interrupt-map code does because soon we are going to have more phandles to fix and some contain an array of phandles (such as "ibm,npu"). Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> --- Changes: v2: * removed fdt-replace-l,
Diffstat (limited to 'board-qemu/slof')
-rw-r--r--board-qemu/slof/fdt.fs25
1 files changed, 17 insertions, 8 deletions
diff --git a/board-qemu/slof/fdt.fs b/board-qemu/slof/fdt.fs
index 8e8921f..3138c9e 100644
--- a/board-qemu/slof/fdt.fs
+++ b/board-qemu/slof/fdt.fs
@@ -279,6 +279,21 @@ fdt-claim-reserve
2drop
;
+: (fdt-replace-phandles) ( old new propname propnamelen node -- )
+ get-property IF 2drop EXIT THEN
+ BEGIN
+ dup
+ WHILE ( old new prop-addr prop-len )
+ over l@
+ 4 pick = IF
+ 2 pick 2 pick l! \ replace old with new in place
+ TRUE TO (fdt-phandle-replaced)
+ THEN
+ 4 - swap 4 + swap
+ REPEAT
+ 2drop 2drop
+;
+
\ Replace one phandle "old" with a phandle "new" in "node" and recursively
\ in its child nodes:
: fdt-replace-all-phandles ( old new node -- )
@@ -288,14 +303,8 @@ fdt-claim-reserve
( old new prop-addr prop-len R: node )
fdt-replace-interrupt-map
THEN
- s" interrupt-parent" r@ get-property 0= IF
- ( old new prop-addr prop-len R: node )
- decode-int -rot 2drop ( old new val R: node )
- 2 pick = IF ( old new R: node )
- dup encode-int s" interrupt-parent" r@ set-property
- TRUE TO (fdt-phandle-replaced)
- THEN
- THEN
+
+ 2dup s" interrupt-parent" r@ (fdt-replace-phandles)
\ ... add more properties that have to be fixed here ...
r>
\ Now recurse over all child nodes: ( old new node )