Subject: macppc boot process.
To: None <port-macppc@netbsd.org>
From: Rian Hunter <rian@thelaststop.cjb.net>
List: port-macppc
Date: 08/23/2004 14:26:19
I've always been very curious about the boot process behind the
NetBSD/macppc port. After some code digging i learned a little. This is
what i think happens with the partition zero config:

////////

1. OF loads and runs bootxx from god knows where from the hard disk into
memory.

2. bootxx loads ofwboot into memory by reading "bbinfo" and loading the
appropriate blocks (they seem to be scattered) into the appropriate
linear memory (load-base) from the device (boot-device):

// after opening correct device specified at OF prompt
	for (j = 0; j < bbinfo.bbi_block_count; j++) {

		// find out where on device next program text is
		if ((blk = bbinfo.bbi_block_table[j]) == 0)
			break;

		// status
		putc('0' + j % 10);

		// seek to the appropriate block
		OF_seek(fd, (u_quad_t)blk * 512);

		// read into memory
		OF_read(fd, addr, bbinfo.bbi_block_size);

		// increment memory address according to how much copied
		addr += bbinfo.bbi_block_size;
	}

3. ofwboot.xcf loads and runs the NetBSD kernel according to the real-base.

////////////

I have some questions though:

1. Where is bootxx supposed to be on the disk device when OF loads it? I
assume this is where NetBSD puts it after installation.

2. How is the bbinfo structure filled? How does bootxx know where
ofwboot.xcf is?

3. Why is ofwboot.xcf in the XCOFF format? why was there a change from
ELF?

4. How are all these programs loaded onto the boot floppies and what are
the steps to creating a macppc boot floppy? Does it go: bootxx, ofwboot,
filesystem (or kernel). This again raises question number 2.

I appreciate any help! thanks a lot!
-rian