在386+处理器中重置向量 [英] Reset vector in 386+ processors

查看:115
本文介绍了在386+处理器中重置向量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

重置矢量的维基百科页面上说(对于386+处理器):

The wikipedia page for Reset vector says (for 386+ processors):

复位时CS寄存器的选择器部分的值为F000h,CS寄存器基部的值为FFFF0000h,复位时IP寄存器的值为FFF0h形成分段地址FFFFF000h:FFF0h在实模式下.

The value of the selector portion of the CS register at reset is F000h, the value of the base portion of the CS register is FFFF0000h, and the value of the IP register at reset is FFF0h to form the segmented address FFFFF000h:FFF0h in real mode.

我在计算机启动时的所有读物都表示处理器以实模式启动,因此不应出现选择器".那为什么在这里提?另外,这里所说的基本部分"是什么,它存储在哪个寄存器中?基本上,我不了解386处理器与以前的处理器之间的复位向量设置有何不同.

All my reading on computer boot up has said that the processor starts in real mode, and hence "selectors" should not come into picture. Then why the mention here ? Also, what is the "base portion" being referred to here, and in which register is it stored ? Basically, I don't understand how the reset vector is set differently for 386 processors versus the previous ones.

推荐答案

是的,加电后,所有x86 CPU均处于实模式,但是具有 奇怪的行为 ,直到找到CS任务!!!

Yes, after power-up, all x86 CPUs are in Real Mode but with a strange behaviour until a CS assignment is found!!!.

在阅读了一些x86文档后,便发现了以下事实:

Being finished reading some x86 documentation, these are the facts:

上电后,"CS寄存器","CS缓存寄存器"和"EIP"的初始值为:

After power-up, 'CS register', 'CS cache register' and 'EIP' initial values are:

CS = F000h(应始终为16位宽!)

CS= F000h (16 bits wide as it should always be!)

CS_segment_start_address = FFFF_0000h (32位值,指向RAM中的某个位置?). CS_segment_lenght = 0_FFFFh(20位大小的值,是的,这是64KB).

CS_segment_start_address= FFFF_0000h (a 32 bits value, pointing somewhere in RAM?). CS_segment_lenght= 0_FFFFh (a 20 bits size value, yes, this is 64KB).

CS_segment在内存中为存在".

CS_segment is 'Present' in memory.

CS_segment是一个读/写"块.

CS_segment is a 'Read/Write' chunk.

CS_segment已被访问".

CS_segment has been 'Accesed'.

EIP = 0000_FFF0h

现在,请注意以下生活事实.

Now, take note of the following fact of life.

== SOF ==(事实开始)

在获取新指令时(采用任何模式:真实,受保护等), 硬件寻址逻辑 似乎总是在使用某些"CS缓存寄存器"值以找出要在地址总线引脚上放置的地址.具体来说:

When fetching a new instruction (being in whatever mode: real, protected, etc) it seems that the hardware addressing logic is always using some 'CS cache register' values to figure out what address to place on the Address Bus pins. Specifically:

Next_Instruction_Address_on_Bus = CS_segment_start_address + EIP

Next_Instruction_Address_on_Bus= CS_segment_start_address + EIP

== EOF ==(事实结束)

所以,加电后,我们有以下数字:

So, after power-up we have these numbers:

Next_Instruction_Address_on_Bus = FFFF_0000h + 0000_FFF0h = FFFF_FFF0h

Next_Instruction_Address_on_Bus= FFFF_0000h + 0000_FFF0h= FFFF_FFF0h

这意味着,加电后我们是否可以访问RAM的最后一角,而远离1MB的限制?是的!!!.哎呀!!

This means, do we have access to the last corner of RAM after power-up, far away from the 1MB limit? Yes!!!. Holy grial!!!.

但是,等等,不要奔跑和跳跃!!!这仅是为了(由软件开发人员)对某些代码块进行远距离跳转",希望将其放置在BIOS ROM区域中!.

But wait, don't run and jump yet!!! This is just intended to place (by the software developer) a 'far jump' to some code chunk which it will be located in the BIOS ROM area hopefully!.

但是,由 主板 来确保复位向量(0xFFFFFFF0h)上的指令是对存储位置的远跳映射到系统BIOS入口点(0x0000:0x000F0000h).总而言之,每个主板"都实现了这种跳跃黑客". [感谢Gustavo Duarte的解释.检查他的智能博客: http://duartes.org/gustavo/blog/post/how-computers-boot-up/]

However, it is the motherboard who ensures that the instruction at the reset vector (0xFFFFFFF0h) is a far jump to the memory location mapped to the system BIOS entry point (0x0000: 0x000F0000h). In summary, every 'motherboard' has implemented this 'jump hack'. [Thanx Gustavo Duarte for this explanation. Check his smart blog: http://duartes.org/gustavo/blog/post/how-computers-boot-up/]

按照上面的解释,最后提到的远跳"是它将用行为良好的实模式"值更新"CS_segment_start_address"的内容:

Following the explanation from above, that last 'far jump' mentioned is what it will update the 'CS_segment_start_address' with a well behaved 'Real Mode' value:

将CS = XYWZ h之类的任务(完成远距",远距"或其他操作)转换为:

An assignment like CS= XYWZh (done with a far 'jump', far 'call' or any other) is translated to:

CS_segment_star_address = 000 X_YZW 0h(其中​​ XYZW 是CS半字节值)

CS_segment_star_address= 000X_YZW0h (where XYZW are the CS nibbles values)

再次像往常一样恢复业务,左移4位,限制为1MB,段长度为cr..p !!!

Back again in bussiness as usual with the 4 bits left-shift, 1MB limit, 64KB segments length cr..p!!!

最后几句话,我想这是为了确保您的加电(引导?)代码始终位于RAM的最后一角.这样一来,它将为未来的操作系统留出大量RAM. [老实说,对我来说,将这个复位"向量放在中断向量表" @向量0中会更有意义.

A final few words, I guess this behaviour is to assure that your power-up (boot?) code will always be at the last corner of RAM. That way it will leave alone plenty of RAM for future OS disposal. [Honestly, for me, it will make more sense to have placed this 'Reset' vector within the 'Interrupt Vector Table' @ vector #0].

如果我错了,请纠正我.希望这会有所帮助.

Please, correct me if I am wrong. Hope this helps.

PD:什么是CS缓存寄存器?好吧,它是与使用中的CS选择器关联的描述符值.所有其他段也具有此高速缓存寄存器"值,以便快速访问.请记住,在x86 CPU上,您不能随意禁用分段".您必须处理它.阅读一些涉及分段的保护模式"以了解更多信息...不幸的是(或幸运的是)分段已不合时宜.分页已成功地作为一种保护机制.

PD: What is CS cache register? Well, it is the descriptor values associated with a CS selector in use. All other segments have this 'cache register' values too for fast accessing. And remember, on x86 CPUs you can not disable 'segmentation' at will. You have to deal with it. Read some 'Protected Mode' involving segmentation to know more... Unfortunately (or fortunately?) segmentation is gone and obsolete. Paging has succeded as a protection mechanism instead.

顺便说一句,某些Wikipedia文章似乎是用错误的逻辑进行编辑的.小心点!!

By the way, some Wikipedia articles seem to be edited with bad logic. Be careful about it!!!

这篇关于在386+处理器中重置向量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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