阅读:1309回复:12
我想撞墙
这么好的一篇文章让我翻译的一无是处,翻完了自己看了一遍觉得我还是撞墙算了!路过的老兄们看不顺眼的给改改,顺便骂两句都行 :D :D
(毕业设计需要,不得不丢人了) 英文: How VMs Can Communicate with VxDs (Q89705) SUMMARY Under the enhanced mode Windows environment, it is sometimes necessary or desirable to provide means by which processes (virtual machines) can communicate with virtual devices (VxDs). This article discusses the techniques by which this can be achieved. MORE INFORMATION Virtual machines (VMs) can communicate with virtual devices either explicitly (which means that the virtual machine is aware of running under control of enhanced mode Windows and submits explicit calls to the VxD) or implicitly (which means that the VxD traps VM requests to the operating system that would otherwise be serviced by the BIOS, TSRs, or the hardware directly). The latter notion is basically a subset of the idea of \"virtualization,\" which means leaving the process under the impression that it runs on a dedicated machine instead of under a multitasking operating system. When VM software wants to call into a VxD explicitly, it must first use the Interrupt 2fh call \"get device api entry point\" (ax=1684h) to receive the callback address to which the call into the VxD must be submitted. The functionality of the VxD when processing this call is up to the VxD; the software running in the virtual machine must know both the OEM VxD ID number that belongs to the VxD and the functionality of the VxD API function to utilize it. Because the VxD runs under a different protection level and in 32-bit code segments instead of 16-bit code segments, a VM cannot directly call into the VxD. The necessary ring transitions and mode switches are performed by the VMM. Because VxDs may also hook software interrupts that are being submitted by a VM (as outlined below), a software interrupt may also be seen as a valid method for a VM to explicitly call into a VxD; however, prior to submitting the software interrupt, the VM should make sure that the VxD is installed, which is possible through the \"get device api entry point\" call mentioned above. If the software interrupt interface provided by the VxD includes an installation check call (such as the VDS implementation provided by a Windows virtual device), there is no need for an explicit VxD installation check. Note that VDS stands for \"Virtual DMA Interface Specification,\" which is a software interface for virtual machines to access physical DMA (direct memory access). The specification is available in the Software/Data Library; just query for VDS. The ways a VxD can cause a VM to trap into it implicitly are the following: ? By hooking software interrupts that will be submitted by the VM ? By trapping accesses from VMs to ports ? By inserting callback addresses in the VMs address space When a VxD wants to hook a software interrupt, it can do so by one of the following techniques: 1. Use Hook_V86_Int_Chain to register a callback function that is being called whenever a VM running in V86 mode submits the software interrupt 2. Use Get/Set V86_Int_Vector or Get/Set PM_Int_Vector to change the interrupt tables of the virtual machines The differences between these strategies are as follows: ? Interrupt hooks established via Hook_V86_Int_Chain are not called by virtual machines running in protected mode unless the last handler in the VM protected-mode interrupt chain reflects the interrupt to V86 mode. ? Get/Set V86/PM_Int_Vector behaves just as if any real/protected mode software running in the VM had used the interrupt vectors; all code and data that will be touched by the interrupt handler must be visible to the VM in the corresponding modes and reside in 16-bit segments (unless it is being sent to a callback); the modified vectors can be manipulated (that is, looked at, chained to, replaced, and so forth) by the VM. ? The calling software in the VM will never be aware of a VxD V86 hook. That is, the hook chain can never be accessed or manipulated by a VM; the interrupt handler resides in a VxD (that is, in a 32-bit segment on ring 0). V86 hooks are generally used to virtualize software interrupt interfaces within VMs (such as providing the VDS or virtual NetBIOS interfaces to VMs). ? V86 hooks cannot be installed on a per-VM basis, whereas PM and V86-mode interrupt handlers can be. ? Scenario 2 is very rarely used because it requires that the VxD must provide code and data in an environment which is not easily accessible to it; in effect, by doing so it would extend the VM with software running in the VMs execution mode, whereas the technique outlined in scenario 1 contains code and data which is directly accessible to the VxD. By trapping port accesses from VMs, a VxD can simulate a hardware device to a VM; whenever the VM accesses the port, the VxD-supplied callback function will gain control and leave the VM under the impression that a hardware device had serviced the port access. Although the main purpose of this mechanism is to virtualize hardware, it can be used to communicate information from a VxD to a VM. This technique is used in VITD, a virtual timer device that is supplied in the Software/Data Library (query on VITD or S12887). To use port trapping for communication, a VxD calls one of the services, Install_IO_Handler or Install_Mult_IO_Handler. A callback, eventually, is an address within the visible range of a VM that will transfer control to a routine supplied in a VxD when being jumped to while the VM is running in its current mode. Callback functions can be combined with interrupt vectors in that an interrupt vector in a VM can be set to a callback function. Note, however, that for VMs running in V86 mode, hooking the interrupt is generally more efficient than setting the V86-mode interrupt vector to a callback because two ring transitions less are needed. To allocate a callback, a VxD can call the service Allocate_V86_Call_back service for VMs running in V86 mode and Allocate_PM_Call_Back for VMs running in protected mode. Calling VM Code from a VxD When a VxD wants to transfer control to code residing in a VM, it will generally do this by scheduling an event for the VM that simulates a far call or an interrupt into the VM. Depending on whether the event has been scheduled using the CallxxxEvent or the SchedulexxxEvent service, and which VM was currently running when the event was scheduled, the call may or may not be executed immediately. In any case, a ring transition will occur that will execute the VM code in a less privileged level in 16-bit mode. If a VxD wants to call software in a VM directly without scheduling an event, it should do so by using the Begin_Nest_Exec and End_Nest_Exec services. Because this mechanism uses the current virtual machine only, a VxD should use it primarily with global TSRs because global TSRs are guaranteed to be shared by all VMs; if a VxD wants to use nested execution to call code that is local to one VM, it must make sure to do this only if the VM hosting the code to call into is the current VM. Nested calls and scheduled events can be used cooperatively. In particular, due to the non-reentrancy of the Windows enhanced mode operating system, certain routines (such as interrupt handlers) will need to schedule events that will eventually submit a nested execution call into a VM. Note that the Exec_VxD_Int service should not be used to communicate information from a VxD to a VM. This service is basically provided to allow VxDs to use extended MS-DOS services. When Exec_VxD_Int is being called, the current virtual machine will be forced into protected mode regardless of the mode it ran under, and the system protected-mode interrupt handler chain is called (note that the current VM\'s protected-mode interrupt chain does not see the interrupt). [编辑 - 5/6/02 作者: trent] |
|
最新喜欢:qgr
|
沙发#
发布于:2002-05-06 16:38
译文:
虚拟机(VMs)怎么和虚拟设备(VxDs)通信 概要: 在Windows增强版的环境下,有时候很有必要提供一种可以供进程(VMs中)和虚拟设备(VxDs)进行通信的方法。而这篇文章的主题就是讨论如何实现这项技术。 正文: 虚拟机能够和虚拟设备显式(意味着虚拟机能够在较高版本的Windows下运行并且能够响应外来的VxD调用)或隐式(意味着VxD能够传达虚拟机(VM)的要求给操作系统,而操作系统由BIOS,ISRS和其它硬件直接提供服务)地进行通信。后一种方式基本上就是一种“虚拟化”,它给我们的感觉就像进程是独占一台机器而不是运行在多任务操作系统下。 当VM中的程序要明确地转入VxD,首先必须以int 2f中断调用来得到“设备的api函数入口点”(ax=1684h),从而得到返回地址。进行这种调用时VxD的功能性由VxD决定。 在虚拟机下运行的程序必须知道原始设备制造商给的这个VxD的ID号,而且还要知道VxD的API函数的功能一边调用它。因为VxD在与虚拟机中的程序运行在不同的保护级别,并且是在32位代码段而不是16位代码段,所以虚拟机不能直接进入VxD。这些必要的级别转换和模式切换由虚拟机管理器(VMM)来执行。 因为VxD还可以钩挂虚拟机下的软中断(如下所示),所以软中断也是从虚拟机(VM)中转入VxD行之有效的方法。然而,在进行软中断之前,虚拟机(VM)必须保证VxD已经安装了,这样才能得到上面所提到的“设备api入口点”。如果由VxD提供的软中断界面已经包含了VxD的安装检查,那么就不需要再去明确的确定VxD是否安装。注意的一点是VDS(Virtual DMA Interface Specification虚拟DMA界面规范)是虚拟机进行DMA(direct memory access)操作的一种软件界面,这种规范同样适用于软件和数据库(参考VDS)。 VxD用如下方法使虚拟机(VM)隐式进入该VxD: 1、 钩挂VM下的软中断。 2、 3、 捕获VMs对端口的访问。 4、 5、 在VMs的地址空间中插入回调地址。 6、 当VxD想要钩挂软中断,可以使用以下技术: 1、 用 Hook_V86_Int_Chain来注册一个回调函数,当虚拟机运行在V86模式下调用软中断时该函数被触发。 2、 3、 用Get/Set V86_Int_Vector或 Get/Set PM_Int_Vector来改变虚拟机的中断向量表。 使用这两种方法的区别在于: ◆ 使用Hook_V86_Int_Chain函数来钩挂软中断,如果虚拟机是运行在保护模式下该函数肯定不能被触发,除非保护模式下的中断处理最后将该中断反射到V86模式下。 ◆ Get/Set V86/PM_Int_Vector的作用就像运行在实模式\\保护模式的VM下的程序使用中断向量;中断处理的所有数据和代码对相应模式下的VM都是可见的,并且是驻留再16位的代码段里边(除非转入回调函数处理);VM可以操作(查看,链接,修改等等)这些向量。 ◆ 运行在VM中的程序根本不知道VxD所进行的对V86模式下的钩挂处理,也就是说,这种钩挂是不能由VM访问和处理的;中断服务程序驻留在VxD中(0级的32位代码段)。对V86的钩挂一般用来对VMs下的软中断的虚拟(就像对VMs提供的VDS或virtual NetBIOS界面)。 ◆ 对V86中断的钩挂不能在所有的VM中安装,然而保护模式或V86模式下的中断处理却可以。 ◆ 第二种方法在实际上很少用到因为它要求VxD必须在上下文中提供代码和数据但是这些代码和数据却是几乎和VxD无关,实际上,这样做只是在虚拟机执行模式下用程序扩充了VM。然而在第一种技术中包含的代码和数据直接受VxD的影响。 通过捕获VMs对端口的访问,VxD可以对VM模拟一种硬件设备;当VM访问端口的时候,VxD提供的回调函数就会被触发而得到控制权,而对VM看来就好像有一种硬件设备为访问端口进行服务。虽然这种机制的目的主要是虚拟硬件,但它也可以被用来VxD与VM之间进行通信。这种技术也被用于VITD,一种应用在软件或数据库中的一种虚拟计时器设备(参考VITD或S12887)。 使用捕获端口进行通信,VxD调用了下边的一种服务,Install_IO_Handler或Install_Mult_IO_Handler。 回调机制归根到底是一种对VM来说可知的地址变换,当WM运行在当前模式下时它将控制权交给了由VxD提供的程序。回调函数和中断向量结合在一起使得VM中的中断向量可以嵌入回调函数。注意,如果VMs运行在V86模式下,钩挂中断的方式通常比设置V86中断向量而转入回调函数的方式有效因为它需要较少的级别转换。 为了分配回调函数,如果虚拟机运行在V86模式下,VxD可以调用Allocate_V86_Call_back服务;如果虚拟机运行在保护模式下,VxD可以调用Allocate_PM_Call_back服务。 在VxD中调用VM代码 当VxD想把控制权转入VM中的代码时,它需要为WM安排一个事件,对WM来说就像是一个远程调用或者中断。根据事件是否被预定可以选择CallxxxEvent 服务或者SchedulexxxEvent服务,当事件被预定时VM正在运行,这种调用可能马上被执行,也可能不立即执行。不过无论如何这时将会进行级别转换并且VM的代码将会在16位模式下以较低的特权被执行。 如果VxD要不通过安排事件而直接调用VM中的代码,可以调用Begin_Nest_Exec服务和End_Nest_Exes服务。但是这种机制只适用当前的VM,VxD主要使用全局TSRs来实现它因为全局TSRs保证是被所有的VMs共享;如果VxD想要通过嵌套执行的方法来调用VM中的局部代码,那么必须保证拥有这段代码的VM是当前的VM。 嵌套调用和安排事件可以配合使用。特别的,由于Windows增强版操作系统是不可重入的,某些程序(如中断处理器)需要安排事件,但是最终还是转换成向VM提交嵌套执行。 注意Exec_VxD_Int服务不应该被用来VM和VxD之间进行通信。这种服务基本功能是允许VxDs使用MS-DOS的扩展服务。当Exec_VxD_Int被调用时,当前的VM被迫转入保护模式而不管原来它是运行在何种模式下,并且系统的保护模式中断处理器被调用(注意当前的中断处理器看不到这个中断)。 |
|
|
板凳#
发布于:2002-05-06 17:03
用户被禁言,该主题自动屏蔽! |
|
地板#
发布于:2002-05-06 17:25
系里要求的,没办法,要5000字以上的翻译,现在才翻了不到2k,估计还得翻2篇,楼上的老兄发表发表高见!
|
|
|
地下室#
发布于:2002-05-06 19:48
用户被禁言,该主题自动屏蔽! |
|
5楼#
发布于:2002-05-06 20:07
要有自信
|
|
|
6楼#
发布于:2002-05-06 20:19
写的足够长,多用专业术语,但逻辑不要太清楚,做到中国字都认识就是不知道意思就好了。
|
|
|
7楼#
发布于:2002-05-06 20:36
呵呵,楼上的说的实在是太对了!!
5K的char,谁仔细的看呀? 这说明了你对VxD不太了解呀,如果了解很深,就会翻译的很好了。 |
|
8楼#
发布于:2002-05-06 20:48
是啊是啊,才接触VxD不到一个月,让我怎么很了解啊,不过我想蒙一蒙老师大概还可以,但弄得自己都不明白那就亏了 :D :D :D
|
|
|
9楼#
发布于:2002-05-06 20:50
主要是这篇文章技术性比较强,很多术语不知道如何翻才好
|
|
|
10楼#
发布于:2002-05-06 20:51
主要是这篇文章技术性比较强,很多术语不知道如何翻才好,只好硬着头皮一个词一个词的翻过去,自己看了都会冒汗!下面还会翻两篇,到时候一块儿贴出来让大家斧正! :P :D
[编辑 - 5/6/02 作者: trent] |
|
|
11楼#
发布于:2002-05-06 20:55
翻译这种东西基本是没有人看的,除了自己,原来我喜欢把英文翻成中文,可现在看以前翻的文章,连自己都不好意思。所以如果自己看的话还是看英文
|
|
12楼#
发布于:2002-05-06 23:05
关键是你自己明白就好了。
|
|