Re: OpenFirmware, Booting and OS Development
Re: OpenFirmware, Booting and OS Development
- Subject: Re: OpenFirmware, Booting and OS Development
- From: Ryan Rempel <email@hidden>
- Date: Wed, 27 Aug 2003 11:28:48 -0500
On Wednesday, August 27, 2003, at 05:24 AM, Andrew McCall wrote:
I am trying to write a simple bootsector that displays the phrase
"Loading..." to the screen - much like the many, many x86 examples
that can be found on the internet, but this time I want to do it on a
mac.
I have read all the information I can on OpenFirmware I understand
that the OpenFirmware is basically the first stage in the boot
process, this will then load software that is at the "real-base"
address, and then this can b
I am making it slightly harder for myself because I want to target old
world Mac's first (as thats what I have), I understand that NewWorld
Mac's can just boot straight to an elf kernel.
Am I right in the above assumptions?
How do I get my bootsector into the "real-base"?
Can anyone help "fill" the gaps in my knowledge?
t is quite correct that Open Firmware is the first stage in the boot
process (well, the first stage you have any influence over, anyway). If
I understand the process correctly, the difference between OldWorld and
NewWorld macs in this respect is as follows.
On OldWorld Macs, the Mac OS X installer makes certain adjustments to
the partition map on the boot volume which, in effect, instructs Open
Firmware to load and execute code which is located at a raw location
(which is specified in the partition map). By "raw location" what I
mean is that Open Firmware (on OldWorld Macs) does not understand the
HFS+ file system, so you have to tell it exactly where the code to
execute is located, as an offset into the partition. (And it has to be
contiguous). The code which is actually executed at this point is
called BootX. (Not to be confused with the Linux BootX, which is
something completely different). The function of BootX is to load any
kernel extensions required for booting, and load the kernel, and then
hand off control to the kernel. BootX does understand the HFS+ file
system (as well as several others), so it can do more useful work. BTW,
the Mac OS X Installer installs BootX in a "special" part of the
partition that is not part of the visible filesystem (on OldWorld macs).
The difference in NewWorld Macs (again, if I understand this
correctly), is that OpenFirmware does understand the HFS+ file system
on NewWorld macs, so the "special" adjustment to the partition map and
"special" install location for BootX are not necessary. BootX can
simply be an ordinary file in the filesystem, and the NVRAM boot
settings can point to it directly. (Actually, there is also a
difference in the format of the BootX code, which you need to unpack
and prepare for OldWorld systems in a different manner than for
NewWorld).
But in both cases, the flow of control is from Open Firmware to BootX
to the kernel.
So to make changes to the earliest part of the boot process, the
easiest option is to create and install a customized version of BootX.
(Another option is NVRAM patches to the Open Firmware boot process,
which execute earlier. But there is limited space for them, especially
on OldWorld machines). BootX itself is part of Darwin, and thus
open-source.
The process for installing it correctly is a little involved on
OldWorld machines--if you want to see an example, you can look at the
source for my XPostFacto application (which helps install Mac OS X on
some OldWorld machines). The source is available at this location:
http://www.opendarwin.org/cgi-bin/cvsweb.cgi/projects/XPostFacto/
My BootX customization is in the "BootX" directory there. The code for
installing it properly is scattered throughout
http://www.opendarwin.org/cgi-bin/cvsweb.cgi/projects/XPostFacto/
XPostFacto/Model/
This description leaves out a few of the complications involved, but
should get you started.
_______________________________________________
darwin-kernel mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/darwin-kernel
Do not post admin requests to the list. They will be ignored.