设备驱动程序通知应用程序的几种方法毕业论文外文翻译.doc

上传人:豆**** 文档编号:29925850 上传时间:2022-08-02 格式:DOC 页数:8 大小:42.50KB
返回 下载 相关 举报
设备驱动程序通知应用程序的几种方法毕业论文外文翻译.doc_第1页
第1页 / 共8页
设备驱动程序通知应用程序的几种方法毕业论文外文翻译.doc_第2页
第2页 / 共8页
点击查看更多>>
资源描述

《设备驱动程序通知应用程序的几种方法毕业论文外文翻译.doc》由会员分享,可在线阅读,更多相关《设备驱动程序通知应用程序的几种方法毕业论文外文翻译.doc(8页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、数学专业英语论文 The device driver notifies the application of several methodsPapers Category:Computer Papers - Computer Application Papers Post Time:2013-2-6 9:48:00 In the current popular Windows operating system, device drivers is the lowest level of manipulation of hardware software interface. To share

2、the device driver design process experience, given the device driver notifies the application of the five kinds of ways, each method specifically described the principle and implementation process, hoping to give the designer of the device driver to provide some help. Operating system in order to en

3、sure peace and stability, and application portability, Windows operating system does not allow applications direct access to the systems hardware resources, but must resort to the appropriate device driver. Device drivers can directly manipulate the hardware, if applications and device drivers to ac

4、hieve a two-way communication between, also reached the underlying hardware device application control purposes. Communication between them, including two aspects Abstract: On the one hand is the application sent to the device driver data; hand is the device driver sends a message to the application

5、. The former to achieve more easily through CreateFile () function to obtain a handle to the device driver, you can use the Win32 functions such as DeviceIoControl (), ReadFile () or WriteFile (), etc. to achieve application and device driver communication. Implementation of the latter than the form

6、er complex and the article describes the situation in this respect less. This does not mean that it is not important, on the contrary, it is in some applications play an important function. Device drivers complete the data collection work, the need to immediately notify the application so that the a

7、pplication can be promptly removed and the data is processed. In cases like these, and so forth. In view of the device driver notifies the application of the importance, I combined some experience, it was summarized summarized five methods Abstract: asynchronous procedure call (APC), event mode (VxD

8、), messaging, asynchronous I / O modes and event mode (WDM). Below were the principles of this in several ways, and given of some of the source code. An asynchronous procedure call (APC) Win32 applications using CreateFile () function to dynamically load the device driver, and then define a callback

9、 function backFunc (), and the address of the callback function% 26amp; backFunc () as a parameter, through DeviceIoControl () sent to the device driver. Device drivers to get the address of a callback function, it will save it in a global variable (eg callback), the simultaneous calls Get_Cur_Threa

10、d_Handle () function to get its application thread handle, and the handle is stored in a global variable (eg appthread ) in. When conditions are ripe, the device driver calls _VWIN32_QueueUserApc () function to send messages to the Win32 application. This function takes three arguments Abstract: The

11、 first parameter is the address of the callback function (already registered); second parameter is passed to the callback message; third parameter to the callers thread handle (already registered). Win32 application receives a message, the automatic callback function (actually called by the device d

12、river). Callback function of the input parameters are populated by the device driver, the callback function here is mainly to handle the message. 2 Event mode (VxD) First, Win32 applications to create an event handler, called Ring3 handle. Because the virtual device driver using events Ring0 handle,

13、 so you need to create Ring0 handle. Using LoadLibrary () function to load the dynamic link library undisclosed Kernel32.dll, get dynamic link library handle. Then, call GetProcAddress (), find the function OpenVxDHandle () in the dynamic link library location. Then, OpenVxDHandle () function will R

14、ing3 event handlers into Ring0 event handler. Win32 applications using CreateFile () function to load the device driver. If the load is successful, call the DeviceIoControl () function will be passed to the event handler Ring0 VxD; while waiting for the signal to create a worker thread becomes signa

15、led state itself can shop and other things. When conditions are ripe, VxD set Ring0 event to signaled state (called _VWIN32_SetWin32Event () function), which corresponds to Ring3 immediately trigger event to signaled state. Once Ring3 event handler for the signaled state, Win32 applications worker t

16、hread on this news be handled accordingly. 3 message mode Win32 application calls CreateFile () function to dynamically load the virtual device driver. Loaded successfully, by calling DeviceIoControl () function handles the form sent to VxD, VxD use this handle to form a message. When the conditions

17、 are met, VxD calls SHELL_PostMessage () function to send messages to Win32 applications. To make use of this function successfully, you must use # define to customize a message, and even so it is defined in the application; also used in the message loop ON_MESSAGE () to define the message processin

18、g function corresponding to the message so that the message is generated , can call the message handler. SHELL_PostMessage () functions first argument for Win32 window handle, the second parameter is the message ID number, and the third, four parameters are sent to the message processing function pa

19、rameters, fifth, six parameters for the callback function and pass to its parameters. Win32 application receives a message, the message is processed. 4 asynchronous I / O mode Win32 application first calls the CreateFile () function to load the device driver. Before calling this function, the penult

20、imate two parameter is set to FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, saying that he can file overlapped I / O operations. When the device driver file is successfully created, create an initial state is no signal, you need to manually reset the event, and will pass this event type is OVERLAPPE

21、D data structure (eg Overlapped). Then, Overlapped as a parameter passed to DeviceIoControl () function. Device driver put the I / O request packet (IRP) is set to pending status, and set a cancel routine. If the current IRP queue is empty, then the IRP sent to StartIo () routine; Otherwise, put it

22、IRP queue. Device drivers after completing such work, ending the DeviceIoControl () processing, so do not wait for Win32 applications may IRP processed, from DeviceIoControl () call to return. By determining the return value, get the IRP handling. If the current IRP is pending, then the main program

23、 do some other work, then call WaitForSingleObject () or WaitForMultipleObject () function waits for the event become Overlapped signal state. Device drivers at the appropriate time to handle the queued IRP, processing is complete, call IoCompleteRequest () function. This function Overlapped the eve

24、nt is set to the signaled state. Win32 applications to respond to this incident immediately exit the wait state, and no signal will be reset to the state of the event, and then call GetOverlappedResult () Function to get the result of the IRP process. 5 Event mode (WDM) Win32 application first creat

25、es an event, and then passed to the event handler device drivers, then create a secondary thread, waiting for an event signaled that he will go on other things. Device drivers access the event handle, can be used to convert it to an event pointer register and put it up for later use. When the condit

26、ions are met, the device driver will set the event to signaled state, so that the application of the worker thread immediately know the news, then make the appropriate treatment. When the device driver no longer uses this event, the event should be lifted pointer. 6 Conclusion In the current popular

27、 Windows operating system, device drivers is the lowest level of manipulation of hardware software interface. It offers up a user interface and hardware-independent, down directly I / O, hardware interrupts, DMA and memory access and other operations. It applications and hardware details shields, so

28、 do not rely on the hardware and software available in portable between different platforms. This article describes the five kinds of device driver notifies the application, in which the first three methods are mainly used in VxD, the latter two methods is mainly used for WDM. This 5 ways to have be

29、en the actual test. Test results show that they are able to reach the device driver notifies the application purposes. References Abstract: 1 European Youth Li, XU Jian-bo, LI Fang-min, etc. virtual device driver VxD inquiry and development. Computer Engineering, 2003 2 (America) Chris Cant. Windows

30、 WDM Device Driver Development Guide. Sun Yi, Ma Libo, the country Xuefei, M., Beijing Abstract: Mechanical Industry Press, 2000 3 Li Heping DSP-based image reconstruction system to explore ICT, Beijing Abstract: Beijing University of Aeronautics and Astronautics Mechanical Engineering and Automatio

31、n, 2002 汉语翻译内容:设备驱动程序通知应用程序的几种方法文件类别:计算机论文-计算机应用论文发表时间:2013-2-6 9:48:00在目前流行的Windows操作系统中,设备驱动程序是操纵硬件的最底层软件接口。为了共享在设备驱动程序设计过程中的经验,给出设备驱动程序通知应用程序的5种方法,具体说明每种方法的原理和实现过程,希望能够给设备驱动程序的设计者提供一些帮助。 为了保证操作系统的平安性和稳定性以及应用程序的可移植性,Windows操作系统不答应应用程序直接访问系统的硬件资源,而是必须借助于相应的设备驱动程序。设备驱动程序可以直接操作硬件,假如应用程序和设备驱动程序之间实现了双向

32、通信,也就达到了应用程序控制底层硬件设备的目的。它们之间的通信包括两个方面摘要:一方面是应用程序传送给设备驱动程序的数据;另一方面是设备驱动程序发送给应用程序的消息。前者的实现较轻易,通过CreateFile()函数获取设备驱动程序的句柄后,就可以使用Win32函数,如DeviceIoControl()、ReadFile()或WriteFile()等实现应用程序和设备驱动程序之间的通信。后者的实现远比前者复杂,同时介绍这方面情况的文章较少。这不等于说它不重要,相反,它在有些应用场合发挥着重要的功能。设备驱动程序完成数据的采集工作后,需要马上通知应用程序,以便应用程序能够及时将数据取走并进行处理

33、。诸如此类情况,不一而足。 鉴于设备驱动程序通知应用程序的重要性,本人结合一些经验,对它进行了总结,归纳出5种方法摘要:异步过程调用(APC)、事件方式(VxD)、消息方式、异步I/O方式和事件方式(WDM)。下面分别说明这几种方式的原理,并给出实现的部分源代码。 1 异步过程调用(APC) Win32应用程序使用CreateFile()函数动态加载设备驱动程序,然后定义一个回调函数backFunc(),并且将回调函数的地址%26amp;backFunc()作为参数,通过DeviceIoControl()传送给设备驱动程序。设备驱动程序获得回调函数的地址后,将它保存在一个全局变量(如callb

34、ack)中,同时调用Get_Cur_Thread_Handle()函数获取它的应用程序线程的句柄,并且将该句柄保存在一个全局变量(如appthread)中。当条件成熟时,设备驱动程序调用_VWIN32_QueueUserApc()函数,向Win32应用程序发送消息。这个函数带有三个参数摘要:第一个参数为回调函数的地址(已经注册);第二个参数为传递给回调函数的消息;第三个参数为调用者的线程句柄(已经注册)。Win32应用程序收到消息后,自动调用回调函数(实际是由设备驱动程序调用)。回调函数的输入参数是由设备驱动程序填入的,回调函数在这里主要是对消息进行处理。 2 事件方式(VxD) 首先,Win

35、32应用程序创建一个事件的句柄,称其为Ring3句柄。由于虚拟设备驱动程序使用事件的Ring0句柄,因此,需要创建Ring0句柄。用LoadLibrary()函数加载未公开的动态链接库Kernel32.dll,获得动态链接库的句柄。然后,调用GetProcAddress(), 找到函数OpenVxDHandle()在动态链接库中的位置。接着,用OpenVxDHandle()函数将Ring3事件句柄转化为Ring0事件句柄。Win32应用程序用CreateFile()函数加载设备驱动程序。假如加载成功,则调用DeviceIoControl()函数将Ring0事件句柄传给VxD;同时,创建一个辅助

36、线程等待信号变成有信号状态,本身则可去干其它的事情。当条件成熟时,VxD置Ring0事件为有信号状态(调用_VWIN32_SetWin32Event()函数),这马上触发对应的Ring3事件为有信号状态。一旦Ring3事件句柄为有信号状态,Win32应用程序的辅助线程就对这个消息进行相应的处理。 3 消息方式 Win32应用程序调用CreateFile()函数动态加载虚拟设备驱动程序。加载成功后,通过调用DeviceIoControl()函数将窗体句柄传送给VxD,VxD利用这个句柄向窗体发消息。当条件满足时,VxD调用SHELL_PostMessage()函数向Win32应用程序发送消息。要

37、让该函数使用成功,必须用#define来自定义一个消息,并且也要照样在应用程序中定义它;还要在消息循环中使用ON_MESSAGE()来定义消息对应的消息处理函数,以便消息产生时,能够调用消息处理函数。SHELL_PostMessage()函数的第一个参数为Win32窗体句柄,第二个参数为消息ID号,第三、四个参数为发送给消息处理函数的参数,第五、六个参数为回调函数和传给它的参数。Win32应用程序收到消息后,对消息进行处理。4 异步I/O方式 Win32应用程序首先调用CreateFile()函数加载设备驱动程序。在调用该函数时,将倒数第2个参数设置为FILE_ATTRIBUTE_NORMAL

38、|FILE_FLAG_OVERLAPPED,表示以后可以对文件进行重叠I/O操作。当设备驱动程序文件创建成功后,创建一个初始态为无信号、需要手动复位的事件,并且将这个事件传给类型为OVERLAPPED的数据结构(如Overlapped)。然后,将Overlapped作为一个参数,传给DeviceIoControl()函数。设备驱动程序把这个I/O请求包(IRP)设置为挂起状态,并且设置一个取消例程。假如当前IRP队列为空,则将这个IRP传送给StartIo()例程;否则,将它放到IRP队列中。设备驱动程序做完这些工作后,结束这个DeviceIoControl()的处理,于是Win32应用程序可

39、能不等待IRP处理完,就从DeviceIoControl()的调用中返回。通过判定返回值,得到IRP的处理情况。假如当前IRP处于挂起状态,则主程序先做一些其它的工作,然后调用WaitForSingleObject()或WaitForMultipleObject()函数等待Overlapped中的事件成为有信号状态。设备驱动程序在适当的时候处理排队的IRP,处理完成后,调用IoCompleteRequest()函数。该函数将Overlapped中的事件设置为有信号状态。Win32应用程序对这个事件马上进行响应,退出等待状态,并且将事件复位为无信号状态,然后调用GetOverlappedResu

40、lt() 函数获取IRP的处理结果。 5 事件方式(WDM) Win32应用程序首先创建一个事件,然后将该事件句柄传给设备驱动程序,接着创建一个辅助线程,等待事件的有信号状态,自己则接着干其它事情。设备驱动程序获得该事件的句柄后,将它转换成能够使用的事件指针,并且把它寄存起来,以便后面使用。当条件具备后,设备驱动程序将事件设置为有信号状态,这样应用程序的辅助线程马上知道这个消息,于是进行相应的处理。当设备驱动程序不再使用这个事件时,应该解除该事件的指针。 6 结语 在目前流行的Windows操作系统中,设备驱动程序是操纵硬件的最底层软件接口。它向上提供和硬件无关的用户接口,向下直接进行I/O、

41、硬件中断、DMA和内存访问等操作。它将应用程序和硬件细节屏蔽开来,使软件不依靠于硬件并且可在多个不同的平台之间移植。本文介绍了5种设备驱动程序通知应用程序的方法,其中前3种方法主要用于VxD中,后2种方法主要用于WDM。这5种方法都经过实际测试。测试结果表明,它们都能够达到设备驱动程序通知应用程序的目的。 参考文献摘要: 1欧青立,徐建波,李方敏,等. 虚拟设备驱动程序VxD的探究和开发. 计算机工程,2003 2(美)Chris Cant. Windows WDM设备驱动程序开发指南. 孙义, 马莉波, 国雪飞等译. 北京摘要: 机械工业出版社 2000 3李和平. 基于DSP的ICT图像重建系统探究. 北京摘要: 北京航空航天大学机械工程及自动化学院, 2002

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 小学资料

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