This contains links to information used in the lectures.
Device drivers are parts of the Unix kernel that manage interaction with particular types of hardware. The device driver translates device independant kernel directives to device dependant hardware commands. In 1980s each device had an interface board and a custom driver, which had to be compiled into the kernel. This has simplified as follows:
probe attach open close read reset stop select strategy dump psize write timeout process a transmit interrupt process a receive interrupt ioctlThe addresses of these are stored in jump tables in the kernel indexed by major device number (usually one for character devices and one for block). The kernel uses the jump table to determine the device specific function to transfer control to. For operations, such as floppy ejection, which have no analogues in the general filesystem model, the ioctl call is used to pass the message dircetly to the device.
HP-UX 9.XX /etc/master /etc/conf/dfile HP-UX 10.XX /usr/conf/master.d/* /stand/system SunOS (Nimitz) /usr/share/sys/sun4m/conf/KERNEL /usr/share/sys/sun4m/conf/filesKERNEL is GENERIC, GENERIC_SMALL, DLmodel, SDSTmodel, etc. On SunOS do man config, and on HP-UX, man config, man master and man uxgen.
Field 1 Device name, used in the user-specified dfile (8
characters maximum).
Field 2 Handler name, used by the kernel to prefix
routines such as cs80_read, lp_write, and others
(8 characters maximum).
Field 3 Element characteristics: Five bits make up the
mask
Bit 1: card
Bit 2: specified only once
Bit 3: required driver
Bit 4: block device
Bit 5: character device (LSB)
Field 4 Functions for the device; 12 bits make up the mask
Bit 1 option1 handler (Series 700 only)
Bit 2 dump handler
Bit 3 size handler
Bit 4 link routine
Bit 5 open handler
Bit 6 close handler
Bit 7 read handler
Bit 8 write handler
Bit 9 ioctl handler
Bit 10 select handler
Bit 11 seltru handler
Bit 12 C_ALLCLOSES flag (LSB)
Field 5 Major device number if a block-type device;
otherwise -1.
Field 6 Major device number if a character-type device;
otherwise -1.
Note that bit 1 is the most significant bit.
If the device does not exist in the kernel configuration file dfile, it is not compiled into the kernel.
After the predefined device there are a number of entries reserved for third party use.
** Reserved for Third Party and User Drivers. * --- - - -1 38 * --- - - -1 39 * --- - - -1 40 * --- - - -1 41 * --- - - -1 42 * --- - - -1 43 * --- - - 8 -1 * --- - - 15 -1 * --- - - 16 -1 * --- - - 17 -1 * --- - - 18 -1Later library dependencies are defined in a driver/library table. This table defines which libraries a given driver depends on. If the driver is included in the dfile, then the libraries that driver depends on will be included on the ld(1) command line. Only optional libraries *need* to be specified in this table, (but required ones can be included, as well).
* Driver handleNote that if one is adding a compiled driver, one must create a library from the .o file by using ar and then copy it to the /etc/conf. One must also add the device name to the dfile in /etc/conf.* * subsystems first netware libnetware.a uipc libuipc.a nipc libuipc.a libnipc.a libinet.a nit libnit.a libnet.a inet libinet.a libnet.a ni libnet.a libinet.a
Device files are created using mknod:
mknod name type major minor
Some systems such as SunOS supply a script MAKEDEV in /dev to automatically supply default values to mknod.
crw-r----- 1 root sys 47 0x201000 Dec 1 1993 /dev/rdsk/c201d0s0 crw-r----- 1 root sys 47 0x201100 Apr 2 1993 /dev/rdsk/c201d1s0 brw-r----- 1 root sys 7 0x201000 Dec 1 1993 /dev/dsk/c201d0s0 brw-r----- 1 root sys 7 0x201100 Apr 2 1993 /dev/dsk/c201d1s0 crw-r----- 1 root 17, 8 Feb 18 1994 /dev/rsd1a crw-r----- 1 root 17, 9 Nov 5 1992 /dev/rsd1b brw-r----- 1 root 7, 8 Nov 5 1992 /dev/sd1a brw-r----- 1 root 7, 9 Nov 5 1992 /dev/sd1bwhere the format is /dev/dsk/c201dNsP and /dev/sdNP, where N is unit and P the partition respectively.
Serial device usually have the form /dev/tty followed by a sequence of letter which identify the port it is attached to:
crw-rw-rw- 2 root other 17 0x000020 Apr 2 1993 /dev/ttyr0 crw-rw-rw- 2 root other 17 0x000021 Apr 2 1993 /dev/ttyr1Can be more than one device per physical port.
In SunOS modstat lists modules and modload and modunload load and unload them. To use loadable modules VDDRV must be included in the kernel configuration file and /dev/vd must exist.
In Solaris, most devices are loadable modules. modinfo lists modules, add_drv adds a driver, and rem_drv removes one. modload and modunload load and unload modules not accessed through device files.