On Apr 18, 2016, at 11:27 PM, Segher Boessenkool wrote:
On Mon, Apr 18, 2016 at 11:21:51PM -0400, Programmingkid wrote:
With my patch I saw mostly the same thing except there was also a message that said "this image is not for this platform". I think this proves that the '\r' to '\n' patch is needed.
[ long lines ]
You need at least four things:
- You need to EVALUATE the boot script per line, not as one string;
How do you decide when to end a line?
When there is an end-of-line character, or you reach the end of the script.
- CARRET should indeed be treated as end-of-line, for that;
Do you mean ^ ? I don't remember any carret characters in the script.
That is a caret. CARRET is an OF word, it is the ASCII 13 character. "Carriage return".
- Return stack in interpret mode;
- Structure words in interpret mode. That is at least
AHEAD IF THEN BEGIN AGAIN UNTIL CASE ENDCASE DO ?DO LOOP +LOOP
I think it would be easier if I was sent a patch. The forth code for Mac OS 9.2 is located in a file called "Mac OS ROM". Just let me know if you need help obtaining this file.
[ long lines ]
Thanks, but no, of course I have it.
The executing one line at a time idea turned out to be a pretty good idea. That is enough to make Mac OS 9.2 boot. It is also entertaining to watch each executed line be printed to the terminal. Here is the patch:
Index: libopenbios/bootinfo_load.c =================================================================== --- libopenbios/bootinfo_load.c (revision 1395) +++ libopenbios/bootinfo_load.c (working copy) @@ -20,7 +20,7 @@ #include "libopenbios/ofmem.h" #include "libc/vsprintf.h"
-//#define DEBUG_BOOTINFO +#define DEBUG_BOOTINFO
#ifdef DEBUG_BOOTINFO #define DPRINTF(fmt, args...) \ @@ -116,6 +116,25 @@ return LOADER_NOT_SUPPORT; }
+// Execute the bootscript one line at a time +static void run_script(char *bootscript) +{ + char *ptr; + char *buffer = malloc(1000 * sizeof(char)); + int index = -1, prev_index = 0; + ptr = strchr(bootscript, '\r'); + while (ptr != NULL) { + prev_index = index; + index = ptr - bootscript; + strncpy(buffer, bootscript + prev_index + 1, index - prev_index); + buffer[index-prev_index] = '\0'; + ptr = strchr(bootscript + index + 1, '\r'); + DPRINTF("%s\n", buffer); + feval(buffer); + } + free(buffer); +} + /* Parse SGML structure like: <chrp-boot> @@ -262,7 +281,7 @@ /* If the payload is bootinfo then we execute it immediately */ if (scriptvalid) { DPRINTF("bootscript: %s\n", bootscript); - feval(bootscript); + run_script(bootscript); } else DPRINTF("Unable to parse bootinfo bootscript\n");