My modified OFBOOT.B file

Jim Harris jimrh at charter.net
Sat Feb 4 18:20:09 EST 2012


@Everyone:

For those of you who have been following this saga, I am posting the contents
of my "hacked" OFBOOT.B file for your perusal.

A blow-by-blow description of how this works comes after the listing, if you are interested.

=================== begin inserted text =========================
<CHRP-BOOT>
<COMPATIBLE>
MacRISC MacRISC3 MacRISC4
</COMPATIBLE>
<DESCRIPTION>
PowerPC GNU/Linux First Stage Bootstrap
Modified to boot more than one OSX partition.
By Jim Harris Feb. 4 2012
Released under the Creative Commons Share Alike license
(unless superseeded by the FSF "copyleft" license which might be applicable)
</DESCRIPTION>
<BOOT-SCRIPT>
: .printf fb8-write drop ;
: bootyaboot " Loading second stage bootstrap for Ubuntu Linux..." .printf 100 ms load-base release-load-area " /pci at f2000000/mac-io at 17/ata-4 at 1f000/disk at 0:2,\\yaboot" $boot ;
: bootold " Booting Original Tiger Install..." .printf 100 ms load-base release-load-area " /pci at f2000000/mac-io at 17/ata-4 at 1f000/disk at 0:6,\\:tbxi" $boot ;
: bootnew " Booting New Tiger Install..." .printf 100 ms load-base release-load-area " /pci at f2000000/mac-io at 17/ata-4 at 1f000/disk at 0:4,\\:tbxi" $boot ;
: bootcd " Booting CDROM..." .printf 100 ms load-base release-load-area " cd:,\\:tbxi" $boot ;
" screen" output
variable interactive
1 interactive !

0 interactive @ = if
  bootyaboot
then

dev screen
" "(0000000000aa00aa0000aaaaaa0000aa00aaaa5500aaaaaa)" drop 0 7 set-colors
" "(5555555555ff55ff5555ffffff5555ff55ffffff55ffffff)" drop 8 15 set-colors
device-end
f to foreground-color
0 to background-color
" "(0C)" .printf

" First Stage Ubuntu Bootstrap"(0d 0a)" .printf
"  "(0d 0a)" .printf
" Press l for GNU/Linux,"(0d 0a)" .printf
"       o for Old Tiger,"(0d 0a)" .printf
"       n for New Tiger,"(0d 0a)" .printf
"       c for CDROM."(0d 0a)" .printf
"  "(0d 0a)" .printf
" Stage 1 Boot: " .printf
get-msecs d# 10 3E8 * +
begin
  key? if
    key case
      ascii l of " l "(0d 0a)" .printf bootyaboot endof
      ascii o of " o "(0d 0a)" .printf bootold endof
      ascii n of " n "(0d 0a)" .printf bootnew endof
      ascii c of " c "(0d 0a)" .printf bootcd endof
    endcase
  then
  dup get-msecs <
