Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does the BIOS copy the 512-byte bootloader to 0x7c00

I am amidst writing a kernel; before writing such a complicated thing, I thought it'd, not only, be helpful but also imperitive to do some theoretical reading of kernels, bootloaders, registers, BIOS, etc.

This article says (and I quote):

The boot sector loader. 
This loads the first 512-byte sector from the boot disk into RAM and jumps to it.

Then it goes on to say:

The first sector of a diskette can be loaded at address 0000:7C00. 

So, the boot-sector loader loads the 512 bytes of the data of a diskette which resides at the memory address 0x7C00 (if I am right) into the RAM; now, my questions are:

  • Since the machine is booting up, the RAM has to be empty, so the bootloader it loaded at 0x0000 of the RAM?
  • (Not really related to this context) Is there any way of getting a source code explanation for the GRUB Legacy (v .9x) bootloader?
  • Lastly, any articles/books I should read to get myself familiar with Kernels, etc?

I have 6 years of programming experience, but they are all with high-level languages on systems which is made possible by a kernel.

Any help is appreciated. Thanks! :)

like image 584
weirdpanda Avatar asked Aug 24 '15 05:08

weirdpanda


Video Answer


2 Answers

... the boot-sector loader loads the 512 bytes of the data of a diskette which resides at the memory address 0x7C00 (if I am right) into the RAM

...

Since the machine is booting up, the RAM has to be empty, so the bootloader it loaded at 0x0000 of the RAM?

No. 0000:7C00 refers to a RAM address. RAM means "Random Access Memory", means each location in the memory can be accessed directly. There is nothing like "empty RAM". You can also refer to the INT13 interrupt function "Read Sectors From Drive": one of the parameters (passed in ES:BX) needs to point to the destination address where the sector contents will be stored. Hence, what the BIOS does is it loads 512 bytes from the drive and stores it into 0000:7C00 to 0000:7DFF, and then jumps to 0000:7C00 to execute the primary boot loader code.

Any articles/books I should read to get myself familiar with Kernels, etc?

This Wiki is very useful: http://wiki.osdev.org/Main_Page. For the boot process, look at http://wiki.osdev.org/Boot_Sequence.

like image 62
Andreas Fester Avatar answered Nov 08 '22 07:11

Andreas Fester


Since the machine is booting up, the RAM has to be empty, so the bootloader it loaded at 0x0000 of the RAM?

Even if it is the start, RAM will be not empty. Therefore it will not able to use 0x00000. Because before O/S execute BIOS also create interrupt table in RAM. (That's why you can press f2, f10 or delete etc. key and go to BIOS setting. If there is no interrupt handler you will not able to do that.). That's why RAM is not empty.

like image 30
Kasun Avatar answered Nov 08 '22 09:11

Kasun