Section 4.2. A Whole New World


4.2. A Whole New World

The Macintosh was not designed to run multiple operating systems. The Macintosh ROM contained both low-level and high-level code. The low-level code was for hardware initialization, diagnostics, drivers, and so on. The higher-level Toolbox was a collection of software routines meant for use by applications, quite like a shared library. Toolbox functionality included the following:

  • Management of dialog boxes, fonts, icons, pull-down menus, scroll bars, and windows

  • Event handling

  • Text entry and editing

  • Arithmetic and logical operations

Before the iMac was introduced, Apple computers used a large, monolithic ROMalso called the Toolbox ROMthat contained a substantial part of the system software as both low-level and high-level code. Examples of low-level, hardware-specific code included hardware initialization code, drivers, feature tables, and diagnostics. Examples of higher-level code included the 68K emulator, the nanokernel, Toolbox managers, SCSI Manager, and QuickDraw. Note that the ROM contained not only code that was needed by the computer at power-up time but also code that provided application-level APIs.

As Macintosh system software increased in functionality and complexity, it became increasingly difficult to maintain the ROM. Apple attempted to ameliorate the situation by redirecting modifications and changes to disk-resident files instead of changing the ROM itself. For example, the System File, which was loaded early on during the boot process, contained portions of the Toolbox, ROM extensions and patches, fonts, sounds, and other resources. The System File was loaded into RAM, after which its contents were available to the operating system and applications. The concept of a System Enabler was introduced in 1992 along with System 7.1. System Enablers allowed Apple to introduce new Macintoshes without revising the base system software. For example, the Macintosh 32-bit System Enabler was a system software extension and a replacement for the MODE32 software, which provided access to memory-addressing features of System 7.1.

MODE32 Software

Certain machines such as the Macintosh II, IIx, IIcx, and SE/30 could have 32-bit support and a larger virtual memory capability through a 32-bit System Enabler program (called MODE32) on System 7. The standard ROMs of these machines were not 32-bit clean and therefore were compatible only with 24-bit addressing. MODE32 allowed selecting and changing between 24-bit and 32-bit addressing modes. With 32-bit addressing, it was possible to use more than 8MB of contiguous physical memory. With virtual memory, it was possible to use hard disk space as "swap" space to run programs.


4.2.1. "New" Is Good News

With the introduction of the iMac, Apple reached a far cleaner separation between the hardware-specific and generic (across various Apple computers) parts of the system software. The new approach used a small Boot ROM that contained only the code needed to boot the computer, with the remaining components of the system software residing as files on diskeffectively, a software ROM. The Boot ROM has the ability to load the software ROM into a portion of physical memory (RAM). This portion, which is marked read-only, is unavailable for other use. Apple used the term New World to refer to this architecture. This was also called the ROM-in-RAM design. Another important feature of the New World machines was the extensive use of Open Firmware. Although it had been introduced in earlier Apple computers, Open Firmware's use was minimal in the so-called Old World machines. Table 41 summarizes the temporal worldliness of the Macintosh family.

Table 41. The Macintosh Family: New and Old Worlds

CPU

Bus

ROM

Software ROM

World

68K

NuBus

Mac OS ROM (68K)

PowerPC

PCI

System ROM (PowerPC)

Mac OS ROM (68K)[a]

PowerPC

PCI

Open Firmware 1.x

Mac OS ROM

Old

PowerPC

PCI

Open Firmware 2.x

Mac OS ROM

Old

PowerPC

PCI

Open Firmware 3.x

Mac OS ROM

New

PowerPC

PCI

Open Firmware 4.x

BootX (Mac OS X)

New


[a] The PowerPC System ROM started the nanokernel, on which the 68K Mac OS ROM ran largely unmodified.

The iMac's ROM image resided in a file called Mac OS ROM in the System Folder. It contained the Toolbox, kernel, and the 68K emulator. Once loaded, the ROM consumed approximately 3MB of physical memory.


NuBus

NuBusspecified by the IEEE 1196 standardwas a simple 32-pin bus originally developed at the Laboratory for Computer Science (LCS), Massachusetts Institute of Technology (MIT). It was used in Apple computers beginning with the Macintosh II, until Apple switched to the PCI bus. NeXT computers also used NuBus.


4.2.2. Modern Boot ROM (PowerPC)

The Boot ROM of a modern PowerPC-based Macintosh is stored in up to 2MB[3] of flash EEPROM.[4] Over time, and especially with the advent of Mac OS X, the composition of the ROM has changed greatly. For example, the modern ROM does not contain a 68K emulator or the nanokernel. The firmware-resident code in the Boot ROM includes POST functionality for hardware initialization and diagnostics. The firmware also contains Open Firmware, which completes hardware initialization,[5] incrementally builds a description of the system's hardware, loads initial operating system software (the bootloader), and eventually transfers control to the latter. Several properties of the Boot ROM can be viewed on Mac OS X using the ioreg command-line utility.

