Hi all,
From my work on running OpenBSD under OpenBIOS/QEMU, I found a couple
of bugs in the NetBSD OF bindings for SPARC64 which also seem to be
relevant to OpenBSD. I've applied patches to OpenBIOS to compensate for
these bugs which allows OpenBSD to boot under QEMU, but thought that as
there is interest here it would be worth documenting them for the sake
of correctness.
1) OF_close has the wrong number of return arguments
src/sys/arch/sparc64/stand/ofwboot/Locore.c specifies the OF_close has
args.nreturns == 1. From the IEEE1275 specification we can see that the
"close" word doesn't return any arguments, and so args.nreturns should
be set to 0. OpenBIOS currently compensates for this and issues a
warning when debugging is enabled.
2) OF_test_method takes a phandle not an ihandle, and also returns 0 on
success
src/sys/arch/sparc64/sparc64/ofw_machdep.c calls OF_test_method with an
ihandle instead of an phandle as detailed in the Open Firmware working
group proposal at
http://www.openfirmware.org/1275/proposals/Closed/Accepted/270-it.txt
(WARNING: the above link is currently down, however Google still has a
cached version available).
Similarly the Forth word signature looks like this:
test-method ( method-cstr phandle -- missing-flag? )
This means that missing-flag? should be true if the method is missing
and false if it is present, which indicates that the check to determine
the existence of SUNW,retain in ofw_machdep.c is the wrong way around,
i.e. the result comparison should be == 0 rather than != 0.
What happens at the moment is that calling OF_test_method with an
ihandle causes an exception and so the client inferface returns -1 to
indicate failure. However since the result is checked for != 0 then this
is taken to indicate that SUNW,retain exists which is why this currently
works on some real PROMs.
It's worth mentioning that this fixes test-method on E250/E450 systems
and so the NetBSD folks were able to remove the is_e250 hack after
testing on real hardware.
For interested parties the corresponding NetBSD diff can be found at
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/sparc64/sparc64/ofw_machdep.c.diff?r1=1.41&r2=1.42&f=h.
ATB,
Mark.