0xffff0 and the BIOS
When a pc first boots up, it starts executing at physical address 0xffff0. This address contains a j开发者_如何学Pythonmp instruction to the BIOS.
Now for my question, I always assume the physical addresses are mapped to RAM. If RAM initially contains garbage values, what exactly puts the jmp instruction in 0xffff0? Is the jmp instruction always the same or is it different for different BIOS's? Does 0xffff0 map from RAM to BIOS then (meaning it's "hard mapped")?
The top 64kB or so are mapped to BIOS ROM, not RAM.
Take a look at PC boot sequence. As Ignacio already answered, it's "hard-mapped" to BIOS read-only memory.
Check out this Intel manual:
http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-vol-3a-part-1-manual.pdf
Go to page 9-6, and subsequent pages, it all describe the initial starting up mode of the CPU. The first instruction fetched is from ffffff00 (which hardwired to the ROM BIOS):
The first instruction that is fetched and executed following a hardware reset is
located at physical address FFFFFFF0H. This address is 16 bytes below the
processor’s uppermost physical address. The EPROM containing the software-
initialization code must be located at this address.
And remembering at this stage it is still in realmode:
The CS register has two parts: the visible segment selector part and the
hidden base address part. In real-address mode, the base address is normally
formed by shifting the 16-bit segment selector value 4 bits to the left to produce a
20-bit base address. However, during a hardware reset, the segment selector in the
CS register is loaded with F000H and the base address is loaded with FFFF0000H. The
starting address is thus formed by adding the base address to the value in the EIP
register (that is, FFFF0000 + FFF0H = FFFFFFF0H).
And then look further, in figure 9-3, is the location of 64K memory - from ffffffff to ffff0000 and indicated there is EPROM, or system bios, and thus not RAM.
See figure 8.4: http://www.iakovlev.org/index.html?p=946
Actually, it's a bit more complex than that. First of all, on any processor since the 386, it actually starts at fffffff0 (i.e., 16 bytes short of the top of the 32-bit address space). Until the processor first executes a far jump instruction, it does some special mapping to make the whole 32-bit address space visible even though it's executing in real mode. After a far jump is executed, it starts "normal" real mode operation.
In any case, on the hardware side you normally have (Flash) ROM mapped to that location, so when it starts executing, it's executing code in ROM. What executes to start with isn't really BIOS though -- it's just code to decompress the real BIOS from the ROM into RAM, then re-map that RAM to the BIOS address range.
精彩评论