Executing .properties for, e.g., the /memory node would print the "reg" property as a series of bytes. Modify the .properties and (.property) words to special-case property display based on property name. Visualize the "reg" format as a table.
Signed-off-by: Andreas Färber andreas.faerber@web.de --- Hello,
This prettification was tested for qemu-ppc (#address-cells == 1 && #size-cells == 1) with a local patch to fix the /memory reg property (uses 2 cells currently).
Is it permissible to modify the (.property) "signature" in this way?
Regards, Andreas
forth/admin/devices.fs | 34 +++++++++++++++++++++++++++++++--- 1 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/forth/admin/devices.fs b/forth/admin/devices.fs index dbb4646..4c72cbb 100644 --- a/forth/admin/devices.fs +++ b/forth/admin/devices.fs @@ -289,9 +289,37 @@ 2drop r> drop 1 ;
+\ TODO honor #address-cells and #size-cells +: (.p-reg) ( data len -- ) + swap >r 0 + begin 2dup > while + dup r@ + c@ + ( len n ch ) + pocket tohexstr dup 2 <> if ." 0" then type + 1+ + dup 8 mod 4 = if + ." " + then + dup 8 mod 0 = if + 2dup <> if + cr 0 begin ." " 1+ dup d# 26 >= until drop + then + then + repeat + 2drop r> drop +; + \ this function tries to heuristically determine the data format -: (.property) ( data len -- ) - dup 0= if 2drop ." <empty>" exit then +: (.property) ( name-str name-len data len -- ) + dup 0= if 2drop 2drop ." <empty>" exit then + + 2over + ( name-str name-len data len name-str name-len ) + s" reg" strcmp 0= if (.p-reg) 2drop exit then + ( name-str name-len data len ) + \ TODO this should be limited to /memory device + 2swap s" available" strcmp 0= if (.p-reg) exit then + ( data len )
.p-string? if exit then .p-int? if exit then @@ -307,7 +335,7 @@ while cr 2dup dup -rot type begin ." " 1+ dup d# 26 >= until drop - 2dup active-package get-package-property drop (.property) + 2dup 2dup active-package get-package-property drop (.property) repeat then r> drop