[PATCH 3/3] zImage: Cleanup and improve zImage entry point

David Gibson david at gibson.dropbear.id.au
Sun Feb 18 18:23:10 EST 2007


On Sat, Feb 17, 2007 at 05:22:24PM -0800, Geoff Levand wrote:
> David Gibson wrote:
> > Index: working-2.6/arch/powerpc/boot/crt0.S
> > @@ -59,6 +60,29 @@ _zimage_start:
> >  	sync
> >  	isync
> >  
> > -	mr	r6,r1
> > -	b	start
> > +	/* Possibly set up a custom stack */
> > +.weak	_platform_stack_top
> > +	lis	r8,_platform_stack_top at ha
> > +	addi	r8,r8,_platform_stack_top at l
> > +	cmpwi	r8,0
> > +	beq	5f
> > +	lwz	r1,0(r8)
> 
> 
> Do you need to make a stack frame here for your
> call to platform_init so it will have a place when it
> stores the link register?

Err... isn't the called function responsible for setting up its own
stack frame if necessary.  I thought all that was needed was for r1 to
point to some free space.

> > +5:
> > +
> > +	/* Clear the BSS */
> > +	lis	r9,__bss_start at ha
> > +	addi	r9,r9,__bss_start at l
> > +	lis	r8,_end at ha
> > +	addi	r8,r8,_end at l
> > +	li	r0,0
> > +6:	stw	r0,0(r9)
> > +	addi	r9,r9,4
> > +	cmplw	cr0,r9,r8
> > +	blt	6b
> 
> 
> This messed me up a bit since I had two stacks in the bss, one for each
> processor thread.  By the time this was called on the primary thread the
> secondary thread could already be using its stack.  I changed the secondary
> thread to use a small stack in the data section, so this seems OK.

Hrm... if you're entering with multiple threads and stacks, you're
probably a prime candidate for providing your own zimage_start,
instead of using this code.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson



More information about the Linuxppc-dev mailing list