Does BIOS read directly the bootloader or load it into RAM

biosbootcpumemory

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?

Best Answer

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.

Related Question