[OpenBIOS] [PATCH] forth: Pretty-print MMU translations property

Andreas Färber andreas.faerber at web.de
Sun Nov 28 19:49:59 CET 2010


Display one MMU translation per row for .properties command.

Signed-off-by: Andreas Färber <andreas.faerber at web.de>
---
 forth/admin/devices.fs |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/forth/admin/devices.fs b/forth/admin/devices.fs
index 7a5b693..00b4f55 100644
--- a/forth/admin/devices.fs
+++ b/forth/admin/devices.fs
@@ -326,6 +326,30 @@
   3drop drop
 ;
 
+\ Print the value of the MMU translations property
+: .p-translations ( data len -- )
+  2dup + -rot ( data+len data len )
+  >r >r [IFDEF] CONFIG_PPC
+    [IFDEF] CONFIG_PPC64 5 [ELSE] 4 [THEN]
+  [ELSE]
+    3
+  [THEN] 4 * dup ( data+len #bytes #bytes  R: len data ) r> r>
+  bounds ( data+len #bytes #bytes data+len data ) ?do
+    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- dup 0= if					\ end of row
+      2 pick i 1+ > if				\ non-last byte
+        cr							\ start new line
+        d# 26 spaces				\ indentation
+      then
+      drop dup						\ update counter
+    then
+  loop
+  2drop drop
+;
+
 \ This function hardwires data formats to particular node properties
 : (.property-by-name) ( name-str name-len data len -- )
   2over " reg" strcmp 0= if
@@ -346,6 +370,10 @@
           1 1 2swap .p-reg
           2drop exit
         then
+        2over " translations" strcmp 0= if
+          .p-translations
+          2drop exit
+        then
       then
     then
   then
-- 
1.7.3




More information about the OpenBIOS mailing list