Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Operating System Utilities /
Chapter 9 - Start Manager


System Initialization and Startup

When a Macintosh computer is first turned on, but before it can load and run an application, it must go through system initialization and system startup. At system initialization, the system initialization code located in ROM is executed: memory is tested and initialized, slot cards are initialized, ROM drivers are installed, device drivers are located, and more. The next section, "System Initialization," describes the various steps included in system initialization. At system startup, the system code that is located on the startup disk is executed: various software modules are initialized and system extensions are run. The section "System Startup" on page 9-4 describes various steps included in system startup.

WARNING
The system initialization and system startup process is not the same for all Macintosh models. In addition, the system initialization sequence and system startup sequence listed in this chapter are both subject to change; therefor use the information in these sections only for informational purposes.
You should read this section if you provide a system extension that installs software, such as a device driver or other code, during system initialization or system startup.

System Initialization

Initialization on a Macintosh computer begins as soon as the power is first supplied to it. Built-in hardware circuits initialize the main processor and other ICs and temporarily alter the memory mapping to make an image of the ROM appear at the location where RAM normally starts (address 0), while making RAM appear at a location higher in memory. This mapping scheme allows the startup routines in the initialization code to obtain critical low-memory vectors. After the initialization code begins executing and obtains the low-memory vectors, it resets the memory mapping back to normal. For further details on this process, see the Guide to Macintosh Family Hardware.

The following list summarizes the events that typically take place when the initialization code in ROM is executed.

IMPORTANT
The system initialization sequence is subject to change; the information in this section is provided for informational purposes only.
  1. Hardware is initialized. The initialization code performs a set of diagnostic tests to verify functionality of some vital hardware components. If the diagnostics succeed, the initialization code initializes these hardware components. If diagnostics fail, the initialization code issues diagnostic tones to indicate the type of hardware failure.
    The initialization code determines how much RAM is available and tests it, then validates the parameter RAM (PRAM). Parameter RAM contains a user's preferences for settings of various control panel settings and port configurations.
    The initialization code determines the global timing variables, TimeDBRA, TimeSCCDB, and TimeSCSIDB. (See "Global Timing Variables" on page 9-9 for more information) and initializes the Resource Manager, Notification Manager, Time Manager, and Deferred Task Manager.
  2. On machines with expansion slots, the initialization code initializes the Slot Manager. The Slot Manager then initializes any installed cards by executing the primary initialization code in each card's declaration ROM. Video expansion cards, including built-in video, initialize themselves by determining the type of connected monitor, and then set the display to 1 bit per pixel, and display a gray screen (alternating black and white dots).
  3. The initialization code initializes the Vertical Retrace Manager and Gestalt Manager. ROM drivers for all built-in functionality are installed in the unit table and initialized. The initialization code initializes the Apple Desktop Bus (ADB) Manager that then initializes each ADB device. The initialization code initializes the Sound Manager and SCSI Manager.
  4. The initialization code loads drivers from all on-line SCSI devices.
  5. The initialization code chooses the boot device, and calls the boot blocks to begin initialization of the System Software.

Having initialized the computer's slots, drivers, and hardware, as well as some of the Operating System managers, the initialization code dispatches to the startup code, which immediately begins the startup procedure described in the next section,
"System Startup."

System Startup

System startup begins as soon as the initialization code in ROM transfers control to the system startup code. The system startup code is responsible for initializing AppleTalk, the debugger, and system extensions. System extensions are covered in detail in the section "Writing a System Extension" beginning on page 9-10.

This section covers the startup sequence for Macintosh computers running System 7 or later; it then describes the boot blocks and defines the boot block header.

The following list summarizes the events that take place when the system startup code is executed.

