USB驱动程序的加载(一)

301 篇文章 0 订阅
120 篇文章 3 订阅

作者:menuconfig

转自:http://blog.csdn.net/menuconfig/article/details/6060890


USB设备插入系统后,系统会从HKEY_LOCAL_MACHINE/Drivers/USB/LoadClients/Group1_ID/Group2_ID/Group3_ID/DriverName加载USB驱动
其中Group1_ID可以为
DeviceVendorID,
DeviceVendorID_DeviceProductID,
DeviceVendorID_DeviceProductID_DeviceReleaseNumber
或Default
其中Group2_ID可以为
DeviceClassCode,
DeviceClassCode_DeviceSubclassCode,
DeviceClassCode_DeviceSubclassCode_DeviceProtocolCode
或Default
其中Group3_ID可以为
InterfaceClassCode,
InterfaceClassCode_InterfaceSubclassCode,
InterfaceClassCode_InterfaceSubclassCode_InterfaceProtocolCode
或Default
最终的注册表值可以为上面三个Group的不同组合,最多可达64种.

例如,有一USB摄像头设备如下:
Device Descriptor:
bcdUSB:             0x0110
bDeviceClass:         0xEF            DeviceClassCode
bDeviceSubClass:      0x02         DeviceSubclassCode
bDeviceProtocol:      0x01           DeviceProtocolCode
bMaxPacketSize0:      0x40 (64)
idVendor:           0x1C4F           DeviceVendorID
idProduct:          0x3000           DeviceProductID
bcdDevice:          0x0100           DeviceReleaseNumber
iManufacturer:        0x01
0x0409: "SiGma Micro"
iProduct:             0x02
0x0409: "USB Web Camera"
0x0409: "USB Web Camera"
iSerialNumber:        0x00
bNumConfigurations:   0x01

ConnectionStatus: DeviceConnected
Current Config Value: 0x01
Device Bus Speed:     Full
Device Address:       0x01
Open Pipes:              1

Endpoint Descriptor:
bEndpointAddress:     0x81
Transfer Type:   Interrupt
wMaxPacketSize:     0x0008 (8)
bInterval:            0x20

Configuration Descriptor:
wTotalLength:       0x0156
bNumInterfaces:       0x02
bConfigurationValue:  0x01
iConfiguration:       0x00
bmAttributes:         0x80 (Bus Powered )
MaxPower:             0x7D (250 Ma)

Unknown Descriptor:
bDescriptorType:      0x0B
bLength:              0x08
08 0B 00 02 0E 03 00 02

Interface Descriptor:
bInterfaceNumber:     0x00
bAlternateSetting:    0x00
bNumEndpoints:        0x01
bInterfaceClass:      0x0E               InterfaceClassCode
bInterfaceSubClass:   0x01               InterfaceSubclassCode
bInterfaceProtocol:   0x00               InterfaceProtocolCode
iInterface:           0x02
0x0409: "USB Web Camera"
0x0409: "USB Web Camera"

Unknown Descriptor:
bDescriptorType:      0x24
bLength:              0x0D
0D 24 01 00 01 43 00 00 6C DC 02 01 01

Unknown Descriptor:
bDescriptorType:      0x24
bLength:              0x12
12 24 02 01 01 02 00 00 00 00 00 00 00 00 03 0A
20 04

Unknown Descriptor:
bDescriptorType:      0x24
bLength:              0x08
08 24 02 02 01 04 00 00

Unknown Descriptor:
bDescriptorType:      0x24
bLength:              0x09
09 24 03 03 01 01 00 05 00

Unknown Descriptor:
bDescriptorType:      0x24
bLength:              0x08
08 24 04 04 02 01 02 00

Unknown Descriptor:
bDescriptorType:      0x24
bLength:              0x0B
0B 24 05 05 04 00 00 02 3F 16 00

Endpoint Descriptor:
bEndpointAddress:     0x81
Transfer Type:   Interrupt
wMaxPacketSize:     0x0008 (8)
bInterval:            0x20

Unknown Descriptor:
bDescriptorType:      0x25
bLength:              0x05
05 25 03 08 00

Interface Descriptor:
bInterfaceNumber:     0x01
bAlternateSetting:    0x00
bNumEndpoints:        0x00
bInterfaceClass:      0x0E
bInterfaceSubClass:   0x02
bInterfaceProtocol:   0x00
iInterface:           0x00

Unknown Descriptor:
bDescriptorType:      0x24
bLength:              0x0E
0E 24 01 01 91 00 88 00 03 02 01 00 01 00

Unknown Descriptor:
bDescriptorType:      0x24
bLength:              0x0B
0B 24 06 01 03 10 01 00 00 00 00

Unknown Descriptor:
bDescriptorType:      0x24
bLength:              0x26
26 24 07 01 03 80 02 E0 01 00 00 4B 00 00 00 4B
00 00 60 09 00 15 16 05 00 00 15 16 05 00 2A 2C
0A 00 15 16 05 00

