My modified OFBOOT.B file
jimrh at charter.net
Sat Feb 4 18:20:09 EST 2012
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 =========================
MacRISC MacRISC3 MacRISC4
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)
: .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
1 interactive !
0 interactive @ = if
" "(0000000000aa00aa0000aaaaaa0000aa00aaaa5500aaaaaa)" drop 0 7 set-colors
" "(5555555555ff55ff5555ffffff5555ff55ffffff55ffffff)" drop 8 15 set-colors
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 * +
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
dup get-msecs <
" "(0d 0a)" .printf bootyaboot
==================== 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.
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
19 dup get-msecs <
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