linux内核 usb卷,Linux内核USB驱动架构:USB卷五 - USB设备枚举过程 - 图文-(30页)-原创力文档...

本文详细剖析了USB设备的枚举过程,包括数据结构和流程。重点介绍了USB设备描述符,如bLength、bDescriptorType、bcdUSB等字段,以及它们在设备初始化和配置中的作用。枚举过程中涉及的配置、接口和端点的描述符也进行了阐述,揭示了USB设备如何与主机通信并确定其功能。
摘要由CSDN通过智能技术生成

USB卷五USB设备的枚举过程

LK版本:2.6.35.3

2013年1月14日 任务目标:

分析整理USB设备枚举过程;

本文要点:

1、USB设备枚举数据结构;

2、USB设备枚举流程;

硬件框图:

2

数据结构:

descriptor usb_device{} *config

… …

**rawdescriptors bLength usb_device_descriptor{} bDescriptorType bNumConfigurations desc usb_host_config{} intf_cache[] … …

… …

每个配置

bLength usb_config_descriptor{} bDescriptorType wTotalLength bNumInterfaces num_altsetting usb_interface_cache{} altsetting[0] … …

bConfigurationValue 每个接口cache

… …

desc usb_host_interface{} *endpoint … …

bLength usb_interface_descriptor{} bDescriptorType bInterfaceNumber bAlternateSetting

bNumEndpoints … …

desc usb_host_endpoint{} urb_list … …

bLength usb_endpoint_descriptor{} bDescriptorType bEndpointAddress bmAttributes bInterval … …

每个端点

每个接口设置

成员说明:

struct usb_device { … …; struct device dev; /* generic device interface */ struct usb_device_descriptor descriptor; /* descriptor*/

struct usb_host_config *config; /* all of the configs */

struct usb_host_config *actconfig; /*the active configuration */ … …; char **rawdescriptors; /* raw descriptors for each config */ … …; char *product; /*iProduct string, if present */

char *manufacturer; /*iManufacturer string, if present */ char *serial;

/*iSerialNumber string,if present */

};

struct usb_device_descriptor { __u8 bLength; __u8 bDescriptorType; __le16 bcdUSB; __u8 bDeviceClass; __u8 bDeviceSubClass; __u8 bDeviceProtocol; __u8 bMaxPacketSize0; __le16 idVendor; __le16 idProduct; __u8 bNumConfigurations;

...... }

bLength :描述符的长度 #define USB_DT_DEVICE_SIZE 18; bDescriptorType :值为USB_DT_DEVICE :0x01

bcdUSB :USB spec 的版本号,如果是2.0版本,值为0x0200,如是1.1版本,则值 为0x0110。

bDeviceClass bDeviceSubClass bDeviceProtocol

idVendor idProduct

bMaxPacketSize0:端点0一次可以处理的最大字节数。 Q:为什么要放在设备描述符里呢?

A:由于它自己没有一个描述符,而每个设备又都有这么一个端点

所以这个信息被保存在了设备描述符里,其中,这个值只能是 8,16,32或64这四者之一,高速模式值只能为64, 低速模式 只能为8,对于中速,可以为8,16,32,64,单位字节。

bNumConfigurations :设备当前速度模式下支持的配置数量

分别指每个设备属于一个Class ,然后Class 下面又分了 SubClass ,SubClass 下面又按各种设备遵循的不同的通信协议继续细分 设备的厂商和ID 号,在USB 设备与驱动匹配时会用

到此成员参数 包括两份:一份来自USB 接口

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值