BIOS ROM如何映射到PC的地址空间? [英] How is the BIOS ROM mapped into address space on PC?

查看:279
本文介绍了BIOS ROM如何映射到PC的地址空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

x86 CPU从物理地址0xFFFFFFF0开始执行。 BIOS ROM位于地址空间的末尾。 CPU从ROM执行的第一条指令跳远了,这导致CS段被重新加载,因此下一条指令从物理区域0x000F0000-0x000FFFFF内执行。

The x86 CPU begins execution at physical address 0xFFFFFFF0. There at the end of the address space the BIOS ROM is located. The first instruction the CPU executes from the ROM is far jump which causes the CS segment to be reloaded so the next instruction is executed from within the physical region 0x000F0000 - 0x000FFFFF.

是什么导致ROM在两个区域上都响应? PC上是否有一些特殊的地址解码逻辑?我在Bochs源代码中发现注释,该注释指出BIOS ROM的最后128K映射到0xE0000-0xFFFFF。但是,我找不到有关此的更多信息。显然,这是特定于PC的东西,因为我具有x86嵌入式板,并且这种镜像不会在其中发生。我只能使用近跳。

What causes the ROM to respond on both regions? Is there some special address decoding logic on PC? I found comment in Bochs source code that states that last 128K of BIOS ROM is mapped to 0xE0000 - 0xFFFFF. However I cannot find more info about this. Clearly this is something PC specific since I have x86 embedded board and such mirroring does not happen there. I can only use near jump.

推荐答案

在PC上总是涉及一些地址解码逻辑,因为其中有一些漏洞/物理地址空间中的 Windows窗口,通过该窗口可以访问BIOS ROM和I / O设备(例如视频卡)而不是RAM。出于兼容性原因,这是设计使然,因此较旧的程序仍可以在较新的计算机上运行。

On the PC there's always some address decoding logic involved because there are a few "holes/windows" in the physical address space through which the BIOS ROM and I/O devices (e.g. video card) are accessible instead of the RAM. That's by design, for compatibility reasons, so older programs can still run on newer computers.

对于复位后CPU开始执行的初始地址,如果您查看文档,您将看到奔腾级CPU以此开头:

EIP = 0xFFF0

CS.Selector = 0xF000

CS.Base = 0xFFFF0000

As for the initial address at which the CPU starts execution after a reset, if you look at the documentation, you will see that Pentium-class CPUs start with this:
EIP=0xFFF0
CS.Selector=0xF000
CS.Base=0xFFFF0000

如果遵循普通的实模式寻址方案,则物理地址应为CS.Selector * 16 + IP,或替换为0xFFFF0。但是,CPU实际上使用CS.Base +(E)IP计算地址(在实模式和16/32位保护模式下,但不在虚拟8086或64位保护模式下),因此CPU请求的第一个地址从内存将是0xFFFFFFF0。您无法使用远跳转来在该高地址的ROM中进行编码可能是由于以下事实:加载到CS中会将CS.Base重置为16 * CS.Selector的新值。因此,跳转到0xF000:0xFFF0会将控制权转移到0xFFFF0而不是0xFFFFFFF0,除非ROM也映射到内存中的那个低位,并且其中的代码适合以CS(.Selector)= 0xF000运行,

If you follow the normal real-mode addressing scheme, the physical address should be CS.Selector*16+IP, or, with the values substituted, 0xFFFF0. However, the CPU actually calculates the address using CS.Base+(E)IP (in the real and 16/32-bit protected mode, but not in virtual 8086 or 64-bit protected mode), hence the first address that the CPU requests from the memory is going to be 0xFFFFFFF0. Your inability to use far jumps to code within the ROM at that high address may be due to the fact that loading into CS will reset CS.Base to 16 * the new value of CS.Selector. So, jumping to, say, 0xF000:0xFFF0 will transfer control to 0xFFFF0 instead of 0xFFFFFFF0 and unless the ROM is also mapped at that low location in the memory and the code in it is suited for running with CS(.Selector)=0xF000, it's not going to run.

此外,如果PC被限制在32位(或更多)地址线上,则CPU及其周围的电路都不必支持全部32条(或更多)地址线。最多16MB(如在i80286和i80386SX上)或4GB(如在i80386DX /原始i80386和i80486上)或2 40-52 字节(在具有64位功能的奔腾级CPU上)和如果是这样,如果忽略了物理地址空间中的许多高位,则可以说执行有效地从低于理论最大值(例如16)的地址开始。 0x00FFFFF0(i80286 / i80386SX)。

Also, neither the CPU nor the circuitry around it has to support all 32 (or more) address lines if the PC is limited to have at most 16MB (as it was on i80286 and i80386SX) or 4GB (as it was on i80386DX/original i80386 and i80486) or 240-52 bytes (on 64-bit capable Pentium-class CPUs) and if that's the case, if a number of high bits in the physical address space are ignored, execution can be said to effectively start at an address lower than the theoretical maximum - 16, e.g. 0x00FFFFF0 (i80286/i80386SX).

如果您需要解决电路板的问题,请参阅其文档和原理图,以了解如何将ROM映射到物理地址空间中

If you need to resolve problems with your board, see its documentation and schematics to find out how the ROM is mapped into the physical address space on it.

这篇关于BIOS ROM如何映射到PC的地址空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