Subject: Re: netbsd-current and ibook g4: kernel freeze
To: leon zadorin <leonleon77@gmail.com>
From: Allen Briggs <briggs@netbsd.org>
List: port-macppc
Date: 02/01/2007 10:23:48
On Thu, Feb 01, 2007 at 05:31:52PM +1000, leon zadorin wrote:
> But first I need someone to clear something up for me... AFAIK (albeit
> my assembler knowledge is about 1.5 days old) the blrl will use the LR
> register and such appears to be set in a few lines above (within the
> same routine):
> 
> 	lis	4,openfirmware_entry@ha	/* get firmware entry point */
> 	lwz	4,openfirmware_entry@l(4)
> 	mtlr	4
> 
> Which appears to take the address of openfirmware_entry variable...
> But where is openfirmware_entry actually defined/assigned in macppc
> port?

It's set by the ofwinit() call which is called first thing on entry
into the kernel (__start in locore.S).

> and then (whilst on the subject - if someone is willing to provide a
> quick lesson/explanation of why there are multiple "1:" sections in
> the following code - that would be extra cool)...

The label is kind of a throwaway.  If you look, you'll see the branches
use 1f or 1b.  That means "the next label '1' forward from here" or "the
next label '1' backward from here".

> 	lis	4,ofwsrsave@ha		/* save current SRs */
> 	addi	4,4,ofwsrsave@l
> 	li	5,0
> 1:	mfsrin	0,5
> 	stw	0,0(4)
> 	addi	4,4,4
> 	addis	5,5,0x10000000@h
> 	cmpwi	5,0
> 	bne	1b

So this "bne 1b" jumps back to the previous label '1' if (r5 != 0).

> 	beq	2f			/* then skip (not initialized yet) */
> 	li	5,0
> 1:	lwz	0,0(4)
> 	mtsrin	0,5
> 	addi	4,4,4
> 	addis	5,5,0x10000000@h
> 	cmpwi	5,0
> 	bne	1b
> 2:

Here we have to use a '2' because we need to jump past the '1' label
between the branch point and the branch target.

There's really no reason to reuse the '1' label, AFAIK.  I think we
could give each labelled point a unique symbol.  That might be more
clear for some and more obscure for others.

-allen

-- 
Allen Briggs  |  http://www.ninthwonder.com/~briggs/  |  briggs@ninthwonder.com