[3] A dual-processor 2.7GHz Power Mac G5 contains 1MB of onboard flash EEPROM.

[4] The "EE" in EEPROM stands for electrically eraseable.

[5] Open Firmware automatically assigns interrupts to PCI devices.

$ ioreg -p IODeviceTree -n boot-rom -w 0 | less ... | +-o boot-rom@fff00000  <class IOService, !registered, !matched, active,                           busy 0, retain count 4>     | |   {     | |     "reg" = <fff0000000100000>     | |     "has-config-block" = <>     | |     "image" = <00080000>     | |     "AAPL,phandle" = <ff8935b8>     | |     "security-modes" = <"none, full, command, no-password">     | |     "write-characteristic" = <"flash">     | |     "BootROM-build-date" = <"10/26/04 at 16:30:32">     | |     "model" = <"Apple PowerMac7,3 5.1.8f7 BootROM built on ...">     | |     "info" = <fff000...000>     | |     "name" = <"boot-rom">     | |     "BootROM-version" = <"$0005.18f7">     | |     "hwi-flags" = <48fdd37e>     | |   } ...


The Boot ROM also contains device drivers for certain fundamental devices, such as the USB hub, Apple USB keyboard and mouse, and Apple Bluetooth keyboard and mouse. Therefore, even with a wireless (Bluetooth) keyboard and mouse, you can drop into the firmware before the operating system boots and interact with the system.


The file type of Apple's software ROM file is tbxi, which stands for Toolbox imagea remnant of the Old World. The Toolbox image file is also called a bootinfo file. It resides on the boot device and has a localizable name. Therefore, it is searched for based on file typenot filename. Its default location is in the directory marked as the "blessed folder" in the HFS Plus volume header.[6] If you perform a file search using the Finder on Mac OS X and specify tbxi as the file type to search for, you should get one result on a computer with a single Mac OS X installation: /System/Library/CoreServices/BootX, which is the Mac OS X bootloader. The same search under Mac OS 9 or Mac OS 8 would yield the file /System Folder/Mac OS ROM. On a Mac OS X 10.4 or newer system, such a search could be performed through Spotlight. The four-character file type is converted to a four-byte (32-bit) integer, each of whose bytes is the ASCII value of the corresponding file type character. The ASCII values of "t", "b", "x", and "i" are 0x74, 0x62, 0x78, and 0x69, respectively. Therefore, the file type to use while searching with Spotlight is 0x74627869.

[6] We will look at details of HFS Plus in Chapter 12.

$ mdfind 'kMDItemFSTypeCode == 0x74627869' /System/Library/CoreServices/BootX /System Folder/Mac OS ROM $


The specifier for Open Firmware's default boot device contains \\:tbxi as the filename component, which tells the firmware to look for a file of type tbxi in the boot directory. The volume header of an HFS Plus file system contains an eight-element array called finderInfo. Each element of this array is a 32-bit unsigned integer. The first element contains the ID of the blessed folder, which contains BootX on Mac OS X, and Mac OS ROM under Mac OS 9. This way, Open Firmware can easily find a bootable systemif one exists. You can use bless(8) to set volume bootability and startup disk options. The -info argument of bless displays relevant elements of the finderInfo array.

$ bless -info / finderinfo[0]:   3317 => Blessed System Folder is /System/Library/CoreServices finderinfo[1]:      0 => No Startup App folder (ignored anyway) finderinfo[2]:      0 => Open-folder linked list empty finderinfo[3]: 877875 => OS 9 blessed folder is /System Folder finderinfo[4]:      0 => Unused field unset finderinfo[5]:   3317 => OS X blessed folder is /System/Library/CoreServices 64-bit VSDB volume id:  0x79A955B7E0610F64


Note that on an x86-based Macintosh computer, the second element of the finderInfo array contains the ID of the blessed system file, which is the EFI bootloader in its case.

$ hostinfo ... 2 processors are physically available. 2 processors are logically available. Processor type: i486 (Intel 80486) ... $ bless -info / finderinfo[0]: 3050 => Blessed System Folder is /System/Library/CoreServices finderinfo[1]: 6484 => Blessed System File is /System/Library/CoreServices/boot.efi ...





Mac OS X Internals. A Systems Approach
Mac OS X Internals: A Systems Approach
ISBN: 0321278542
EAN: 2147483647
Year: 2006
Pages: 161
Authors: Amit Singh

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net