SPARC64 *BSDs accidentally call test-method with an ihandle rather than a phandle which causes OpenBIOS to crash. Work around this by checking to ensure that the phandle exists within the tree before trying to use it.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/forth/system/ciface.fs | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/openbios-devel/forth/system/ciface.fs b/openbios-devel/forth/system/ciface.fs index 727f0a3..fc40cff 100644 --- a/openbios-devel/forth/system/ciface.fs +++ b/openbios-devel/forth/system/ciface.fs @@ -55,6 +55,17 @@ variable callback-function ." <" dup cstrlen dup 20 < if type else 2drop ." BAD" then ." >" ;
+: phandle-exists? ( phandle -- found? ) + false swap 0 + begin iterate-tree ?dup while + ( found? find-ph current-ph ) + over over = if + rot drop true -rot + then + repeat + drop +; + \ ------------------------------------------------------------- \ public interface \ ------------------------------------------------------------- @@ -317,11 +328,15 @@ external outer-interpreter ;
-( cstring-method phandle -- missing ) - -: test-method - swap dup cstrlen rot - find-method 0= if -1 else drop 0 then +: test-method ( cstring-method phandle -- missing? ) + swap dup cstrlen rot + + \ Check for incorrect phandle + dup phandle-exists? false = if + -1 throw + then + + find-method 0= if -1 else drop 0 then ;
finish-device