USB device is recognized process "go"

Source: Internet
Author: User

Transferred from: http://blog.csdn.net/myarrow/article/details/8286876

USB module includes USB Core,host,hub,device driver, where hub will start a kernel thread name: KHUBD (Hub_events has been querying (the hub uses interrupt transfer), when the USB device is connected to a port on the hub, The hub detects that a device is connected, the hub calls the Hub_port_status function to get the hub port status, and if there is a device, the call to the Hub_port_connect_change function calls USB_ALLOC_ The dev function assigns a struct Usb_device structure object to the device and initializes it, which sets the state of the USB device to attached and calls the Usb_set_device_state function to set the state of the device to Usb_state_ Powered power on the state, and then reset the device, after the successful reset, the device will enter the default state (this state can receive HCD response);

Then the device should enter the address state, first call hub_set_address set address state needs to send usb_control_msg function to set, in usb_control_msg inside called Usb_internal_ Control_msg function, the main function of this function is to create a control URB, and send it to the USB device, and then wait for it to complete, this process includes (Usb_alloc_urb, Usb_fill_control_urb, Usb_start_ WAIT_URB) These three function calls, after the end, call Usb_hcd_submit_urb will URB sent to HCD,HCD each received URB, it will be added to this URB designated Urb_list, form the list, now into the HCD module (slightly), After processing, will return a state, and finally usb_api_blocking_completion will deal with this URB finishing work, if the success of the device is formally entered the address state;

Next the device to enter the Configer state, this process needs to get the configuration Usb_get_device_descriptor->usb_get_descriptor first to get the Wtotallength field in the configuration descriptor, Then through the wtotallength length, get the configuration information, and then the obtained configuration resolved out processing (this process is more cumbersome), configured to call the Usb_new_device instructions later found the device driver;

Then tell the world (Announce_device) that the device has been found, and finally call the device model provided by the interface Device_add add the device to the USB bus device list, then the USB bus will traverse each driver in the drive list, call its own The match (usb_device_match) function looks at whether they match your device or interface, calls the Device_bind_driver function if it matches, and now controls the power to the device driver.

The function call flow is as follows:

Usb_hub_init (Kthread_run (Hub_thread, NULL, "KHUBD"))
Hub_thread->
Hub_events->
Hub_port_connect_change->
Usb_new_device->
Usb_enumerate_device (Udev); /* Read descriptors */
Announce_device (Udev); /* Tell the world! */
Device_add
Usb_create_ep_devs

USB device is recognized process "go"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.