分享
 
 
 

Driver Code Structure (驱动结构)--翻译

王朝other·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

Most Windows CE–based device drivers use a layered approach. The advantage of this approach is that you only need to modify the upper or the lower layer. The upper layer is also known as the model device driver (MDD), and the lower layer is also known as the platform dependent driver (PDD).

大多数驱动程序使用分层的方法。这种方法使得驱动程序可以单独进行修改。上层通常被叫做模型设备驱动(MDD),下层通常被叫做平台相关驱动(PDD)。

Layered Code (分层的驱动)

Layered device drivers split the code into an upper layer called the model device driver (MDD) and a lower layer called the platform dependent driver (PDD). The MDD layer contains code that is common to all drivers of a given type. The PDD layer consists of the code that is specific to a given hardware device or platform. The MDD calls specific PDD routines to access the hardware or hardware specific information. When using a layered driver, you can reuse the common MDD code provided by Microsoft, and only write new PDD code that is specific to the your hardware. Alternatively, if you are porting one of the sample drivers to new hardware, you only need to port the PDD layer, and you can use the MDD layer directly from the sample driver.

分层的设备驱动程序把代码分成一个模型设备驱动(MDD)层和平台相关驱动层(PDD)。MDD层驱动可以对一个类型的设备进行驱动。PDD层的驱动则是根据具体的硬件设备和平台专门编写。MDD通过调用特定的PDD历城来对硬件进行访问。使用分层的驱动程序,微软提供了很多公用MDD代码,开发者只需要编写与自己平台有区别的地方。如果要将一个示例驱动代码移植到一个新的平台,也只需要修改PDD部分的代码而直接使用示例代码的MDD层。

The layered driver style is not required and may not be appropriate for all drivers. In particular, splitting device driver code into two layers imposes additional function call overhead in the device driver's operation. For performance critical situations, a monolithic driver may be more appropriate.

但是分层的驱动程序并不是必须的而且在可能在有些驱动上面并不适用。将驱动程序分层两个层使得设备驱动需要更多的调用操作,在一些性能要求特别高的场合,单体的驱动程序可能更加适用。

In general, Microsoft provides the MDD for a layered driver. The MDD is common to all platforms and functions, both as source code and as a library. It performs the following tasks:

· Links to the PDD layer and defines the DDSI functions it expects to call in that layer.

· Exposes DDI functions to the operating system.

· Handles complex tasks such as interrupt processing.

Each MDD handles a specific set of devices, such as audio hardware or touch screens.

对于所有平台来说,MDD的代码和库是公用的。通常,微软提供了这层的代码。它主要完成下面这些任务:

· 与PDD层链接同时定义DDSI函数提供给PDD层作为接口

· 给操作系统提供DDI函数接口

· 处理复杂的中断处理等任务

每种MDD处理一个像音频设备或者是触摸屏这样的一系列的设备。

The device driver interface (DDI) is a set of functions exposed by an MDD layer or monolithic driver and called by other OS modules. The device driver service provider interface (DDSI) is a set of functions exposed by the PDD layer of a layered device driver and called by the MDD. Classes of related device drivers can share the same DDI.

设备驱动接口(DDI)是由MDD层或者单体驱动提给内核模块调用的一个函数集合。而设备驱动服务器提供者接口(DDSI)则是由分层驱动的PDD层提给给MDD层调用的一个函数集合,一类相关的设备可以使用相同的DDI。

In contrast, DDSI layers are rarely the same from one PDD implementation to another. PDD implementations are designed to work with specific MDD implementations, and as such can vary widely from one layered device driver to the next. An exception is in cases where a single MDD layer is capable of using multiple PDDs, in which case the PDDs could expose the same set of DDSI functions. For example, a serial port MDD layer that supported multiple PDDs for controlling different types of serial port hardware, such as a 16550 UART based serial port and an infrared serial port, might require its PDDs to expose the same set of DDSI functions.

比较而言,PDD实现之间,DDSI很少相同的。因为PDD是专门为特定的MDD设计的,而MDD在不同的驱动之间有着很大的不同。有时候,几个PDD也可能使用相同的DDSI给同一个能够使用多个MDD。比如说,串口驱动的MDD层就可以使用多个PDD层,这些PDD层可以是基于UART的串口或者是红外串口,这就要求这些PDD使用相同的DDSI函数。

In general, the MDD requires no changes. If you choose to modify the MDD, be aware that Microsoft does not test, warrant, or support custom MDDs. You are responsible for all further MDD maintenance if Microsoft supplies an updated MDD in order to fix bugs or to support later versions of Windows CE.

一般来讲,MDD时不需要修改的。如果你要修改这些代码,一定要注意微软不会测试、授权或者支持用户写的MDD。如果微软为了修复bug或者版本升级而修改MDD,你将要负起MDD的维护工作。

You must develop the PDD layer specifically for your target platform. The PDD generally consists of functions that perform specific discrete tasks. These functions serve to isolate the MDD from the specifics of the hardware. Because the PDD is hardware-dependent, you must create a customized PDD for your platform hardware, or port one of the sample PDD layers to your hardware. To assist you, Microsoft provides several sample PDD layers for various built-in devices.

针对自己的目标平台,开发者必须要开发自己的PDD层。PDD主要是由一些平台特定的一些任务函数组成。这些函数用来将MDD与特定的硬件隔离。由于PDD使硬件相关的,因此,你必须为自己的硬件平台定制PDD,或者移植一个示例代码。为了方便开发者,微软公司为各种各样的设备提供了样本PDD层代码。

Monolithic Code (单体代码)

You can forego the MDD and PDD layers by implementing your device driver as a monolithic driver. Source code for a monolithic driver consists of both interrupt service thread code and platform specific code. For example, if performance is a critical factor for your device, a monolithic driver might be a better choice than a layered driver because a monolithic driver avoids the overhead associated with the function calls that take place between the MDD and PDD layers. You might also choose to implement a monolithic driver if the capabilities of your device are well matched to the tasks that the functions in the MDD layer perform. In such a case, implementing a monolithic driver might be simpler and more efficient than implementing a layered driver. Regardless of whether you implement a monolithic driver or a layered driver, you can base your implementation on the source code for any of the sample drivers.

你完全可以把你的设备实现为一个单体的驱动程序。单体驱动的源代码由中断服务线程和平台相关的代码组成。比如,如果对你的设备来说,性能要求比较苛刻,单体的驱动程序可能比分层驱动更适合你,因为单体的驱动避免了PDD层和MDD层只见多余的函数调用。如果你的设备的功能与MDD层功能函数非常一致,你也可以将驱动实现为单体。在这些情况下,实现为单体驱动就要比分层驱动更加简单而且更加高效。不管是实现为单体驱动还是分层的驱动,所有的示例驱动都可以作为实现驱动程序的参考。

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有