Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 24 Dec 2011 13:03:15 +0100
From:      Milan Obuch <freebsd-ppc@dino.sk>
To:        freebsd-ppc@freebsd.org
Subject:   Multiboot setup on Mac mini
Message-ID:  <20111224130315.0cc68c60@atom.dino.sk>

next in thread | raw e-mail | index | archive | help
Hi,

as I managed to install both 9-PRERELEASE and 10-CURRENT along with
supplied MacOS on HDD in Mac mini, I hacked a bit on multiboot setup.
Openfirmware allows for flexible scripting similar to that of our
loader, but before even our boot blocks come to the show.

OPT method (holding OPT key - ALT in PC parlance) while turning on Mac
means scanning devices for bootable partitions. It looks simple,
graphics selection of bootable partition with mouse, but there are some
drawbacks. First, it is slow, mostly becasue of scanning devices (at
least HDD and CD, if present), maybe graphics is not the speediest,
too. What was not satisfactory for me is impossibility to distinguish
various non-MacOS bootable partitions - they are presented as disc
icons all alike, bootable CD, if present, looks different. MacOS
partition is denoted with X in circle put over disc icon and text label
under it, but I did not find the way to do something similar to my
partitions' icons.

After some browsing I found Openfirmware uses Forth - just like our
loader at least for i386 and amd64 does - and so I decided to play with
it a bit, too. First, I modified boot block so it takes an argument
telling which partition should be used to mount rootfs, not finding it
via some magic. Then I was able to boot system from any partition
just writing 'boot hd:<n>,\ppc\boot1.elf hd:<m>' in OpenFirmware
prompt, using <n> where my modified block is installed and <m> beeing
system partition I would like to boot from.

Then I modified bootinfo file...

<CHRP-BOOT>
<DESCRIPTION>FreeBSD/powerpc bootloader</DESCRIPTION>
<OS-NAME>FreeBSD</OS-NAME>
<VERSION> $FreeBSD: src/sys/boot/powerpc/boot1.chrp/bootinfo.txt,v 1.2
2008/10/31 00:52:31 nwhitehorn Exp $ </VERSION>

<COMPATIBLE>
MacRISC MacRISC3 MacRISC4
</COMPATIBLE>
<BOOT-SCRIPT>
begin
 s" 1. Apple Mac OS X" type cr
 s" 2. FreeBSD  9-PRERELEASE" type cr
 s" 3. FreeBSD 10-CURRENT" type cr
 s" 4. OpenFirmware prompt" type cr
 cr
 key
 dup
 31 =
 if
  drop
  " boot hd:3,\\:tbxi" eval
 else
  dup
  32 =
   if
    drop
    " boot hd:2,\ppc\boot1.elf hd:4" eval
   else
    dup
    33 =
     if
      drop
      " boot hd:2,\ppc\boot1.elf hd:6" eval
     else
      34 =
       if
        exit
       else
        s" ?" type cr cr
       then
     then
   then
 then
0 until
</BOOT-SCRIPT>
</CHRP-BOOT>

and it works the way I intended... almost. I have set boot-command to
invoke 'boot hd:2,\ppc\bootinfo.txt' instead of standard mac-boot.
After switching on Mac mini, I hear boot chime, and when monitor comes
on, I see there

load-size=800 adler32=23467718
1. Apple Mac OS X
2. FreeBSD  9-PRERELEASE
3. FreeBSD 10-CURRENT
4. OpenFirmware prompt


Method <write> not found; ihandle=0 phandle=0

Apple PowerMac10,1 4.8.9f4BootROM built on 03/23/05 at 14:22:23
Copyright 1994-2005 Apple Computer, Inc.
Welcome to Open Firmware, the system time and date is: nn/nn/nnnn
nn:nn:nn
To continue booting, type "mac-boot" and press return.
To shut down, type "shut-down" and press return.

 ok
0 >

So my script is definitelly being called, as seen menu is drawn, but
something bad happens and script is being stopped. Now I can simply
write 'boot hd:2,\ppc\bootinfo.txt' on console and menu is drawn,
again, this time waiting for keypress to select desired partition to
boot an acting on it correctly.

Is someone here who knows Open Firmware and sees what's wrong with my
script or can suggest some work-around, if I hit some bug elsewhere?

Regards,
Milan

N. B. Merry Christmas and no bugs in system in New Year :)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20111224130315.0cc68c60>