[OpenBIOS] patch that causes a regression with Mac OS X booting

Programmingkid programmingkidx at gmail.com
Fri Dec 11 16:31:03 CET 2015

On Dec 11, 2015, at 6:28 AM, Mark Cave-Ayland wrote:

> On 10/12/15 15:02, Programmingkid wrote:
>> https://lists.gnu.org/archive/html/qemu-devel/2015-10/msg05556.html
>> From the message in the link, you said there was a patch that is needed to boot Mac OS 9, but can't be applied because it causes a regression with Mac OS X. Could you send me the patch. I would like to fix it so that all the patches needed to boot Mac OS 9 can be applied to OpenBIOS. Thanks.
> The outstanding OpenBIOS patch is this one:
> http://www.openfirmware.info/pipermail/openbios/2015-August/008763.html
> The reason it can't be applied is a little complicated. The MacOS 9
> bootloader alters the call stack using >r and r> which is illegal
> outside of a word in Forth - it's like a function changing it's stack
> pointing and hoping the caller can cope upon return.

Apple really made something that does that? What were they thinking?
I can only guess that they didn't like Forth.

> I suspect the above patch only works through chance because OpenBIOS
> uses a trampoline to execute words and so the trampoline is corrupted on
> exit. It also causes yaboot to throw errors in my tests here, as found
> on a Fedora PPC Linux for example which isn't a good solution either :(

Given the info about how Mac OS 9 corrupts the call stack,
maybe we could make it so that this patch only works
when booting Mac OS 9. So that leads to the question - How
do we know when Mac OS 9 is booting? There are several tags
in the bootx and yaboot files that can be used to help. 

The <DESCRIPTION> tag looks like this in yaboot (Used by Linux): 
PowerPC GNU/Linux First Stage Bootstrap

It looks like this in Mac OS 9's boot script:
MacROM for NewWorld.

It looks like this in Mac OS X's bootx:
Boot Loader for Mac OS X.

Maybe something like this can be added to OpenBIOS:

if(strcmp(descriptionString, "MacROM for NewWorld.") == 0) // Mac OS 9
	using_Mac_OS_9 = true;

Given that the patch looks like this:

-    i c@ 0a = if 
+    i c@ dup 0a = swap 0d = or if

This might be the solution:

i c@ /* common to both conditions, so always execute it */
if(using_Mac_OS_9 == true) {
	0a = if 
else {
	dup 0a = swap 0d = or if

The if/else code would probably be in forth. Setting the using_Mac_OS_9 variable can be done in C.

Does this solution sound good?

I know you are not convinced the code added in the patch is the right way to do things, do you have an idea what might be a better solution? Something that isn't so hacky?

More information about the OpenBIOS mailing list