Am 06.11.2010 um 01:23 schrieb Segher Boessenkool:
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.
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
Acked-by: Segher Boessenkool segher@kernel.crashing.org
(assuming you tested it :-) )
I did, 1/1, 3/2 and now 1/0, all for ppc. It looks okay. But...
diff --git a/forth/device/property.fs b/forth/device/property.fs index 285113b..fb529a5 100644 --- a/forth/device/property.fs +++ b/forth/device/property.fs @@ -157,6 +157,20 @@ then ;
+\ HELPER: get #size-cells value (from parent) +\ Legal values are 1..4 (we may optionally support larger sizes) +: 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
- \ we don't have to support more than 4 (and 0 is illegal)
- decode-int nip nip 4 min 1 max
This seems wrong: 0 appears be a valid #size-cells value for device_type cpu. If I use 0 max here though, I just get one column for the /cpus/ PowerPC,970FX available property instead of two...
Andreas
- 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 -- 1.7.3