Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Mar 2011 20:21:55 +0100
From:      Torfinn Ingolfsen <torfinn.ingolfsen@broadpark.no>
To:        freebsd-ppc@freebsd.org
Subject:   Re: PowerPC, gpart and multiboot (Was: Trying to install FreeBSD 8.2-RC1 on a PowerMac G5)
Message-ID:  <20110321202155.eda24313.torfinn.ingolfsen@broadpark.no>
In-Reply-To: <4D867A48.50408@freebsd.org>
References:  <20110113220450.57d09983.torfinn.ingolfsen@broadpark.no> <AANLkTi=6ma_3o9wvoOH92LPk7j1FUa7y=KpsmtAymmGg@mail.gmail.com> <20110114221406.34969090.torfinn.ingolfsen@broadpark.no> <4D31582F.1060300@FreeBSD.org> <20110115190637.7ac32abe.torfinn.ingolfsen@broadpark.no> <AANLkTimBYrU=2=z%2BjscSmcSFO0mF3OGgkc2CU4EcVpcy@mail.gmail.com> <20110122200810.2386cbef.torfinn.ingolfsen@broadpark.no> <20110313221425.a8d3361f.torfinn.ingolfsen@broadpark.no> <4200D52B-ED04-4F6A-BA2A-EAD7DF3EBF37@gmail.com> <20110314212840.91564b62.torfinn.ingolfsen@broadpark.no> <AANLkTi=na4swbiU6L7gJ7Xhb0QRaMfxXxByRy=xzu-Z0@mail.gmail.com> <AANLkTinsDODsYGgeQezo8rged6khBkVyB=H=ggo7iFoF@mail.gmail.com> <20110318200242.f957f677.torfinn.ingolfsen@broadpark.no> <AANLkTi=SBKMKqpNC-J3qJW_QYOO4uWE5rrie-9K-y-j-@mail.gmail.com> <20110320230002.1d23e985.torfinn.ingolfsen@broadpark.no> <4D867A48.50408@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 20 Mar 2011 17:06:00 -0500
Nathan Whitehorn <nwhitehorn@freebsd.org> wrote:

> On 03/20/11 17:00, Torfinn Ingolfsen wrote:
> > Anyway, here is my plan for multiboot:
> > root@kg-g5# gpart show ad0
> > =>        18  625142430  ad0  APM  (298G)
> >           18       1600    1  apple-boot  (800K)
> >         1618  155189248    2  freebsd-ufs  (74G)
> >    155190866    8388608    3  freebsd-swap  (4.0G)
> >    163579474       1600    4  apple-boot  (800K)
> >    163581074  155189248    5  freebsd-ufs  (74G)
> >    318770322  306372126       - free -  (146G)
> >
> > The boot code in partition 4 (ad0s5) will be modified so that it boots from
> > the next partition (the partition after the one the bootcode itself is loaded from)
> > instead of the first partition. Do you think it's doable?
> >
> > I have examined boot1.c (in /usr/src/sys/boot/powerpc/boot1.chrp) but I don't
> > really understand how it is finding the partition to boot / load the kernel from.
> >
> > Can anyone explain it?
> 
> I wrote it, so hopefully I can provide some insight. At line 423 of 
> boot1.c, it loops through the first 16 (arbitrary) partitions on the 
> device from which it was booted, then tries to find loader on the first 
> UFS partition it can mount. This isn't actually a good algorithm, but it 
> works pretty well.
> 
> Making it choose the first following UFS partition might be a good idea, 

Provided the bootblock is able to figure out from where it is booted.
My thinking is this; boot1.c figure out which partition it is started from, starts looking at 
own partition + 1, and the just goes through all 16 partitions (by doing n - 16; then 1 - n) lookinf for the first
ufs partition with /boot/loader on it.
This way, the boot block will still work for all cases; and worst case will be if you have the ufs partition with /boot/loader
preceeding the bootstrap partition.

Perhaps the code won't be as elegant, it would need two for loops, or a rewrite.

> or do something useful with its arguments.

I'm a bit usure about if there are any useful parameters available.
On my G5 quad, it prints the following values when booted from ad0s2 (the first 800K bootstrap partition):
Boot path:	/ht@0,f2000000/pci@9/k2-sata-root@c/k2-sata@0/disk@0:
Boot loader:	/boot/loader
Boot volume:	/ht@0,f2000000/pci@9/k2-sata-root@c/k2-sata@0/disk@0:3

After the boot, ofwdump shows this
root@kg-g5# ofwdump -S -P bootargs /chosen
/ht@0,f2000000/pci@9/k2-sata-root@c/k2-sata@0/disk@0:3
root@kg-g5# ofwdump -S -P bootpath /chosen
/ht@0,f2000000/pci@9/k2-sata-root@c/k2-sata@0/disk@0:2,\ppc\boot1.elf

And, if I boot from the boot block at ad0s5 (the second 800K bootstrap partition), it prints exactly the same values,
but ofwdump differs:
root@kg-g5# ofwdump -S -P bootargs /chosen
/ht@0,f2000000/pci@9/k2-sata-root@c/k2-sata@0/disk@0:3
root@kg-g5# ofwdump -S -P bootpath /chosen
/ht@0,f2000000/pci@9/k2-sata-root@c/k2-sata@0/disk@0:5,\ppc\boot1.elf

So now I just need to figure out how to get this in your bootblock. Hmm....
Ok, I think I see it now - in the function ofw_init, at line 139 of boot1.c, you just terminate the string after the ':', thus
discarding the partition number and the remainder of the string. Correct?

A global varoiable to keep the booted-from-partition in, perhaps?
-- 
Torfinn




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110321202155.eda24313.torfinn.ingolfsen>