xref: /freebsd/share/man/man4/intro.4 (revision 123af6ec70016f5556da5972d4d63c7d175c06d3)
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$
27.\"
28.Dd January 20, 1996
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
69.Ux Ns
70-like operating system are accessed
71through so-called
72.Em device nodes ,
73sometimes also called
74.Em special files .
75They are usually located under the directory
76.Pa /dev
77in the file system hierarchy
78(see also
79.Xr hier 7 ) .
80.Pp
81Note that this could lead to an inconsistent state, where either there
82are device nodes that do not have a configured driver associated with
83them, or there may be drivers that have successfully probed for their
84devices, but cannot be accessed since the corresponding device node is
85still missing.
86In the first case, any attempt to reference the device
87through the device node will result in an error, returned by the upper
88layers of the kernel, usually
89.Er ENXIO .
90In the second case, the device node needs to be created before the
91driver and its device will be usable.
92.Pp
93Some devices come in two flavors:
94.Em block
95and
96.Em character
97devices, or to use better terms, buffered and unbuffered
98(raw)
99devices.
100The traditional names are reflected by the letters
101.Ql b
102and
103.Ql c
104as the file type identification in the output of
105.Ql ls -l .
106Buffered devices are being accessed through the buffer cache of the
107operating system, and they are solely intended to layer a file system
108on top of them.
109They are normally implemented for disks and disk-like
110devices only and, for historical reasons, for tape devices.
111.Pp
112Raw devices are available for all drivers, including those that also
113implement a buffered device.
114For the latter group of devices, the
115differentiation is conventionally done by prepending the letter
116.Ql r
117to the path name of the device node, for example
118.Pa /dev/rda0
119denotes the raw device for the first SCSI disk, while
120.Pa /dev/da0
121is the corresponding device node for the buffered device.
122.Pp
123Unbuffered devices should be used for all actions that are not related
124to file system operations, even if the device in question is a disk
125device.
126This includes making backups of entire disk partitions, or
127to
128.Em raw
129floppy disks
130(i.e., those used like tapes).
131.Pp
132Access restrictions to device nodes are usually subject to the regular
133file permissions of the device node entry, instead of being enforced
134directly by the drivers in the kernel.
135.Ss Drivers without device nodes
136Drivers for network devices do not use device nodes in order to be
137accessed.
138Their selection is based on other decisions inside the
139kernel, and instead of calling
140.Xr open 2 ,
141use of a network device is generally introduced by using the system
142call
143.Xr socket 2 .
144.Ss Configuring a driver into the kernel
145For each kernel, there is a configuration file that is used as a base
146to select the facilities and drivers for that kernel, and to tune
147several options.
148See
149.Xr config 8
150for a detailed description of the files involved.
151The individual manual pages in this section provide a sample line for the
152configuration file in their synopsis portion.
153See also the sample config file
154.Pa /sys/i386/conf/LINT
155(for the
156.Em i386
157architecture).
158.Sh SEE ALSO
159.Xr close 2 ,
160.Xr ioctl 2 ,
161.Xr mmap 2 ,
162.Xr open 2 ,
163.Xr read 2 ,
164.Xr select 2 ,
165.Xr socket 2 ,
166.Xr write 2 ,
167.Xr devfs 5 ,
168.Xr hier 7 ,
169.Xr config 8
170.Sh HISTORY
171This manual page first appeared in
172.Fx 2.1 .
173.Sh AUTHORS
174.An -nosplit
175This man page has been written by
176.An J\(:org Wunsch
177with initial input by
178.An David E. O'Brien .
179