j
: Next unread message k
: Previous unread message j a
: Jump to all threads
j l
: Jump to MailingList overview
Author: afaerber Date: Mon Nov 15 23:04:03 2010 New Revision: 957 URL: http://tracker.coreboot.org/trac/openbios/changeset/957
Log: 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
Modified: trunk/openbios-devel/forth/admin/devices.fs trunk/openbios-devel/forth/device/property.fs
Modified: trunk/openbios-devel/forth/admin/devices.fs ============================================================================== --- trunk/openbios-devel/forth/admin/devices.fs Mon Nov 15 22:58:39 2010 (r956) +++ trunk/openbios-devel/forth/admin/devices.fs Mon Nov 15 23:04:03 2010 (r957) @@ -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) ;
Modified: trunk/openbios-devel/forth/device/property.fs ============================================================================== --- trunk/openbios-devel/forth/device/property.fs Mon Nov 15 22:58:39 2010 (r956) +++ trunk/openbios-devel/forth/device/property.fs Mon Nov 15 23:04:03 2010 (r957) @@ -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