Re: How does OS recognise a driver for a device.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>        I have a very simple question . How does 
> Linux know that it has to load driver 'x' for
> device 'y'.

 It doesn't :)

 Drivers can either be built into the kernel or
built as loadable modules. Drivers that are part 
of the kernel are initialized early in the boot
sequence - even if there are no devices that a
driver can support (kernel doesn't know). The
driver has to check if it can support any of the
devices on the system. This can be done through
bus specific interfaces (like PCI) or some other
device specific way. If it finds one or more devices,
it initializes them and registers itself with the
kernel.

 If the driver is configured as a module, it can
be loaded manually (insmod or modprobe) or 
automatically when needed. Again, in the first case,
kernel doesn't have to know what devices are supported
by the driver. The driver claims the devices that it
can manage.

The second case is slightly different.
When a user program tries to access a device (usually
thorugh the device file in /dev) but no corresponding
driver is registered, the kernel tries to load a
driver module. Of course, the kernel does not know
the actual driver name. So it uses generic names
like 'eth0', 'char-major-135' or 'scsi_hostadapter'.
The mapping between these names and actual module
names is provided in a file (/etc/modules.conf or
something similar). Once the module is loaded, it
initializes the usual way and claims the devices that
it can manage.

Hope this helps,
Ravi.


__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux