CE下的驱动程序和服务开发笔记,体验及总结
2005-01-01 18:22
471 查看
为了完成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驱动
一会在下面会详细介绍这个
驱动的种类:
lAudio Drivers
lBattery Drivers
lBlock Drivers
lBluetooth HCI Transport Driver
lDirect3D Device Driver Interface
lDirectDraw Display Drivers
lDisplay Drivers
lDVD-Video Renderer
lIEEE 1394 Drivers
lKeyboard Drivers
lNotification LED Drivers
lParallel Port Drivers
lPC Card Drivers
lPrinter Drivers
lSerial Port Drivers
lSmart Card Drivers
lStream Interface Drivers
lTouch Screen Drivers
lUSB 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。
直接使用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下的服务
一个CE服务也是一个DLL,结构和一个流式驱动程序的差不多:有3字符前缀,有10个进入口函数
最后一次更新:2005年1月1日19:29:47
还是先把知识复习一下:
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驱动
一会在下面会详细介绍这个
驱动的种类:
lAudio DriverslBattery Drivers
lBlock Drivers
lBluetooth HCI Transport Driver
lDirect3D Device Driver Interface
lDirectDraw Display Drivers
lDisplay Drivers
lDVD-Video Renderer
lIEEE 1394 Drivers
lKeyboard Drivers
lNotification LED Drivers
lParallel Port Drivers
lPC Card Drivers
lPrinter Drivers
lSerial Port Drivers
lSmart Card Drivers
lStream Interface Drivers
lTouch Screen Drivers
lUSB 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
相关文章推荐
- .net开发笔记(十六) 对前部分文章的一些补充和总结
- IOS开发笔记之九——类型不匹配导致的app崩溃问题(bug总结二)
- Linux字符设备驱动程序开发之笔记及摘要
- PHP 开发 APP 接口 学习笔记与总结 - JSON 方式封装通信接口
- arcgis开发笔记【rest服务参考】
- PHP 开发 APP 接口 学习笔记与总结 - 静态缓存
- CMU J2EE网络开发课程总结笔记
- Android开发总结笔记 RatingBar(评分条) 1-1-12
- Android开发总结笔记 属性动画(上) 4-1
- 嵌入式开发之C基础学习笔记10--总结
- IoT小能手:机智云自助开发平台及云服务小白体验
- 视频开发初步体验 学习笔记
- 第二行代码学习笔记——第十一章:Android特色开发——基于位置的服务
- SAP公开课笔记:基于HANA的软件开发 - 第六周总结
- SOA与面向服务开发-笔记
- 开发小总结常用命令笔记
- Android IOS WebRTC 音视频开发总结(五十)-- 技术服务如何定价?
- Linux运维笔记-文档总结-NFS网络文件系统和autofs自动挂载服务
- Android开发总结笔记 ImageView(图像视图) 1-1-8
- PHP 开发 APP 接口学习笔记与总结 - [ Linux ] 定时任务