B Kernel Reconfiguration





This appendix explains how to add the Serial Parallel Controller device driver to your system kernel. This method of configuring your device driver is an alternative to loading your device driver as explained in Chapter 3 of this book. Before performing the following instructions, make sure you first run the installation script to install the device driver on your system. At the question Run the configuration script? [yes] type n and press the Return key. Follow the instructions explained in this appendix.

Incorrectly reconfiguring your system kernel can make your system inoperable. Only a trained system administrator or other technical personnel with kernel reconfiguration experience should follow these instructions.

Summary

To add the Serial Parallel Controller device driver to your system kernel, complete the following steps explained in this appendix:

The System Kernel

The system kernel is the heart of your SunOS Operating System, and is configured to meet the needs of most users. You can reconfigure the system kernel to make your device driver part of the kernel. This procedure assumes that your system has a kernel on its local disk. For information about reconfiguring other types of kernels, see System & Network Administration.

Creating a New Configuration File

The first step in reconfiguring your system kernel is to create a new kernel configuration file to provide the system software support you require. Since it is easier to use an existing kernel configuration file than to create a new file, you can:

    1. Locate your current or generic kernel configuration file.
    2. Copy this existing file.
    3. Change the copied file.
    4. Change your kernel files.

To locate your current kernel configuration file, type arch -k to determine the kernel architecture name.

Since the kernel architecture name is sun4c, the kernel configuration file is stored in the /usr/share/sys/sun4c/conf directory.

If you do not know which kernel configuration file was used to build your current kernel, look for the generic kernel configuration file appropriate to the kernel architecture of your system. The name of the generic kernel configuration file is GENERIC.

For example, /usr/share/sys/sun4c/conf/GENERIC is the generic kernel configuration file for a SPARC desktop system.

To copy your current kernel configuration file:
    1. Type su to become superuser and press the Return key. Then type your superuser password and press the Return key.
    2. Type cd, a space, the name of the directory where the kernel configuration file is located, and press the Return key.
    3. Copy the existing kernel configuration file to a new file name. Type cp, a space, and the following arguments, separated by spaces:
    4. Press the Return key.

    The old kernel configuration file can be the GENERIC kernel configuration file shipped with your system. Or, if you have renamed the kernel configuration file, use that kernel configuration file name.

    For example:

To change your new kernel configuration file:
    1. Edit the new kernel configuration file using vi or another text editor of your choice.
    2. Add the device driver information to the new kernel configuration file.

    The information you need to add is listed in the following example. To add a comment to the kernel configuration file, type a pound character (#) at the beginning of the line containing the comment.

    The following example creates a new kernel configuration file named /usr/share/sys/sun4c/conf/MYKERNEL based on the /usr/share/sys/sun4c/conf/GENERIC generic kernel configuration file, and adds an entry for the device driver.

    3. Save the file and quit the editor.

Adding the Driver to the New Configuration File

Your Serial Parallel Controller device driver, like all new device drivers, requires an entry in the following kernel files:

To change your kernel files:
    1. As superuser, type cd /usr/share/sys/sun4c/conf and press the Return key.
    2. Type vi files and press the Return key.

    3. Add the line sbusdev/stc.c optional stc device-driver to the files file as in the following example:

    4. Save the file and quit the editor.
    5. Type chmod +w /sys/sun/conf.c and press the Return key.
    6. Type vi /sys/sun/conf.c and press the Return key.

    7. Add the following lines to the /sys/sun/conf.c file:

    8. Determine the major number for the new device by finding the major number of the last entry in the cdevsw table and using the next number.

    In the following example, the last number used is 103; so 104 is used as the major number for the new card. Your major number might be different.

Remember the major number and to which device it is assigned. You will need this information to create the device files later in this chapter.
    9. Add the following lines to the end of the struct cdevsw definition to define the new cdevsw elements:
You do not need separate entries for each card installed in your system. Only one entry is needed for n cards, where n is the number of cards you install into your system.

    10. Save the file and quit the editor.

Building the New System Kernel

After copying and modifying the kernel, build a new kernel from your new kernel configuration file.

To build a system kernel from the new kernel configuration file:

    1. As superuser, type cd /usr/share/sys/sun4c/conf at the # prompt.
    2. Type config and the name of your new kernel configuration file, and press the Return key.

    The system displays the message:

    Doing a "make depend"

    3. Type cp /usr/sys/unbundled/stc/stc.o, a space, /sys/sun4c/OBJ/stc.o and press the Return key.
    4. Type cd ../, no space, the name of the new kernel configuration file you specified as an argument to the config command, and press the Return key.
    5. Type make and press the Return key.

    The system displays kernel build messages.

    This example builds a kernel on a SPARC desktop system using a new kernel configuration file named /usr/share/sys/sun4c/conf/ MYKERNEL:

If you receive error messages, resolve the errors and repeat the foregoing instructions. Do not use a faulty kernel to run your system.

Installing the New System Kernel

This section explains how to install your new kernel, so that your system will use it when you boot.

Before moving your new kernel, save a copy of the old kernel. You can run your system using the old kernel if your new kernel does not work correctly.

To install your new system kernel:

    1. As superuser, type cd /usr/sys/unbundled/stc and press the Return key.
    2. Type the ./stc_config -c and press the Return key.

    This removes old Serial Parallel Controller device driver files and device entries, if present.

    3. Type mv /vmunix /vmunix.old and press the Return key.

    This saves a copy of the current kernel file.

    4. Type cp, a space, the name of the new kernel file, a space, /vmunix, and press the Return key.
    5. Type halt and press the Return key.
    6. Type b and press the Return key.

    The system boots using the new kernel. For more information about booting your system, see Sun System & Network Manager's Guide.

This example installs and boots a kernel named /usr/share/sys/sun4c/MYKERNEL/vmunix:

Creating Device Files

This section explains how to create device files.

    1. As superuser, type cd /usr/sys/unbundled/stc and press the Return key.
    2. Type ./stc_config -M# -m and press the Return key.

    Replace # with the major number of your Serial Parallel Controller device driver, determined earlier in this appendix. For example, if the major number of your device driver is 104, type ./stc_config -M104 -m and press the Return key.

Restoring the Old Kernel

If your system does not boot correctly with the new kernel, you can restore your old kernel by following the instructions in this section. If you are upgrading to a new release of the Serial Parallel Controller card or no longer wish to use it, you can also follow these instructions to remove your Serial Parallel Controller device driver from your system.

To restore your old kernel, you must be superuser. As superuser, boot the old kernel in single-user mode, move the old kernel back to /vmunix, and reboot your system. The system should now function as it did before you reconfigured your kernel. The following example boots with the old kernel, moves the old kernel back to /vmunix and reboots the system:

After rebooting your system with the old kernel and logging in, remove the Serial Parallel Controller device driver files and device entries from your system.

To remove the device driver from your system:

    1. As superuser, type cd /usr/sys/unbundled/stc and press the Return key.
    2. Type ./stc_config -c and press the Return key.

    This removes the Serial Parallel Controller device driver from your system.

    3. Undo changes made to any system files to reflect the removal of your device driver.

For more information about reconfiguring your kernel, see the SunOS Reference Manual or the config(8) Man Page. Also see your Sun System & Network Manager's Guide.