1.\" 2.\" Copyright (c) 1996 David E. O'Brien, Joerg Wunsch 3.\" 4.\" All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 15.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR 16.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, 19.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25.\" 26.\" $FreeBSD: src/share/man/man4/intro.4,v 1.13.2.6 2002/01/09 15:36:51 ru Exp $ 27.\" 28.Dd June 20, 2015 29.Dt INTRO 4 30.Os 31.Sh NAME 32.Nm intro 33.Nd introduction to devices and device drivers 34.Sh DESCRIPTION 35This section contains information related to devices, device drivers 36and miscellaneous hardware. 37.Ss The device abstraction 38Device is a term used mostly for hardware-related stuff that belongs 39to the system, like disks, printers, or a graphics display with its 40keyboard. 41There are also so-called 42.Em pseudo-devices 43where a device driver emulates the behaviour of a device in software 44without any particular underlying hardware. 45A typical example for 46the latter class is 47.Pa /dev/mem , 48a loophole where the physical memory can be accessed using the regular 49file access semantics. 50.Pp 51The device abstraction generally provides a common set of system calls 52layered on top of them, which are dispatched to the corresponding 53device driver by the upper layers of the kernel. 54The set of system 55calls available for devices is chosen from 56.Xr open 2 , 57.Xr close 2 , 58.Xr read 2 , 59.Xr write 2 , 60.Xr ioctl 2 , 61.Xr select 2 , 62and 63.Xr mmap 2 . 64Not all drivers implement all system calls, for example, calling 65.Xr mmap 2 66on terminal devices is likely to be not useful at all. 67.Ss Accessing Devices 68Most of the devices in a unix-like operating system are accessed 69through so-called 70.Em device nodes , 71sometimes also called 72.Em special files . 73They are usually located under the directory 74.Pa /dev 75in the file system hierarchy 76(see also 77.Xr hier 7 ) . 78.Pp 79Some devices come in two flavors: 80.Em block 81and 82.Em character 83devices, or to use better terms, buffered and unbuffered 84(raw) 85devices. 86The traditional names are reflected by the letters 87.Ql b 88and 89.Ql c 90as the file type identification in the output of 91.Ql ls -l . 92Buffered devices are being accessed through the buffer cache of the 93operating system, and they are solely intended to layer a file system 94on top of them. 95They are normally implemented for disks and disk-like 96devices only and, for historical reasons, for tape devices. 97.Pp 98Raw devices are available for all drivers, including those that also 99implement a buffered device. 100For the latter group of devices, the 101differentiation is conventionally done by prepending the letter 102.Ql r 103to the path name of the device node, for example 104.Pa /dev/rda0 105denotes the raw device for the first SCSI disk, while 106.Pa /dev/da0 107is the corresponding device node for the buffered device. 108.Pp 109Unbuffered devices should be used for all actions that are not related 110to file system operations, even if the device in question is a disk 111device. 112This includes making backups of entire disk partitions, or 113to 114.Em raw 115floppy disks 116(i.e. those used like tapes). 117.Pp 118Access restrictions to device nodes are usually subject to the regular 119file permissions of the device node entry, instead of being enforced 120directly by the drivers in the kernel. 121.Ss Drivers without device nodes 122Drivers for network devices do not use device nodes in order to be 123accessed. 124Their selection is based on other decisions inside the 125kernel, and instead of calling 126.Xr open 2 , 127use of a network device is generally introduced by using the system 128call 129.Xr socket 2 . 130.Ss Configuring a driver into the kernel 131For each kernel, there is a configuration file that is used as a base 132to select the facilities and drivers for that kernel, and to tune 133several options. 134See 135.Xr config 8 136for a detailed description of the files involved. 137The individual manual pages in this section provide a sample line for the 138configuration file in their synopsis portion. See also the sample 139config file 140.Pa /sys/config/LINT64 141(for the 142.Em x86_64 143architecture). 144.Sh SEE ALSO 145.Xr close 2 , 146.Xr ioctl 2 , 147.Xr mmap 2 , 148.Xr open 2 , 149.Xr read 2 , 150.Xr select 2 , 151.Xr socket 2 , 152.Xr write 2 , 153.Xr hier 7 , 154.Xr config 8 155.Sh HISTORY 156The 157.Nm 158manual page first appeared in 159.Fx 2.1 . 160.Sh AUTHORS 161.An -nosplit 162This man page was written by 163.An J\(:org Wunsch 164with initial input by 165.An David E. O'Brien . 166