13

For the BIOS, Wikipedia states:

The address of the BIOS's memory is located such that it will be executed when the computer is first started up. A jump instruction then directs the processor to start executing code in the BIOS.

I know that BIOS lives in non-volatile memory. But it would have to be loaded into the RAM for it to be executed. So who loads the BIOS into RAM ?

I have also read that a memory map is loaded at start-up. Does the BIOS load this memory map ? Where is is stored ?

5
  • 5
    You can very much run a BIOS from ROM.
    – nos
    Commented Dec 31, 2013 at 17:35
  • 1
    This question is off topic here. Use superuser.com in the future, this question is already covered. Commented Dec 31, 2013 at 19:29
  • The memory map is hard coded into the hardware AFAIK. There isn't a 'memory map' to load.
    – tangrs
    Commented Jan 1, 2014 at 3:07
  • 1
    I think this other topic answers your question. stackoverflow.com/questions/5300527/… Commented Jan 6, 2014 at 14:58
  • 3
    @tangrs the memory map is definitely not always hard-coded - if it was, how would it support changing the amount of RAM? Commented Jan 8, 2014 at 9:53

1 Answer 1

20

At initial power on, the BIOS is executed directly from ROM. The ROM chip is mapped to a fixed location in the processor's memory space (this is typically a feature of the chipset). When the x86 processor comes out of reset, it immediately begins executing from 0xFFFFFFF0.

However, executing directly from ROM is quite slow, so usually one of the first things the BIOS does is to copy and decompress the BIOS code into RAM, and it executes from there. Of course, the memory controller must be initialized first! The BIOS takes care of that beforehand.

The memory map layout will vary from system to system. At power-on, the BIOS will query the attached PCI/PCIe devices, determine what resources are needed, and place them in the memory map at the optimal location. If everything is working properly, memory-mapped devices should not overlap with RAM. (Note that on a 64-bit system with >3GB of RAM, things get complicated because you need a "hole" in the middle of RAM for your 32-bit PCI/PCIe devices. Some early x64 BIOSes and chipsets had issues with this.)

11
  • 2
    @Sled: No, physical address space includes DRAM but also PCIe and other device memory. Physical addresses that don't refer to DRAM are routed to the "system agent" on the ring bus, instead of one of the memory controllers. The system agent has off-chip connections to the chipset (and some other dedicated PCIe lanes that are usually wired up to a PCIe x16 slot for a graphics card.) X86 Address Space Controller? Commented Oct 28, 2021 at 3:40
  • 1
    @MehdiCharife: How does a modern x86 CPU access the BIOS ROM has a sort of answer. In terms of X86 Address Space Controller?, think of ROM as just another device the CPU can access via a range of physical addresses. The motherboard designers set things up so the ROM responds to those addresses. Commented Nov 9, 2022 at 9:21
  • 1
    @MehdiCharife: The CPU doesn't find out from the motherboard where the ROM is, it's hard-wired to fetch code from physical address 0xFFFFFFF0 at bootup. It's up to the motherboard designer to build a system that has useful machine code at that physical address, normally by wiring up a flash ROM. Commented Nov 9, 2022 at 9:24
  • 1
    @MehdiCharife: Re: who said what: maybe you're looking at someone else's comments or answer. Before you replied, the only text of mine on this page was the 2nd comment. If I search-within-page in my web browser, the phrase "memory space" appears in the answer and the comment above mine, but not in my comment. I can't help it if other people use weird and confusing terminology, but I intentionally didn't repeat it. (OTOH I didn't think it was bad enough to explicitly call out and correct.) Commented Nov 9, 2022 at 9:26
  • 1
    @MehdiCharife: One or the other of those, yes; either microcode sets the initial CS:EIP, or they're just built to default to that value at power-up. Depends on the CPU design, both sound valid. Also related re: motherboards having ROM at that address, Software initialization code at 0xFFFFFFF0H / Is address 0xFFFFFFF0 hardwired for system BIOS ROM? Or better, How is the BIOS ROM mapped into address space on PC? Commented Nov 9, 2022 at 9:31

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