COHERENT manpages
This page displays the COHERENT manpage for device drivers [Overview].
List of available manpages
Index
device drivers -- Overview A device driver is a program that controls the action of one of the physical devices attached to your computer system. The following table lists the device drivers included with the COHERENT system. The first field gives the device's major device number; the second gives its name; and the third describes it. If a major number does not appear in this table, that number is available for a driver yet to be written. 0: clock System clock 0: cmos System CMOS 0: freemem Amount of memory that is free at any given moment 0: idle System idle time 0: kmem Device to manage kernel memory 0: kmemhi 0: mem Interface to memory and null device 0: null The ``bit bucket'' 0: ps Processes currently being executed 1: ct Controlling terminal device (/dev/tty) 2: console Video module for console (/dev/console) 2: vtkb Non-configurable keyboard driver, virtual consoles 2: vtnkb Configurable keyboard driver, virtual consoles 2: mm The video driver 3: lp Parallel line printer 4: fd Floppy-disk drive 4: fdc 765 diskette and floppy-tape controller 4: ft Floppy-tape drive 5: asy Serial driver 6: tr Trace driver 8: rm Dual RAM disk 9: pty Pseudoterminals 11: at AT hard disk 13: hai Host adapter-independent SCSI driver 14: cdu31 Sony CD-ROM drives 16: mcd Mitsumi CD-ROM drives Please note that the devices with major number 0 are not portable, and non- DDI/DKI. Also note that in future releases of COHERENT, the hai driver will be divided into several optional SCSI host-bus adapters (HBAs) and target devices. It is not unusual for one major number to admit several driver service modules. Instances of this include the following major numbers: 0 This number is for a number of system-dependent drivers. 2 This number supports the console, both its keyboard modules and its video modules. 4 This describes varieties of floppy-disk and floppy-tape controllers and drives. 13 This describes a number of SCSI host modules, HBA modules, and target modules. Major and Minor Numbers COHERENT uses a system of major and minor device numbers to manage devices and drivers. In theory, COHERENT assigns a unique major number to each type of device, and a unique minor number to each instance of that type. In practice, however, a major number describes a device driver (rather than a device per se). The individual devices serviced by that driver are identified by a minor number. Sometimes, certain parts of the minor number specify configuration. For example, bits 0 through 6 of the minor number for COHERENT RAM disks indicate the size of the allocated device. Optional Kernel Components The kernel also contains the following optional components: em87 Emulate hardware floating-point routines msg Perform System V-style message operations sem Perform System V-style semaphore operations shm Perform System V-style shared-memory operations streams Perform STREAMS operations These components resemble device drivers, in that that they perform discreet work and can be linked into or excluded from the kernel, as shown below. However, they do not perform I/O with a device, and so are not true drivers. For details on these modules, see their entries in the Lexicon. Configuring Drivers and the Kernel Beginning with release 4.2, COHERENT lets you tune kernel and driver variables, enable or disable drivers, and easily build a new bootable kernel that incorporates your changes. The command idenable lets you enable or disable a driver within the kernel. The command idtune lets you set a user-modifiable variable within the kernel. Finally, the command idmkcoh generates a new kernel that incorporates all changes you have made with the other three commands. Changes are entered with idenable and idtune do not take effect until you invoke idmkcoh to generate a new kernel, and boot the new kernel. Scripts /etc/conf/*/mkdev simpify the choices of idenable and idtune during installation and reconfiguration: they invoke idtune and idenable For details, see these commands' entries in the Lexicon. Adding a New Device Driver The commands described above make it easy for you to add a new device driver to your COHERENT kernel. The following walks you through the processing of adding a new driver. We will add the driver foo, which enables the popular ``widget'' device. Please note that this example has the user modify the files mtune and stune by hand. It is not a good idea for you to do this; however, we describe how to do this to show how these files fit into the process of building a new kernel: 1. To begin, log in as the superuser root. 2. The next step is to create a directory to hold the driver's sources and object. Every driver must have its own directory under directory /etc/conf; and the sources must be held in directory src in that driver's directory. In this case, create directory /etc/conf/foo; then create directory /et/conf/foo/src. 3. Copy the sources for the driver into its source directory; in this case, copy them into /etc/conf/foo/src. 4. Create a Makefile in your driver's source directory, e.g., /etc/conf/foo/src/makefile. The easiest way to see what is required is to review several of the driver Makefiles shipped in the COHERENT driver kit. You can perform a test compilation of your driver by running make with the driver's src directory as the current directory. This should create one object file that has the suffix .o. Copy this file in the driver's home directory, and name it Driver.o. In this case, the object for the driver should be in file /etc/conf/foo/Driver.o. In some rare cases, a driver compile into more than one object. You should store all of these objects into one archive; name the archive Driver.a and store it in the driver's home directory. The COHERENT commands that build the new kernel know how to handle archives correctly. The main idea is that files Space.c (if one exists) and Driver.o or Driver.a be placed in the driver directory, i.e., the parent of the src directory. 5. Add an entry to file /etc/conf/sdevice for this driver. sdevice, as described above, names the drivers to be included in the kernel. The entries for practically every entry are identical; you need to note only that the second column marks whether to include the driver in the kernel. In this case, the entry for the driver foo should read as follows: foo Y 0 0 0 0 0x0 0x0 0x00x0 For details on what each column means, read the comments in file /etc/conf/sdevice. 6. Add an entry to file /etc/conf/mdevice for the new driver. This file is a little more complex than sdevice; in particular, it distinguishes between STREAMS-style drivers and ``old-style'' COHERENT drivers. In most cases, you can simply copy an entry for an existing driver of the same type, and modify it slightly. In this case, the entry for foo should read as follows: # full func misc code block char minor minor dma cpu # name flags flags prefix major major min max chan id foo - CGo foo 15 15 0 255 -1 -1 In almost every case, the full name and the code prefix are identical. The code prefix also names the directory that holds the driver's object. Function flags are always always a hyphen, and miscellaneous flags almost always CGo. The block-major and character-major numbers again are almost always identical. The major number is usually assigned by the creator of the device driver. In future releases of the kernel, these will be assigned dynamically by the kernel itself; poorly written drivers that depend upon the driver having a magic major-device number will no longer work. Finally, the last four columns for non-STREAMS drivers are almost always 0, 255, -1, and -1, respectively. See the comments in file /etc/conf/mdevice. 7. If the driver has tunable variables, these should be set in the file Space.c, which should be stored in the driver's home directory. As it happens, foo does not need a Space.c file. For examples of such files, look in the various sub-directories of /etc/conf. 8. Type the command idmkcoh to build a new kernel. If necessary, move the new kernel into the root directory; you cannot boot it until it is in the root directory. 9. Save the old kernel and link the newly build kernel to /autoboot. You want save the old kernel, just in case the new one doesn't work. For directions on how to boot a kernel other than /autoboot, see the Lexicon entry for booting. 10. Back up your files! With a new driver in your kernel, it's best to play it safe. 11. Reboot your system to invoke the new kernel. If all goes well, you will now be enjoying the services of the new device driver. For scripts on how to add or remove individual drivers from your kernel, see the article of the driver in question. See Also Administering COHERENT, asy, at, boot, console, ct, em87, floppy disk, hard disk, idle, kernel, lp, mboot, mdevice, mem, msg, mtune, null, pty, sdevice, sem, sgtty, shm, STREAMS, stty, stune, tape, termio Notes Note that in future releases of COHERENT, major numbers will not be static, as they are in the above table. Rather, they will be assigned by the config script when you install COHERENT onto your system. This scheme will allow more flexible arrangements of drivers, and will also allow COHERENT to support more than 32 drivers at once. If you write code to work with device drivers, you should not make any assumptions about a given driver's major or minor number. See the Release Notes for your release of COHERENT for a full list of supported devices and device drivers. Source code for almost all COHERENT device drivers is published in the COHERENT Device-Driver Kit. The only except is the source for ft, which includes proprietary information from manufacturers. Experienced writers of device drivers will find the driver kit a good tool for writing or importing drivers for devices that COHERENT does not yet support.