Next | Prev | Up | Top | Contents | Index

Including a Device Driver in the Kernel

The lboot utility allows you to link device drivers to the kernel. It requires the following files, all of which must reside under the /var/sysgen directory:

boot

This file is a symbolic link to the directory /usr/cpu/sysgen/IPxxboot, where xx represents the CPU type. This directory contains all the device driver object files and archives. When your driver is successfully compiled, you must copy it to the /usr/cpu/sysgen/IPxxboot directory. The name of your driver must end with an ".o" suffix (or with ".a" if it is a library). See "CPU Types" for a listing of MIPS CPUs and their IP numbers.

Note: For successful compilation, IRIX 5.x drivers require the -coff option; IRIX 6.0 drivers cannot use the -coff option.

master

This file contains information that lboot uses to create the device switch table, as well as to indicate dependencies among other kernel modules. Each driver must have a master file stored in the /var/sysgen/master.d directory. The name of the master file must be the same as the software module. Among other things, the master file contains the major device number for the device-special file. It also contains a prefix used to build the driver entry points. For more information, see the master(4) man page.

mtune

This directory contains information on the external system tunable parameters of the driver module, including default values and valid value ranges. For more information, see the mtune(4) man page.

system

This directory contains files with directives that tell lboot whether to:

  1. Include a driver module.

  2. Conditionally include a driver module.

  3. Exclude a driver module.
For each driver, you must create a system file in the directory /var/sysgen/system. The restriction on filenames is that they must end in .sm in order for lboot to recognize and process them. See the system(4) man page for more information.

Chapter 3, "Writing a VME Device Driver," Chapter 4, "Writing an EISA Device Driver," Chapter 5, "Writing a SCSI Device Driver," and Chapter 6, "Writing Kernel-level GIO Device Drivers," provide details on the syntax of these files.

When these files are present under /var/sysgen, you can create a kernel that includes the new driver. To create a new kernel:

  1. Become root.

  2. Copy the current kernel to a safe place before rebooting.[6]

    # cp /unix /unix.orig

  3. Create the new kernel, /unix.install, by running:

    # /etc/autoconfig -f

    (Use the -v option during debugging.)

  4. Reboot the system. When you issue the reboot command, the system removes the current kernel and renames unix.install, the kernel you have just created, to /unix:

    # reboot

Note: If you include a just-written and undebugged device driver, create a debuggable kernel. See "Making a Debuggable Kernel" in Chapter 10 for more information. It is also useful in this case to examine the generated file /var/sysgen/master.c to confirm that the entries for your new driver are correct.


[6] You can save disk space by using the ln command instead of cp; However, when you reboot, unix.install gets copied to unix, thus wiping out the old kernel if it is linked. Use ln to save space, use cp for reliability.

Next | Prev | Up | Top | Contents | Index