Andreas Färber | 1 Dec 2010 20:38
Picon
Gravatar

Nested [IFDEF]s not working?

Hello,

A construct like:

[IFDEF] CONFIG_PPC
   [IFDEF] CONFIG_PPC64
     5
   [ELSE]
     4
   [THEN]
[ELSE]
   [IFDEF] CONFIG_SPARC64
     6
   [ELSE]
     3
   [THEN]
[THEN]

has been seen to return, e.g., 4 3 according to the debug word.

Is this nesting forbidden in Forth? Easily fixable? A better way to do  
this? I do want a final catch-all since returning no value would have  
unexpected results, and we currently do not have a define CONFIG_PPC32  
so that a concatenation of independent [IFDEF]...[THEN]s wouldn't work.

TIA,

Andreas

(Continue reading)

Mark Cave-Ayland | 2 Dec 2010 12:21
Picon

Re: Reducing OpenBIOS memory footprint

Tarl Neustaedter wrote:

>> I see that for PPC in packages/video.c::init_video the framebuffer is 
>> allocated using OFMEM and then mapped 1:1. Blue has suggested that if 
>> direct access to the framebuffer is not required then we could try a 
>> similar dynamic allocation for SPARC - does anyone how/where OpenBoot 
>> stores its VGA framebuffer?
> 
> Assuming the AST driver is VGA (I think it is, but I'm not all that 
> familiar with VGA), it does a simple map-in of BAR 10 for size 80.0000, 
> and smaller amounts for BARs 14 and 18. That probably lands it in the 
> 0xfexx.xxxx window.

Look at the Debian sparc-utils prtconf example output, I see the 
following for the SS-5:

             Node 0xffd41b1c
                 address:  ffdcd000
                 character-set:  'ISO8859-1'
                 intr:  00000039.00000000
                 reg:  00000003.00000000.01000000
                 dblbuf:  00000000
                 vmsize:  00000001
                 depth:  00000008
                 height:  00000384
                 awidth:  00000480
                 linebytes:  00000480
                 width:  00000480
                 emulation:  'cgsix'
                 montype:  00000004
(Continue reading)

Mark Cave-Ayland | 2 Dec 2010 12:25
Picon

Re: Nested [IFDEF]s not working?

Andreas Färber wrote:
> Hello,
> 
> A construct like:
> 
> [IFDEF] CONFIG_PPC
>   [IFDEF] CONFIG_PPC64
>     5
>   [ELSE]
>     4
>   [THEN]
> [ELSE]
>   [IFDEF] CONFIG_SPARC64
>     6
>   [ELSE]
>     3
>   [THEN]
> [THEN]
> 
> has been seen to return, e.g., 4 3 according to the debug word.
> 
> Is this nesting forbidden in Forth? Easily fixable? A better way to do 
> this? I do want a final catch-all since returning no value would have 
> unexpected results, and we currently do not have a define CONFIG_PPC32 
> so that a concatenation of independent [IFDEF]...[THEN]s wouldn't work.

IIRC [IFDEF] [ELSE] and [THEN] are simply Forth words that swallow the 
input unless the condition is met.

I suspect it will be similar to the bbranch & friends Fcode instructions 
(Continue reading)

Tarl Neustaedter | 2 Dec 2010 19:13

Re: Reducing OpenBIOS memory footprint

On 2010-12-2 6:21 AM, Mark Cave-Ayland wrote:
> [...]
> This seems to suggest memory within the 0xff rather than the 0xfe range. 
> Interestingly enough, the screen device looks like this:
>
> screen:  '/iommu <at> 0,10000000/sbus <at> 0,10001000/cgsix <at> 3,0'
>
> Perhaps it's hiding on the SBUS and so it doesn't need a direct mapping? 
> Does the IOMMU allow paged access into SBUS space to avoid having to map it 
> in its entirety?

Not sure I understand your question - but yes, the IOMMU (IO memory management 
unit) allows paged access into SBUS space. When "map-in" is called, it maps 
only the specific pages into virtual memory without bringing the rest of SBUS 
in. We do the same on PCI without having a separate iommu node.

