Brute Force Building Drivers into the Kernel

One approach to loading drivers is to build them into the main Linux kernel file. When so configured, Linux should load the driver and detect the hardware when the system boots. In most cases, no other configuration is required for basic hardware functionality, although you may need to configure user software to take advantage of the hardware. For instance, you may need to add entries to /etc/fstab in order to use partitions on a SCSI hard disk, or you may need to tell your system its IP address and related information in order to use an Ethernet card.

To build a driver into the kernel, you must recompile the kernel. Chapter 15 describes kernel configuration in more detail. If the driver isn't part of the standard kernel, you must patch the kernel source code to include a new driver. Drivers that are designed to be used in this way come with instructions for performing this operation. Some drivers aren't designed to be so included, so you must compile and use them as modules.

On rare occasions, it's necessary to pass parameters to a driver for it to work correctly. This is most likely to be necessary when using old ISA cards, which sometimes aren't auto-detected by the kernel, especially if they're configured using unusual hardware settings. To pass parameters for drivers that are compiled into the main kernel file, you must modify your boot loader. The procedure for doing so depends on which boot loader you're using:

LILO If you're using the older Linux Loader (LILO) boot loader, you can add an append line to the configuration for your Linux kernel in lilo.conf. This line looks something like append="0,0x240,ethO".

GRUB If you're using the Grand Unified Bootloader (GRUB), add the parameters to the end of the kernel line in the grub.conf file. For instance, this line might read kernel /boot/bzlmage ro root=/dev/hda6 0,0x240,ethO.

The details of what you can pass to the kernel vary from one device to another, so you should consult the driver's documentation for details. These specific examples tell Linux to use I/O port 0x240 for the first Ethernet card. After you've compiled a new kernel, modified the configuration file, and in the case of LILO, reinstalled the boot loader by typing lilo, you must reboot your computer in order to use the new kernel and pass it the new parameters. The tedium of doing this can be a problem if you need to experiment with settings, which is one of the reasons that kernel modules are popular—you can load and unload kernel modules at will without rebooting the computer.

0 0

Post a comment