View Full Version : Open Firmware and EFI

02-26-2005, 07:40 AM
Guide to Open Firmware

Understanding System Startup Process:

BootX: Launchd Tiger (http://developer.apple.com/documentation/MacOSX/Conceptual/BPSystemStartup/Articles/BootProcess.html)
IBM: Open Firmware Boot Interface (http://www-106.ibm.com/developerworks/library/pa-spec2.html?ca=dgr-mw01OpenFirmware)
Resources (http://www-106.ibm.com/developerworks/library/pa-spec2.html?ca=dgr-mw01OpenFirmware#resources)
NetBSD PowerPC FAQ: Open Firmware (http://www.netbsd.org/Ports/macppc/faq.html)
Understanding Mac OS Open Firmware (http://www.netneurotic.de/mac/openfirmware.html)
NewWorld ROM Boot Process (http://developer.apple.com/technotes/tn/tn1167.html)
BootX - Booting OS X (Open Firmware) (http://www.kernelthread.com/mac/osx/arch_boot.html)
System Startup Process (http://developer.apple.com/documentation/macosx/Conceptual/BPSystemStartup/index.html)
Recover from "?" (http://www.bombich.com/mactips/openfirmware.html)
Won't Boot into OS X (http://docs.info.apple.com/article.html?artnum=106464)
Isolating Issues in OS X (http://docs.info.apple.com/article.html?artnum=25392)
Startup Beeps (http://docs.info.apple.com/article.html?artnum=58442)
Reset NVRAM (http://www.macgurus.com/forums/showthread.php?t=19219)
How to Reset PRAM/NVRAM (http://docs.info.apple.com/article.html?artnum=2238)
Typical NVRAM Structure (pre "ROM in RAM") (http://developer.apple.com/documentation/Hardware/DeviceManagers/pci_srvcs/pci_cards_drivers/PCI_BOOK.1b4.html)
What's Stored in PRAM (http://docs.info.apple.com/article.html?artnum=86194)
OF: the Device Tree (http://developer.apple.com/technotes/tn/tn1062.html)
Displaying the Device Tree (http://developer.apple.com/qa/qa2001/qa1004.html)
Setting the number of processors (http://developer.apple.com/qa/qa2001/qa1141.html#Clearcpus)
OF: User Interface: Part I (http://developer.apple.com/technotes/tn/tn1061.html)
Running Open Firmware Code (http://developer.apple.com/technotes/tn/tn2001.html)
AHT Boots into Open Firmware (http://docs.info.apple.com/article.html?artnum=25415)
Open Firmware Password Protection (http://docs.info.apple.com/article.html?artnum=106482)
SecureMac: Open Firmware Password (http://www.securemac.com/openfirmwarepasswordprotection.php)
Network Booting (http://developer.apple.com/technotes/tn/tn2004.html)
Open Firmware Quick Reference (http://www.firmworks.com/QuickRef.html)
Open Firmware Booting (http://www.kernelthread.com/mac/osx/arch_boot.html)
RealVNC network console (http://www.realvnc.com/)

10-09-2005, 11:26 AM
The Basics of Open Firmware

Open Firmware
Many people assume that, since the Mac doesn't display a prompt to enter a PC-style BIOS, it's not configurable. In fact, it's quite the opposite: the Mac's boot firmware is years more advanced than PC boot firmware. It has a command prompt which is a full-featured Forth interpreter. Open Firmware needs some kind of console. On older Macs, you could use a serial port, but the Mini doesn't have serial ports, so Open Firmware connects to the keyboard and display by default. The display has to be some kind of VGA display. The video output won't work properly until the system's fully booted, because the boot firmware doesn't know about video refresh rates. If you went ahead and got into Open Firmware without knowing this, just type mac-boot to cause it to boot up. Open Firmware is also useful for ejecting stuck CDs; the Mini has no eject button. The trick is to get into Open Firmware and type eject cd.

In the long run, you might want a way not to use a display. Displays chew up power, and if you're using the machine in an embedded project, you may not have any actual use for one. You're in luck: Open Firmware can be configured to run over the network! All recent Macs, including the Mini, support this. Apple's Tech Note 2004 (see Resources) discusses the procedure for setting this up. This does require an ethernet connection: you can't use the wireless network to do it.

A few other likely things to do at the Open Firmware console are disabling auto-booting (setenv auto-boot? false), or setting the machine to verbose boot mode (setenv boot-args -v). Verbose boot mode will be familiar to experienced UNIX users, who have probably been wondering where the familiar and comforting string of console messages have been going all this time.

More on boot options
Verbose booting is most useful if you're trying to debug driver problems that occur early in the boot. You can also tell the machine to go into verbose boot mode by holding down command-V. As with Open Firmware, it won't work if you're using a composite or S-video adapter; the refresh rate will probably be incompatible until the machine is almost finished booting.

Another way to control boot options is by setting the boot-args nvram variable from the command line within Mac OS X. The command to do this is nvram. For instance, you could use nvram boot-args="-v" to force verbose booting. Other options are available too. For instance, you could set boot-args to maxmem=256 to test whether your application will run on a machine with less memory than your development system.

If you're going to be doing much playing around with boot settings, do yourself a favor, and set the auto-boot? variable to false. This will cause the machine to drop into Open Firmware on power-up instead of trying to boot automatically. Otherwise, a perfectly reasonable mistake, such as setting the system to 255 megabytes of memory, could leave your machine unwilling to boot. Note also that getting into Open Firmware can sometimes be a nuisance, even at the best of times. This is often made worse on a cold boot, because the system may not recognize the keyboard quickly enough. Thus, it's sometimes hard to get into Open Firmware except by rebooting again after having booted fully into Mac OS X. See Resources for lots more documentation on Open Firmware and booting.

Remote console
Finally, there's always the option of a real remote console. The best option for this is VNC (Virtual Network Console), a freely available virtual console protocol, program, and everything else. There's a Mac OS X server available for VNC. So... set your machine to start the server automatically on boot, then go ahead and run headless, and connect over the network. Just don't expect to play any video games -- VNC is perfectly reasonable for typing commands, and usable for Web-browsing, but it's too slow for video.

VNC clients are available for Mac, WindowsÂ, and UNIX systems, including Linux and the various BSDs. This won't let you get at the system before it boots, which is why it's nice to be able to configure Open Firmware for network access.
Open Firmware Booting (http://www-128.ibm.com/developerworks/power/library/pa-macmini1/?ca=dgr-lnxw25MacMiniP1)

10-09-2005, 11:29 AM
Tiger: System Startup: BootX and launchd

BootX and System Initialization

Once BootROM is finished and a Mac OS X partition has been selected, control passes to the BootX booter on that partition in the /System/Library/CoreServices directory. The principal job of BootX is to load the kernel environment. As it does this, BootX draws the –booting” image on the screen.

When it loads the kernel environment, BootX attempts to load a previously cached set of device drivers (called an mkext cache) for hardware that is specifically involved in the boot process. If this cache is out-of-date, missing, or corrupt, BootX searches /System/Library/Extensions for drivers and other kernel extensions whose OSBundleRequired property is set to a value appropriate to the type of boot (for example, local or network boot). For more information on how drivers are loaded, see I/O Kit Fundamentals.

Once the kernel and all drivers necessary for booting are loaded, BootX starts the kernelęs initialization procedure. At this point, enough drivers are loaded for the kernel to find the root device. Also from this point, Open Firmware is no longer accessible.

The kernel initializes the Mach and BSD data structures and then initializes the I/O Kit. The I/O Kit links the loaded drivers into the kernel, using the device tree to determine which drivers to link. Once the kernel finds the root device, it roots BSD off of it.

Prior to Mac OS X v10.4, the remaining system initialization was handled by the mach_init and init processes. During the course of initialization, these processes would call various system scripts (including /etc/rc), run startup items, and generally prepare the system for the user. While many of the same scripts and daemons are still run, the mach_init and init processes have been replaced by launchd in Mac OS X v10.4 and later. This change means that launchd is now the root system process.

In addition to initializing the system, the launchd process coordinates the launching of system daemons in an orderly manner. Like the inetd process, launchd launches daemons on-demand. Daemons launched in this manner can shut down during periods of inactivity and be relaunched as needed. (When a subsequent service request comes in, launchd automatically relaunches the daemon to process the request.) This technique frees up memory and other resources associated with the daemon, which is worthwhile if the daemon is likely to be idle for extended periods of time. For more information about daemons and how to launch them, see –Daemons”.

As the final part of system initialization, launchd launches loginwindow. The loginwindow program controls several aspects of user sessions and coordinates the display of the login window and the authentication of users.
BootX: Launchd Tiger (http://developer.apple.com/documentation/MacOSX/Conceptual/BPSystemStartup/Articles/BootProcess.html)

10-26-2005, 08:07 AM
Since last saturday it works better (no more freezes) after I reset the NVRAM again in Open Firmware (reset-nvram) and disconnected the SanDisk 8-in-1 cardreader.

However I had still the following issues:

- Kernel panics at the very beginning of the boot process just after the turning wheel (not the coloured one) appeared. Somehow it appears, that the printer (hp psc 950) may have had some influence on these kernel panics...
- One kernel panic later in the case I reconnected the card-reader - however I am not sure, the card-reader is the culprit in this case.

Therefore I have changed now the boot-command in "open firmware" from its original value "mac-boot" by entering the following commands:

setenv boot-command catch 2000 ms mac-boot

This to allow the entire hardware to stabilize before the boot process takes over - I will see, if this leads to a further improvement

01-25-2006, 07:37 AM
How to reset a MacIntel:

Unplug the power cord while simultaneously pressing and holding the power button on the back of the computer.