Comprehensive Understanding of the Computer Boot Process
First, let's understand some basic concepts. The first one is the very familiar BIOS (Basic Input/Output System). BIOS is the bottom-layer code that directly interacts with hardware, and it provides the basic functions for the operating system to control hardware devices. BIOS includes system BIOS (commonly known as the motherboard BIOS), graphics card BIOS, and BIOS of other devices (such as IDE controllers, SCSI cards, or network cards, etc.). Among them, system BIOS is the protagonist of this discussion because the computer boot process is carried out under its control. BIOS is generally stored in ROM (read-only storage chips), and even when the computer is powered off or loses power, these codes will not disappear.
The second basic concept is the memory address. Our machine generally has 32MB, 64MB, or 128MB of memory installed. Each byte of this memory is assigned an address for the CPU to access the memory. The address range of 32MB in hexadecimal is 0 - 1FFFFFFH. Among them, the low-end 1MB memory from 0 - FFFFFH is very special because the initial 8086 processor can only access a maximum of 1MB of memory. The low-end 640KB of this 1MB is called base memory, while A0000H - BFFFFH is reserved for the video memory of the graphics card, and C0000H - FFFFFH is reserved for BIOS. Among them, system BIOS generally occupies the last 64KB or a little more space, graphics card BIOS is generally at C0000H - C7FFFH, and IDE controller BIOS is at C8000H - CBFFFH.
Step 1: When we press the power switch, the power supply starts to supply power to the motherboard and other devices. At this time, the voltage is not very stable. The control chipset on the motherboard will send and maintain a RESET signal to the CPU, so that the CPU internal automatically restores to the initial state, but the CPU will not execute instructions immediately at this moment. When the chipset detects that the power supply has started to supply power stably (of course, the process from unstable to stable is just a moment), it will remove the RESET signal (if it is restarting the machine by manually pressing the Reset button on the computer panel, then when the button is released, the chipset will remove the RESET signal). The CPU immediately starts to execute instructions from address FFFF0H. From the previous introduction, this address is actually within the address range of system BIOS. Whether it is Award BIOS or AMI BIOS, only a jump instruction is placed here, jumping to the real boot code in system BIOS.
Step 2: The boot code of system BIOS first needs to do POST (Power-On Self Test). The main task of POST is to detect whether some key devices in the system exist and can work normally, such as memory and graphics card, etc. Since POST is the earliest detection process, at this time the graphics card has not been initialized. If system BIOS finds some fatal errors during the POST process, such as not finding memory or having problems with memory (at this time, only 640K conventional memory is checked), then system BIOS will directly control the speaker to make a sound to report the error. The length and number of sounds represent the type of error. Under normal circumstances, the POST process is very fast, and we can hardly feel its existence. After POST ends, other codes will be called to perform more complete hardware detection.
Step 3: Next, system BIOS will look for the BIOS of the graphics card. As mentioned earlier, the starting address of the ROM chip storing graphics card BIOS is usually set at C0000H. After system BIOS finds the graphics card BIOS here, it will call its initialization code, and the graphics card BIOS will initialize the graphics card. At this time, most graphics cards will display some initialization information on the screen, introducing the manufacturer, graphics chip type, etc., but this screen almost flashes by. System BIOS then will look for the BIOS programs of other devices. After finding them, it will also call the initialization codes inside these BIOS to initialize the relevant devices.
Step 4: After finding the BIOS of all other devices, system BIOS will display its own boot screen, which includes the type, serial number, and version number of system BIOS, etc.
Step 5: Then system BIOS will detect and display the type and working frequency of the CPU, and then start testing all RAM and at the same time display the progress of memory testing on the screen. We can decide in the CMOS settings to use a simple and time-consuming test or a detailed and time-consuming test method.
Step 6: After the memory test passes, system BIOS will start to detect some standard hardware devices installed in the system, including hard disks, CD-ROMs, serial ports, parallel ports, floppy drives, etc. In addition, most relatively new versions of system BIOS will also automatically detect and set memory timing parameters, hard disk parameters, and access modes, etc., in this process.
Step 7: After the detection of standard devices is completed, the code in system BIOS that supports plug and play will start to detect and configure the plug and play devices installed in the system. After each device is found, system BIOS will display the name and model of the device on the screen, and at the same time allocate interrupts, DMA channels, and I/O ports, etc., for this device.
Step 8: Up to this step, all hardware has been detected and configured. Most system BIOS will clear the screen again and display a table at the top of the screen, which roughly lists various standard hardware devices installed in the system, as well as the resources they use and some relevant working parameters.
Step 9: Next, system BIOS will update ESCD (Extended System Configuration Data). ESCD is a means for system BIOS to exchange hardware configuration information with the operating system. These data are stored in CMOS (a small piece of special RAM powered by the battery on the motherboard). Usually, ESCD data are only updated when the system hardware configuration changes. So we cannot see the information like "Update ESCD... Success" every time we start the machine. However, the system BIOS of some motherboards uses a different data format from Windows 9x when saving ESCD data. Then Windows 9x will modify the ESCD data into its own format during its own boot process. But when starting the machine next time, even if the hardware configuration has not changed, system BIOS will change the ESCD data format back. In this way, a cycle will occur, which will lead to system BIOS updating ESCD every time the machine is started. This is the reason why some machines display relevant information every time they are started.
Step 10: After ESCD is updated, the boot code of system BIOS will carry out its last task, that is, boot from a floppy disk, hard disk, or CD-ROM according to the boot sequence specified by the user. Taking booting from the C drive as an example, system BIOS will read and execute the master boot record on the hard disk. The master boot record then finds the first active partition from the partition table, and then reads and executes the partition boot record of this active partition. The partition boot record will be responsible for reading and executing IO.SYS, which is the most basic system file of DOS and Windows 9x. IO.SYS of Windows 9x first needs to initialize some important system data, and then display the familiar blue sky and white clouds. Under this screen, Windows will continue to carry out the boot and initialization work of the DOS part and the GUI (Graphical User Interface) part.
If there is a tool software that can boot multiple operating systems installed in the system, usually the master boot record will be replaced with the boot code of this software. These codes will allow the user to select an operating system, and then read and execute the basic boot code of this operating system (the basic boot code of DOS and Windows is the partition boot record).
The above introduction is the various initialization work that the computer needs to complete when turning on the power switch (or pressing the Reset key) for cold boot. If we press the Ctrl + Alt + Del combination key under DOS (or select to restart the computer from Windows) to perform hot boot, then the POST process will be skipped, and it will start directly from step 3. In addition, the detection of the CPU and the memory test in step 5 will not be carried out again. We can see that whether it is cold boot or hot boot, system BIOS repeatedly carries out these things that we usually don't pay much attention to. However, it is these monotonous hardware detection steps that provide the basis for us to use the computer normally.