|
-
July 19th, 2004, 07:12 AM
#14
This is what happens when you boot your PC:
Firstly, the BIOS is executed from a chip held on your motherboard.
This is a very basic, low level program, which checks out the hardware on your PC (memory, hard drives, other standard devices etc.). It has nothing whatsoever to do with your OS and will work in exactly the same way on linux as in Windows (or anything else, come to that!).
And, no you don't want to tamper with this, except perhaps to install an upgrade from your manufacturer to support new hardware.
Each BIOS uses its own unique code, and each mother board is designed to run a particular type of BIOS.
Next, assuming your PC is working, the BIOS will find your primary hard drive.
It then looks for a special part of the hard drive which is located at the very first part of your hard drive (Cylinder 0; Head 0; Sector 1) which is known as the MBR (master boot record).
This will execute a simple sequence of instructions to start to load your OS - when I say simple we are talking about 512 bytes here - the size of memory I had when I first started programming
So, yes, you do need to program this in assembler (x86 if you are using an Intel chip), but the way Windows and linux work is that the whole of the first cylinder (usually 32Kb) is not used, so your basic 512 byte program can link to code stored in this area, as they do.
This code can be written in C/C++, but you need to be very careful, as most system calls will not work, but anyway you'll end up with some binary code, which you can write to this part of the hard drive.
So when you boot, your BIOS loads the MBR, which in turn usually executes the rest of the code you have stored in Cylinder 0, which in Windows & linux presents you with a basic menu (if you choose to enable it), and then your system completes its boot.
Needless to say, if you get your code wrong, then your PC won't boot until you replace the MBR, together with the rest of the code stored in Cylinder 0.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|