CE下的驱动程序和服务开发笔记,体验及总结

      为了完成CE作业又来看CE下的驱动程序设计了,后悔上那堂课时没认真听......
       还是先把知识复习一下:



1    在UNIX & Windows 9x系列中驱动程序和操作系统是绑定在一起的,在核心态里运行。但在CE里,大部分的驱动程序只是一个DLL文件,在用户态下运行。

2      大部分的驱动程序都是用来控制硬件的,但某些硬件是不需要驱动的,如:CPU,Memory......也有一些虚拟设备的驱动 ,如:文件系统驱动,RAM disk

3     CE提供逻辑中断SYSINTRs,中断仅被当作用户态下的一个线程(IST)
l
 
4    硬件的OEMs并不提供该硬件在CE上的驱动,而只是一个硬件规约(Hardware Specification)

驱动的分类:
1    Native
2    Bus
3    Stream interface

一,Native驱动
    也叫做Built-in驱动,是硬件所必须的,由OEM设计硬件时所完成的。如:键盘,触摸屏......
也许不支持一般设备驱动接口 。当OS的新版本出来时,一般Native驱动只需做很少的改动。

二,Bus驱动
    管理系统总线,如PCI总线;PCMICA和CompactFlash也被当作总线。负责询问总线上的硬件来决定什么硬件被安装和正在分配资源。也会要求设备管理器(Device Manager)来为线上硬件装载合适的驱动。
 
三,Stream interface驱动
    一会在下面会详细介绍这个

驱动的种类:
 

  • l Audio Drivers  
  • l Battery Drivers  
  • l Block Drivers  
  • l Bluetooth HCI Transport Driver  
  • l Direct3D Device Driver Interface  
  • l DirectDraw Display Drivers  
  • l Display Drivers  
  • l DVD-Video Renderer  
  • l IEEE 1394 Drivers  
  • l Keyboard Drivers  
  • l Notification LED Drivers  
  • l Parallel Port Drivers  
  • l PC Card Drivers  
  • l Printer Drivers  
  • l Serial Port Drivers  
  • l Smart Card Drivers  
  • l Stream Interface Drivers  
  • l Touch Screen Drivers  
  • l USB Drivers  
驱动的装载过程:
1    大部分的驱动都是由系统启动时的设备管理进程(Device.exe)来完成装载的。

2    而一些Buit-in驱动由GWES.exe来装载。这些驱动包括显示驱动(DDI.dll),键盘驱动和触摸屏(鼠标)驱动

3    Device.exe会查看注册表里的[HKEY_LOCAL_MACHINE]/Drivers中一个被称为RootKey的字符串,通常是Builtin。这个RootKey里的驱动列表就是设备管理器必须初始化的。
[帖图1]
4    装载驱动的DLL, 为它创建一个ActiveKey(在[HKEY_LOCAL_MACHINE/Drivers/Active 下),并将这个DLL作为设备驱动注册到系统中。
3.
[帖图2]

5    也可以由应用程序来手工装载驱动,如ActiveDeviceEx函数;另一个老的装载驱动的方法是用:RegisterDevice和 DeregisterDevice。


Stream Interface

    一个流式接口驱动是指一个驱动把流式接口函数暴露出来,而不考虑驱动所控制的设备类型。典型的流式接口驱动:文件系统驱动(iostream,fstream),COM,LPT。。。。。

 直接使用win32文件系统API:
hSer = CreateFile(TEXT(“COM1:”), GENERIC_READ, 0, NULL, OPEN_EXSITING, 0, NULL);
rc = ReadFile(hSer, &ch, 1, &cBytes, NULL);
TransmitCommChar(hSer, ‘a’);
CloseHandle(hSer);

创建一个流式驱动的过程:
1    写一个DLL,把流式接口的函数都expose出来
2    创建设备驱动
3    配置注册表


XXX_Close
Closes the device context identified by hOpenContext.
XXX_Deinit
Called by the Device Manager to de-initialize a device.
XXX_Init
Called by the Device Manager to initialize a device.
XXX_IOControl
Sends a command to a device.
XXX_Open
Opens a device for reading, writing, or both. An application indirectly invokes this function when it calls CreateFile to open special device file names.
XXX_PowerDown
Ends power to the device. It is useful only with devices that can be shut off under software control.
XXX_PowerUp
Restores power to a device.
XXX_Read
Reads data from the device identified by the open context.
XXX_Seek
Moves the data pointer in the device.
XXX_Write
Writes data to the device.

注册表配置:
 
[HKEY_LOCAL_MACHINE/Drivers/BuiltIn/Sample]
    "Dll" = "mydriver.Dll"
    "Prefix" = "DEM"
    "Index" = dword:1
    "Order" = dword:0
    "FriendlyName" = "Demo Driver"
    "Ioctl" = dword:0

CE下的服务
    在CE4.0之前是没有服务可用的,4.0之后服务管理被加入进来了。


    一个CE服务也是一个DLL,结构和一个流式驱动程序的差不多:有3字符前缀,有10个进入口函数


        

 


未完待续........


最后一次更新:2005年1月1日19:29:47
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值