IMPORTANT
The system startup sequence is subject to change; the information in this section is provided for informational purposes only.
  1. The system startup code looks for an appropriate startup device. It first checks the internal 3.5-inch floppy drive. If a disk is found, it attempts to read it and looks for a System file. If it doesn't find a disk or System file, it checks the default startup device specified by the user in the Startup Disk control panel. If no default device is specified or if the device specified is not connected, it checks for other devices connected to the SCSI port, beginning with the internal drive and proceeding successively from drive 6 through drive 1. If it doesn't find a startup device, it displays the question-mark disk icon until a disk is inserted. If the startup device itself fails, the startup code displays the sad Macintosh icon until the computer is turned off.
  2. After selecting a startup device, the system startup code reads system startup information from the startup device. The system startup information is located in the boot blocks, the logical blocks 0 and 1 on the startup disk. The boot blocks contain important information such as the name of the System file and the Finder. The boot blocks are described in detail in the next section.
  3. The system startup code displays the happy Macintosh icon.
  4. The system startup code reads the System file and uses that information to initialize the System Error Handler and the Font Manager.
  5. The system startup code verifies that the necessary hardware is available to boot the system software and displays on the startup screen an alert box with the message "Welcome to Macintosh."
  6. The system startup code performs miscellaneous tasks: it verifies that enough RAM is available to boot the system software, it loads and turns on Virtual Memory if it is enabled in the Memory control panel, it loads the debugger, if present. (The system startup information contains the name of the debugger --usually MacsBug), it sets up the disk cache for the file system, and it loads and executes CPU-specific software patches. At this point, the system begins to trace mouse movement.
  7. For any NuBus cards installed, the system startup code executes the secondary init code on the card's declaration ROM.
  8. The system startup code loads and initializes all script systems, including components for all keyboard input methods. It also executes the initialization resources in the System file.
  9. The system startup code loads and executes system extensions. (System extensions can be located in the Extensions folder, in the Control Panels folder, and in the System Folder).
  10. The system startup code launches the Process Manager, which takes over at this point and launches the Finder. The Finder then displays the desktop and the menu bar. The desktop shows all mounted volumes; it also shows any windows that were open the last time the computer was shut down. The Memory Manager sets up a large, unsegmented application heap, which is divided into partitions as applications start up.

At this point, the system has successfully booted.

The next section, "Boot Blocks," describes the format of the boot block header. This header contains information that the startup code uses to start up the system.

Boot Blocks

The first two logical blocks on every Macintosh volume are boot blocks. These blocks contain system startup information: instructions and information necessary to start up (or "boot") a Macintosh computer. This information consists of certain configurable system parameters (such as the capacity of the event queue, the number of open files allowed, and so forth) and is contained in a boot block header. The system startup information also includes actual machine-language instructions that could be used to load and execute the System file. Usually these instructions follow immediately after the boot block header. Generally, however, the boot code stored on disk is ignored in favor of boot code stored in a resource in the System file.

The boot block header has a structure that can be described by the BootBlkHdr data type.

WARNING
The format of the boot block header is subject to change. If your application relies on the information presented here, it should check the boot block header version number and react gracefully if that number is greater than that documented here.
Note that there are two boot block header formats. The current format includes two fields at the end that are not contained in the older format. These fields allow the Operating System to size the system heap relative to the amount of available physical RAM. A boot block header that conforms to the older format sizes the system heap absolutely, using values specified in the header itself. You can determine whether a boot block header uses the current or the older format by inspecting a bit in the high-order byte of the bbVersion field, as explained in its field description.

TYPE BootBlkHdr =          {boot block header}
RECORD
   bbID:          Integer; {boot blocks signature}
   bbEntry:       LongInt; {entry point to boot blocks}
   bbVersion:     Integer; {boot blocks version number}
   bbPageFlags:   Integer; {used internally}
   bbSysName:     Str15;   {System filename}
   bbShellName:   Str15;   {Finder filename}
   bbDbg1Name:    Str15;   {first debugger filename}
   bbDbg2Name:    Str15;   {second debugger filename}
   bbScreenName:  Str15;   {name of startup screen}
   bbHelloName:   Str15;   {name of startup program}
   bbScrapName:   Str15;   {name of system scrap file}
   bbCntFCBs:     Integer; {number of FCBs to allocate}
   bbCntEvts:     Integer; {number of event queue elements}
   bb128KSHeap:   LongInt; {system heap size on 128K Mac}
   bb256KSHeap:   LongInt; {system heap size on 256K Mac}
   bbSysHeapSize: LongInt; {system heap size on all machines}
   filler:        Integer; {reserved}
   bbSysHeapExtra:LongInt; {additional system heap space}
   bbSysHeapFract:LongInt; {fraction of RAM for system heap}
