Specifications

D
evice Driver Programming
15-4
Installing a Driver for Testing 15
Many of the steps that follow require you to modify files and directories owned by root.
You must therefore be logged in as root or execute with the appropriate privileges to
develop and debug device drivers.
1. First of all, it would be a good idea to make a copy of your current UNIX
operating system kernel before reconfiguring the system. The backup is
made automatically by the idbuild command saving the kernel as
/stand/unix.old (if there is enough disk space), but it is still a good
idea to have a “pre-driver test” backup kernel, because the second and sub-
sequent executions of idbuild overwrites the previously saved
/stand/unix.old.
2. Create the required Master and System files (these are described in
Chapter 14 (“Driver Installation and Tuning”)), and put them along with
your Driver.o device driver module into the /tmp directory.
3. You can also create the Mtune, Node and other optional DSP component
files if needed. However, if possible, you should test your driver first in as
simple an environment as possible.
4. Change directory (cd)to/tmp, and use the idinstall -a command
to install the new driver.
5. Use the idbuild command (with the appropriate options, depending on
whether or not your device driver is to be loadable or static) to rebuild the
UNIX system kernel.
6. If you get errors, correct them and repeat the above step. If the kernel built
correctly, a new UNIX system image is created. Running shutdown -i0
or init 6 causes the system to be automatically copied to
/stand/unix. On the next boot, the new kernel executes, and upon
entering init state 2, the new device nodes, inittab entries, and so
on, is installed.
When the system comes up, test your driver.
Emergency Recovery (New Kernel Does Not Boot) 15
There is a possibility that the kernel fails to boot if your driver contains a serious bug. This
can be due to a cmn_err(D3) call with CE_PANIC that you put in your driver, or some
other system problem. If this happens, you should reset your system and boot your origi-
nal kernel that you, hopefully, saved as recommended above. To do this, reset your
machine, and use the p boot 1.” console processor command to select the “request
unix name option during boot. When the boot prompt displays, type the name of a
backup copy of the kernel (for example, /stand/unix.old). If this fails or you have
not saved a copy of the kernel, type unix.generic. This is a default unix.kernel that is
installed with the system. It should be present unless it has been removed.