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

BALATON Zoltan balaton at eik.bme.hu
Tue Apr 26 22:11:13 CEST 2016


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.

> This patch also makes it so that the boot script is executed one line at a time.

This part below would be basically all that remains. Is this also 
equivalent to the previous patch to interpreter.fs for also handling \r 
the same as \n or does it do something else? If not then maybe the whole 
thing could be done in Forth entirely.

Regards,
BALATON Zoltan

> +/* 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++;
> +        DPRINTF("%s\n", buffer);
> +        feval(buffer);
> +        if (c == '\0') {
> +            break;
> +        }
> +    }
> +    free(buffer);
> +}
> +
> /*
>   Parse SGML structure like:
>   <chrp-boot>
> @@ -209,9 +279,6 @@
> 					script = 0;
> 					bootscript[scriptlen] = '\0';
>
> -					DPRINTF("got bootscript %s\n",
> -						bootscript);
> -
> 					scriptvalid = -1;
>
> 					break;
> @@ -261,8 +328,8 @@
>
> 	/* If the payload is bootinfo then we execute it immediately */
> 	if (scriptvalid) {
> -		DPRINTF("bootscript: %s\n", bootscript);
> -		feval(bootscript);
> +        replace_return_stack_words(bootscript);
> +		run_script(bootscript);
> 	}
> 	else
> 		DPRINTF("Unable to parse bootinfo bootscript\n");



More information about the OpenBIOS mailing list