2012-07-12 197 views
1

我阅读文章http://www.technovelty.org/code/linux/plugging-in-usb.html。它非常好。Linux USB枚举和事件

在哪个函数中,连接设备的枚举完全由主机完成,并且函数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:新的高速USB设备使用fsl-ehci和地址3

[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,产品= 2,的SerialNumber = 3

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

[111.214196] USB 2-1.2:制造商:苹果公司

[111.218728] USB 2-1.2:的SerialNumber:9356b662a93170509226069e5adf53f2351d774e

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

检查时间戳虽然udevadm出来放在最后(udevadm运行在用户空间)它真的得到的事件在[110.940183],因为usb_new_device被调用在[111.189722]

回答

3

我几乎Linux内核文盲,的http://www.cs.fsu.edu/~baker/devices/lxr/http/find?v=2.6.11.8

这里帮助的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.. 
+0

感谢StormeHawke格式化它,我仍然是新手。 – Abhyuth 2013-09-30 21:28:33