END;
Field Description
bbID
A signature word. For Macintosh volumes, this field always contains the value $4C4B.
bbEntry
The entry point to the boot code stored in the boot blocks. This field contains machine-language instructions that translate to BRA.S *+$90 (or BRA.S *+$88, if the older block header format is used), which jumps to the main boot code following the boot block header. This field is ignored, however, if bit 6 is clear in the high-order byte of the bbVersion field or if the low-order byte in that field contains $D.
bbVersion
A flag byte and boot block version number. The high-order byte of this field is a flag byte whose bits have the following meanings:
BitMeaning
0-4Reserved; must be 0
5Set if relative system heap sizing is to be used
6Set if the boot code in boot blocks is to be executed
7Set if new boot block header format is used
If bit 7 is clear, then bits 5 and 6 are ignored and the version number is found in the low-order byte of this field. If that byte contains a value that is less than $15, the Operating System ignores any values in the bb128KSHeap and bbSysHeapSize fields and configures the system heap to the default value contained in the bbSysHeapSize field. If that byte contains a value that is greater than or equal to $15, the Operating System sets the system heap to the value in bbSysHeapSize. In addition, the Operating System executes the boot code in the bbEntry field only if the low-order byte contains $D.
If bit 7 is set, the Operating System inspects bit 6 to determine whether to execute the boot code contained in the bbEntry field and inspects bit 5 to determine whether to use relative sizing of the system heap. If bit 5 is clear, the Operating System sets the system heap to the value in bbSysHeapSize. If bit 5 is set, the system heap is extended by the value in bbSysHeapExtra plus the fraction of available RAM specified in bbSysHeapFract.
bbPageFlags
Used internally.
bbSysName
The name of the System file.
bbShellName
The name of the shell file. Usually, the system shell is the Finder.
bbDbg1Name
The name of the first debugger installed during the boot process. Typically this is Macsbug.
bbDbg2Name
The name of the second debugger installed during the boot process. Typically, this is Disassembler.
bbScreenName
The name of the file containing the information (welcome message) initially displayed on the startup screen. Usually, this is StartUpScreen.
bbHelloName
The name of the startup program. Usually, this is the Finder.
bbScrapName
The name of the system scrap file. Usually, this is the Clipboard.
bbCntFCBs
The number of file control blocks (FCBs) to put in the FCB buffer. In System 7 and later, this field specifies only the initial number of FCBs in the FCB buffer because the Operating System can usually resize the FCB buffer if necessary. See the chapter "File Manager" in Inside Macintosh: Files for details on the file control block (FCB) buffer.
bbCntEvts
The number of event queue elements to allocate. This number determines the maximum number of events that can be stored by the Event Manager at any one time. Usually this field contains the value 20.
bb128KSHeap
The size of the system heap on a Macintosh computer having 128 KB of RAM.
bb256KSHeap
Reserved.
bbSysHeapSize
The size of the system heap on a Macintosh computer having 512 KB or more of RAM. This field might be ignored, as explained in the description of the bbVersion field.
filler
Reserved.
bbSysHeapExtra
The minimum amount of additional system heap space required. If bit 5 of the high-order word of the bbVersion field is set, this value is added to the bbSysHeapSize.
bbSysHeapFract
The fraction of RAM available to be used for the system heap. If bit 5 of the high-order word of the bbVersion field is set, this fraction of available RAM is added to the bbSysHeapSize.

Global Timing Variables

During system initialization, the initialization code initializes the following global variables with timing information.
VariableContents
TimeDBRAThe number of times the DBRA (decrement branch always instruction) can be executed per millisecond.
TimeSCCDBThe number of times the SCC can be accessed per millisecond.
TimeSCSIDBThe number of times the SCSI can be accessed per millisecond.

Note
The TimeDBRA value is calculated in ROM and is affected by the processing method of the CPU. Accordingly, for routines running in RAM, it is not necessarily a good measure of how fast the computer is.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996