[OpenBIOS] [PATCH v2 2/3] forth: Pretty-print MMU translations property
Andreas Färber
andreas.faerber at web.de
Sat Dec 4 15:30:16 CET 2010
Am 04.12.2010 um 14:38 schrieb Andreas Färber:
> Display one MMU translation per row for .properties command.
> Define a variable number of columns to handle platform specifics.
>
> v2:
> * Define columns for spacing. Add helpers to facilitate this.
>
> Signed-off-by: Andreas Färber <andreas.faerber at web.de>
> ---
> forth/admin/devices.fs | 68 +++++++++++++++++++++++++++++++++++++++
> +++++++++
> 1 files changed, 68 insertions(+), 0 deletions(-)
>
> diff --git a/forth/admin/devices.fs b/forth/admin/devices.fs
> index 7a5b693..1bf7e6f 100644
> --- a/forth/admin/devices.fs
> +++ b/forth/admin/devices.fs
> @@ -326,6 +326,70 @@
> 3drop drop
> ;
>
> +\ Return the number of cells per physical address
> +: .p-translations-#pacells
> + " /" find-package if
> + " #address-cells" rot get-package-property if
> + 1
> + else
> + decode-int nip nip 1 max
> + then
> + else
> + 1
> + then
> +;
> +
> +\ Return the number of cells per translation entry
> +: .p-translations-#cells ( -- #cells )
> + [IFDEF] CONFIG_PPC
> + my-#acells 3 *
> + [ELSE]
> + my-#acells 2 *
> + [THEN]
> + .p-translations-#pacells +
This is wrong. Only on ppc the physical address is contained in the
translations property.
my-#acells 3 * should work for sparc and happens to result in
identical values due to no #address-cells on /virtual-memory.
> +;
> +
> +\ Set up column offsets
> +: .p-translations-cols ( -- col1 ... coln #cols )
> + [IFDEF] CONFIG_PPC
> + 4
> + 8
> + dup .p-translations-#pacells 4 * +
> + 3
> + [ELSE]
> + my-#acells 4 *
> + dup my-#scells 4 * +
> + 2
> + [THEN]
> +;
> +
> +\ Print the value of the MMU translations property
> +: .p-translations ( data len -- )
> + >r >r .p-translations-cols r> r> ( col1 ... coln #cols data len )
> + 2dup + -rot ( col1 ... coln #cols data+len data len )
> + >r >r .p-translations-#cells 4 * dup r> r>
> + ( col1 ... coln #cols data+len #bytes #bytes len data )
> + bounds ( col1 ... coln #cols data+len #bytes #bytes data+len
> data ) ?do
> + 3 pick 4 + 4 ?do \ check all defined columns
> + i pick over 3 pick swap - = if
> + 2 spaces \ start new column
> + then
> + loop
> + 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 0 ?do drop loop
> +;
> +
> \ 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 +410,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
>
>
> --
> OpenBIOS http://openbios.org/
> Mailinglist: http://lists.openbios.org/mailman/listinfo
> Free your System - May the Forth be with you
More information about the OpenBIOS
mailing list