MODULE_DEVICE_TABLE 宏是必需的,它允许用户空间工具判断该驱动可控制什么设备. 对于 USB 驱动, 这个宏中的第一个值必须是 usb . 如果你需要这个驱动被系统中每个 USB 设备调用, 创建仅需设置 driver_info 成员: staticstructusb_device_id usb_ids[]={ {.driver_info=42}, {} }; 注册USB驱动程序 所有US...
struct usb_hcd *usb_create_hcd(conststruct hc_driver *driver,struct device *dev,constchar *bus_name){ return usb_create_shared_hcd(driver, dev, bus_name, NULL); } struct usb_hcd *usb_create_shared_hcd(conststruct hc_driver *driver,struct device *dev,constchar *bus_name,struct usb_hcd...
dev = interface_to_usbdev(interface); /* It is important to check that id->driver_info is nonzero, since an entry that is all zeroes except for a nonzero id->driver_info is the way to create an entry that indicates that the driver want to examine every device and interface. */ fo...
当usb_driver和usb设备匹配上后,我们准备一个urb对象通过usb_fill_int_urb()/_bulk_/_control_注册到总线,并在合适的时机通过usb_submit_urb向控制器驱动发出发送这个urb对象的命令,总线的控制器驱动收到我们的发送命令之后,会根据我们注册时设置的周期不断向匹配的设备发送请求,如果子设备响应了我们的请求,控制器...
kernel_ulong_t driver_info;} 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. (设备描述符接口描述符结构体参考:https://mp.csdn.net/postedit/81025137) 我们参考/drivers/hid/usbhid/usbmouse.c(内核自带的USB鼠标驱动),是如何使用的,...
static struct usb_device_id usb_ids[ ] = { {.driver_info = 42}, { } }; int (*probe) (struct usb_interface *intf, const struct usb_device_id *id) Pointer to the probe function in the USB driver. This function (described inSection 13.4.3) is called by the USB core when it th...
void WdfUsbInterfaceGetEndpointInformation( [in] WDFUSBINTERFACE UsbInterface, [in] UCHAR SettingIndex, [in] UCHAR EndpointIndex, [in, out] PWDF_USB_PIPE_INFORMATION EndpointInfo ); 参数[in] UsbInterface通过调用 WdfUsbTargetDeviceGetInterface 获取的 USB 接口对象的句柄。[...
若要获取配置描述符,客户端驱动程序必须调用WdfUsbTargetDeviceRetrieveConfigDescriptor方法。 必须使用帮助程序例程,USBD_ParseConfigurationDescriptorEx和USBD_ParseDescriptor。 有关代码示例,请参阅如何枚举 USB 管道中的名为 RetrieveStreamInfoFromEndpointDesc 的示例函数。
struct bus_type usb_bus_type={.name="usb",//总线名称,存在/sys/bus下.match=usb_device_match,//匹配函数,匹配成功就会调用usb_driver驱动的probe函数成员.uevent=usb_uevent,//事件函数.suspend=usb_suspend,//休眠函数.resume=usb_resume,//唤醒函数}; ...
(4)如果两个HardwareID是一样的,那么就利用SetupDiBuildDriverInfoList得到这个设备的驱动程序信息列表 (5)利用SetupDiEnumDriverInfo遍历驱动程序信息列表,得到所有需要的信息,保存在一个名为SP_DRVINFO_DATA的结构中 (6)从SP_DRVINFO_DATA中就可以得到驱动程序的...