Writing Device Drivers

ProcedureTo Boot With an Alternate Kernel

To avoid rendering a system inoperable, you should boot from a copy of the kernel and associated binaries rather than from the default kernel.

  1. Make a copy of the drivers in /platform/*.


    # cp -r /platform/`uname -i`/kernel /platform/`uname -i`/kernel.test
    
  2. Place the driver module in /platform/`uname -i`/kernel.test/drv.

  3. Boot the alternate kernel instead of the default kernel.

    After you have created and stored the alternate kernel, you can boot this kernel in a number of ways.

    • You can boot the alternate kernel by rebooting:


      # reboot -- kernel.test/unix
      
    • On a SPARC-based system, you can also boot from the PROM:


      ok boot kernel.test/sparcv9/unix
      

      Note –

      To boot with the kmdb debugger, use the -k option as described in Getting Started With the Modular Debugger.


    • On an x86-based system, when the Select (b)oot or (i)nterpreter: message is displayed in the boot process, type the following:


      boot kernel.test/unix
      

Example 22–4 Booting an Alternate Kernel

The following example demonstrates booting with an alternate kernel.


ok boot kernel.test/sparcv9/unix
Rebooting with command: boot kernel.test/sparcv9/unix
Boot device: /sbus@1f,0/espdma@e,8400000/esp@e,8800000/sd@0,0:a File and \
    args:
kernel.test/sparcv9/unix


Example 22–5 Booting an Alternate Kernel With the -a Option

Alternatively, the module path can be changed by booting with the ask (-a) option. This option results in a series of prompts for configuring the boot method.


ok boot -a
Rebooting with command: boot -a
Boot device: /sbus@1f,0/espdma@e,8400000/esp@e,8800000/sd@0,0:a File and \
args: -a
Enter filename [kernel/sparcv9/unix]: kernel.test/sparcv9/unix
Enter default directory for modules
[/platform/sun4u/kernel.test /kernel /usr/kernel]: <CR>
Name of system file [etc/system]: <CR>
SunOS Release 5.10 Version Generic 64-bit
Copyright 1983-2002 Sun Microsystems, Inc. All rights reserved.
root filesystem type [ufs]: <CR>
Enter physical name of root device
[/sbus@1f,0/espdma@e,8400000/esp@e,8800000/sd@0,0:a]: <CR>