Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When the computer starts up, the code in BIOS is executed first. However, how is the code in BIOS loaded into the RAM for execution ?

I have referred to this question - Is BIOS read from the BIOS chip or copied into RAM on startup?. However, it has confused me more. If the BIOS is loaded from ROM and the ROM is a separate chip, what is the point of talking about segment addresses in RAM ? Also, where is the BIOS code loaded - is it in the last 1 MiB of real mode address space, or some other location ?

If someone could list the steps from computer start-up upto the execution of first BIOS instruction including the memory addresses used, it would be very helpful

share|improve this question

1 Answer 1

As I wrote in my answer to that question the received folk wisdom on the subject — as unfortunately exemplified by other answers there (and elsehere in SuperUser) — is stuck in the world as it was around 1991, despite the wealth of technical references available explaining how it is now otherwise.

You wouldn't have been this confused if you had read my answer, because you wouldn't be asking about "BIOS loaded from ROM" in the first place.

Your "BIOS chip" is not ROM; there is no machine code between processor startup and the first instruction in firmware; and the "M" in both "RAM" and "ROM" means "memory".

As I wrote before, in modern PCs, the machine firmware is held in non-volatile RAM. It's not ROM as it used to be. See the previous answer for details of the NVRAM chip connected to the LPC bus. (For example: On a machine sitting disassembled beside me as I type this, the NVRAM holding the firmware is a Pm49FL004T, an LPC Flash RAM chip.)

32-bit CPUs don't start up in real mode, and don't start with an address that is below the 1MiB line. That's decades out of date rubbish from the times of 16-bit x86 processors. They start in what is colloquially known as unreal mode, and again in my prior answer I gave the details of what has actually been the case since the advent of the 80386. They load their first instruction from an address that is in fact right at the top of the 32-bit address space, FFFFFFF0.

In my prior answer I told you in detail where the machine firmware is principally mapped into physical address space on 32-bit and 64-bit x86 machines. Remember: Both RAM and ROM are memory. Physical addresses are memory addresses, on the system bus. They can address either RAM or ROM. (They can even address other things as well, but that's just complicating this discussion.) The physical address FFFFFFF0 is 16 bytes below the top of the 512KiB range where the top 512KiB of the firmware, in non-volatile RAM, is always mapped on the system bus by the "chipset".

There's no "loading" from some mythical ROM chip that goes on at processor initialization or reset. The chip holding the firmware is non-volatile RAM. It retains its contents, written when it is "flashed", across power cycles. And the CPU just reads the firmware instructions and data from it, over the system bus and over an LPC bus (and possibly an LPC/FWH bridge) connected to the system bus via the chipset, using a physical memory address.

Further reading

share|improve this answer
    
Thank you, this seems much more clear to me. However, when you say non-volatile RAM and data being read from it, does it mean that the BIOS is coupled with the RAM in some way ? Does each RAM chip come with a BIOS ? I know this may seem stupid, but I'm a beginner in this topic. –  Cygnus Jan 1 at 16:41
    
When he says non-volatile random access memory (NVRAM) he is referring to a different technology than the RAM used as main system memory (Typically Dynamic Random Access Memory, DRAM). It's a separate chip from main RAM that contains the firmware even when powered off, thus the "non-volatile" part. –  Dougvj Jan 1 at 16:46
    
@Dougvj : In that case, why do we have a separate address of FFFFFFF0 for it ? Wouldn't the NVRAM size be just the size of the firmware ? –  Cygnus Jan 1 at 16:54
    
I think that your questions are better handled as actual questions, not comments on this answer. Look at some of the "Related" questions on the right, then figure out a question to ask that will further your understanding. (There's certainly room on SuperUser for some questions+answers on the very basics, it seems from a brief shufti.) –  JdeBP Jan 1 at 16:59
    
@JdeBP : I have added a new question- superuser.com/questions/695769/… –  Cygnus Jan 1 at 18:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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