Wednesday, July 07, 2004

Booting an Operating System

This is my first technical article that i am writing. Hope to share some information that i have obtained over time and make things clearer to the interested people. Most of the information here is specific to the PC with intel x86 architecture(286, 386, 486, Pentium Series, AMD).

The Operating System is the main component of any computer. It is the layer of software that handles requests for resources between processes that are running on the system, resources including the processor, memory, access to devices like printers, monitor(s), storage devices, network etc.
Normally, we just press on a switch and wait till the desktop / a login prompt or the command line to appear. We dont bother to know(maybe we dont need to know) what happens during the time we wait looking at progress bars going from the left end to right end (progress bar syndrome ;)

All computers have a BIOS (Basic Input Output System). This is a piece of hardware that gets control of the computer the moment it is powered on. The BIOS has instructions that are executed by the processor. This process detects the hardware attached with some details of the same.( One can see these details in the second screen that is shown when a PC is booting). You may ask, what ensures that the BIOS instructions are executed in order from instruction 1 onwards. Actually, x86 processors perform a hardware reset and initialise a set of registers to predefined values immediately on power on. These ensure that the control is transferred to the BIOS correctly.

The BIOS has in it 2 vectors, one that identified the list of devices that can be booted from (this is updated dynamically) and another that lists the priorities within these identified devices.(These are stored in a non volatile RAM area. You can set the priorities when u choose the boot sequence by pressing F2 key on booting.)The BIOS then cycles through the devices specified in the order of descending prority repeatedly trying to see if Bootable Code (the operating system code) is there. The BIOS reads 512 bytes from the boot sector and then examines the last two bytes(octets). If it is not 0xAA55, it identifies that the code is NOT bootable. If none of the devices have any code, it will signal an error and hang.

The boot sector code will be moved into the memory at address 0X7c00. Now it is the users code that is having control of the computer. Normally this code cant do much in just 512 bytes. This code generally loads and transfers control to another piece of code that does the loads the actual operating system.
If you want to write your own "Hello World" Operating system or know more on Boot process, u can visit these links :
NonDot.org-Includes sample code and specifications.
Getting started with OS development
Boot process


As far as I'm concerned, if something is so complicated that you can't explain it in 10 seconds, then it's probably not worth knowing anyway. - The Indispensable Calvin and Hobbes p25

3 comments:

Sundar said...

A very informative post for laypersons like me. If you can rewrite this in third person, may be, you can post it in Wikipedia-- Sundar

Epiphany said...

I completely agree wid CALVIN as alwayz

Smart-Alecky said...

VOILLA!
Another free E-book on OS.
Anthro...
tussi gr8 ho pappaji
;)