[OpenBIOS] [PATCH] libopenbios/bootinfo_load.c: Implement Mac OS 9.2 boot script support

Programmingkid programmingkidx at gmail.com
Tue Apr 26 23:53:37 CEST 2016


On Apr 26, 2016, at 4:11 PM, BALATON Zoltan wrote:

> On Tue, 26 Apr 2016, Programmingkid wrote:
>> This patch makes booting Mac OS 9.2 possible. It replaces all occurrences of
>> >r and r> with sub_>r and sub_r>. This allows for the return stack to be left
>> alone.
> 
> Can we have Segher's Forth version of this instead:
> 
> https://www.coreboot.org/pipermail/openbios/2016-April/009338.html
> 
> That should be equivalent and would make the C code much simpler and allow dropping most of these patches.

That code doesn't work. It causes a "Dictionary space overflow" message
to be printed. My code does work.

Here is my patch I made to test out that code. If you have the ability
please test out any changes before submitting any patches. 

Index: arch/ppc/ppc.fs
===================================================================
--- arch/ppc/ppc.fs	(revision 1395)
+++ arch/ppc/ppc.fs	(working copy)
@@ -66,3 +66,11 @@
 
 \ Set by BootX when booting Mac OS X
 defer spin
+
+hex
+20 cells CREATE stash  VARIABLE #stash  #stash off
+: stash-push  stash #stash cells + !  1 stash +! ;
+: stash-pop   -1 stash +!  stash #stash cells + @ ;
+: >r  state @ IF postpone >r EXIT THEN  stash-push ; immediate
+: r>  state @ IF postpone r> EXIT THEN  stash-pop ; immediate
+: r@  state @ IF postpone r@ EXIT THEN  stash-pop dup stash-push ; immediate
Index: libopenbios/bootinfo_load.c
===================================================================
--- libopenbios/bootinfo_load.c	(revision 1395)
+++ libopenbios/bootinfo_load.c	(working copy)
@@ -116,6 +116,33 @@
 	return LOADER_NOT_SUPPORT;
 }
 
+/* Runs the bootscript one line at a time */
+void run_script(char *bootscript)
+{
+    int index = 0, buf_index = 0;
+    char c;
+    char *buffer = malloc(1000 * sizeof(char));
+    
+    while (1) {
+        c = bootscript[index];
+        
+        // fill up buffer
+        while (c != '\n' && c != '\r' && c != '\0') {
+            buffer[buf_index++] = c;
+            c = bootscript[++index];
+        }
+        buffer[buf_index] = '\0';
+        buf_index = 0;
+        index++;
+        printk("%s\n", buffer);
+        feval(buffer);
+        if (c == '\0') {
+            break;
+        }
+    }
+    free(buffer);
+}
+
 /*
   Parse SGML structure like:
   <chrp-boot>
@@ -262,7 +289,8 @@
 	/* If the payload is bootinfo then we execute it immediately */
 	if (scriptvalid) {
 		DPRINTF("bootscript: %s\n", bootscript);
-		feval(bootscript);
+		//feval(bootscript);
+        run_script(bootscript);
 	}
 	else
 		DPRINTF("Unable to parse bootinfo bootscript\n");




More information about the OpenBIOS mailing list