intro(7) intro(7)NAME intro - introduction to device drivers and interfaces DESCRIPTION The entries in this section provide useful information for users and programmers, although programmers may be able to benefit more. Users need to know what device files are typically associat- ed with which devices or ports so that the commands that ac- cept device files as arguments can be specified accurately. For example, /dev/tty0 and /dev/tty1 refer to serial ports, and /dev/dsk/c0d0s0 through /dev/dsk/c7d0s0 refer to slice 0 of each of the hard disks set to SCSI ID 0 through 7. To rebuild or make custom-named device files, users need to know what major device numbers correspond to particular dev- ice drivers, as well as the operational or addressing modes selected by the minor device numbers associated with a par- ticular device driver. Note that the A/UX autoconfiguration utilities automatically create and remove device files (with default filenames) whenever necessary for a particular dev- ice configuration they are establishing (see autoconfig(1M), newconfig(1M), and newunix(1M)). This section also includes information helpful to readers who wish to manipulate a device directly through its corresponding interface. For example, you can format a car- tridge tape through the general mt device interface to tape devices. These device-level interfaces allow access to device-specific functions, such as cartridge tape format- ting, that would not normally be available as a standard operation for all tape devices. Non-universal operations typically would not be available through the flag options for the standard programs, such as tar and cpio, described in Section 1 of A/UX Command Reference. Programmers who wish to write programs that can access all the peculiarities of specific devices may find the standard I/O library lacking the necessary capabilities. If you need to know this information, Section 7 describes the special system calls, or ioctls, associated with particular device drivers. The device files identified with the letter ``P'' following the section number are part of the A/UX POSIX environment. The differences between the A/UX environment and the A/UX POSIX environment are described in A/UX Guide to POSIX, which is provided in A/UX Programming Languages and Tools, Volume 1. April, 1990 1
intro(7) intro(7)User interface Although a programmer knows that each device is controlled by a designated device driver, this fact is usually less well known to users. Because a disk device is selected and accessed properly whenever files are manipulated, users are sheltered from learning about the requirements of the disk device driver. However, for devices other than disk dev- ices, there are often various addressing options or operat- ing modes that require awareness from users. While the pro- visions of the file system helps users transparently access the correct disk device for read and write operations, other devices require a more visible, low-level interface. To provide a flexible way to access to these device-level and interface-level features, A/UX stretches the file-system model to encompass references to devices other than disks. The file-system files that reference a device (or communca- tions port) are called device files. Device files are spe- cial because the data written to them does not usually re- side on the disk. For example, the device file for a termi- nal (/dev/console) stays a constant size when data is writ- ten to it. In such a case, the data is not written to a disk file at all. Instead, the data is written to the actual dev- ice that the device file references. When initially created, the device file is given two un- changeable attributes that no other files have: a major device number that selects a device driver, and a minor dev- ice number that selects a particular device out of several possible devices, or a particular operating mode from among several operating modes. The meaning of the minor device number varies from device driver to device driver. Select- ing reading or writing operations for a device is usually a function of the command line within which the device filename appears: sometimes the command itself works uni- directionally (restore, dump.bsd, finc); other times the command is bidirectional and the direction of data flow is determined by flag options or associated arguments (tar, pax, cpio, dd). Device files are available for use only within certain com- mand lines. Usually, but not always, commands that accept device file as arguments have metanames such as device-file or devname within their syntax descriptions. The device filenames are customarily derived from the hardware configuration. However, some of the device filenames are seemingly arbitrary for various historical reasons. Sometimes a device file references a port rather than an ac- tual device. For example, a printer connected through the 2 April, 1990
intro(7) intro(7)printer port can be referenced as /dev/tty1, as described in serial(7). In this case, the device file references the first serial port. Conventionally, you can use the first Ma- cintosh serial port to attach a serial printer. It is also possible to attach a modem or an A/UX user terminal to this port. Major and minor device numbers Programs that support devices, such as hard disks and tape drives, are known as device drivers. One device driver usu- ally controls all the instances of one type of device. The exception is the serial device driver. It provides low- level support for a variety devices that are capable of com- municating over a serial communications port. For example, a serial device driver helps control user terminals, modems, serial printers, and similar serial input/output devices. To allow many devices of the same type to be controlled by the same device driver, each can be assigned a unique minor number using mknod(1M). This number is passed to the device driver for interpretation. By convention, the minor number may appear as the last part of the name of the device file for particular classes of devices. For example, /dev/tty0 refers to the first serial port, or the port with minor dev- ice number 0. Note that this is a naming convention only, and is achieved by using mknod. In reality, device selec- tion is realized through the minor number exclusively. The -l option of ls will show what major and minor device numbers have been assigned to a device file of a particular name, helping you verify whether a device file was named reasonably well. The minor number is often used by a device driver as an ini- dication of the intended operational modes. For example, the device files for cartridge tape drives that contain an n suffix select a non-rewinding mode of tape operation through a minor number that is correctly interpreted by the device driver. April, 1990 3