Subject: Re: [Cannot boot netbsd-3.0 on my powerbook 12'] It does boot!
To: None <port-macppc@netbsd.org>
From: Antoine Reilles <Antoine.Reilles@loria.fr>
List: port-macppc
Date: 02/10/2006 14:33:42
--eRtJSFbw+EEWtPj3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Feb 09, 2006 at 10:21:49PM +0100, Antoine Reilles wrote:
> Hi,
>=20
> On Wed, Feb 08, 2006 at 03:36:33PM +0100, Antoine Reilles wrote:
> > On Wed, Jan 04, 2006 at 01:43:09PM +0100, Antoine Reilles wrote:
> > > On Tue, Dec 27, 2005 at 03:07:34PM +0100, Olivier MATZ wrote:
> > > > I tried to boot netbsd on my powerbook laptop :
> > > >   12' (feb 2005)
> > > >   768MB DDR333 (256MB built-in + 512MB SO-DIMM)
> > > >   80GB Ultra ATA drive (5400rpm)
> > > >   8x SuperDrive (DVD R/CD-RW)
> > > >   AirPort Extreme Card
> > > >   Keyboard & Mac OS  768MB RAM
> >=20
> > To help identify the problem, i followed the steps from:
> > http://mail-index.netbsd.org/port-macppc/2004/08/30/0015.html
> > to get more information on the issue.
> > I tried that with a -current kernel, on a very similar Powerbook 6,8
> > (the only difference is the 1GB DIMM), with both ofwboot.xcf and the
> > kernel being on a small HFS partition.
> > Here is the output, i hope it can help to get what is wrong here
>=20
> Since i often get a Decrementer exception when trying to boot, i tried
> to disable the exception earlier (thanks martin and macallan), using
> the following patch
>=20
> Index: sys/arch/macppc/macppc/locore.S
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> RCS file: /cvsroot/src/sys/arch/macppc/macppc/locore.S,v
> retrieving revision 1.54
> diff -u -r1.54 locore.S
> --- sys/arch/macppc/macppc/locore.S	11 Dec 2005 12:18:06 -0000	1.54
> +++ sys/arch/macppc/macppc/locore.S	9 Feb 2006 21:18:50 -0000
> @@ -82,10 +82,10 @@
>  	.text
>  	.globl	__start
>  __start:
> +	mtmsr	0			/* Disable FPU/MMU/exceptions */
>  	bl	_C_LABEL(ofwinit)	/* init OF */
> =20
>  	li	0,0
> -	mtmsr	0			/* Disable FPU/MMU/exceptions */
>  	isync
> =20
>  /* compute end of kernel memory */
>=20
> With this, it looks like the kernel hangs just after being loaded, and
> i get:
> >> NetBSD/macppc OpenFirmware Boot, Revision 1.10
> >> (tonio@193.180.97-84.rev.gaoland.net, Sat Feb  4 16:33:38 CET 2006)
> 1550068+158792 [112736+104103]=3D0x1d6610
>  start=3D0x100000
> _
>=20
> and have to reboot. So it looks like my problem is located in the
> ofwinit routine. I'm stuck to this point

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=20
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 ?

Best regards,
antoine


Index: sys/arch/powerpc/oea/ofw_subr.S
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/src/sys/arch/powerpc/oea/ofw_subr.S,v
retrieving revision 1.2
diff -u -r1.2 ofw_subr.S
--- sys/arch/powerpc/oea/ofw_subr.S	13 Feb 2003 15:02:49 -0000	1.2
+++ sys/arch/powerpc/oea/ofw_subr.S	10 Feb 2006 13:26:09 -0000
@@ -64,6 +64,9 @@
 	mtlr	30
 1:
 #endif
+	mflr	%r31                        /* save return address */
+	mr	%r13,%r6                /* save args (only pointer used) */
+
 	lis	8,openfirmware_entry@ha
 	stw	5,openfirmware_entry@l(8) /* save client interface handler*/
=20
@@ -85,6 +88,8 @@
 	lis	9,_C_LABEL(OF_buf)@ha
 	stw	8,_C_LABEL(OF_buf)@l(9)
=20
+	mr	%r6,%r13                /* restore args pointer */
+	mtlr	%r31                        /* restore return address */
 	blr
=20
 /*

--eRtJSFbw+EEWtPj3
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (NetBSD)

iD8DBQFD7JY24VqmoGDE/mwRAnTUAJ43uVJS6e01d1Z8z65UrEb2i7Ss9QCeKdrB
Mli5BQBTN32WqXG5iLcHkrg=
=n2TJ
-----END PGP SIGNATURE-----

--eRtJSFbw+EEWtPj3--