Writing Device Drivers


The /etc/system file serves several purposes, but for driver development, the most important is that it allows you to set the value of kernel variables at boot time. This can be used to toggle different behaviors in a driver, or to enable certain debugging features made available by the kernel.

/etc/system is read only once, while the kernel is booting. After this file is modified, the system must be rebooted for the changes to take effect. If a change in the file causes the system not to work, boot with the ask (-a) option and specify /dev/null as the system file.

The set command is used to change the value of module or kernel variables:

See system(4) for more information.

Note -

Most kernel variables are not guaranteed to be present in subsequent releases.


moddebug is a kernel variable that controls the module loading process. The possible values are:


Prints messages to the console when loading or unloading modules 


Gives more detailed error messages 


Prints more detail when loading or unloading (such as including the address and size) 


No auto-unloading drivers: the system will not attempt to unload the device driver when the system resources become low 


No auto-unloading streams: the system will not attempt to unload the streams module when the system resources become low 


No auto-unloading of kernel modules of any type 


If running with kadb, moddebug causes a breakpoint to be executed and a return to kadb immediately before each module's _init(9E) routine is called. Also generates additional debug messages when the module's _info and _fini routines are executed.


kmem_flags is a kernel variable used to enable debugging features in the kernel's memory allocator. Setting kmem_flags to 0xf enables the allocator's debugging features. These include runtime checks to find:

The "Debugging With the Kernel Memory Allocator" in the Solaris Modular Debugger Guide describes how the kernel memory allocator can be used to determine the root cause of these problems.

Note -

Testing and developing with kmem_flags set to 0xf is extremely valuable since it can detect latent memory corruption bugs. Because setting kmem_flags to 0xf changes the internal behavior of the kernel memory allocator, it remains important to thoroughly test without kmem_flags as well.