> Date: Sat, 10 Mar 2012 22:59:24 +0100
> From: Tobias Ulmer <tobi...@tmux.org>
> 
> (Ivan: would be nice if you could test it and tell us about any
> success/failure)
> 
> socppc saves registers r3 (fwfdtsave) and r29 (fwargsave) in locore.S.
> initppc() checks for the absence of a flat device tree structure, in which
> case it uses the older bd_t aka bootinfo.
> 
> It then checks whether the FDT checksum is valid and eventually uses that.
> 
> If fwfdtsave (r3) contains rubbish and u-boot does not supply a valid
> FDT, it will go into neither branch, doesn't set the amount of memory
> and silently panics in pmap.c.
> 
> This diff changes the logic to first try the FDT and
> unconditionally fall back to bootinfo. If that doesn't work, we're toast
> anyway.
> 
> I suspect r3 was zero by pure chance and the code works on a different
> model. The one I have here has a 8 pin serial connector, unlike what's
> described in the install document.
> 
> U-boot's README.standalone only mentions r29 being set and I can't find
> any reference where it sets r3 in do_go().
> 
> Can a kind soul please tell me how to cross-compile a RAMDISK kernel? I
> keep running into errors no matter which way I try. It would be nice to
> install it, now that it boots :-)
> 
> Index: socppc/machdep.c
> ===================================================================
> RCS file: /home/vcs/cvs/openbsd/src/sys/arch/socppc/socppc/machdep.c,v
> retrieving revision 1.33
> diff -u -p -r1.33 machdep.c
> --- socppc/machdep.c  29 Aug 2011 20:21:44 -0000      1.33
> +++ socppc/machdep.c  10 Mar 2012 20:52:06 -0000
> @@ -177,21 +177,6 @@ initppc(u_int startkernel, u_int endkern
>       /* Make a copy of the args! */
>       strlcpy(bootpathbuf, args ? args : "wd0a", sizeof bootpathbuf);
>  
> -     if (fwfdtsave == NULL) {
> -             /*
> -              * We were loaded by an old U-Boot that didn't provide
> -              * a flattened device tree.  It should have provided a
> -              * valid bootinfo structure which we'll use to build
> -              * such a device tree ourselves.
> -              *
> -              * XXX We don't build a flattened device tree yet.
> -              */
> -             memcpy(&bootinfo, *fwargsave, sizeof bootinfo);
> -
> -             extern uint8_t dt_blob_start[];
> -             fdt_init(&dt_blob_start);
> -     }
> -
>       if (fwfdtsave && fwfdtsave->fh_magic == FDT_MAGIC) {
>               /* 
>                * Save the FDT firmware blob passed by the bootloader
> @@ -231,6 +216,19 @@ initppc(u_int startkernel, u_int endkern
>                       if (fdt_node_property(node, "mac-address", &addr))
>                               memcpy(bootinfo.bi_enetaddr, addr, 6);
>               }
> +     } else {
> +             /*
> +              * We were loaded by an old U-Boot that didn't provide
> +              * a flattened device tree.  It should have provided a
> +              * valid bootinfo structure which we'll use to build
> +              * such a device tree ourselves.
> +              *
> +              * XXX We don't build a flattened device tree yet.
> +              */
> +             memcpy(&bootinfo, *fwargsave, sizeof bootinfo);
> +
> +             extern uint8_t dt_blob_start[];
> +             fdt_init(&dt_blob_start);
>       }
>  
>       proc0.p_cpu = &cpu_info[0];

Thanks.  Verified that this doesn't break the rb600.  Dereferencing a
garbage pointer is still a bit risky I suppose, but this is better
than what's currently in the tree.  So I have committed this.

New snapshots should start appearing soon.  Not sure if the first one
will have this diff, but the one after that surely will.

Cheers,

Mark

Reply via email to