[OpenBIOS] [RFC PATCH] ppc correctly replace &device; and &partition;

Laurent Vivier Laurent at vivier.eu
Tue Feb 3 17:59:44 CET 2009


Hi,

Could you split your patch in two patches: on for device and  
partition, and one for openSuse part.

I don't like the hack part, but I'll apply both if it doesn't break  
debian. I'll try to correct the mac partition management to remove  
this later.

Regards,
Laurent

Le 3 févr. 09 à 14:27, Stefan Assmann a écrit :

> Subject: ppc correctly replace &device; and &partition;
>
> This patch correctly replaces the variables &device; and &partition;
> with firmware values thus allowing to boot from different partitions.
>
> Signed-off-by: Stefan Assmann <sassmann at suse.de>
>
> Index: arch/ppc/qemu/main.c
> ===================================================================
> --- arch/ppc/qemu/main.c	(revision 439)
> +++ arch/ppc/qemu/main.c	(working copy)
> @@ -154,9 +154,9 @@
> static void
> try_bootinfo(const char *path)
> {
> -    int fd;
> -    char tagbuf[256], bootscript[256], c, *left, *right;
> -    int len, tag, taglen, script, scriptlen;
> +    int fd, len, tag, taglen, script, scriptlen;
> +    char tagbuf[256], bootscript[256], c;
> +    char *buf, *partition;
>
>     snprintf(bootscript, sizeof(bootscript), "%s,ppc\\bootinfo.txt",  
> path);
>     ELF_DPRINTF("Trying %s\n", bootscript);
> @@ -195,22 +195,33 @@
>             bootscript[scriptlen++] = c;
>         }
>     } while (1);
> -
>     ELF_DPRINTF("got bootscript %s\n", bootscript);
>
> -    // Replace &device;: with original path
> -    push_str(bootscript);
> -    PUSH('&');
> -    fword("left-split");
> -    fword("2swap");
> -    PUSH(':');
> -    fword("left-split");
> -    fword("2drop");
> -    right = pop_fstr_copy();
> -    left = pop_fstr_copy();
> -    while (right[0] != '\\' && right[0] != '\0')
> -    right++;
> -    snprintf(bootscript, sizeof(bootscript), "%s%s,%s", left, path,  
> right);
> +    /* replace &device; and &partition; */
> +    if ( (buf =  strstr(bootscript, (const char *) "&device;")) !=  
> NULL ) {
> +            buf[0] = '\0';
> +	    buf += strlen("&device;");
> +            snprintf(bootscript, sizeof(bootscript), "%s%s%s",  
> bootscript, path, buf);
> +    }
> +    if ( (partition = strchr(path, ':')) != NULL ) {
> +        *partition = '\0';
> +        partition++;
> +        if ( (buf = strstr(bootscript, (const char *)  
> "&partition;")) != NULL ) {
> +            *buf = '\0';
> +            buf += strlen("&partition;");
> +            snprintf(bootscript, sizeof(bootscript), "%s%s%s",  
> bootscript, partition, buf);
> +        } else {
> +            /* FIXME: allow booting of SUSE media with following  
> layout (fails without this workaround)
> +             * Number  Start  End     Size    File system   
> Name        Flags
> +             * 1      512B   1535B   1024B                 
> Apple       , , , , , , , , , , , , type=Apple_partition_map
> +             * 2      8192B  4126MB  4126MB                
> SU1110.001  , , , , , , , , , , , , type=Apple_HFS
> +             */
> +            if ( (buf = strstr(bootscript, (const char *) "1,\ 
> \suseboot\\yaboot.ibm")) != NULL ) {
> +                *buf = *partition;
> +                ELF_DPRINTF("SUSE bootscript hack %s\n", bootscript);
> +            }
> +	}
> +    }
>     ELF_DPRINTF("fixed bootscript %s\n", bootscript);
>
>     feval(bootscript);
>
>  Stefan
>
> -- 
> Stefan Assmann          | SUSE LINUX Products GmbH
> Software Engineer       | Maxfeldstr. 5, D-90409 Nuernberg
> Mail: sassmann at suse.de  | GF: Markus Rex, HRB 16746 (AG Nuernberg)
>
> --
> OpenBIOS                 http://openbios.org/
> Mailinglist:  http://lists.openbios.org/mailman/listinfo
> Free your System - May the Forth be with you




More information about the OpenBIOS mailing list