When a PC is powered on, the PC searches for a disk that has a magic number (0xAA55) at an offset of 510 bytes in its first sector. (The search order of the disks is configurable.)
When this magic number is found, the disk's first sector is loaded into memory at address LOADOFF and then executed. This is done by code in the PC's ROM BIOS and is independent of the operating system to be used. If the disk was initialized by minix, then the code loaded will be either the master bootblock code (masterboot.s) or the bootstrap code (bootblock.s). Other operating systems will provide their own functional equivalents of masterboot or bootblock. From this point on, this discussion will describe the minix boot system.
If the code on the first sector is the master bootblock (masterboot.s), the code copies itself to BUFFER and then jumps there. The user can choose which partition to boot by holding down the ALT key (see top of masterboot.s). If the user does not hold down the ALT key, the code either loads the partition specified by the fix variable (which the installboot utility patched in) or searches through the partition table to find the active partition. If an active partition is not found, the first sector of the next disk is loaded.
This code will either be another master bootblock or it will be the bootstrap (bootblock.s). The bootstrap is also loaded at LOADOFF but does not copy itself (as the master bootblock does). The bootstrap is responsible for loading the boot monitor. The bootstrap loads the boot monitor code at BOOTSEG and then jumps to BOOTSEG:BOOTOFF (in other words, it skips the header).
The remaining four files (boothead.s, boot.c, bootimage.c, and rawfs.c) make up the boot monitor. The boot monitor's main function is to load the minix operating system or another OS. (For Kees Bot's description of the boot monitor (written primarily for system administrators), read the following man page.)
As the comments at the top of boothead.s suggest, boothead.s contains startup and low level support (generally involving BIOS system calls). Immediately after the bootstrap jumps to the boot monitor, code from boothead.s is executed. This code determines the memory layout, the processor (286, 386, 486, etc.), the current video mode, and what device was booted and then finally calls boot() (which is found in boot.c). Additionally, boothead.s has functions that exit the monitor (by rebooting), determine device parameters, read and write data to the disk, and read/write characters from/to the keyboard/screen. The function that jumps to the Minix OS (and switches from real mode to protected mode if appropriate) is also found in boothead.s.
boot.c contains the high level functions in the monitor. The highest level function in boot.c is boot(). boot() calls initialize() (also in boot.c). initialize() relocates the boot monitor and removes the boot monitor from the memory map that is passed to the kernel (preventing the kernel from overwriting the boot monitor). initialize() then calls the following functions:
get_parameters() (also in boot.c) sets several environment variables and functions and gets the values of a few parameters from the bootparams sector (the second sector of an active partition). Environment variables such as "processor", "bus", and "video" are set in this function.
r_super() (found in rawfs.c) verifies that the system is a minix file system and determines the parameters of the file system.
After these two functions return, the boot monitor executes the commands that are entered by the user, most important of which is boot (which boots the system).
bootimage.c's main function is bootminix(), which is invoked by the boot monitor's boot command (see man page). bootminix() calls the following functions:
select_image() finds the desired OS image on disk.
exec_image() loads the OS image into memory.
minix() (found in boothead.s) switches to protected mode (if the kernel was compiled for protected mode) and then jumps to the kernel.
bootminix() returns when the OS returns to the boot monitor (for example, when the user issues the minix shutdown command).
rawfs.c, as the name suggests, performs a small subset of file system operations you'd find in a typical OS file system. For example, blocks can be read from disks, information about a file can be found, the contents of a directory can be read, and a pathname can be translated to an inode number. However, many common file system operations are not part of the boot monitor's file system. For example, files cannot be created (although you would probably never need to create a file from within the boot monitor).