Device driver model found in Unix and Linux is a natural partitioning of functionality between application code and hardware or kernel devices related code. It isolates user's application from directly access to critical kernel data structure and hardware devices. It hides the operation details of particular hardwares. And a loadable device driver ease the embedded system development and field updates/upgrades.
Note: When we talk about device drivers, loadable kernel module (LKM), loadable module, and module, we usually refer to the same thing, a loadable kernel device driver module.
Device driver is running in the kernel space. It could be statically compiled into the kernel. This is done by selecting the specific driver when we configure the kernel in the build process. For example, if we want a system to boot from a NFS root system, we have to compile the network-related drivers such as TCP/IP, ethernet driver into the kernel image, so that they are available during system boot from a remote root file system.
In many cases device drivers are loadable modules. They are compiled into seperate binaries files (against the kernel on which it will be running), and can be installed/uninstalled after the kernel has booted. They can be loaded by startup scripts, can be "demand loaded" when needed, or can be loaded manually by user space commands.
The following are the mostly used commands:
lsmod ---> list the modules that are inserted into the kernel
insmod ---> insert a module into a running kernel, it takes the module's file name.
rmmod ---> removes a module from a running kernel
modprobe ---> most powerful tool, load/unload a module, togather with dependent modules, etc.
There are a few files that are working togather with loadable modules. They are:
/etc/modprobe.conf ---> configuration file for modprobe. It enables a system developer to associate devices with device drivers. For simple embedded system, modprobe.conf might be empty or might contains very few lines. The modprobe utility is compiled with a set of default rules that establish the defaults in the absence of a valid modprobe.conf.
../modules.dep ---> in the same location where modules are installed. It contains a list of all the modules that the kernel build system is configured for, along with dependency info for each. It's used by modprobe to decide dependencies.
No comments:
Post a Comment