[OpenBIOS] [PATCH] package.fs: fix "child" word being called with a NULL phandle

Mark Cave-Ayland mark.cave-ayland at ilande.co.uk
Sun Nov 23 16:29:15 CET 2014


Solaris 9 relies on an undocumented feature that calling "child" with
a NULL phandle is equivalent to using the phandle of the device tree
root node.

Make sure that we emulate the same behaviour to avoid a crash when
dereferencing a NULL pointer.

This patch fixes Solaris 9 boot on SPARC32 and is based upon a
proof-of-concept patch submitted by Artyom Tarasenko <atar4qemu at gmail.com>.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>
---
 openbios-devel/forth/device/package.fs |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/openbios-devel/forth/device/package.fs b/openbios-devel/forth/device/package.fs
index eb17551..d5b52c3 100644
--- a/openbios-devel/forth/device/package.fs
+++ b/openbios-devel/forth/device/package.fs
@@ -49,6 +49,10 @@
 ;
 
 : child ( phandle.parent -- phandle.child )
+  \ Assume phandle == 0 indicates root node (not documented but similar
+  \ behaviour to "peer"). Used by some versions of Solaris (e.g. 9).
+  ?dup if else device-tree @ then
+
   >dn.child @
 ;
   
-- 
1.7.10.4




More information about the OpenBIOS mailing list