Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do normal x86 or AMD PCs run startup/BIOS code directly from ROM, or do they copy it first to RAM? [closed]

I understand modern computers have modified Harvard architectures.

Can the fact that they can read instructions from somewhere other than where they hold data allow them to fetch instructions directly from ROM chips? Do they load the BIOS to RAM first, or do they execute it directly from the chip? I don't have a computer I can open nearby, so... If I remove ALL the RAM from the memory slots, will the computer be able to start the full BIOS, run the POST stuff and tell me I need RAM? It's funny I've never tried it...

EDIT: my intention with this question is to learn whether commercial CPUs (or at least intel cpus) can execute code directly from ROM. It's not for practical purposes, it's to increase my understanding of computer architectures and stuff. The removing-RAM-part is not my main doubt, just an example

like image 563
salvador p Avatar asked Mar 14 '11 15:03

salvador p


1 Answers

It both directly executes from ROM and copies stuff into RAM.

On a modern x86 processor, the chipset memory controller is uninitialized at initial power-up, so there is no RAM available.

A modern BIOS is usually divided into two parts:

  1. Boot Block (early POST)
  2. Compressed Area (mid-to-late POST)

When the processor comes out of reset, it begins executing instructions at a fixed address in memory, called the "reset vector". The BIOS flash chip is mapped to this address in memory. The processor simply starts executing instructions from this address.

The "Boot Block" refers to the BIOS code starting at the reset vector (plus a few JMPs). This is executed directly from ROM (memory controller isn't up yet), so it is very slow.

The BIOS Boot Block generally does the following:

  1. Initialize the memory controller. (If you get a "memory not detected" beep code from a motherboard, it happens here.)
  2. Perform a checksum on the Compressed Area to make sure the rest of the BIOS is free of corruption.
  3. Jump into a Recovery Mode if any corruption is detected.
  4. If the checksum passes, decompress the rest of the BIOS into RAM somewhere (typically below the 1MB boundary).
  5. Jump to the decompressed code in RAM and continue with boot.
like image 75
myron-semack Avatar answered Sep 19 '22 06:09

myron-semack