Unknown Descriptor:
bDescriptorType:      0x24
bLength:              0x26
26 24 07 02 03 40 01 F0 00 00 00 4B 00 00 00 4B
00 00 60 09 00 15 16 05 00 00 15 16 05 00 2A 2C
0A 00 15 16 05 00

Unknown Descriptor:
bDescriptorType:      0x24
bLength:              0x26
26 24 07 03 03 A0 00 78 00 00 00 4B 00 00 00 4B
00 00 60 09 00 15 16 05 00 00 15 16 05 00 2A 2C
0A 00 15 16 05 00

Unknown Descriptor:
bDescriptorType:      0x24
bLength:              0x13
13 24 03 00 03 80 02 E0 01 40 01 F0 00 A0 00 78
00 01 80

Unknown Descriptor:
bDescriptorType:      0x24
bLength:              0x06
06 24 0D 01 01 01

Interface Descriptor:
bInterfaceNumber:     0x01
bAlternateSetting:    0x01
bNumEndpoints:        0x01
bInterfaceClass:      0x0E
bInterfaceSubClass:   0x02
bInterfaceProtocol:   0x00
iInterface:           0x00

Endpoint Descriptor:
bEndpointAddress:     0x88
Transfer Type: Isochronous
wMaxPacketSize:     0x025C (604)
bInterval:            0x01

Interface Descriptor:
bInterfaceNumber:     0x01
bAlternateSetting:    0x02
bNumEndpoints:        0x01
bInterfaceClass:      0x0E
bInterfaceSubClass:   0x02
bInterfaceProtocol:   0x00
iInterface:           0x00

Endpoint Descriptor:
bEndpointAddress:     0x88
Transfer Type: Isochronous
wMaxPacketSize:     0x03BC (956)
bInterval:            0x01

Interface Descriptor:
bInterfaceNumber:     0x01
bAlternateSetting:    0x03
bNumEndpoints:        0x01
bInterfaceClass:      0x0E
bInterfaceSubClass:   0x02
bInterfaceProtocol:   0x00
iInterface:           0x00

Endpoint Descriptor:
bEndpointAddress:     0x88
Transfer Type: Isochronous
wMaxPacketSize:     0x024C (588)
bInterval:            0x01

Interface Descriptor:
bInterfaceNumber:     0x01
bAlternateSetting:    0x04
bNumEndpoints:        0x01
bInterfaceClass:      0x0E
bInterfaceSubClass:   0x02
bInterfaceProtocol:   0x00
iInterface:           0x00

Endpoint Descriptor:
bEndpointAddress:     0x88
Transfer Type: Isochronous
wMaxPacketSize:     0x02B0 (688)
bInterval:            0x01

系统会搜索如下路径:
Drivers/USB/LoadClients/7247_12288_256/239_2_1/Default
Drivers/USB/LoadClients/7247_12288_256/239_2/Default
Drivers/USB/LoadClients/7247_12288_256/239/Default
Drivers/USB/LoadClients/7247_12288/239_2_1/Default
Drivers/USB/LoadClients/7247_12288/239_2/Default
Drivers/USB/LoadClients/7247_12288/239/Default
Drivers/USB/LoadClients/7247/239_2_1/Default
Drivers/USB/LoadClients/7247/239_2/Default
Drivers/USB/LoadClients/7247/239/Default
Drivers/USB/LoadClients/7247_12288_256/Default/Default
Drivers/USB/LoadClients/7247_12288/Default/Default
Drivers/USB/LoadClients/7247/Default/Default
Drivers/USB/LoadClients/Default/239_2_1/Default
Drivers/USB/LoadClients/Default/239_2/Default
Drivers/USB/LoadClients/Default/239/Default
...
如果以上路径都没有,则提示用户输入驱动程序名.

用户输入驱动程序名后,系统调用该驱动程序中的USBInstallDriver().USBInstallDriver()会调用RegisterClientDriverID()与RegisterClientSettings()注册USB Client 驱动.
该函数成功调用后,会生成如下的注册表项:
HKEY_LOCAL_MACHINE/Drivers/USB/ClientDrivers/Video_Class
   "DLL"="camera.dll"
    "Prefix"="CAM"
[HKEY_LOCAL_MACHINE/Drivers/USB/LoadClients/GroupID1/GroupID2/GroupID3/Video_Class]
   "DLL"="camera.dll"
并且会重新调用LoadUSBClient()来加载USB Client Driver.
其中GroupID1,GroupID2,GroupID3为上述的某种组合,Video_Class会因为设备类别不同而不同。

RegisterClientDriverID:
生成HKEY_LOCAL_MACHINE/Drivers/USB/ClientDrivers/Video_Class
RegisterClientSettings:
生成[HKEY_LOCAL_MACHINE/Drivers/USB/LoadClients/GroupID1/GroupID2/GroupID3/Video_Class]
   "DLL"="camera.dll"

 最后在USBDeviceAttach()调用ActivateDevice()来加载该驱动程序。

http://www.cnblogs.com/cdfyanghua/articles/1179651.html


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值