Section 14.2. Bootstrapping

   


14.2. Bootstrapping

Bootstrapping a program is a machine-dependent operation. On most machines, this operation is supported by a Basic Input/Output System (BIOS). The BIOS is resident in nonvolatile storage and is invoked automatically when the CPU is reset. The facilities provided by the BIOS are expected to support the bootstrap of standalone programs. Most BIOSs also execute diagnostic operations when a machine is reset to ensure that the hardware is functioning properly.

The boot Program

The BIOS does not understand the format of the FreeBSD filesystem. Instead, the startup procedure reads a program from a reserved area of the boot disk. This procedure ultimately results in the execution of the FreeBSD boot program. This program is a general-purpose standalone program that the system can use to load and execute other standalone programs. A standalone program is a program that is capable of operating without the assistance of the FreeBSD kernel. Standalone programs usually are linked with the standalone I/O library, a library that supports a FreeBSD-like I/O interface on a variety of hardware devices. The standalone I/O library provides these facilities through a collection of standalone device drivers and a library of routines that support reading of files from FreeBSD filesystems that reside on the devices. The boot program is stored in a location accessible to the BIOS, which is the first few sectors of a system disk.

Once the boot program has been loaded and started, it must load the file containing the executable image of the program to be bootstrapped and then must start the loaded program running. To load the appropriate file, boot must know the pathname of the file to be loaded and the hardware device on which the file resides. The boot program usually has a default device and program name from which it tries to load. Often, this default is stored in the boot sectors of the boot disk along with the boot program. The BIOS communicates the bootstrapping information to the boot program by initializing the run-time stack and then placing the parameters on the stack in the same way that the FreeBSD kernel passes arguments to programs. Alternatively, a user may type in the device and program name to be used.

Boot always loads programs at a well-known memory location. Since boot is initially loaded in memory at the same well-known location, it must copy its own image to another place in memory to avoid loading on top of itself the image of the program that it bootstraps (see Figure 14.1). This relocation implies that the boot program must be created with its starting address set to the memory location at which it will be copied; otherwise, references to data structures in the boot program will access the wrong memory locations after boot is copied (remember that boot operates with virtual-address translation disabled).

Figure 14.1. Placement of the boot program in memory.



   
 


The Design and Implementation of the FreeBSD Operating System
The Design and Implementation of the FreeBSD Operating System
ISBN: 0201702452
EAN: 2147483647
Year: 2003
Pages: 183

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