4

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?
  • Take a look at this first: duartes.org/gustavo/blog/post/how-computers-boot-up – slm Jun 3 '14 at 22:49
  • @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? – Pierre-Jean Jun 3 '14 at 23:14
  • Yes that's a location in RAM. The BIOS is pre-conditioned to always jump to that location after loading the contents of MBR. This is often called a bootstrap. – slm Jun 3 '14 at 23:21
  • 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 – slm Jun 3 '14 at 23:30
  • 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. – slm Jun 3 '14 at 23:33
2

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.

  • 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. – mikeserv Jun 4 '14 at 0:42
  • @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. – Gilles Jun 4 '14 at 0:53
  • No, in the world BIOS is Basic In/Out System whereas UEFI is the Unified Extensible Firmware Interface. I'm sorry but you're wrong - flat out. uefi.org/faq en.wikipedia.org/wiki/BIOS – mikeserv Jun 4 '14 at 0:58
  • "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) – MSalters Jan 23 '18 at 14:14
3

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.