Does the BIOS copy the 512-byte bootloader to 0x7c00
Asked Answered
L

2

10

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! :)

Laocoon answered 24/8, 2015 at 5:9 Comment(1)
The boot sector loader is the code in the BIOS(after a power on/reset) that reads the boot sector (first 512 bytes) from the disk and will copy it to 0000:7c00 . Once the boot sector is loaded the BIOS will jmp to 0000:7c00 where the boot sector code will begin executing.Kilimanjaro
S
13

... 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.

Sferics answered 24/8, 2015 at 5:20 Comment(1)
thanks a lot! It's a little confusing as compared to Java and C++.Laocoon
W
6

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.

Weese answered 3/1, 2021 at 12:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.