Author: mcayland
Date: 2009-12-02 11:44:35 +0100 (Wed, 02 Dec 2009)
New Revision: 637
Modified:
trunk/openbios-devel/arch/ppc/briq/methods.c
trunk/openbios-devel/arch/ppc/mol/methods.c
trunk/openbios-devel/arch/ppc/pearpc/methods.c
trunk/openbios-devel/arch/ppc/qemu/methods.c
trunk/openbios-devel/arch/sparc64/lib.c
trunk/openbios-devel/forth/system/ciface.fs
trunk/openbios-devel/modules/client.c
Log:
In the IEEE 1275-1994 specification the parameters for Client Interface calls
are not in forth stack order but in reversed (heh!) order. Our implementation
confused this.
This second patch is fairly straightforward; probably the only unexpected part is
the need to rename the existing /openprom/client-services "claim" and
"release" words to "cif-claim" and "cif-release" respectively. This is
because we need to use the "claim" and "release" words in
forth/system/ciface.fs to reverse the argument order before calling the real
underlying words.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland(a)siriusit.co.uk>
Modified: trunk/openbios-devel/arch/ppc/briq/methods.c
===================================================================
--- trunk/openbios-devel/arch/ppc/briq/methods.c 2009-11-29 13:49:47 UTC (rev 636)
+++ trunk/openbios-devel/arch/ppc/briq/methods.c 2009-12-02 10:44:35 UTC (rev 637)
@@ -309,8 +309,8 @@
};
NODE_METHODS( mmu_ciface ) = {
- { "claim", ciface_claim },
- { "release", ciface_release },
+ { "cif-claim", ciface_claim },
+ { "cif-release", ciface_release },
};
Modified: trunk/openbios-devel/arch/ppc/mol/methods.c
===================================================================
--- trunk/openbios-devel/arch/ppc/mol/methods.c 2009-11-29 13:49:47 UTC (rev 636)
+++ trunk/openbios-devel/arch/ppc/mol/methods.c 2009-12-02 10:44:35 UTC (rev 637)
@@ -447,8 +447,8 @@
};
NODE_METHODS( mmu_ciface ) = {
- { "claim", ciface_claim },
- { "release", ciface_release },
+ { "cif-claim", ciface_claim },
+ { "cif-release", ciface_release },
};
Modified: trunk/openbios-devel/arch/ppc/pearpc/methods.c
===================================================================
--- trunk/openbios-devel/arch/ppc/pearpc/methods.c 2009-11-29 13:49:47 UTC (rev 636)
+++ trunk/openbios-devel/arch/ppc/pearpc/methods.c 2009-12-02 10:44:35 UTC (rev 637)
@@ -311,8 +311,8 @@
};
NODE_METHODS( mmu_ciface ) = {
- { "claim", ciface_claim },
- { "release", ciface_release },
+ { "cif-claim", ciface_claim },
+ { "cif-release", ciface_release },
};
Modified: trunk/openbios-devel/arch/ppc/qemu/methods.c
===================================================================
--- trunk/openbios-devel/arch/ppc/qemu/methods.c 2009-11-29 13:49:47 UTC (rev 636)
+++ trunk/openbios-devel/arch/ppc/qemu/methods.c 2009-12-02 10:44:35 UTC (rev 637)
@@ -290,8 +290,8 @@
};
NODE_METHODS( mmu_ciface ) = {
- { "claim", ciface_claim },
- { "release", ciface_release },
+ { "cif-claim", ciface_claim },
+ { "cif-release", ciface_release },
};
Modified: trunk/openbios-devel/arch/sparc64/lib.c
===================================================================
--- trunk/openbios-devel/arch/sparc64/lib.c 2009-11-29 13:49:47 UTC (rev 636)
+++ trunk/openbios-devel/arch/sparc64/lib.c 2009-12-02 10:44:35 UTC (rev 637)
@@ -469,6 +469,6 @@
push_str("/openprom/client-services");
fword("find-device");
- bind_func("claim", mmu_claim);
- bind_func("release", mmu_release);
+ bind_func("cif-claim", mmu_claim);
+ bind_func("cif-release", mmu_release);
}
Modified: trunk/openbios-devel/forth/system/ciface.fs
===================================================================
--- trunk/openbios-devel/forth/system/ciface.fs 2009-11-29 13:49:47 UTC (rev 636)
+++ trunk/openbios-devel/forth/system/ciface.fs 2009-12-02 10:44:35 UTC (rev 637)
@@ -77,35 +77,31 @@
: child child ;
: parent parent ;
-: getproplen ( phandle name -- len|-1 )
- \ ." PH " over . dup cstrlen ." GETPROPLEN " 2dup type cr
- dup cstrlen
- rot ?phandle get-package-property
+: getproplen ( name phandle -- len|-1 )
+ over cstrlen swap
+ ?phandle get-package-property
if -1 else nip then
;
-: getprop ( phandle name buf buflen -- size|-1 )
- \ ." PH " 3 pick . ." GETPROP " 2 pick dup cstrlen type cr
- >r >r dup cstrlen
- rot
+: getprop ( buflen buf name phandle -- size|-1 )
\ detect phandle == -1
dup -1 = if
- r> r> 2drop 3drop -1 exit
+ 2drop 2drop -1 exit
then
\ return -1 if phandle is 0 (MacOS actually does this)
- ?dup 0= if r> r> 2drop 2drop -1 exit then
-
- ?phandle get-package-property if r> r> 2drop -1 exit then
- r> r>
- ( prop proplen dest destlen )
- rot dup >r min move r>
+ ?dup 0= if 2drop 2drop -1 exit then
+
+ over cstrlen swap
+ ?phandle get-package-property if 2drop -1 exit then
+ ( buflen buf prop proplen )
+ >r swap rot r> min
+ dup >r move r>
;
\ 1 OK, 0 no more prop, -1 prev invalid
-: nextprop ( phandle prev buf -- 1|0|-1 )
- rot >r
- swap ( buf prev )
+: nextprop ( buf prev phandle -- 1|0|-1 )
+ >r
dup 0= if 0 else dup cstrlen then
( buf prev prev_len )
@@ -131,11 +127,12 @@
then
;
-: setprop ( phandle name buf len -- size )
- dup >r encode-bytes rot dup cstrlen
- ( phandle buf len name name_len R: size )
- 4 pick (property)
- drop r>
+: setprop ( len buf name phandle -- size )
+ 3 pick >r
+ >r >r swap encode-bytes \ ( prop-addr prop-len R: phandle name )
+ r> dup cstrlen r>
+ (property)
+ r>
;
: finddevice ( dev_spec -- phandle|-1 )
@@ -149,39 +146,38 @@
?ihandle ihandle>phandle
;
-: package-to-path ( phandle buf buflen -- length )
- rot
+: package-to-path ( buflen buf phandle -- length )
\ XXX improve error checking
dup 0= if 3drop -1 exit then
+ >r swap r>
get-package-path
( buf buflen str len )
ci-strcpy
;
-: canon ( dev_specifier buf buflen -- len )
- rot dup cstrlen find-dev if
- ( buf buflen phandle )
- -rot
+: canon ( buflen buf dev_specifier -- len )
+ dup cstrlen find-dev if
+ ( buflen buf phandle )
package-to-path
else
2drop -1
then
;
-: instance-to-path ( ihandle buf buflen -- length )
- rot
+: instance-to-path ( buflen buf ihandle -- length )
\ XXX improve error checking
dup 0= if 3drop -1 exit then
+ >r swap r>
get-instance-path
\ ." INSTANCE: " 2dup type cr dup .
( buf buflen str len )
ci-strcpy
;
-: instance-to-interposed-path ( ihandle buf buflen -- length )
- rot
+: instance-to-interposed-path ( buflen buf ihandle -- length )
\ XXX improve error checking
dup 0= if 3drop -1 exit then
+ >r swap r>
get-instance-interposed-path
( buf buflen str len )
ci-strcpy
@@ -212,20 +208,20 @@
close-dev
;
-: read ( ihandle addr len -- actual )
- rot dup ihandle>phandle " read" rot find-method
+: read ( len addr ihandle -- actual )
+ >r swap r>
+ dup ihandle>phandle " read" rot find-method
if swap call-package else 3drop -1 then
;
-: write ( ihandle addr len -- actual )
- rot dup ihandle>phandle " write" rot find-method
+: write ( len addr ihandle -- actual )
+ >r swap r>
+ dup ihandle>phandle " write" rot find-method
if swap call-package else 3drop -1 then
;
-: seek ( ihandle pos_hi pos_lo -- status )
- \ package methods uses ( pos_lo pos_hi -- status )
- swap
- rot dup ihandle>phandle " seek" rot find-method
+: seek ( pos_lo pos_hi ihandle -- status )
+ dup ihandle>phandle " seek" rot find-method
if swap call-package else 3drop -1 then
;
@@ -234,9 +230,18 @@
\ 6.3.2.4 Memory
\ -------------------------------------------------------------
-\ : claim ( virt size align -- baseaddr|-1 ) ;
-\ : release ( virt size -- ) ;
+: claim ( align size virt -- baseaddr|-1 )
+ -rot swap
+ ciface-ph " cif-claim" rot find-method
+ if execute else 3drop -1 then
+;
+: release ( size virt -- )
+ swap
+ ciface-ph " cif-release" rot find-method
+ if execute else 2drop -1 then
+;
+
\ -------------------------------------------------------------
\ 6.3.2.5 Control transfer
\ -------------------------------------------------------------
Modified: trunk/openbios-devel/modules/client.c
===================================================================
--- trunk/openbios-devel/modules/client.c 2009-11-29 13:49:47 UTC (rev 636)
+++ trunk/openbios-devel/modules/client.c 2009-12-02 10:44:35 UTC (rev 637)
@@ -288,7 +288,7 @@
return handle_calls( pb );
dstacksave = dstackcnt;
- for( i=0; i<pb->nargs; i++ )
+ for( i=pb->nargs-1; i>=0; i-- )
PUSH( pb->args[i] );
push_str( pb->service );