I'll admit that SBUS is at the very edge of my knowledge - my first project at 
Sun was PCI for SPARC (1994), so SBUS was already on its way out.

Andreas Färber | 4 Dec 2010 01:11
Picon
Gravatar

Re: Nested [IFDEF]s not working?

Am 02.12.2010 um 12:25 schrieb Mark Cave-Ayland:

> Andreas Färber wrote:
>> Hello,
>> A construct like:
>> [IFDEF] CONFIG_PPC
>>  [IFDEF] CONFIG_PPC64
>>    5
>>  [ELSE]
>>    4
>>  [THEN]
>> [ELSE]
>>  [IFDEF] CONFIG_SPARC64
>>    6
>>  [ELSE]
>>    3
>>  [THEN]
>> [THEN]
>> has been seen to return, e.g., 4 3 according to the debug word.
>> Is this nesting forbidden in Forth? Easily fixable? A better way to  
>> do this? I do want a final catch-all since returning no value would  
>> have unexpected results, and we currently do not have a define  
>> CONFIG_PPC32 so that a concatenation of independent [IFDEF]... 
>> [THEN]s wouldn't work.
>
> IIRC [IFDEF] [ELSE] and [THEN] are simply Forth words that swallow  
> the input unless the condition is met.
>
> I suspect it will be similar to the bbranch & friends Fcode  
> instructions whereby at compile time the current nested state is  
(Continue reading)

Segher Boessenkool | 4 Dec 2010 03:16

Re: Nested [IFDEF]s not working?

> I don't really understand the code in forth/lib/preprocessor.fs but it
> looks as if some state is held in three variables. Also the [ELSE]
> case handling in the [IF] loop looks unintuitive...

It looks like a bastardised version of the example code in the standard.
It only handles nested [IF] , not [IFDEF] etc.  It wouldn't be hard to
add it (just add and extra case, where it does a string compare for
[IF] ).

Segher

Segher Boessenkool | 4 Dec 2010 03:26

Re: Nested [IFDEF]s not working?

>> I don't really understand the code in forth/lib/preprocessor.fs but it
>> looks as if some state is held in three variables. Also the [ELSE]
>> case handling in the [IF] loop looks unintuitive...
>
> It looks like a bastardised version of the example code in the standard.
> It only handles nested [IF] , not [IFDEF] etc.  It wouldn't be hard to
> add it (just add and extra case, where it does a string compare for
> [IF] ).

Or, write it as

[DEFINED] bla [IF]
[DEFINED] blub [IF]
...
[ELSE]

etc.

Segher

Andreas Färber | 4 Dec 2010 12:35
Picon
Gravatar

Re: Nested [IFDEF]s not working?

Am 04.12.2010 um 03:16 schrieb Segher Boessenkool:

>> I don't really understand the code in forth/lib/preprocessor.fs but  
>> it
>> looks as if some state is held in three variables. Also the [ELSE]
>> case handling in the [IF] loop looks unintuitive...
>
> It looks like a bastardised version of the example code in the  
> standard.
> It only handles nested [IF] , not [IFDEF] etc.  It wouldn't be hard to
> add it (just add and extra case, where it does a string compare for
> [IF] ).

Thanks for the hint, working nicely now!

Andreas

Andreas Färber | 4 Dec 2010 14:38
Picon
Gravatar

[PATCH v2 2/3] forth: Pretty-print MMU translations property

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
 <at>  <at>  -326,6 +326,70  <at>  <at> 
   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
(Continue reading)

Andreas Färber | 4 Dec 2010 14:38
Picon
Gravatar

[PATCH 1/3] forth: Fix ([IF]) to handle nested [IFDEF] as well

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 <at> kernel.crashing.org>
Signed-off-by: Andreas Färber <andreas.faerber <at> 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
 <at>  <at>  -19,6 +19,7  <at>  <at> 
     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

(Continue reading)


Gmane