| usblog ( @ 2004-11-16 16:02:00 |
Linux USB SubSystem (1)
Hello,
This blog is soleley dedicated for USB susbsystem and Video4Linux applications
and drivers.
The posting in this blog are taken from
http://www.livejournal.com/users/rr x.
(I am rrx and I an researching the Linux USB susbsystem with
empasis on Video4Linux).
I intend to add postings here regarding this
issues quite soon. Stay tuned.
These postings will appear here and also in
http://www.livejournal.com/users/rr x.
However , http://www.livejournal.com/users/rr x is
a general blog , and it d
deals also with other matters (mainly Linux programming,kernel,gcc,
and other goodies).
There are 2 reasons for that:
1) To dedicate one blog for this issue.
2) To ease finding it using search engines.
I hope linux community will find this blog helpful
and enjoy it.
You are invited to comment / question / remark.
the following post is from Sunday, November 14th, 2004:
Linux USB SubSystem (1) :
usb_init()
The following text is based on 2.67 kernel.
So what do we have in the usb initialization?
Let's have a look at usb_init() in inode.c (/drivers/usb/core/usb.c):
We call 6 initialization routines: only 3 of them are
part of the sub subsystem.
1) bus_register(&usb_bus_type);
The bus_register() method is not a part of the USB subsystem.
It's a general bus method ; it's implementation is in /drivers/base/bus.c.
2)usb_host_init(); calls class_register(); again ,this is not a part of the
USB subsystem. It's implementation is in /drivers/base/class.c
3)usb_major_init();
This calls register_chre_dev(); The MAJOR number of USB is 180.
and also devfs_mk_dir("usb") and class_register().
All entries under /dev/usb have major number 180 (except
/dev/ttyUSB* , which have major number 188).
the call to class_register() is relatively new (It did not exist
in 2.4 kernel). We should not be surprised; Greg Kroach Hartman, which
is the maintainer of usb subsystem, is also deeply involved
in the new device model (see for example his
talk in OLS2004 kobjects and krefs - Lockless Reference Counting for Kernel
Structure
(http://www.kroah.com/linux/talks/ols_2 004_kref_talk)
4) usbfs_init(); usually, in most distros , the usbfs (which is
also called usbdevfs) , is mounted under /proc/bus.
(Needless to say: This of course can be changed by issuing umount and then mount
on a different mounting point,or changing /etc/fstab).
This is a filesystem which resembles in some ways ordinary file systems
like etxt3 or xfs; what I mean is that you call register_filesystem()
(in /drivers/usb/core/inode.c) in order to register the filesystem.
And you pass a pointer to file_system_type.
The usbfs is responsible for creating and updating the devices file
(/proc/bus/usb/devices).
The devices file is updated dynamically; if you insert a webcam , (or any other
USB device), and run cat /proc/bus/usb/devices , you will find that some
configuration entries were added to the devices file.If you will remove the
webcam and run cat /proc/bus/usb/devices, you will find that these devices were
removed from the devices file.
Creating the devices file is done, eventually,by calling regular
filesystem methods (like d_instantiate() and dget () from dcache.c).
More on it in the future.
5) usb_hub_init(): creates a kernel daemon thread named khubd.
(implenentation in /drivers/usb/core/hub.c).
The khubd thread is responsible for configuring devices.
More on it in the future.
6) driver_register();
This method is again not a part of the
USB subsystem. It's implementation is in /drivers/base/driver.c
Cheers,
USBLOG
Hello,
This blog is soleley dedicated for USB susbsystem and Video4Linux applications
and drivers.
The posting in this blog are taken from
http://www.livejournal.com/users/rr
(I am rrx and I an researching the Linux USB susbsystem with
empasis on Video4Linux).
I intend to add postings here regarding this
issues quite soon. Stay tuned.
These postings will appear here and also in
http://www.livejournal.com/users/rr
However , http://www.livejournal.com/users/rr
a general blog , and it d
deals also with other matters (mainly Linux programming,kernel,gcc,
and other goodies).
There are 2 reasons for that:
1) To dedicate one blog for this issue.
2) To ease finding it using search engines.
I hope linux community will find this blog helpful
and enjoy it.
You are invited to comment / question / remark.
the following post is from Sunday, November 14th, 2004:
Linux USB SubSystem (1) :
usb_init()
The following text is based on 2.67 kernel.
So what do we have in the usb initialization?
Let's have a look at usb_init() in inode.c (/drivers/usb/core/usb.c):
We call 6 initialization routines: only 3 of them are
part of the sub subsystem.
1) bus_register(&usb_bus_type);
The bus_register() method is not a part of the USB subsystem.
It's a general bus method ; it's implementation is in /drivers/base/bus.c.
2)usb_host_init(); calls class_register(); again ,this is not a part of the
USB subsystem. It's implementation is in /drivers/base/class.c
3)usb_major_init();
This calls register_chre_dev(); The MAJOR number of USB is 180.
and also devfs_mk_dir("usb") and class_register().
All entries under /dev/usb have major number 180 (except
/dev/ttyUSB* , which have major number 188).
the call to class_register() is relatively new (It did not exist
in 2.4 kernel). We should not be surprised; Greg Kroach Hartman, which
is the maintainer of usb subsystem, is also deeply involved
in the new device model (see for example his
talk in OLS2004 kobjects and krefs - Lockless Reference Counting for Kernel
Structure
(http://www.kroah.com/linux/talks/ols_2
4) usbfs_init(); usually, in most distros , the usbfs (which is
also called usbdevfs) , is mounted under /proc/bus.
(Needless to say: This of course can be changed by issuing umount and then mount
on a different mounting point,or changing /etc/fstab).
This is a filesystem which resembles in some ways ordinary file systems
like etxt3 or xfs; what I mean is that you call register_filesystem()
(in /drivers/usb/core/inode.c) in order to register the filesystem.
And you pass a pointer to file_system_type.
The usbfs is responsible for creating and updating the devices file
(/proc/bus/usb/devices).
The devices file is updated dynamically; if you insert a webcam , (or any other
USB device), and run cat /proc/bus/usb/devices , you will find that some
configuration entries were added to the devices file.If you will remove the
webcam and run cat /proc/bus/usb/devices, you will find that these devices were
removed from the devices file.
Creating the devices file is done, eventually,by calling regular
filesystem methods (like d_instantiate() and dget () from dcache.c).
More on it in the future.
5) usb_hub_init(): creates a kernel daemon thread named khubd.
(implenentation in /drivers/usb/core/hub.c).
The khubd thread is responsible for configuring devices.
More on it in the future.
6) driver_register();
This method is again not a part of the
USB subsystem. It's implementation is in /drivers/base/driver.c
Cheers,
USBLOG