Subject: Re: [Cannot boot netbsd-3.0 on my powerbook 12'] It does boot!
To: None <port-macppc@netbsd.org>
From: Chuck Silvers <chuq@chuq.com>
List: port-macppc
Date: 02/13/2006 07:00:54
On Fri, Feb 10, 2006 at 02:33:42PM +0100, Antoine Reilles wrote:
> After looking at the ofwinit routine in openbsd, I tried to add code to
> save and restore return address, and now, i can boot a GENERIC macppc
> kernel on my powerbook 6,8
> 
> I don't exactly know why it was not working before, neither why exactly
> it does not, but so far three different kernels with different config,
> but the same tweak to boot without problem.
> It is also surely related to the problem Olivier was experiencing
> (http://mail-index.netbsd.org/port-macppc/2005/12/27/0001.html),
> or davide
> (http://mail-index.netbsd.org/port-macppc/2004/08/30/0010.html), and 
> also PR #22316.
> 
> Here the patch i used.
> I borrowed those lines from openbsd, so they use %r, since they
> converted all their assembly to that.
> Can someone who has a clue please look at it ?

the openbsd version of this code saves and restores those caller-saved
registers around calling some functions (savemmu and save_ofw_mapping).
since ofwinit() in netbsd doesn't call any functions (outside the
FIRMWORKSBUGS case, which does its own save-and-restore dance and
is not enabled for macppc), saving and restoring those registers
is not necessary.  if this change really is making a difference for you,
then I would guess that it's because it changes the position of the
instructions that come after your change.  if that's true, then adding
the same number of nop instructions instead of the other instructions
would work just as well.  could you give that a try?

-Chuck