until
drop
"  "(0d 0a)" .printf bootyaboot
</BOOT-SCRIPT>
<OS-BADGE-ICONS>
1010
000000000000F8FEACF6000000000000
0000000000F5FFFFFEFEF50000000000
00000000002BFAFEFAFCF70000000000
0000000000F65D5857812B0000000000
0000000000F5350B2F88560000000000
0000000000F6335708F8FE0000000000
00000000005600F600F5FD8100000000
00000000F9F8000000F5FAFFF8000000
000000008100F5F50000F6FEFE000000
000000F8F700F500F50000FCFFF70000
00000088F70000F50000F5FCFF2B0000
0000002F582A00F5000008ADE02C0000
00090B0A35A62B0000002D3B350A0000
000A0A0B0B3BF60000505E0B0A0B0A00
002E350B0B2F87FAFCF45F0B2E090000
00000007335FF82BF72B575907000000
000000000000ACFFFF81000000000000
000000000081FFFFFFFF810000000000
0000000000FBFFFFFFFFAC0000000000
000000000081DFDFDFFFFB0000000000
000000000081DD5F83FFFD0000000000
000000000081DDDF5EACFF0000000000
0000000000FDF981F981FFFF00000000
00000000FFACF9F9F981FFFFAC000000
00000000FFF98181F9F981FFFF000000
000000ACACF981F981F9F9FFFFAC0000
000000FFACF9F981F9F981FFFFFB0000
00000083DFFBF981F9F95EFFFFFC0000
005F5F5FDDFFFBF9F9F983DDDD5F0000
005F5F5F5FDD81F9F9E7DF5F5F5F5F00
0083DD5F5F83FFFFFFFFDF5F835F0000
000000FBDDDFACFBACFBDFDFFB000000
000000000000FFFFFFFF000000000000
0000000000FFFFFFFFFFFF0000000000
0000000000FFFFFFFFFFFF0000000000
0000000000FFFFFFFFFFFF0000000000
0000000000FFFFFFFFFFFF0000000000
0000000000FFFFFFFFFFFF0000000000
0000000000FFFFFFFFFFFFFF00000000
00000000FFFFFFFFFFFFFFFFFF000000
00000000FFFFFFFFFFFFFFFFFF000000
000000FFFFFFFFFFFFFFFFFFFFFF0000
000000FFFFFFFFFFFFFFFFFFFFFF0000
000000FFFFFFFFFFFFFFFFFFFFFF0000
00FFFFFFFFFFFFFFFFFFFFFFFFFF0000
00FFFFFFFFFFFFFFFFFFFFFFFFFFFF00
00FFFFFFFFFFFFFFFFFFFFFFFFFF0000
000000FFFFFFFFFFFFFFFFFFFF000000
</OS-BADGE-ICONS>
</CHRP-BOOT>

==================== end inserted text ==========================

The interesting parts are:

First:  The Menu
(I have added line numbers for clarity)

1 " First Stage Ubuntu Bootstrap"(0d 0a)" .printf
2 "  "(0d 0a)" .printf
3 " Press l for GNU/Linux,"(0d 0a)" .printf
4 "       o for Old Tiger,"(0d 0a)" .printf
5 "       n for New Tiger,"(0d 0a)" .printf
6 "       c for CDROM."(0d 0a)" .printf
7 "  "(0d 0a)" .printf
8 " Stage 1 Boot: " .printf
9 get-msecs d# 10 3E8 * +

Lines 1 & 2 print a heading (title) line above the menu.
Note:  The "(0d 0a)" lines are the ASCII line-feed / carriage-return
       characters as, apparently, the Open Firmare screens require the "MS-DOS"
       style CR/LF instead of the "Unix" (and Mac) style "/n" (0x00) line terminator.

Lines 3-8 print the actual menu itself, followed by a blank line and "Stage 1 Boot:"

Line 9 is the like that actually grabs the single menu-key keypress.
"get-msecs" appears to be used as a label, and the rest of the line does the dirty work.

10 begin
11  key? if
12    key case
13      ascii l of " l "(0d 0a)" .printf bootyaboot endof
14      ascii o of " o "(0d 0a)" .printf bootold endof
15      ascii n of " n "(0d 0a)" .printf bootnew endof
16      ascii c of " c "(0d 0a)" .printf bootcd endof
17    endcase
18  then
19  dup get-msecs <
20 until
21 drop
22"  "(0d 0a)" .printf bootyaboot

