1f00e21baSJoerg Wunsch.\" 2f00e21baSJoerg Wunsch.\" Copyright (c) 1996 David E. O'Brien, Joerg Wunsch 3f00e21baSJoerg Wunsch.\" 4f00e21baSJoerg Wunsch.\" All rights reserved. 5f00e21baSJoerg Wunsch.\" 6f00e21baSJoerg Wunsch.\" Redistribution and use in source and binary forms, with or without 7f00e21baSJoerg Wunsch.\" modification, are permitted provided that the following conditions 8f00e21baSJoerg Wunsch.\" are met: 9f00e21baSJoerg Wunsch.\" 1. Redistributions of source code must retain the above copyright 10f00e21baSJoerg Wunsch.\" notice, this list of conditions and the following disclaimer. 11f00e21baSJoerg Wunsch.\" 2. Redistributions in binary form must reproduce the above copyright 12f00e21baSJoerg Wunsch.\" notice, this list of conditions and the following disclaimer in the 13f00e21baSJoerg Wunsch.\" documentation and/or other materials provided with the distribution. 14f00e21baSJoerg Wunsch.\" 15f00e21baSJoerg Wunsch.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR 16f00e21baSJoerg Wunsch.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17f00e21baSJoerg Wunsch.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18f00e21baSJoerg Wunsch.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, 19f00e21baSJoerg Wunsch.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20f00e21baSJoerg Wunsch.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21f00e21baSJoerg Wunsch.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22f00e21baSJoerg Wunsch.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23f00e21baSJoerg Wunsch.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24f00e21baSJoerg Wunsch.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25f00e21baSJoerg Wunsch.\" 267f3dea24SPeter Wemm.\" $FreeBSD$ 27f00e21baSJoerg Wunsch.\" 28f00e21baSJoerg Wunsch.Dd January 20, 1996 29f00e21baSJoerg Wunsch.Dt INTRO 4 303d45e180SRuslan Ermilov.Os 31f00e21baSJoerg Wunsch.Sh NAME 32f00e21baSJoerg Wunsch.Nm intro 33f00e21baSJoerg Wunsch.Nd introduction to devices and device drivers 34f00e21baSJoerg Wunsch.Sh DESCRIPTION 354057c9f0SDima DorfmanThis section contains information related to devices, device drivers 36f00e21baSJoerg Wunschand miscellaneous hardware. 37f00e21baSJoerg Wunsch.Ss The device abstraction 38f00e21baSJoerg WunschDevice is a term used mostly for hardware-related stuff that belongs 39f00e21baSJoerg Wunschto the system, like disks, printers, or a graphics display with its 40f00e21baSJoerg Wunschkeyboard. There are also so-called 41f00e21baSJoerg Wunsch.Em pseudo-devices 42f00e21baSJoerg Wunschwhere a device driver emulates the behaviour of a device in software 43f00e21baSJoerg Wunschwithout any particular underlying hardware. A typical example for 44f00e21baSJoerg Wunschthe latter class is 45f00e21baSJoerg Wunsch.Pa /dev/mem , 46f00e21baSJoerg Wunscha loophole where the physical memory can be accessed using the regular 47f00e21baSJoerg Wunschfile access semantics. 48f00e21baSJoerg Wunsch.Pp 49f00e21baSJoerg WunschThe device abstraction generally provides a common set of system calls 50f00e21baSJoerg Wunschlayered on top of them, which are dispatched to the corresponding 51f00e21baSJoerg Wunschdevice driver by the upper layers of the kernel. The set of system 52f00e21baSJoerg Wunschcalls available for devices is chosen from 53f00e21baSJoerg Wunsch.Xr open 2 , 54f00e21baSJoerg Wunsch.Xr close 2 , 55f00e21baSJoerg Wunsch.Xr read 2 , 56f00e21baSJoerg Wunsch.Xr write 2 , 57f00e21baSJoerg Wunsch.Xr ioctl 2 , 58f00e21baSJoerg Wunsch.Xr select 2 , 59f00e21baSJoerg Wunschand 60f00e21baSJoerg Wunsch.Xr mmap 2 . 61f00e21baSJoerg WunschNot all drivers implement all system calls, for example, calling 62f00e21baSJoerg Wunsch.Xr mmap 2 634057c9f0SDima Dorfmanon terminal devices is likely to be not useful at all. 64f00e21baSJoerg Wunsch.Ss Accessing Devices 65faf1a4f7SRuslan ErmilovMost of the devices in a 66faf1a4f7SRuslan Ermilov.Ux Ns 67faf1a4f7SRuslan Ermilov-like operating system are accessed 68f00e21baSJoerg Wunschthrough so-called 69f00e21baSJoerg Wunsch.Em device nodes , 70f00e21baSJoerg Wunschsometimes also called 71f00e21baSJoerg Wunsch.Em special files . 72f00e21baSJoerg WunschThey are usually located under the directory 73f00e21baSJoerg Wunsch.Pa /dev 74f00e21baSJoerg Wunschin the file system hierarchy 75c4d9468eSRuslan Ermilov(see also 76c4d9468eSRuslan Ermilov.Xr hier 7 ) . 77f00e21baSJoerg Wunsch.Pp 78f00e21baSJoerg WunschNote that this could lead to an inconsistent state, where either there 79f00e21baSJoerg Wunschare device nodes that do not have a configured driver associated with 80f00e21baSJoerg Wunschthem, or there may be drivers that have successfully probed for their 81f00e21baSJoerg Wunschdevices, but cannot be accessed since the corresponding device node is 82f00e21baSJoerg Wunschstill missing. In the first case, any attempt to reference the device 83f00e21baSJoerg Wunschthrough the device node will result in an error, returned by the upper 84f00e21baSJoerg Wunschlayers of the kernel, usually 85b92a189eSRuslan Ermilov.Er ENXIO . 86f00e21baSJoerg WunschIn the second case, the device node needs to be created before the 87f00e21baSJoerg Wunschdriver and its device will be usable. 88f00e21baSJoerg Wunsch.Pp 89f00e21baSJoerg WunschSome devices come in two flavors: 90f00e21baSJoerg Wunsch.Em block 91f00e21baSJoerg Wunschand 92f00e21baSJoerg Wunsch.Em character 934057c9f0SDima Dorfmandevices, or to use better terms, buffered and unbuffered 94c4d9468eSRuslan Ermilov(raw) 95f00e21baSJoerg Wunschdevices. The traditional names are reflected by the letters 96f00e21baSJoerg Wunsch.Ql b 97f00e21baSJoerg Wunschand 98f00e21baSJoerg Wunsch.Ql c 99f00e21baSJoerg Wunschas the file type identification in the output of 100f00e21baSJoerg Wunsch.Ql ls -l . 101f00e21baSJoerg WunschBuffered devices are being accessed through the buffer cache of the 102f00e21baSJoerg Wunschoperating system, and they are solely intended to layer a file system 103f00e21baSJoerg Wunschon top of them. They are normally implemented for disks and disk-like 1044057c9f0SDima Dorfmandevices only and, for historical reasons, for tape devices. 105f00e21baSJoerg Wunsch.Pp 106f00e21baSJoerg WunschRaw devices are available for all drivers, including those that also 107f00e21baSJoerg Wunschimplement a buffered device. For the latter group of devices, the 10884a6ebdcSBill Fumeroladifferentiation is conventionally done by prepending the letter 109f00e21baSJoerg Wunsch.Ql r 110f00e21baSJoerg Wunschto the path name of the device node, for example 11193a4ebf3SRobert Nordier.Pa /dev/rda0 112f00e21baSJoerg Wunschdenotes the raw device for the first SCSI disk, while 11393a4ebf3SRobert Nordier.Pa /dev/da0 114f00e21baSJoerg Wunschis the corresponding device node for the buffered device. 115f00e21baSJoerg Wunsch.Pp 116f00e21baSJoerg WunschUnbuffered devices should be used for all actions that are not related 117f00e21baSJoerg Wunschto file system operations, even if the device in question is a disk 118f00e21baSJoerg Wunschdevice. This includes making backups of entire disk partitions, or 119f00e21baSJoerg Wunschto 120f00e21baSJoerg Wunsch.Em raw 121f00e21baSJoerg Wunschfloppy disks 122c4d9468eSRuslan Ermilov(i.e. those used like tapes). 123f00e21baSJoerg Wunsch.Pp 1244057c9f0SDima DorfmanAccess restrictions to device nodes are usually subject to the regular 1254057c9f0SDima Dorfmanfile permissions of the device node entry, instead of being enforced 126f00e21baSJoerg Wunschdirectly by the drivers in the kernel. 127f00e21baSJoerg Wunsch.Ss Drivers without device nodes 128f00e21baSJoerg WunschDrivers for network devices do not use device nodes in order to be 129f00e21baSJoerg Wunschaccessed. Their selection is based on other decisions inside the 130f00e21baSJoerg Wunschkernel, and instead of calling 131f00e21baSJoerg Wunsch.Xr open 2 , 132f00e21baSJoerg Wunschuse of a network device is generally introduced by using the system 133f00e21baSJoerg Wunschcall 134f00e21baSJoerg Wunsch.Xr socket 2 . 135f00e21baSJoerg Wunsch.Ss Configuring a driver into the kernel 136f00e21baSJoerg WunschFor each kernel, there is a configuration file that is used as a base 137f00e21baSJoerg Wunschto select the facilities and drivers for that kernel, and to tune 138f00e21baSJoerg Wunschseveral options. See 139f00e21baSJoerg Wunsch.Xr config 8 140f00e21baSJoerg Wunschfor a detailed description of the files involved. The individual 141f00e21baSJoerg Wunschmanual pages in this section provide a sample line for the 142f00e21baSJoerg Wunschconfiguration file in their synopsis portion. See also the sample 143f00e21baSJoerg Wunschconfig file 144f00e21baSJoerg Wunsch.Pa /sys/i386/conf/LINT 145c4d9468eSRuslan Ermilov(for the 146f00e21baSJoerg Wunsch.Em i386 147c4d9468eSRuslan Ermilovarchitecture). 148f00e21baSJoerg Wunsch.Sh SEE ALSO 149f00e21baSJoerg Wunsch.Xr close 2 , 150f00e21baSJoerg Wunsch.Xr ioctl 2 , 151f00e21baSJoerg Wunsch.Xr mmap 2 , 1520b992c1dSWolfram Schneider.Xr open 2 , 1530b992c1dSWolfram Schneider.Xr read 2 , 1540b992c1dSWolfram Schneider.Xr select 2 , 155f00e21baSJoerg Wunsch.Xr socket 2 , 1560b992c1dSWolfram Schneider.Xr write 2 , 1574e11acf8SMike Pritchard.Xr devfs 5 , 158f00e21baSJoerg Wunsch.Xr hier 7 , 159494a5dabSGiorgos Keramidas.Xr config 8 160f00e21baSJoerg Wunsch.Sh AUTHORS 161f4d874a1SRuslan Ermilov.An -nosplit 162f00e21baSJoerg WunschThis man page has been written by 163726b61abSRuslan Ermilov.An J\(:org Wunsch 164aaf1f16eSPhilippe Charnierwith initial input by 165aaf1f16eSPhilippe Charnier.An David E. O'Brien . 166f00e21baSJoerg Wunsch.Sh HISTORY 167aaf1f16eSPhilippe Charnier.Nm Intro 168400d45a3SMike Pritchardappeared in 169400d45a3SMike Pritchard.Fx 2.1 . 170