Does BIOS read directly the bootloader or load it into RAM?

8,122

Solution 1

The CPU read the BIOS […]

That's a somewhat simplified view, but the basic idea is right. Typical initialization code actually consists of several successive pieces.

The Bios will then read the MBR to load the primary boot loader

That's a legacy BIOS. Modern PC BIOS has a standardized bootloader interface: UEFI. Non-PC platforms don't call their manufacturer-provided bootloader “BIOS”.

When the BIOS read and load the primary boot loader in memory, are we talking the RAM memory?

Yes. There is no other memory that can be written to (under normal operation).

Can the CPU address directly (read instructions) from the HDD without loading the content into RAM (we disregard performance issue here)?

No. No architecture that I know of has a magnetic storage that's addressable by the CPU. It always takes some code in the operating system to access the hard disk.

Same question for the BIOS: is it read directly or loaded in RAM before execution?

That would depend on the hardware. Some code in ROM or flash memory can be executed directly from ROM. Usually, apart from some initial bootloader code executed from ROM (or EEPROM on PC hardware I think), the code would be copied into RAM first, because RAM is faster.

Solution 2

Thanks to @slm, I found most of the answer.

When the BIOS read and load the primary boot loader in memory, are we talking the RAM memory?

Yes, we do. The BIOS load the bootloader code on a specific address (0x7c00), and then jump to this address to executes the instructions.

Can the CPU address directly (read instructions) from the HDD without loading the content into RAM (we disregard performance issue here)?

I don't think the CPU can execute an instruction that is not in the memory address space, but please correct me if I'm wrong (Can I execute an instruction from the I/O address space?).

Same question for the BIOS: is it read directly or loaded in RAM before execution?

The BIOS is read directly: some address zone from the memory address space redirect directly to the ROM memory.

Source: http://duartes.org/gustavo/blog/post/how-computers-boot-up/

References

Share:
8,122

Related videos on Youtube

Pierre-Jean
Author by

Pierre-Jean

Software engineer, passionate about open source, free culture, hacking and DIY.

Updated on September 18, 2022

Comments

  • Pierre-Jean
    Pierre-Jean over 1 year

    I'm trying to understand the very first steps of the boot process.

    1. The CPU read the BIOS

      • It reads a fixed address instruction
      • It will jump to the first BIOS instructions address
      • It will execute the code
      • It will do the "Power-On Selt Test", check devices and find first bootable device
    2. The Bios will then read the MBR to load the primary boot loader

    3. The primary boot loader will execute the loader's second stage (ex: Grub)
    4. The loader's second stage will load the Kernel in memory

    My question are:

    • When the BIOS read and load the primary boot loader in memory, are we talking the RAM memory?
    • Can the CPU address directly (read instructions) from the HDD without loading the content into RAM (we disregard performance issue here)?
    • Same question for the BIOS: is it read directly or loaded in RAM before execution?
    • Admin
      Admin almost 10 years
    • Admin
      Admin almost 10 years
      @slm, thank you, the article is really good. But when it says: "it simply loads the contents of the MBR into memory location 0x7c00 and jumps to that location to start executing whatever code is in the MBR." Is this address 0x7c00 match a RAM location? Or something else?
    • Admin
      Admin almost 10 years
      The other thing of consequence is the use of the hex value 55AA as a signature to denote the end of the block of the MBR code. It's discussed here: bydavy.com/2012/01/lets-decrypt-a-master-boot-record
    • Admin
      Admin almost 10 years
      Much of the underlying technology that makes up a PC + BIOS was designed in the 1980's and so much of this behavior is extremely archaic. There are lots of these special addresses and little hex values that you'll know about if you've ever written your own bootable OS. I did this in college many years ago and still vividly remember all this useless info.
    • Admin
      Admin almost 10 years
  • mikeserv
    mikeserv almost 10 years
    modern pc BIOS is not UEFI - modern pc UEFI is UEFI. I downvoted this because that is a misleading answer to n already too seldom understood question. If you can fix it, I'll reverse it.
  • Gilles 'SO- stop being evil'
    Gilles 'SO- stop being evil' almost 10 years
    @mikeserv Maybe in your world “BIOS” means “legacy BIOS”, but in the world of people who design UEFI BIOSes, “UEFI BIOS” is perfectly normal terminology. This isn't a matter of understanding, it's a matter of terminology, and I'll stick with the professionals' terminology over your personal preferences.
  • MSalters
    MSalters over 6 years
    "Some code in ROM or flash memory can be executed directly" - true, that's in fact very common. The BIOS itself (and UEFI) is nowadays stored in such flash, for direct execution. This used to be stored in ROM, and later EEPROM (an early variant of flash, but more expensive)