Managing and Developing Dynamically Loadable Kernel Modules
Managing and Developing Dynamically Loadable Kernel Modules
Developing Dynamically Loadable Kernel Modules
Chapter 12552
aware that a subsequent kmupdate(1M) will again overwrite the
vmunix.prev kernel.
The recommended way to permanently save /stand/vmunix is to move it
to a safe name, such as /stand/vmunix.bkup.
Do Not Copy!: Copying the /stand/vmunix file may result in the
eventual loss of the kernel component set necessary to boot the copy.
Furthermore, if /stand/vmunix had been the running kernel, we
recommend an immediate reboot from the renamed location:
#mv /stand/vmunix /stand/vmunix.bkup
#shutdown -r
Once /stand/vmunix has been moved, there is no longer a default kernel
from which to boot until a new kernel is configured and updated via the
kmupdate(1M) command. To boot from a non-default kernel, refer to
“Booting from an Alternate Kernel” in the chapter “Administering a
System: Booting and Shutdown” in Managing Systems and Workgroups.
Creating the Module’s Component Files
Create the mod.o, master, system, space.h (optional), and Modstub.o
(optional) files for the DLKM module in a single directory. It is suggested
that you use a subdirectory of /usr/conf such as /usr/conf/
module_name
.
When choosing a name for your module, choose a unique name to avoid
conflict with kernel functions and global variables. Consider using your
company’s name and something that indicates the module’s purpose.
To compile your module source code, use the ANSI C compiler /opt/
ansic/bin/cc and the compiler options shown below. You can also use
the compiler options found in the makefile /stand/build/config.mk or
/stand/build/config.mod.
To compile your module source code, follow these steps:
1. Change directories to the directory containing the module’s
component files.
2. For a 64-bit PA target machine, execute the following cc (1) command:
/opt/ansic/bin/cc -I. -I/usr/conf -I/usr/conf/sys \
-Wp,-H300000 +Hx0 +R500 +ESsfc +ESssf +XixdU \
+ES1.Xindirect_calls +ESlit +O2 +Oentrysched +Ofastaccess \