linux内核USB相关数据结构
2017-06-12 09:15
267 查看
本文主要是linux内核USB驱动相关数据结构的整理,方便阅读linux内核驱动相关代码的时候查阅
本文主要是linux内核USB驱动相关数据结构的整理,方便阅读linux内核驱动相关代码的时候查阅
usb_interface_descriptor结构体:
struct usb_interface_descriptor {
__u8 bLength; // 描述符大小
__u8 bDescriptorType;
__u8 bInterfaceNumber;
__u8 bAlternateSetting;
__u8 bNumEndpoints; // 端点数
__u8 bInterfaceClass; // 接口类
__u8 bInterfaceSubClass; // 接口子类
__u8 bInterfaceProtocol; // 接口协议
__u8 iInterface;
} __attribute__ ((packed));
struct usb_device 结构体,linux内核源码下面的可以找到(include/linux/usb.h)
/**
* struct usb_device - kernel's representation of a USB device
* @devnum: device number; address on a USB bus
* @devpath: device ID string for use in messages (e.g., /port/...)
* @route: tree topology hex string for use with xHCI
* @state: device state: configured, not attached, etc.
* @speed: device speed: high/full/low (or error)
* @tt: Transaction Translator info; used with low/full speed dev, highspeed hub
* @ttport: device port on that tt hub
* @toggle: one bit for each endpoint, with ([0] = IN, [1] = OUT) endpoints
* @parent: our hub, unless we're the root
* @bus: bus we're part of
* @ep0: endpoint 0 data (default control pipe)
* @dev: generic device interface
* @descriptor: USB device descriptor
* @config: all of the device's configs
* @actconfig: the active configuration
* @ep_in: array of IN endpoints
* @ep_out: array of OUT endpoints
* @rawdescriptors: raw descriptors for each config
* @bus_mA: Current available from the bus
* @portnum: parent port number (origin 1)
* @level: number of USB hub ancestors
* @can_submit: URBs may be submitted
* @persist_enabled: USB_PERSIST enabled for this device
* @have_langid: whether string_langid is valid
* @authorized: policy has said we can use it;
* (user space) policy determines if we authorize this device to be
* used or not. By default, wired USB devices are authorized.
* WUSB devices are not, until we authorize them from user space.
* FIXME -- complete doc
* @authenticated: Crypto authentication passed
* @wusb: device is Wireless USB
* @string_langid: language ID for strings
* @product: iProduct string, if present (static)
* @manufacturer: iManufacturer string, if present (static)
* @serial: iSerialNumber string, if present (static)
* @filelist: usbfs files that are open to this device
* @usb_classdev: USB class device that was created for usbfs device
* access from userspace
* @usbfs_dentry: usbfs dentry entry for the device
* @maxchild: number of ports if hub
* @children: child devices - USB devices that are attached to this hub
* @quirks: quirks of the whole device
* @urbnum: number of URBs submitted for the whole device
* @active_duration: total time device is not suspended
* @connect_time: time device was first connected
* @do_remote_wakeup: remote wakeup should be enabled
* @reset_resume: needs reset instead of resume
* @wusb_dev: if this is a Wireless USB device, link to the WUSB
* specific data for the device.
* @slot_id: Slot ID assigned by xHCI
*
* Notes:
* Usbcore drivers should not set usbdev->state directly. Instead use
* usb_set_device_state().
*/
struct usb_device {
int devnum; /*usb设备在总线上的编号*/
char devpath[16];
u32 route;
enum usb_device_state state;
enum usb_device_speed speed;
struct usb_tt *tt;
int ttport;
unsigned int toggle[2];
struct usb_device *parent;
struct usb_bus *bus;
struct usb_host_endpoint ep0; /*端点0,特殊对待*/
struct device dev;
struct usb_device_descriptor descriptor;
struct usb_host_config *config;/*拥有的所有配置*/
struct usb_host_config *actconfig;/*当前激活的配置*/
struct usb_host_endpoint *ep_in[16];/*全速也最多使用15个端点*/
struct usb_host_endpoint *ep_out[16];
char **rawdescriptors;/*字符指针数组,每一项都指向GET_DESCRIPTOR请求获得配置描述符所得到到结果*/
unsigned short bus_mA;
u8 portnum;
u8 level;
unsigned can_submit:1;
unsigned persist_enabled:1;
unsigned have_langid:1;
unsigned authorized:1;
unsigned authenticated:1;
unsigned wusb:1;
int string_langid;
/* static strings from the device */
char *product;
char *manufacturer;
char *serial;
struct list_head filelist;
#ifdef CONFIG_USB_DEVICE_CLASS
struct device *usb_classdev;
#endif
#ifdef CONFIG_USB_DEVICEFS
struct dentry *usbfs_dentry;
#endif
int maxchild;
struct usb_device *children[USB_MAXCHILDREN];
u32 quirks;
atomic_t urbnum;
unsigned long active_duration;
#ifdef CONFIG_PM
unsigned long connect_time;
unsigned do_remote_wakeup:1;
unsigned reset_resume:1;
#endif
struct wusb_dev *wusb_dev;
int slot_id;
};
在linux内核源码下面还可以找到如下结构体(include/linux/usb.h)
struct usb_device;
struct usb_driver;
struct usb_device_driver;
struct usb_class_driver;
struct urb;
struct usb_sg_request;
int usb_sg_init;
struct usb_host_endpoint;
struct usb_host_interface;
struct usb_interface;
struct usb_interface_cache;
struct usb_host_config;
struct usb_host_bos;
struct usb_devmap;
struct usb_bus;
struct usb2_lpm_parameters;
struct usb3_lpm_parameters;
struct usb_dynids;
struct usb_dynid;
struct usbdrv_wrap;
struct usb_iso_packet_descriptor;
struct usb_anchor;
本文主要是linux内核USB驱动相关数据结构的整理,方便阅读linux内核驱动相关代码的时候查阅
usb_interface_descriptor结构体:
struct usb_interface_descriptor {
__u8 bLength; // 描述符大小
__u8 bDescriptorType;
__u8 bInterfaceNumber;
__u8 bAlternateSetting;
__u8 bNumEndpoints; // 端点数
__u8 bInterfaceClass; // 接口类
__u8 bInterfaceSubClass; // 接口子类
__u8 bInterfaceProtocol; // 接口协议
__u8 iInterface;
} __attribute__ ((packed));
struct usb_device 结构体,linux内核源码下面的可以找到(include/linux/usb.h)
/**
* struct usb_device - kernel's representation of a USB device
* @devnum: device number; address on a USB bus
* @devpath: device ID string for use in messages (e.g., /port/...)
* @route: tree topology hex string for use with xHCI
* @state: device state: configured, not attached, etc.
* @speed: device speed: high/full/low (or error)
* @tt: Transaction Translator info; used with low/full speed dev, highspeed hub
* @ttport: device port on that tt hub
* @toggle: one bit for each endpoint, with ([0] = IN, [1] = OUT) endpoints
* @parent: our hub, unless we're the root
* @bus: bus we're part of
* @ep0: endpoint 0 data (default control pipe)
* @dev: generic device interface
* @descriptor: USB device descriptor
* @config: all of the device's configs
* @actconfig: the active configuration
* @ep_in: array of IN endpoints
* @ep_out: array of OUT endpoints
* @rawdescriptors: raw descriptors for each config
* @bus_mA: Current available from the bus
* @portnum: parent port number (origin 1)
* @level: number of USB hub ancestors
* @can_submit: URBs may be submitted
* @persist_enabled: USB_PERSIST enabled for this device
* @have_langid: whether string_langid is valid
* @authorized: policy has said we can use it;
* (user space) policy determines if we authorize this device to be
* used or not. By default, wired USB devices are authorized.
* WUSB devices are not, until we authorize them from user space.
* FIXME -- complete doc
* @authenticated: Crypto authentication passed
* @wusb: device is Wireless USB
* @string_langid: language ID for strings
* @product: iProduct string, if present (static)
* @manufacturer: iManufacturer string, if present (static)
* @serial: iSerialNumber string, if present (static)
* @filelist: usbfs files that are open to this device
* @usb_classdev: USB class device that was created for usbfs device
* access from userspace
* @usbfs_dentry: usbfs dentry entry for the device
* @maxchild: number of ports if hub
* @children: child devices - USB devices that are attached to this hub
* @quirks: quirks of the whole device
* @urbnum: number of URBs submitted for the whole device
* @active_duration: total time device is not suspended
* @connect_time: time device was first connected
* @do_remote_wakeup: remote wakeup should be enabled
* @reset_resume: needs reset instead of resume
* @wusb_dev: if this is a Wireless USB device, link to the WUSB
* specific data for the device.
* @slot_id: Slot ID assigned by xHCI
*
* Notes:
* Usbcore drivers should not set usbdev->state directly. Instead use
* usb_set_device_state().
*/
struct usb_device {
int devnum; /*usb设备在总线上的编号*/
char devpath[16];
u32 route;
enum usb_device_state state;
enum usb_device_speed speed;
struct usb_tt *tt;
int ttport;
unsigned int toggle[2];
struct usb_device *parent;
struct usb_bus *bus;
struct usb_host_endpoint ep0; /*端点0,特殊对待*/
struct device dev;
struct usb_device_descriptor descriptor;
struct usb_host_config *config;/*拥有的所有配置*/
struct usb_host_config *actconfig;/*当前激活的配置*/
struct usb_host_endpoint *ep_in[16];/*全速也最多使用15个端点*/
struct usb_host_endpoint *ep_out[16];
char **rawdescriptors;/*字符指针数组,每一项都指向GET_DESCRIPTOR请求获得配置描述符所得到到结果*/
unsigned short bus_mA;
u8 portnum;
u8 level;
unsigned can_submit:1;
unsigned persist_enabled:1;
unsigned have_langid:1;
unsigned authorized:1;
unsigned authenticated:1;
unsigned wusb:1;
int string_langid;
/* static strings from the device */
char *product;
char *manufacturer;
char *serial;
struct list_head filelist;
#ifdef CONFIG_USB_DEVICE_CLASS
struct device *usb_classdev;
#endif
#ifdef CONFIG_USB_DEVICEFS
struct dentry *usbfs_dentry;
#endif
int maxchild;
struct usb_device *children[USB_MAXCHILDREN];
u32 quirks;
atomic_t urbnum;
unsigned long active_duration;
#ifdef CONFIG_PM
unsigned long connect_time;
unsigned do_remote_wakeup:1;
unsigned reset_resume:1;
#endif
struct wusb_dev *wusb_dev;
int slot_id;
};
在linux内核源码下面还可以找到如下结构体(include/linux/usb.h)
struct usb_device;
struct usb_driver;
struct usb_device_driver;
struct usb_class_driver;
struct urb;
struct usb_sg_request;
int usb_sg_init;
struct usb_host_endpoint;
struct usb_host_interface;
struct usb_interface;
struct usb_interface_cache;
struct usb_host_config;
struct usb_host_bos;
struct usb_devmap;
struct usb_bus;
struct usb2_lpm_parameters;
struct usb3_lpm_parameters;
struct usb_dynids;
struct usb_dynid;
struct usbdrv_wrap;
struct usb_iso_packet_descriptor;
struct usb_anchor;
相关文章推荐
- 第四十六篇:Linux中的USB XHCI HOST TRANSFER RING的相关数据结构 (1)
- linux内核中usb系统主要的数据结构
- 第四十七篇:Linux中的USB XHCI HOST TRANSFER RING的相关数据结构 (2)
- 算法与数据结构之图的相关知识,简单易懂。
- BMP格式相关数据结构
- 数据结构之链表——环相关问题及解决思路汇总
- soot基础 -- 相关数据结构SootClass,SootMethod,SootBody,Unit的进一步说明
- VFS 相关数据结构
- [ext4]空间管理 - 与分配相关的关键数据结构
- usb子系统相关结构体
- 文件相关内核数据结构
- 线性表数据结构类型定义及相关操作总结
- 6.2 相关数据结构及其创建
- 基于OHCI的USB主机 —— UFI数据结构1 推荐
- 数据结构——顺序表的相关操作
- 自己总结的USB数据结构及其描述符
- Linux内核的一种数据结构——task_struct
- Linux2.6内核--VFS层中和进程相关的数据结构
- 位图初级(二)——相关数据结构
- 线性表的相关操作 数据结构实验报告第二个