]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man4/intro.4
mdoc(7) police:
[FreeBSD/FreeBSD.git] / share / man / man4 / intro.4
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
35 This section contains information related to devices, device driver
36 and miscellaneous hardware.
37 .Ss The device abstraction
38 Device is a term used mostly for hardware-related stuff that belongs
39 to the system, like disks, printers, or a graphics display with its
40 keyboard.  There are also so-called
41 .Em pseudo-devices
42 where a device driver emulates the behaviour of a device in software
43 without any particular underlying hardware.  A typical example for
44 the latter class is
45 .Pa /dev/mem ,
46 a loophole where the physical memory can be accessed using the regular
47 file access semantics.
48 .Pp
49 The device abstraction generally provides a common set of system calls
50 layered on top of them, which are dispatched to the corresponding
51 device driver by the upper layers of the kernel.  The set of system
52 calls available for devices is chosen from
53 .Xr open 2 ,
54 .Xr close 2 ,
55 .Xr read 2 ,
56 .Xr write 2 ,
57 .Xr ioctl 2 ,
58 .Xr select 2 ,
59 and
60 .Xr mmap 2 .
61 Not all drivers implement all system calls, for example, calling
62 .Xr mmap 2
63 on a terminal devices is likely to be not useful at all.
64 .Ss Accessing Devices
65 Most of the devices in a unix-like operating system are accessed
66 through so-called
67 .Em device nodes ,
68 sometimes also called
69 .Em special files .
70 They are usually located under the directory
71 .Pa /dev
72 in the file system hierarchy
73 (see also
74 .Xr hier 7 ) .
75 .Pp
76 Until
77 .Xr devfs 5
78 is fully functional, each device node must be created statically and
79 independently of the existence of the associated device driver,
80 usually by running
81 .Xr MAKEDEV 8 .
82 .Pp
83 Note that this could lead to an inconsistent state, where either there
84 are device nodes that do not have a configured driver associated with
85 them, or there may be drivers that have successfully probed for their
86 devices, but cannot be accessed since the corresponding device node is
87 still missing.  In the first case, any attempt to reference the device
88 through the device node will result in an error, returned by the upper
89 layers of the kernel, usually
90 .Er ENXIO .
91 In the second case, the device node needs to be created before the
92 driver and its device will be usable.
93 .Pp
94 Some devices come in two flavors:
95 .Em block
96 and
97 .Em character
98 devices, or by a better name, buffered and unbuffered
99 (raw)
100 devices.  The traditional names are reflected by the letters
101 .Ql b
102 and
103 .Ql c
104 as the file type identification in the output of
105 .Ql ls -l .
106 Buffered devices are being accessed through the buffer cache of the
107 operating system, and they are solely intended to layer a file system
108 on top of them.  They are normally implemented for disks and disk-like
109 devices only, for historical reasons also for tape devices.
110 .Pp
111 Raw devices are available for all drivers, including those that also
112 implement a buffered device.  For the latter group of devices, the
113 differentiation is conventionally done by prepending the letter
114 .Ql r
115 to the path name of the device node, for example
116 .Pa /dev/rda0
117 denotes the raw device for the first SCSI disk, while
118 .Pa /dev/da0
119 is the corresponding device node for the buffered device.
120 .Pp
121 Unbuffered devices should be used for all actions that are not related
122 to file system operations, even if the device in question is a disk
123 device.  This includes making backups of entire disk partitions, or
124 to
125 .Em raw
126 floppy disks
127 (i.e. those used like tapes).
128 .Pp
129 Access restrictions to device nodes are usually subject of the regular
130 file permissions of the device node entry, instead of being implied
131 directly by the drivers in the kernel.
132 .Ss Drivers without device nodes
133 Drivers for network devices do not use device nodes in order to be
134 accessed.  Their selection is based on other decisions inside the
135 kernel, and instead of calling
136 .Xr open 2 ,
137 use of a network device is generally introduced by using the system
138 call
139 .Xr socket 2 .
140 .Ss Configuring a driver into the kernel
141 For each kernel, there is a configuration file that is used as a base
142 to select the facilities and drivers for that kernel, and to tune
143 several options.  See
144 .Xr config 8
145 for a detailed description of the files involved.  The individual
146 manual pages in this section provide a sample line for the
147 configuration file in their synopsis portion.  See also the sample
148 config file
149 .Pa /sys/i386/conf/LINT
150 (for the
151 .Em i386
152 architecture).
153 .Sh SEE ALSO
154 .Xr close 2 ,
155 .Xr ioctl 2 ,
156 .Xr mmap 2 ,
157 .Xr open 2 ,
158 .Xr read 2 ,
159 .Xr select 2 ,
160 .Xr socket 2 ,
161 .Xr write 2 ,
162 .Xr devfs 5 ,
163 .Xr hier 7 ,
164 .Xr config 8 ,
165 .Xr MAKEDEV 8
166 .Sh AUTHORS
167 .An -nosplit
168 This man page has been written by
169 .An J\(:org Wunsch
170 with initial input by
171 .An David E. O'Brien .
172 .Sh HISTORY
173 .Nm Intro
174 appeared in
175 .Fx 2.1 .