Hello !
I have tried to recreate the 3 known variants of next-property:
Standard : a) true "string" b) false c) false
Sun Ultra10 : a) -1 "string" b) nothing c) nothing
PowerPC iBook : a) -1 "string" b) -1 0 0 c) 0
Here is a tentative patch :
Index: forth/admin/devices.fs
===================================================================
--- forth/admin/devices.fs (révision 1269)
+++ forth/admin/devices.fs (copie de travail)
@@ -451,7 +451,7 @@
?active-package dup >r if
0 0
begin
- r@ next-property
+ r@ next-property-std
while
cr 2dup dup -rot type
begin ." " 1+ dup d# 26 >= until drop
Index: forth/device/property.fs
===================================================================
--- forth/device/property.fs (révision 1269)
+++ forth/device/property.fs (copie de travail)
@@ -63,14 +63,14 @@
;
\ From package (5.3.4.1)
-: next-property
+: next-property-std
( previous-str previous-len phandle -- false | name-str name-len true )
>r
2dup 0= swap 0= or if
2drop r> >dn.properties @
else
r> find-property dup if @ then
- ?dup if >prop.next @ then
+ dup if >prop.next @ then
then
?dup if
@@ -81,7 +81,57 @@
then
;
+: next-property-ppc
+( previous-str previous-len phandle -- false | name-str name-len true |
0 0 true )
+ >r
+ 2dup 0= swap 0= or if
+ 2drop r> >dn.properties @ true
+ else
+ r> find-property dup if @ then
+ dup if >prop.next @ true then
+ then
+ if
+ dup if
+ >prop.name @ dup cstrlen
+ ( phandle name-str name-len )
+ else
+ 0
+ ( 0 0 )
+ then
+ true
+ else
+ false
+ then
+;
+
+: next-property-std-bis
+ next-property-ppc
+ dup
+ if over 0=
+ if
+ 2drop
+ then
+ then
+;
+
+: next-property-s64
+ next-property-std
+ ?dup drop
+;
+
+: next-property
+ [IFDEF] CONFIG_PPC
+ next-property-ppc
+ [ELSE]
+ [IFDEF] CONFIG_SPARC64
+ next-property-s64
+ [ELSE]
+ next-property-std
+ [THEN]
+ [THEN]
+;
+
\
\ 5.3.5.4 Property value access
\
Index: forth/system/ciface.fs
===================================================================
--- forth/system/ciface.fs (révision 1269)
+++ forth/system/ciface.fs (copie de travail)
@@ -121,7 +121,7 @@
( buf prev prev_len )
- r> next-property if
+ r> next-property-std if
( buf name name_len )
dup 1+ -rot ci-strcpy drop 1
else
===================================================================
there are :
next-property-std = standard, used by Sparc32 "romvec" C code and by
forth code, like ".properties"
next-property-s64 = Sparc64 version, built from next-property-std
next-property-ppc = PowerPC version
next-property-std-bis = Alternate standard version, built from the PPC
one (e.g. when compiling for PPC target)
Tests :
showstack
cd screen
\ Sparc32
" " ?active-package next-property-std cr . type cr
" name" ?active-package next-property-std cr . type cr
" interrupts" ?active-package next-property-std cr . cr
" ttttt" ?active-package next-property-std cr . cr
\ PowerPC
" " ?active-package next-property-ppc cr . type cr
" name" ?active-package next-property-ppc cr . type cr
" interrupts" ?active-package next-property-ppc cr . . . cr
" ttttt" ?active-package next-property-ppc cr . cr
\ Sparc64
" " ?active-package next-property-s64 cr . type cr
" name" ?active-package next-property-s64 cr . type cr
" interrupts" ?active-package next-property-s64 cr
" ttttt" ?active-package next-property-s64 cr
" " ?active-package next-property-std-bis cr . type cr
" name" ?active-package next-property-std-bis cr . type cr
" interrupts" ?active-package next-property-std-bis cr . cr
" ttttt" ?active-package next-property-std-bis cr . cr
Currently all variants are available simultaneously.
Additional [IFDEF] can be used to hide some variants according
to compilation options, generate the -std from the -ppc,..
One more oddity:
NetBSD is not the only one to do strange things with properties.
In OpenBSD, one can find :
arch/sparc/dev/sbus.c:int sbus_testdma(sc, ca)
...
getpropint(0, "slave-only", 0)
...
arch/sparc/dev/sbus.c:int sbus_print(args, sbus)
...
getpropint(0, sl, 0)
...
Here, 0 should select the 'root' node.
It really looks like a bug in OpenBSD.
It does not prevent the OS from running though.
Olivier
Author: mcayland
Date: Sun Feb 16 17:26:46 2014
New Revision: 1269
URL: http://tracker.coreboot.org/trac/openbios/changeset/1269
Log:
SPARC32: alter obp_dumb_memalloc() to handle allocation with va == 0
It seems that the obp_dumb_memalloc() function can be called with va == 0
which means that OpenBIOS should pick the next free virtual address itself.
Otherwise we end up accidentally mapping into zero page causing all sorts of
problems.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland(a)ilande.co.uk>
Modified:
trunk/openbios-devel/arch/sparc32/lib.c
Modified: trunk/openbios-devel/arch/sparc32/lib.c
==============================================================================
--- trunk/openbios-devel/arch/sparc32/lib.c Sun Feb 16 17:26:43 2014 (r1268)
+++ trunk/openbios-devel/arch/sparc32/lib.c Sun Feb 16 17:26:46 2014 (r1269)
@@ -229,14 +229,28 @@
char *obp_dumb_memalloc(char *va, unsigned int size)
{
unsigned long align = size;
+ phys_addr_t phys;
+ ucell virt;
DPRINTF("obp_dumb_memalloc: virta 0x%x, sz %d\n", (unsigned int)va, size);
/* Solaris seems to assume that the returned value is physically aligned to size.
- e.g. it is used for setting up page tables. Fortunately this is now handled by
- ofmem_claim_phys() above. */
+ e.g. it is used for setting up page tables. */
- return obp_memalloc(va, size, align);
+ /* Claim physical memory */
+ phys = ofmem_claim_phys(-1, size, align);
+
+ /* Claim virtual memory - if va == NULL then we choose va address */
+ if (va == NULL) {
+ virt = ofmem_claim_virt((ucell)-1, size, align);
+ } else {
+ virt = ofmem_claim_virt(pointer2cell(va), size, 0);
+ }
+
+ /* Map the memory */
+ ofmem_map(phys, virt, size, ofmem_arch_default_translation_mode(phys));
+
+ return cell2pointer(virt);
}
void obp_dumb_memfree(char *va, unsigned size)
Author: mcayland
Date: Sun Feb 16 17:26:43 2014
New Revision: 1268
URL: http://tracker.coreboot.org/trac/openbios/changeset/1268
Log:
OFMEM: ensure minimum alignment of PAGE_SIZE
NextStep appears to request an alignment of 4 for some of its large memory
ranges, and since this is an exact power of 2 then the code to ensure a
minimum alignment of PAGE_SIZE is accidentally bypassed. Move this to a
separate check so we can guarantee the minimum alignment requirement is always
observed.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland(a)ilande.co.uk>
Modified:
trunk/openbios-devel/libopenbios/ofmem_common.c
Modified: trunk/openbios-devel/libopenbios/ofmem_common.c
==============================================================================
--- trunk/openbios-devel/libopenbios/ofmem_common.c Sun Feb 16 17:26:40 2014 (r1267)
+++ trunk/openbios-devel/libopenbios/ofmem_common.c Sun Feb 16 17:26:43 2014 (r1268)
@@ -428,13 +428,20 @@
{
phys_addr_t base = min;
range_t *r2;
- ucell old_align;
+ ucell old_align = align;
int i;
+ if( (align < PAGE_SIZE) ) {
+
+ /* Minimum alignment is page size */
+ align = PAGE_SIZE;
+
+ OFMEM_TRACE("warning: bad alignment " FMT_ucellx " rounded up to " FMT_ucellx "\n", old_align, align);
+ }
+
if( (align & (align-1)) ) {
/* As per IEEE1275 specification, round up to the nearest power of 2 */
- old_align = align;
if (old_align <= PAGE_SIZE) {
align = PAGE_SIZE;
} else {
@@ -447,8 +454,6 @@
OFMEM_TRACE("warning: bad alignment " FMT_ucellx " rounded up to " FMT_ucellx "\n", old_align, align);
}
- if( !align )
- align = PAGE_SIZE;
base = reverse ? max - size : min;
r2 = reverse ? NULL : r;
Author: mcayland
Date: Sun Feb 16 17:26:40 2014
New Revision: 1267
URL: http://tracker.coreboot.org/trac/openbios/changeset/1267
Log:
SPARC32: unmap freed memory in ofmem_arch_unmap_pages()
During NextStep boot, all the virtual memory is probed so freed memory must be
properly unmapped.
Signed-off-by: Olivier Danet <odanet(a)caramail.com>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland(a)ilande.co.uk>
Modified:
trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c
Modified: trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c
==============================================================================
--- trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c Sun Feb 16 17:26:37 2014 (r1266)
+++ trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c Sun Feb 16 17:26:40 2014 (r1267)
@@ -142,8 +142,16 @@
/* Unmap a set of pages */
void ofmem_arch_unmap_pages(ucell virt, ucell size)
{
- /* OFMEM re-maps the pages for us, so just ensure the TLB is in sync */
- srmmu_flush_whole_tlb();
+ unsigned long pa;
+ ucell i;
+
+ for (i = 0; i < size; i += PAGE_SIZE) {
+ pa = find_pte(virt, 0);
+ *(uint32_t *)pa = 0;
+ virt += PAGE_SIZE;
+ }
+
+ srmmu_flush_whole_tlb();
}
/* Map a set of pages */
Author: mcayland
Date: Sun Feb 16 17:26:34 2014
New Revision: 1265
URL: http://tracker.coreboot.org/trac/openbios/changeset/1265
Log:
SPARC32: copy the a.out header beneath load-base during load
NextSTEP's bootloader for Sparc32 expects that the 32 bytes a.out header
is copied just before the start address.
Since this is a compatibility hack for an implementation detail of OBP then
implement the functionality within a #define AOUT_HEADER_COPY section so
it can easily be removed if people really need a strictly compliant firmware.
Signed-off-by: Olivier Danet <odanet(a)caramail.com>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland(a)ilande.co.uk>
Modified:
trunk/openbios-devel/libopenbios/aout_load.c
Modified: trunk/openbios-devel/libopenbios/aout_load.c
==============================================================================
--- trunk/openbios-devel/libopenbios/aout_load.c Sun Feb 16 17:26:31 2014 (r1264)
+++ trunk/openbios-devel/libopenbios/aout_load.c Sun Feb 16 17:26:34 2014 (r1265)
@@ -10,6 +10,12 @@
#define CONFIG_SPARC64_PAGE_SIZE_8KB
#endif
+/* NextStep bootloader on SPARC32 expects the a.out header directly
+ below load-base (0x4000) */
+#ifdef CONFIG_SPARC32
+#define AOUT_HEADER_COPY
+#endif
+
#include "libopenbios/sys_info.h"
#include "libopenbios/bindings.h"
#include "libopenbios/aout_load.h"
@@ -143,6 +149,11 @@
debug("Loaded %lu bytes\n", size);
debug("entry point is %#lx\n", start);
+#ifdef AOUT_HEADER_COPY
+ // Copy the a.out header just before start
+ memcpy((char *)(start - 0x20), &ehdr, 0x20);
+#endif
+
// Initialise saved-program-state
PUSH(addr_fixup(start));
feval("saved-program-state >sps.entry !");
Author: mcayland
Date: Sun Feb 16 17:26:31 2014
New Revision: 1264
URL: http://tracker.coreboot.org/trac/openbios/changeset/1264
Log:
SPARC32: implement Forth get-msecs word
Switch obp_ticks over to be a pointer to the counter rather than its value, then
point this to the contents of a new Forth obp-ticks variable. This allows a
simple get-msecs word to be implemented for SPARC32 which simply reads the value
of the obp-ticks variable and places it on the stack.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland(a)ilande.co.uk>
Modified:
trunk/openbios-devel/arch/sparc32/romvec.c
trunk/openbios-devel/arch/sparc32/romvec.h
trunk/openbios-devel/arch/sparc32/vectors.S
trunk/openbios-devel/forth/device/other.fs
Modified: trunk/openbios-devel/arch/sparc32/romvec.c
==============================================================================
--- trunk/openbios-devel/arch/sparc32/romvec.c Sun Feb 16 17:26:28 2014 (r1263)
+++ trunk/openbios-devel/arch/sparc32/romvec.c Sun Feb 16 17:26:31 2014 (r1264)
@@ -449,7 +449,7 @@
dstackcnt = dstacktmp;
}
-volatile uint32_t obp_ticks;
+volatile uint32_t *obp_ticks;
void *
init_openprom(void)
@@ -482,9 +482,11 @@
romvec0.pv_printf = obp_printf_handler;
romvec0.pv_abort = obp_abort_handler;
- /* Reset the tick counter */
- obp_ticks = 0;
- romvec0.pv_ticks = &obp_ticks;
+ /* Point to the Forth obp-ticks variable and reset */
+ fword("obp-ticks");
+ obp_ticks = cell2pointer(POP());
+ *obp_ticks = 0;
+ romvec0.pv_ticks = obp_ticks;
romvec0.pv_halt = obp_halt_handler;
romvec0.pv_synchook = &sync_hook;
Modified: trunk/openbios-devel/arch/sparc32/romvec.h
==============================================================================
--- trunk/openbios-devel/arch/sparc32/romvec.h Sun Feb 16 17:26:28 2014 (r1263)
+++ trunk/openbios-devel/arch/sparc32/romvec.h Sun Feb 16 17:26:31 2014 (r1264)
@@ -2,7 +2,7 @@
* romvec main C function and handler declarations
*/
-extern volatile uint32_t obp_ticks;
+extern volatile uint32_t *obp_ticks;
void *init_openprom(void);
int obp_devopen(char *str);
Modified: trunk/openbios-devel/arch/sparc32/vectors.S
==============================================================================
--- trunk/openbios-devel/arch/sparc32/vectors.S Sun Feb 16 17:26:28 2014 (r1263)
+++ trunk/openbios-devel/arch/sparc32/vectors.S Sun Feb 16 17:26:31 2014 (r1264)
@@ -208,9 +208,10 @@
ld [%l7 + %lo(counter_regs)], %l7
ld [%l7], %g0
sethi %hi(obp_ticks), %l7
- ld [%l7 + %lo(obp_ticks)], %l6
+ ld [%l7 + %lo(obp_ticks)], %l7
+ ld [%l7], %l6
add %l6, 10, %l6
- st %l6, [%l7 + %lo(obp_ticks)]
+ st %l6, [%l7]
jmp %l1
rett %l2
Modified: trunk/openbios-devel/forth/device/other.fs
==============================================================================
--- trunk/openbios-devel/forth/device/other.fs Sun Feb 16 17:26:28 2014 (r1263)
+++ trunk/openbios-devel/forth/device/other.fs Sun Feb 16 17:26:31 2014 (r1264)
@@ -93,12 +93,25 @@
\ 5.3.7.3 Time
+[IFDEF] CONFIG_SPARC32
+
+\ OBP tick value updated by timer interrupt
+variable obp-ticks
+
+: get-msecs ( -- n )
+ obp-ticks @
+ ;
+
+[ELSE]
+
0 value dummy-msecs
: get-msecs ( -- n )
dummy-msecs dup 1+ to dummy-msecs
;
-
+
+[THEN]
+
: ms ( n -- )
get-msecs +
begin dup get-msecs < until