diff options
author | Andreas Färber <andreas.faerber@web.de> | 2010-11-15 22:04:03 +0000 |
---|---|---|
committer | Andreas Färber <afaerber@suse.de> | 2010-11-15 22:04:03 +0000 |
commit | 3c35849d2a0cc5c6afea339183b9fee032f4c508 (patch) | |
tree | 7e7043c1391e77c9bc4fb0a52eaf0f641ad3738b | |
parent | 589a2b2d3fdf45fb475d0c7d0f277980f93ac349 (diff) | |
download | openbios-3c35849d2a0cc5c6afea339183b9fee032f4c508.zip openbios-3c35849d2a0cc5c6afea339183b9fee032f4c508.tar.gz openbios-3c35849d2a0cc5c6afea339183b9fee032f4c508.tar.bz2 |
Pretty-print reg property
Executing .properties for, e.g., the /memory node would print the
"reg" property as a series of bytes.
Visualize the "reg" format as a table, with address and size columns.
v6:
* Drop lower limit for my-#scells, since #size-cells is unsigned.
Pointed out by Segher.
* Drop comment outdated by v5.
v5:
* Drop the upper limit for my-#scells, suggested by Segher.
* Fix indentation.
v4:
* Fix my-#scells to allow 0 return value.
* Pass #address-cells and #size-cells as arguments.
* Add some more comments.
v3:
* Optimization, based on code suggested by Segher.
v2:
* Use my-#acells for address size.
* Introduce my-#scells for size size.
Cc: Segher Boessenkool <segher@kernel.crashing.org>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@957 f158a5a8-5612-0410-a976-696ce0be7e32
-rw-r--r-- | forth/admin/devices.fs | 27 | ||||
-rw-r--r-- | forth/device/property.fs | 12 |
2 files changed, 39 insertions, 0 deletions
diff --git a/forth/admin/devices.fs b/forth/admin/devices.fs index 91fbde5..7313a35 100644 --- a/forth/admin/devices.fs +++ b/forth/admin/devices.fs @@ -304,8 +304,35 @@ 2drop ." <unimplemented type>" ; +\ Print the value of a property in "reg" format +: .p-reg ( #acells #scells data len -- ) + 2dup + -rot ( #acells #scells data+len data len ) + >r >r -rot ( data+len #acells #scells R: len data ) + 4 * swap 4 * dup r> r> ( data+len #sbytes #abytes #abytes data len ) + bounds ( data+len #sbytes #abytes #abytes data+len data ) ?do + dup 0= if 2 spaces then \ start of "size" part + 2dup <> if \ non-first byte in row + dup 3 and 0= if space then \ make numbers more readable + then + i c@ 2 0.r \ print byte + 1- 3dup nip + 0= if \ end of row + 3 pick i 1+ > if \ non-last byte + cr \ start new line + d# 26 spaces \ indentation + then + drop dup \ update counter + then + loop + 3drop drop +; + \ This function hardwires data formats to particular node properties : (.property-by-name) ( name-str name-len data len -- ) + 2over " reg" strcmp 0= if + my-#acells my-#scells 2swap .p-reg + 2drop exit + then + 2swap 2drop ( data len ) (.property) ; diff --git a/forth/device/property.fs b/forth/device/property.fs index 285113b..d19546c 100644 --- a/forth/device/property.fs +++ b/forth/device/property.fs @@ -157,6 +157,18 @@ then ; +\ HELPER: get #size-cells value (from parent) +: my-#scells ( -- #size-cells ) + my-self ?dup if >in.device-node @ else active-package then + ?dup if >dn.parent @ then + ?dup if + " #size-cells" rot get-package-property if 1 exit then + decode-int nip nip + else + 1 + then +; + : decode-string ( prop-addr1 prop-len1 -- prop-addr2 prop-len2 str len ) dup 0> if 2dup bounds \ check property for 0 bytes |