Lines 10 - 22 acutally process the key entered in the menu.
The interesting thing to note is the word *after* the ".printf".
My knowlege of FORTH is WAY rusty, but this case statement
appears to "jump" to the line at the top of the script whose
label matches the word used here (before the "endof"

Line 11 captures the key entered into the variable "key"
Line 12 takes the variable "key" and tests to see if it is
identical to any of the four letters listed in lines 13 - 16

If it's equal to any of these letters, it branches to the line (near the top)
that has the same label.

If not, it falls past the "then" (which is the other side of the "if"),
and hits line 19, the "dup get-msecs" line.

The "<" checks to see if the time-out timer has expired.
If it has, it falls past the "until" line at line 20.  Othewise the "dup get-msecs <"
sends it back to line 9 to see if there have been any other keys pressed.
It continues to do this until either a valid key is pressed, or the timer expires.

Line 20, the "until" is the other half of the "begin" statement, and it is the "until"
that actually does the "expired timer" test.  If it has not, line 19 gets control.
If it has, control passes to line 21.

During the process of waiting for a valid keypress, the user may have been typing random
stuff on the keyboard - which might screw things up later.
Because of that, line 21, the "drop" statement, tells the program to forget any bogus keys
that might have been pressed.  Then line 22 forces a branch to the line that launches
the Linux install.  (which is the default if nothing was pressed.)

If you wanted a different default - the "new" OSX or the "CD" - you would put the associated
label her instead of "bootyboot".

This brings us to the labeled lines near the top of the script.
These are the statements that actually boot what we asked for.

(a) : bootyaboot " Loading second stage bootstrap for Ubuntu Linux..." .printf 100 ms load-base release-load-area " /pci at f2000000/mac-io at 17/ata-4 at 1f000/disk at 0:2,\\yaboot" $boot ;
(b) : bootold " Booting Original Tiger Install..." .printf 100 ms load-base release-load-area " /pci at f2000000/mac-io at 17/ata-4 at 1f000/disk at 0:6,\\:tbxi" $boot ;
(c) : bootnew " Booting New Tiger Install..." .printf 100 ms load-base release-load-area " /pci at f2000000/mac-io at 17/ata-4 at 1f000/disk at 0:4,\\:tbxi" $boot ;
(d) : bootcd " Booting CDROM..." .printf 100 ms load-base release-load-area " cd:,\\:tbxi" $boot ;

Before we get started, let's look at the heiroglyphics near the end of these lines.

Example:  /pci at f2000000/mac-io at 17/ata-4 at 1f000/disk at 0:6

This is an example of an "Open Firmware fully qualified device specifier"

/ - start at the beginning of the Open Firmware device tree - and look for. . .
pci at f2000000 - the PCI "slot" that has the physical address of hexidecimal "f2000000", and then. . .
mac-io at 17 - the I/O (input-output) port located at address "17", then look for. . . .
ata-4 at 1f000 - the ATA (hard drive controller circutry) device #4 located at address "1f000:. . . .
disk at 0:6 - this is the hard drive located at ATA controller position "0" (the primary hard drive)
and then look within partition #6 for the blessed boot file.

(After all that, you might wonder if this was "blessed" or maybe "cursed"? ( :laughing: ) )
It looks like gibberish, but that's the way the Open Firmware works.

If you look at the lines above, you will notice that the "original" install was placed within partition #6
whereas the "new" install is located at partition #4

Going back to the program, if you selected "l", to boot Linux, you branch up here to line (a).
Line (a) tells the Open Firmware to go to that primary hard drive, look at partition #2 for a file called "yaboot".
Yaboot is a small program launcher that actually gets the Linux kernel running and passes control to Linux
so it can boot.

Line (b) tells the Open Firmware to go back to that primary hard drive, look at partition #6, and look for the
"blessed" boot file ending in "tbxi"  (the Mac boot program that does the same thing as yaboot does for Linux)

Line (c) tells the Open Firmware to do the same thing as line (b), except to look for the blessed boot file
within partition #4.

Finally, line (d) tells the Open Firmware to go to the device named "cd" and look for the blessed "tbxi" file.
("cd" is an alias for another long string of gibberish, ending up at the CD-ROM device)

At this point, your Mac should be booting either a Macintosh OS, or your Linux installation.

Now, that wasn't that hard, was it?




More information about the Yaboot-users mailing list