14

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

salvador p
  • 2,905
  • 5
  • 26
  • 26

2 Answers2

17

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.
myron-semack
  • 6,259
  • 1
  • 26
  • 38
  • 1
    Do modern CPUs try to execute code directly from the normal system memory bus, or do they have some "special" connection to the BIOS chip? I would think that it would be simpler to have a special low-speed (perhaps even one-bit serial) boot-flash connection than to try to put a flash device on the main bus. There's certainly no reason for the flash to be 64 bits wide, and having it sit on just part of the data bus would add unbalanced capacitive loading for no good reason. – supercat May 08 '12 at 15:47
  • The BIOS chip is usually connected to the Southbridge of chipset. The physical interface between the BIOS flash and the chipset is usually a relatively low bandwidth bus. For many years, it was the LPC or FWH bus (8 data bits, 33MHz). Intel has recently begun using SPI for the BIOS interface on their newer chipsets. (http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus) – myron-semack May 10 '12 at 12:59
  • 2
    Keep in mind that the PHYSICAL connection is (somewhat) independent from its LOGICAL mapping into the processor's address space. The chipset contains logic to map the flash chip into the processor's address space at the reset vector. – myron-semack May 10 '12 at 13:04
  • So without RAM, you can't change the BIOS config, because the part that captures the keyboard input isn't decompressed? – jiggunjer Oct 03 '16 at 04:00
  • @jiggunjer BIOS setup is a program that runs in memory, just like your OS boot loader. Without RAM, there is nowhere for it to run. – myron-semack Oct 03 '16 at 11:00
  • But in theory it could just run from the ROM, like the Boot Block, the designers just made it so it loads into RAM to save memory and speed things up? – jiggunjer Oct 03 '16 at 11:15
  • 1
    @jiggunjer In theory, yes. You still need SOME RAM for temporary variables. However there is a mechanism called Cache as RAM (CAR) that could be used. However, converting the existing BIOS code to do this would be a big deal, and would not be terribly useful as most systems are useless without RAM anyway. – myron-semack Oct 03 '16 at 12:34
  • I'm under the impression that RAM would only be available for use after POST. So how is the Boot Block able to decompress any data into RAM? – wmjdgla Aug 10 '20 at 14:56
  • @wmjdgla RAM becomes available during POST. One of the earliest steps is to initialize the memory controller. – myron-semack Aug 11 '20 at 15:25
  • Ah I see, so that means the BIOS Boot Block performs POST, during which it initializes the memory controller? – wmjdgla Aug 29 '20 at 10:13
  • POST is the entire boot process. Not just one step. Keep in mind the “test” part of POST is basically nonexistent. Tests are time consuming and people like computers to boot quickly. – myron-semack Aug 30 '20 at 18:33
0

If you remove the RAM completely the PC should start to beep incessantly when you turn it on.

Here is a good description of what happens: http://www.pcguide.com/ref/mbsys/bios/boot.htm

There's also Hans-Peter Messmer's 'The Indespensible PC Hardware Book' that describes the process too.

James
  • 9,064
  • 3
  • 31
  • 49