精华区 [关闭][返回]

当前位置:网易精华区>>讨论区精华>>编程开发>>嵌入式开发>>操作系统设计与实现>>翻译计划—《写你自己的操作系统》>>TRANSLATE: How do I detect v8086 mode? 请指教:)

主题:TRANSLATE: How do I detect v8086 mode? 请指教:)
发信人: wucheng_ai(子程)
整理人: wenbobo(2003-01-09 10:07:24), 站内信件
How do I detect v8086 mode? 
     我怎么检测到处理器工作在V8086模式?



What is Virtual 8086, why is it causing problems for me? 
什么是虚拟V8086模式,为什么它给我带来问题?

     Virtual 8086 mode is a sub-mode of protected mode. In short, virtual 8086 mode is whereby the cpu (in protected mode) is running a "Emulated" 16bit 'segmented' model (real mode) machine. 
     虚拟V8086模式是一种特殊的保护模式。简而言之,虚拟V8086模式是因为CPU工作在保护模式下,并向下兼容了16位实地址模式。

     V8086 mode can cause all different kinds of problems for OS programmers.
     V8086模式给OS程式员带来许多各种各样的问题.

     The most common problem with v86 mode is that, you can't "enter" protected mode inside a v86 task.
     最通常的V86难题就是,在运行V86模式任务时你不能切进保护模式。

     That meaning, if you are running Windows or have emm386 in memory, you can't do a "raw" switch into protected mode (it causes an exception if I remember correctly!)
     这个意思即是,如果你的处理器正跑着Windows或者EMM386内存管理程式管理着内存时,你不可以强制切进保护模式(如果我没记错的话,这样会产生异常!)

     There are a few other more "technical" problems people have when using v86 mode, mostly because v86 has some instructions "emulated" by what's known as a v86-monitor program, as the cpu is in protected mode, some instructions are high up on the security/protection level and running those directly would cause no-end of trouble for the OS.
     大家在使用V86模式时,很少有其它“技术性”问题,通常是因为V86有一些指令被V86监控程式所兼容,如同处理器是在保护的模态中,一些指令在安全或保护级别上被挂起,直接运行这些指令将会引起该操作系统的当机。

     Such technicalities are beyond the scope of a simple FAQ
     如此专业的术语已超出常见问题解答的范畴了。


How do I detect if my machine is in Virtual 8086 mode?
我怎样才能检测到,处理器正跑在虚拟V8086模式下?

    EFLAGS.VM is NEVER pushed onto the stack if the V86 task uses PUSHFD. You should check if CR0.PE=1 and then assume it's V86 if that bit is set.  
    如果V86任务使用PUSHFD,EFLAGS.VM是决不会被压入栈的。 你应该检查CR0寄存器PE位是否为1 ,如果CR0.PE=1则它是就是V86模式。示例如下:
detect_v86:
smsw ax
and eax,1 ;CR0.PE bit
ret



[关闭][返回]