一个WDM驱动里面创建多个不同类型的设备
没钱吃饭 2010-07-30 09:28:39 大虾们:
芯片: XR17D158
内容: UART COM ,MPIO
在同一个WDM驱动程序文件ser15x.sys中:
status = IoCreateDevice(DriverObject, sizeof(SERIAL_DEVICE_EXTENSION),
&deviceObjName, FILE_DEVICE_SERIAL_PORT,
0, TRUE, &deviceObject);
MpioStatus = IoCreateDevice(DriverObject,sizeof(MPIO_DEVICE_EXTENSION),
&MpioDeviceObjName,FILE_DEVICE_UNKNOWN,
0,
TRUE,
&MpioDeviceObject);
上述均成功创建对应的设备.同时 与之相关的两个Inf:(ser15x.inf,asdports.inf);
asdport.inf:
; asdport.inf
; Copyright (c) 2008 CDASD Inc.
;
; INF file to specify another PNP ID for serial ports
;
[version]
signature="$Windows NT$"
Class=Ports
ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}
Provider=%OEM%
DriverVer=03/27/2006,3.2.0.0
[DestinationDirs]
ComPort.OEM.NT.Copy = 12
[ControlFlags]
ExcludeFromSelect=*
; Drivers
;----------------------------------------------------------
[Manufacturer]
%OEM%=OEM
[OEM]
%OEMPNP0501.DeviceDesc% = ComPort.OEM, OEMPORT ; Communications Port
[ComPort.OEM.NT]
; NT install section, redirect
; we also need to add this for benefit of Ports class
AddReg=ComPort.OEM.AddReg
CopyFiles=ComPort.OEM.NT.Copy
; addreg and copy files for PnP serenum.sys
Include=msports.inf
Needs=SerialEnumerator.NT
[ComPort.OEM.AddReg]
; Let Ports class know this is a serial port
HKR,,PortSubClass,1,01
[ComPort.OEM.NT.Copy]
ser15x.sys
[ComPort.OEM.NT.HW.AddReg]
HKR,,UpperFilters,0x00010000,serenum
[ComPort.OEM.NT.HW]
AddReg=ComPort.OEM.NT.HW.AddReg
[ComPort.OEM.NT.Services]
AddService = Ser15x, 0x00000002, Ser15x_Service_Inst, Ser15x_EventLog_Inst
; install the serenum service itself
Include=msports.inf
Needs=SerialEnumerator.NT.Services
; -------------- Serial Port Driver install sections
[Ser15x_Service_Inst]
DisplayName = %Ser15x.SVCDESC%
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 3 ; SERVICE_DEMAND_START
ErrorControl = 0 ; SERVICE_ERROR_IGNORE
ServiceBinary = %12%\ser15x.sys
LoadOrderGroup = Extended base
[Ser15x_EventLog_Inst]
AddReg = Ser15x_EventLog_AddReg
[Ser15x_EventLog_AddReg]
HKR,,EventMessageFile,0x00020000,"%%SystemRoot%%\System32\IoLogMsg.dll;%%SystemRoot%%\System32\drivers\ser15x.sys"
HKR,,TypesSupported,0x00010001,7
; User readable strings
;----------------------------------------------------------
[Strings]
OEM= "CDASD Inc."
OEMPNP0501.DeviceDesc = "CDASD Communications Port"
Ser15x.SVCDESC = "CDASD's Serial Port Driver"
ser15x.inf:
; ser15x.INF
; Copyright (c) 2006 Your Company Name
;
; Instead of specifying a hardware id of *PNP0501, a vendor-specific
; hardware id is used to trigger the install of a filter driver that
; filters the resources of the children so that they are acceptable to
; serial/serenum
;
[Version]
Signature="$Windows NT$"
Class=MultiFunction
ClassGUID={4d36e971-e325-11ce-bfc1-08002be10318}
Provider=%OEM%
DriverVer=03/27/2006,3.2.0.0
[ControlFlags]
ExcludeFromSelect=*
[Manufacturer]
%OEM%=OEM
; VID/PID section
[OEM]
%OEM_2PORT%=OEM2PORT_inst, PCI\VEN_13a8&DEV_0152
%OEM_2PORT%=OEM2PORT_inst, PCI\VEN_13a8&DEV_0252
%OEM_4PORT%=OEM4PORT_inst, PCI\VEN_13a8&DEV_0154
%OEM_4PORT%=OEM4PORT_inst, PCI\VEN_13a8&DEV_0254
%OEM_8PORT%=OEM8PORT_inst, PCI\VEN_13a8&DEV_0158
%OEM_8PORT%=OEM8PORT_inst, PCI\VEN_13a8&DEV_0258
;
; -------------------- 2-Port UART Card Section ------------------------
;
[OEM2PORT_inst]
Include = mf.inf
Needs = MFINSTALL.mf
[OEM2PORT_inst.HW]
AddReg=OEM2PORT_inst.RegHW
[OEM2PORT_inst.Services]
Include = mf.inf
Needs = MFINSTALL.mf.Services
[OEM2PORT_inst.RegHW]
HKR,Child00,HardwareID,,OEMPORT
HKR,Child00,ResourceMap,1,00,02
HKR,Child01,HardwareID,,OEMPORT
HKR,Child01,ResourceMap,1,00,02
;
; -------------------- 4-Port UART Card Section ------------------------
;
[OEM4PORT_inst]
Include = mf.inf
Needs = MFINSTALL.mf
[OEM4PORT_inst.HW]
AddReg=OEM4PORT_inst.RegHW
[OEM4PORT_inst.Services]
Include = mf.inf
Needs = MFINSTALL.mf.Services
[OEM4PORT_inst.RegHW]
HKR,Child00,HardwareID,,OEMPORT
HKR,Child00,ResourceMap,1,00,02
HKR,Child01,HardwareID,,OEMPORT
HKR,Child01,ResourceMap,1,00,02
HKR,Child02,HardwareID,,OEMPORT
HKR,Child02,ResourceMap,1,00,02
HKR,Child03,HardwareID,,OEMPORT
HKR,Child03,ResourceMap,1,00,02
;
; -------------------- 8-Port UART Card Section ------------------------
;
[OEM8PORT_inst]
Include = mf.inf
Needs = MFINSTALL.mf
[OEM8PORT_inst.HW]
AddReg=OEM8PORT_inst.RegHW
[OEM8PORT_inst.Services]
Include = mf.inf
Needs = MFINSTALL.mf.Services
[OEM8PORT_inst.RegHW]
HKR,Child00,HardwareID,,OEMPORT
HKR,Child00,ResourceMap,1,00,02
HKR,Child01,HardwareID,,OEMPORT
HKR,Child01,ResourceMap,1,00,02
HKR,Child02,HardwareID,,OEMPORT
HKR,Child02,ResourceMap,1,00,02
HKR,Child03,HardwareID,,OEMPORT
HKR,Child03,ResourceMap,1,00,02
HKR,Child04,HardwareID,,OEMPORT
HKR,Child04,ResourceMap,1,00,02
HKR,Child05,HardwareID,,OEMPORT
HKR,Child05,ResourceMap,1,00,02
HKR,Child06,HardwareID,,OEMPORT
HKR,Child06,ResourceMap,1,00,02
HKR,Child07,HardwareID,,OEMPORT
HKR,Child07,ResourceMap,1,00,02
[Strings]
OEM= "Your Company Name"
OEM_2PORT="OEM's 2-Port UART PCI Card"
OEM_4PORT="OEM's 4-Port UART PCI Card"
OEM_8PORT="OEM's 8-Port UART PCI Card"
问题:
为什么我找得到COM设备,而找不到MPIO设备,也就是打开MPio设备失败?
谢谢