2 .\" Copyright (c) 1996 David E. O'Brien, Joerg Wunsch
3 .\" Copyright (c) 2019 Andrew Gierth
5 .\" All rights reserved.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\" notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\" notice, this list of conditions and the following disclaimer in the
14 .\" documentation and/or other materials provided with the distribution.
16 .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
17 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 .Nd introduction to devices and device drivers
34 This section contains information related to devices, device drivers
35 and miscellaneous hardware.
36 .Ss The device abstraction
37 Device is a term used mostly for hardware-related stuff that belongs
38 to the system, like disks, printers, or a graphics display with its
40 There are also so-called
42 where a device driver emulates the behaviour of a device in software
43 without any particular underlying hardware.
47 a mechanism whereby the physical memory can be accessed using file
50 The device abstraction generally provides a common set of system
51 calls, which are dispatched to the corresponding device driver by the
52 upper layers of the kernel.
53 The set of system calls available for devices is chosen from
62 Not all drivers implement all system calls; for example, calling
64 on a keyboard device is not likely to be useful.
66 Aspects of the device abstraction have changed significantly in
68 over the past two decades.
71 describes some of the more important differences.
73 Most of the devices in
79 They are located within instances of the
81 filesystem, which is conventionally mounted on the directory
83 in the file system hierarchy
89 filesystem creates or removes device nodes automatically according to
90 the physical hardware recognized as present at any given time.
91 For pseudo-devices, device nodes may be created and removed dynamically
92 as required, depending on the nature of the device.
94 Access restrictions to device nodes are usually subject to the regular
95 file permissions of the device node entry, instead of being enforced
96 directly by the drivers in the kernel.
97 But since device nodes are not stored persistently between reboots,
98 those file permissions are set at boot time from rules specified in
100 or dynamically according to rules defined in
105 In the latter case, different rules may be used to make different sets
106 of devices visible within different instances of the
108 filesystem, which may be used, for example, to prevent jailed
109 subsystems from accessing unsafe devices.
110 Manual changes to device
111 node permissions may still be made, but will not persist.
112 .Ss Drivers without device nodes
113 Drivers for network devices do not use device nodes in order to be
115 Their selection is based on other decisions inside the
116 kernel, and instead of calling
118 use of a network device is generally introduced by using the system
121 .Ss Configuring a driver into the kernel
122 For each kernel, there is a configuration file that is used as a base
123 to select the facilities and drivers for that kernel, and to tune
127 for a detailed description of the files involved.
128 The individual manual pages in this section provide a sample line for the
129 configuration file in their synopsis portions.
131 .Pa /usr/src/sys/conf/NOTES
133 .Pa /usr/src/sys/${ARCH}/conf/NOTES .
135 Drivers need not be statically compiled into the kernel; they may also be
136 loaded as modules, in which case any device nodes they provide will appear
137 only after the module is loaded (and has attached to suitable hardware,
142 device nodes could be created in the traditional way as persistent
143 entries in the file system.
144 While such entries can still be created, they no longer function to
149 devices for disk and tape drives existed in two variants, known as
153 devices, or to use better terms, buffered and unbuffered
156 The traditional names are reflected by the letters
160 as the file type identification in the output of
162 Raw devices were traditionally named with a prefix of
166 would denote the raw version of the disk whose buffered device was
168 .Em This is no longer the case ;
169 all disk devices are now
171 in the traditional sense, even though they are not given
175 devices no longer exist at all.
177 Buffered devices were accessed through a buffer cache maintained by
178 the operating system; historically this was the system's primary disk
181 this was rendered obsolete by the introduction of unified virtual
183 Buffered devices could be read or written at any
184 byte position, with the buffer mechanism handling the reading and
185 writing of disk blocks.
186 In contrast, raw disk devices can be read or
187 written only at positions and lengths that are multiples of the
188 underlying device block size, and
192 not returning to the caller until the data has been handed off to the
207 This manual page first appeared in
211 This man page has been rewritten by
213 from an earlier version written by
215 with initial input by
216 .An David E. O'Brien .