xorl %eax, %eax

Booting the PC

leave a comment »

This is a retarded little post that demonstrates the beauty of the simplest operation that people do on their computers. Just press the “power on” :P What’s happening when you’re doing this? Let’s break it into steps to make it more structured.

Step 1: Pressing the Power On button

Yeah, this is the simple part. This button is a common switch which is connected to the motherboard through two wires. The switch is open and when pressed it closes a circuit. The circuit is closed as long as the switch is pressed down. The two cables attached to the motherboard are indirectly (through the motherboard) connected to the power supply unit (PSU). For this reason we’re going to move to the next step.

Step 2: The motherboard (well.. the PSU)

If you have a look at your ATX power supply unit’s 24-pin connector you’ll see that there is only one green cable. This is the power-on cable. The switch discussed on step one is connected to this cable as well as a black (black PSU cables are ground) cable. When pressed, the circuit is closed and the power-on cable is now connected to the ground (black cable). This makes the PSU boot, PSU has some hardware based simple controls (self tests) that can ensure the voltage is sufficient before providing power to its connectors. If everything went as expected, then the PSU sends a signal known as Power_Good, practically this is a +5V signal which orders the CPU to execute whatever it has at address FFFF:0000. This process takes from 0.1 to 0.5 seconds and if the PSU does not send this signal the CPU will be restarting the computer until it receives one.

Step 3: The motherboard

The motherboard catches the Power_Good and starts executing whatever it founds at FFFF:0000. Almost certainly, this is where a ROM/EPROM/FLASH-ROM known as BIOS (Basic Input/Output System) is located. If nothing strange happened during this simple operations on the processor, the motherboard and the BIOS then motherboard’s job is almost done.

Step 3: POST

When processor attempts to execute BIOS’ code it runs the well known POST (Power-On Self Test). This code performs some simple tasks including: to verify BIOS code, make sure that everything can be powered on, test memory for possible corruption, check the motherboard’s embedded chips-controllers for devices like keyboard, mouse, disc controllers and various connection ports such as serial, parallel, USB etc. Most modern POST perform numerous additional tasks and can be configured easily using the so-called CMOS (Complementary Metal Oxide Semiconductor) setup utility. This utility uses a CMOS memory to store your settings. In order to have settings on this static RAM you have to provide to it continuously power, this is why a standard CR2032 lithium cell battery is attached on most motherboards. It’s there to keep CMOS active and rescue your settings. Assuming that everything went fine, then…

Step 4: BIOS

The POST has completed with no errors and it transfers the execution back to BIOS. Now the BIOS checks its boot sequence of devices and tries to access the first 512 bytes of the first device in the boot sequence. If it fails, it moves to the next one in the boot sequence, 512 bytes is one sector, if BIOS is able to read these data, it stores them to the memory and starts executing whatever this sector has (which is always LBA Sector 0). This is known as the Boot Sector (also known as MBR – Master Boot Record).

Step 5: Boot Loader

This is where the first stage boot loader is located. In most cases, this loader just calls the second stage boot loader which is located theoretically anywhere you want. The first stage boot loader MUST be 512 bytes maximum and it interacts with BIOS to display data on the screen using interrupt 0x10 as well as 0x0E which is known as teletype mode etc. Boot loader checks its partition table and attempts to transfer the code execution to the requested one. If this succeeds then boot loader’s task is finished.

Step 6: Operating System

This is of course out of the scope of this post but generally, the operating system once booted by the boot loader will start loading its kernel and device drivers, next it will load system applications and services and finally user applications. Then.. just login and enjoy your successful boot!

Written by xorl

January 12, 2009 at 15:22

Posted in fun, Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s