Managing and Developing Dynamically Loadable Kernel Modules

Managing and Developing Dynamically Loadable Kernel Modules
Developing Dynamically Loadable Kernel Modules
Chapter 12 555
Also, set the following bit values in the flags field in the drv_info_t
structure: if you have a block driver, set the DRV_BLOCK value; if you
have a character driver set the DRV_CHAR value; if your driver is both
a block and a character driver, set both values.
Note that this step applies only to statically configured modules. The
drv_info_t structure in driver source is ignored for dynamic
configuration.
To create device special files for your driver, follow these steps:
1. Use the lsdev (1M) command to identify the major number assigned
to the device driver. lsdev lists all device drivers configured into the
kernel and their block and character major numbers.
To extract the block major number from the display for a driver
named mydriver, execute the following command:
/usr/sbin/lsdev -h -d mydriver | awk ’{print $2}’
To extract the character major number from the display for a driver
named mydriver, execute the following command:
/usr/sbin/lsdev -h -d mydriver | awk ’{print $1}’
As an alternative and assuming a dynamically loadable driver, you
can execute the following two commands to identify the major
number assigned to a driver named mydriver:
/usr/sbin/kmadmin -L mydriver
/usr/sbin/kmadmin -Q mydriver
2. Construct a minor number for each device special file that you create
for the driver. See Appendix C, “Major and Minor Numbers,” in the
Configuring HP-UX For Peripherals document for more information
about bit assignments and dev_t.
3. Use the mknod command to create the device special files for the
driver.
In the example below, mydriver was dynamically assigned the block
and character major numbers 65 and 234, respectively. Its minor
number, 0x026000, is constructed like that of instr0 (bits 8 through
15 encode 2 as the instance of the interface card, and bits 16 through
19 encode 6 of the device’s address).
/usr/sbin/mknod /dev/mydriver b 65 0x026000
/usr/sbin/mknod /dev/mydriver c 234 0x026000