Display one MMU translation per row for .properties command.
Signed-off-by: Andreas Färber andreas.faerber@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
Am 28.11.2010 um 19:49 schrieb Andreas Färber:
Display one MMU translation per row for .properties command.
Signed-off-by: Andreas Färber andreas.faerber@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
This value seems wrong: On a Sun Fire V480 in /virtual-memory there's six cells displayed in a row (3 x2). On sparc32 I guess this might be four? Can anyone check that please? Thanks!
Andreas
On Tue, Nov 30, 2010 at 8:47 PM, Andreas Färber andreas.faerber@web.de wrote:
Am 28.11.2010 um 19:49 schrieb Andreas Färber:
Display one MMU translation per row for .properties command.
Signed-off-by: Andreas Färber andreas.faerber@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
This value seems wrong: On a Sun Fire V480 in /virtual-memory there's six cells displayed in a row (3 x2). On sparc32 I guess this might be four? Can anyone check that please? Thanks!
'translations' doesn't exist in any Sparc32 trees that I have.
Depending on the condition either the [IFDEF] foo or the [ELSE] would get compiled as an [IF], eating words until [ELSE] or [THEN] respectively. While doing so, [IFDEF] does not get compiled to [IF], so we need to handle nested [IFDEF] to account for its [ELSE] or [THEN].
This fixes [IFDEF] not disabling the full section of code.
Thanks to Segher for pointing me in the right direction.
Cc: Segher Boessenkool segher@kernel.crashing.org Signed-off-by: Andreas Färber andreas.faerber@web.de --- forth/lib/preprocessor.fs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/forth/lib/preprocessor.fs b/forth/lib/preprocessor.fs index ac88885..89d478c 100644 --- a/forth/lib/preprocessor.fs +++ b/forth/lib/preprocessor.fs @@ -19,6 +19,7 @@ repeat
2dup " [IF]" strcmp 0= if 1 throw then + 2dup " [IFDEF]" strcmp 0= if 1 throw then 2dup " [ELSE]" strcmp 0= if 2 throw then 2dup " [THEN]" strcmp 0= if 3 throw then " \" strcmp 0= if linefeed parse 2drop then
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@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 + +; + +\ 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
On sparc64 a virtual address or size value is contained within one stack cell but that makes two property cells. The columns for the /virtual-memory "available" property thus looked wrong.
Do read the number of cells from #address-cells but make sure the size is at least one to not break ppc.
Cc: Tarl Neustaedter tarl-b2@tarl.net Signed-off-by: Andreas Färber andreas.faerber@web.de --- forth/admin/devices.fs | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/forth/admin/devices.fs b/forth/admin/devices.fs index 1bf7e6f..38cb5bb 100644 --- a/forth/admin/devices.fs +++ b/forth/admin/devices.fs @@ -407,7 +407,7 @@ " mmu" rot get-package-property 0= if decode-int nip nip ihandle>phandle active-package = if 2over " available" strcmp 0= if - 1 1 2swap .p-reg + my-#acells my-#scells 1 max 2swap .p-reg 2drop exit then 2over " translations" strcmp 0= if
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@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 thenthen then
-- 1.7.3
-- OpenBIOS http://openbios.org/ Mailinglist: http://lists.openbios.org/mailman/listinfo Free your System - May the Forth be with you
Display one MMU translation per row for .properties command. Define a variable number of columns to handle platform specifics.
v3: * Only ppc includes the physical address in the translations property. Simplify loop by reverting to decreasing column offsets.
v2: * Define columns for spacing. Add helpers to facilitate this.
Signed-off-by: Andreas Färber andreas.faerber@web.de --- forth/admin/devices.fs | 69 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 69 insertions(+), 0 deletions(-)
diff --git a/forth/admin/devices.fs b/forth/admin/devices.fs index 7a5b693..6e70b77 100644 --- a/forth/admin/devices.fs +++ b/forth/admin/devices.fs @@ -326,6 +326,71 @@ 3drop drop ;
+\ Return the number of cells per physical address +: .p-translations-#pacells ( -- #cells ) + " /" 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 * + .p-translations-#pacells + + [ELSE] + my-#acells 3 * + [THEN] +; + +\ Set up column offsets +: .p-translations-cols ( -- col1 ... coln #cols ) + .p-translations-#cells 4 * + [IFDEF] CONFIG_PPC + 4 - + dup 4 - + 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 = 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 +411,10 @@ 1 1 2swap .p-reg 2drop exit then + 2over " translations" strcmp 0= if + .p-translations + 2drop exit + then then then then
Am 05.12.2010 um 12:40 schrieb Andreas Färber:
Display one MMU translation per row for .properties command. Define a variable number of columns to handle platform specifics.
v3:
- Only ppc includes the physical address in the translations property.
Simplify loop by reverting to decreasing column offsets.
v2:
- Define columns for spacing. Add helpers to facilitate this.
Signed-off-by: Andreas Färber andreas.faerber@web.de
These have been around for a week now. If there are no comments, I'll apply 2-3 of v3 later.
Andreas
Am 05.12.2010 um 12:40 schrieb Andreas Färber:
Display one MMU translation per row for .properties command. Define a variable number of columns to handle platform specifics.
v3:
- Only ppc includes the physical address in the translations property.
Simplify loop by reverting to decreasing column offsets.
v2:
- Define columns for spacing. Add helpers to facilitate this.
Signed-off-by: Andreas Färber andreas.faerber@web.de
Applied in r983-984.
Depending on the condition either the [IFDEF] foo or the [ELSE] would get compiled as an [IF], eating words until [ELSE] or [THEN] respectively. While doing so, [IFDEF] does not get compiled to [IF], so we need to handle nested [IFDEF] to account for its [ELSE] or [THEN].
This fixes [IFDEF] not disabling the full section of code.
Thanks to Segher for pointing me in the right direction.
Cc: Segher Boessenkool segher@kernel.crashing.org Signed-off-by: Andreas Färber andreas.faerber@web.de
Signed-off-by: Segher Boessenkool segher@kernel.crashing.org
forth/lib/preprocessor.fs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/forth/lib/preprocessor.fs b/forth/lib/preprocessor.fs index ac88885..89d478c 100644 --- a/forth/lib/preprocessor.fs +++ b/forth/lib/preprocessor.fs @@ -19,6 +19,7 @@ repeat
2dup " [IF]" strcmp 0= if 1 throw then
- 2dup " [IFDEF]" strcmp 0= if 1 throw then 2dup " [ELSE]" strcmp 0= if 2 throw then 2dup " [THEN]" strcmp 0= if 3 throw then " \" strcmp 0= if linefeed parse 2drop then
-- 1.7.3
Am 04.12.2010 um 15:30 schrieb Segher Boessenkool:
Depending on the condition either the [IFDEF] foo or the [ELSE] would get compiled as an [IF], eating words until [ELSE] or [THEN] respectively. While doing so, [IFDEF] does not get compiled to [IF], so we need to handle nested [IFDEF] to account for its [ELSE] or [THEN].
This fixes [IFDEF] not disabling the full section of code.
Thanks to Segher for pointing me in the right direction.
Cc: Segher Boessenkool segher@kernel.crashing.org Signed-off-by: Andreas Färber andreas.faerber@web.de
Signed-off-by: Segher Boessenkool segher@kernel.crashing.org
Thanks, applied as r979.
Andreas