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.\" 26aaf1f16eSPhilippe Charnier.\" $Id: intro.4,v 1.9 1997/09/29 10:10:14 wosch Exp $ 27f00e21baSJoerg Wunsch.\" 28f00e21baSJoerg Wunsch.Dd January 20, 1996 29f00e21baSJoerg Wunsch.Dt INTRO 4 30f00e21baSJoerg Wunsch.Os FreeBSD 2.1 31f00e21baSJoerg Wunsch.Sh NAME 32f00e21baSJoerg Wunsch.Nm intro 33f00e21baSJoerg Wunsch.Nd introduction to devices and device drivers 34f00e21baSJoerg Wunsch.Sh DESCRIPTION 35f00e21baSJoerg WunschThis section contains information related to devices, device driver 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 63f00e21baSJoerg Wunschon a terminal devices is likely to be not useful at all. 64f00e21baSJoerg Wunsch.Ss Accessing Devices 65f00e21baSJoerg WunschMost of the devices in a unix-like operating system are accessed 66f00e21baSJoerg Wunschthrough so-called 67f00e21baSJoerg Wunsch.Em device nodes , 68f00e21baSJoerg Wunschsometimes also called 69f00e21baSJoerg Wunsch.Em special files . 70f00e21baSJoerg WunschThey are usually located under the directory 71f00e21baSJoerg Wunsch.Pa /dev 72f00e21baSJoerg Wunschin the file system hierarchy 73f00e21baSJoerg Wunsch.Pq see also Xr hier 7 . 74f00e21baSJoerg Wunsch.Pp 75f00e21baSJoerg WunschUntil 76f00e21baSJoerg Wunsch.Xr devfs 5 77f00e21baSJoerg Wunschis fully functional, each device node must be created statically and 78f00e21baSJoerg Wunschindependently of the existence of the associated device driver, 79f00e21baSJoerg Wunschusually by running 80f00e21baSJoerg Wunsch.Xr MAKEDEV 8 . 81f00e21baSJoerg Wunsch.Pp 82f00e21baSJoerg WunschNote that this could lead to an inconsistent state, where either there 83f00e21baSJoerg Wunschare device nodes that do not have a configured driver associated with 84f00e21baSJoerg Wunschthem, or there may be drivers that have successfully probed for their 85f00e21baSJoerg Wunschdevices, but cannot be accessed since the corresponding device node is 86f00e21baSJoerg Wunschstill missing. In the first case, any attempt to reference the device 87f00e21baSJoerg Wunschthrough the device node will result in an error, returned by the upper 88f00e21baSJoerg Wunschlayers of the kernel, usually 89f00e21baSJoerg Wunsch.Ql ENXIO . 90f00e21baSJoerg WunschIn the second case, the device node needs to be created before the 91f00e21baSJoerg Wunschdriver and its device will be usable. 92f00e21baSJoerg Wunsch.Pp 93f00e21baSJoerg WunschSome devices come in two flavors: 94f00e21baSJoerg Wunsch.Em block 95f00e21baSJoerg Wunschand 96f00e21baSJoerg Wunsch.Em character 97f00e21baSJoerg Wunschdevices, or by a better name, buffered and unbuffered 98f00e21baSJoerg Wunsch.Pq raw 99f00e21baSJoerg Wunschdevices. The traditional names are reflected by the letters 100f00e21baSJoerg Wunsch.Ql b 101f00e21baSJoerg Wunschand 102f00e21baSJoerg Wunsch.Ql c 103f00e21baSJoerg Wunschas the file type identification in the output of 104f00e21baSJoerg Wunsch.Ql ls -l . 105f00e21baSJoerg WunschBuffered devices are being accessed through the buffer cache of the 106f00e21baSJoerg Wunschoperating system, and they are solely intended to layer a file system 107f00e21baSJoerg Wunschon top of them. They are normally implemented for disks and disk-like 108f00e21baSJoerg Wunschdevices only, for historical reasons also for tape devices. 109f00e21baSJoerg Wunsch.Pp 110f00e21baSJoerg WunschRaw devices are available for all drivers, including those that also 111f00e21baSJoerg Wunschimplement a buffered device. For the latter group of devices, the 112f00e21baSJoerg Wunschdifferentiation is conventionally done by prepending the latter 113f00e21baSJoerg Wunsch.Ql r 114f00e21baSJoerg Wunschto the path name of the device node, for example 115f00e21baSJoerg Wunsch.Pa /dev/rsd0 116f00e21baSJoerg Wunschdenotes the raw device for the first SCSI disk, while 117f00e21baSJoerg Wunsch.Pa /dev/sd0 118f00e21baSJoerg Wunschis the corresponding device node for the buffered device. 119f00e21baSJoerg Wunsch.Pp 120f00e21baSJoerg WunschUnbuffered devices should be used for all actions that are not related 121f00e21baSJoerg Wunschto file system operations, even if the device in question is a disk 122f00e21baSJoerg Wunschdevice. This includes making backups of entire disk partitions, or 123f00e21baSJoerg Wunschto 124f00e21baSJoerg Wunsch.Em raw 125f00e21baSJoerg Wunschfloppy disks 126f00e21baSJoerg Wunsch.Pq i.e. those used like tapes . 127f00e21baSJoerg Wunsch.Pp 128f00e21baSJoerg WunschAccess restrictions to device nodes are usually subject of the regular 129f00e21baSJoerg Wunschfile permissions of the device node entry, instead of being implied 130f00e21baSJoerg Wunschdirectly by the drivers in the kernel. 131f00e21baSJoerg Wunsch.Ss Drivers without device nodes 132f00e21baSJoerg WunschDrivers for network devices do not use device nodes in order to be 133f00e21baSJoerg Wunschaccessed. Their selection is based on other decisions inside the 134f00e21baSJoerg Wunschkernel, and instead of calling 135f00e21baSJoerg Wunsch.Xr open 2 , 136f00e21baSJoerg Wunschuse of a network device is generally introduced by using the system 137f00e21baSJoerg Wunschcall 138f00e21baSJoerg Wunsch.Xr socket 2 . 139f00e21baSJoerg Wunsch.Ss Configuring a driver into the kernel 140f00e21baSJoerg WunschFor each kernel, there is a configuration file that is used as a base 141f00e21baSJoerg Wunschto select the facilities and drivers for that kernel, and to tune 142f00e21baSJoerg Wunschseveral options. See 143f00e21baSJoerg Wunsch.Xr config 8 144f00e21baSJoerg Wunschfor a detailed description of the files involved. The individual 145f00e21baSJoerg Wunschmanual pages in this section provide a sample line for the 146f00e21baSJoerg Wunschconfiguration file in their synopsis portion. See also the sample 147f00e21baSJoerg Wunschconfig file 148f00e21baSJoerg Wunsch.Pa /sys/i386/conf/LINT 149f00e21baSJoerg Wunsch.Po 150f00e21baSJoerg Wunschfor the 151f00e21baSJoerg Wunsch.Em i386 152f00e21baSJoerg Wunscharchitecture 153f00e21baSJoerg Wunsch.Pc . 154f00e21baSJoerg Wunsch.Sh SEE ALSO 155f00e21baSJoerg Wunsch.Xr close 2 , 156f00e21baSJoerg Wunsch.Xr ioctl 2 , 157f00e21baSJoerg Wunsch.Xr mmap 2 , 1580b992c1dSWolfram Schneider.Xr open 2 , 1590b992c1dSWolfram Schneider.Xr read 2 , 1600b992c1dSWolfram Schneider.Xr select 2 , 161f00e21baSJoerg Wunsch.Xr socket 2 , 1620b992c1dSWolfram Schneider.Xr write 2 , 1634e11acf8SMike Pritchard.Xr devfs 5 , 164f00e21baSJoerg Wunsch.Xr hier 7 , 165bceb8aedSWolfram Schneider.Xr config 8 , 166bceb8aedSWolfram Schneider.Xr MAKEDEV 8 167f00e21baSJoerg Wunsch.Sh AUTHORS 168f00e21baSJoerg WunschThis man page has been written by 169f00e21baSJoerg Wunsch.if t J\(:org Wunsch 170f00e21baSJoerg Wunsch.if n Joerg Wunsch 171aaf1f16eSPhilippe Charnierwith initial input by 172aaf1f16eSPhilippe Charnier.An David E. O'Brien . 173f00e21baSJoerg Wunsch.Sh HISTORY 174aaf1f16eSPhilippe Charnier.Nm Intro 175400d45a3SMike Pritchardappeared in 176400d45a3SMike Pritchard.Fx 2.1 . 177