首页 文章

Linux USB Enumeration和uevents

提问于
浏览
1

我在http://www.technovelty.org/code/linux/plugging-in-usb.html读了一篇文章 . 它非常好 .

在哪个函数中,连接设备的枚举是由主机完成的,并且在哪个函数中发送了uevent?

我在usb_new_device等函数中引入了printks,如果我使用“udevadm monitor --kernel”,它甚至在hub.c中的usb_new_device中调用的枚举函数之前显示内核事件?

记录如下

[110.819399] 123456 hub_irq

[110.824952] 123456 hub_port_connect_change

[110.979624] 123456 hub_port_init

[111.059625] usb 2-1.2:使用fsl-ehci和地址3的新型高速USB设备

[111.189722] 123456 usb_new_device

[111.196219] usb 2-1.2:找到新的USB设备,idVendor = 05ac,idProduct = 12a0

[111.203113] usb 2-1.2:新的USB设备字符串:Mfr = 1,Product = 2,SerialNumber = 3

[111.210438] usb 2-1.2:产品:iPhone

[111.214196] usb 2-1.2:制造商:Apple Inc.

[111.218728] usb 2-1.2:SerialNumber:9356b662a93170509226069e5adf53f2351d774e

KERNEL [110.940183]添加/devices/platform/fsl-ehci.1/usb2/2-1/2-1.2(usb)

检查时间戳虽然udevadm输出结束(udevadm在用户空间运行),但它的实际操作在[110.940183]获得了事件,其中usb_new_device被调用[111.189722]

1 回答

  • 3

    我几乎是Linux内核的文盲,所以不是100%肯定这个信息..但是设法在http://www.cs.fsu.edu/~baker/devices/lxr/http/find?v=2.6.11.8的帮助下追踪USB初始化

    这是USB主机代码的流程(如果这是错误请纠正我),在Linux 2.6.11.8内核上

    usb_init()     // invoked in ../core/usb.c it initializes host, major, usbfs and usb_hub 
    usb_hub_init() // in core/hub.c it creates a kernel thread hub_thread()
    hub_thread()   // in core/hub.c
    hub_events()   // next this if called 
    hub_port_connect_change() // then this..
    

相关问题