Linux usb_device usb_bus usb_driver的三角关系-USB Bus

一、USB Device

1. struct device:

The Basic Device Structure, generic device interface(所有设备的抽象) -struct bus_type*bus; /* type of bus device is on */ -struct device_driver *driver; /* which driver has allocated this device */

2. struct usb_device:

kernel’s representation of a USB device (它包含struct device,USB设备)

-struct device dev; /*generic device interface*/

-struct usb_device_descriptor descriptor; /* USB device descriptor */ -struct usb_bus *bus; /* bus we’re part of*/ -struct usb_host_endpoint ep0; /* endpoint 0 data (default control pipe)*/

-struct usb_host_config *config; /* all of the device’s configs */ -struct usb_host_config *actconfig; /* the active configuration */ -struct usb_host_endpoint *ep_in[16]; /* array of IN endpoints */ -struct usb_host_endpoint *ep_out[16]; /* array of OUT endpoints */

3. struct usb_host_config

representation of a device’s configuration

/* array of pointers to usb_interface structures,one for eachinterface in the configuration.These pointers are valid only while thethe configuration is active.*/

-struct usb_interface *interface[USB_MAXINTERFACES];

/* array of pointers to usb_interface_cache structures, onefor each interface in theconfiguration. These structures existfor the entirelife of the device. Interface information availableeven when this isnotactiveconfiguration*/

-struct usb_interface_cache *intf_cache[USB_MAXINTERFACES];

4. struct usb_interface

what usb device drivers talk to

/* array of alternate settings for this interface, stored in no particular order. one for each alternate setting that may be selected. Each one includes a set of endpoint configurations.*/-struct usb_host_interface *altsetting;-struct usb_host_interface *cur_altsetting;/* the currently

5. struct usb_host_interfacehost-side wrapper for one interface setting’s parsed descriptors-struct usb_interface_descriptordesc;/* array of desc.bNumEndpoint endpoints associated with this interface setting. these will be in no particular order.*/-struct usb_host_endpoint *endpoint;

6. struct usb_host_endpoint

host-side endpoint descriptor and queue

/* descriptor for this endpoint, e.g.: wMaxPacketSize */

-struct usb_endpoint_descriptordesc;

/*urbs queued to this endpoint; maintained by usbcore*/-struct list_headurb_list;

/* for use by HCD; typically holds hardware dma queue head (QH)*/-void*hcpriv;

/* ep_device for sysfs info*/

-struct ep_device *ep_dev;

7. usb_alloc_dev

usb device constructor (usbcore-internal)struct usb_device *usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port1)

@parent: hub to which device is connected; null to allocate a root hub @bus: bus used to access the device @port1: one-based index of port; ignored for root hubs

二、USB Bus

每一条USB总线对应一个struct usb_bus结构体变量.

struct bus_type usb_bus_type = {.name ="usb",.match =usb_device_match,.uevent =usb_uevent,.pm =&usb_bus_pm_ops,};

struct bus_type表示总线的类型,而usb_bus_type定义了一种usb总线类型,通过bus_register(&usb_bus_type)让系统知道有usb这么一个类型的总线。

而一个总线类型和一条总线是两码子事儿。从硬件上来讲,一个host controller就会连出一条usb总线,而从软件上来讲,不管你有多少个host controller,或者说有多少条总线,它们通通属于usb_bus_type这么一个类型,只是每一条总线对应一个struct usb_bus结构体变量,这个变量在host controller的驱动程序中去申请。

HCD is bus. struct usb_hcd包含一个struct usb_bus.

寂寞时,想想我的影子,我会在远方给你一个微笑;难过时,

Linux usb_device usb_bus usb_driver的三角关系-USB Bus

相关文章:

你感兴趣的文章:

标签云: