On Sun, Nov 22, 2009 at 10:39 PM, Tarl Neustaedter Tarl.Neustaedter@sun.com wrote:
Blue Swirl wrote:
[...] But this patch also does not work [...]
It looks like you're missing the patch Mark Cave-Ayland proposed, with a str2cstr conversion. He noticed that call-method requires a c-string (pointer only), rather than a traditional forth string (pointer, len). The problem is that " seek" is a forth-format string, and the first thing call-method is doing is converting from cstring to forth string - which doesn't work if you are already supplying a forth string.
Right, I missed that. But this version (fixing also the loop check noticed by Stefan) does not work either. [sparc64] Booting file 'cdrom' with parameters '' Not a bootable ELF image Not a Linux kernel image Loading a.out image... Loaded 7680 bytes entry point is 0x4000 Jumping to entry point... switching to new context: entry point 0x4000 stack 0x00000000ffe02a71 Unhandled Exception 0x0000000000000034 PC = 0x00000000ffd0fc78 NPC = 0x00000000ffd0fc7c Stopping execution
However, something interesting happens with MilaX: [sparc64] Booting file 'cdrom' with parameters '' Not a bootable ELF image Not a Linux kernel image Not a bootable a.out image Loading FCode image... Loaded 7392 bytes entry point is 0x4000 Evaluating FCode... Unhandled Exception 0x9000170000000000 PC = 0x00000000ffd0e2c4 NPC = 0x00000000ffd0e2c8 Stopping execution
Maybe the FCode gets something loaded and starts to execute?
diff --git a/forth/lib/string.fs b/forth/lib/string.fs index eb64749..6d7a229 100644 --- a/forth/lib/string.fs +++ b/forth/lib/string.fs @@ -49,6 +49,19 @@ then ;
+\ convert string to cstr +: str2cstr ( addr len -- cstr) + dup if + \ like strdup but with len + 1 for NULL + dup >r + dup 1+ alloc-mem dup >r swap move + \ add null + r> dup r> + 0 swap c! + else + 2drop 0 0 + then +; + : dict-strdup ( str len -- dict-addr len ) dup here swap allot null-align swap 2dup >r >r move r> r> diff --git a/forth/system/ciface.fs b/forth/system/ciface.fs index eefb1b7..8b2ec6b 100644 --- a/forth/system/ciface.fs +++ b/forth/system/ciface.fs @@ -212,21 +212,16 @@ external close-dev ;
-: read ( ihandle addr len -- actual ) - rot dup ihandle>phandle " read" rot find-method - if swap call-package else 3drop -1 then +: read ( len addr ihandle -- actual ) + rot swap " read" str2cstr call-method drop ;
-: write ( ihandle addr len -- actual ) - rot dup ihandle>phandle " write" rot find-method - if swap call-package else 3drop -1 then +: write ( len addr ihandle -- actual ) + rot swap " write" str2cstr call-method drop ;
-: seek ( ihandle pos_hi pos_lo -- status ) - \ package methods uses ( pos_lo pos_hi -- status ) - swap - rot dup ihandle>phandle " seek" rot find-method - if swap call-package else 3drop -1 then +: seek ( pos_lo pos_hi ihandle -- status ) + " seek" str2cstr call-method drop ;
diff --git a/modules/client.c b/modules/client.c index cf47692..dfb092c 100644 --- a/modules/client.c +++ b/modules/client.c @@ -239,7 +239,7 @@ handle_calls( prom_args_t *pb ) pb->nargs, pb->nret); #endif
- for( i=pb->nargs-1; i>=0; i-- ) + for (i = 0; i < pb->nargs; i++) PUSH( pb->args[i] );
push_str( pb->service );