xref: /freebsd/share/man/man4/intro.4 (revision b5e7e9995091a8dbcf193564b2ceaf886252fc9b)
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
40b5e7e999SRuslan Ermilovkeyboard.
41b5e7e999SRuslan ErmilovThere are also so-called
42f00e21baSJoerg Wunsch.Em pseudo-devices
43f00e21baSJoerg Wunschwhere a device driver emulates the behaviour of a device in software
44b5e7e999SRuslan Ermilovwithout any particular underlying hardware.
45b5e7e999SRuslan ErmilovA typical example for
46f00e21baSJoerg Wunschthe latter class is
47f00e21baSJoerg Wunsch.Pa /dev/mem ,
48f00e21baSJoerg Wunscha loophole where the physical memory can be accessed using the regular
49f00e21baSJoerg Wunschfile access semantics.
50f00e21baSJoerg Wunsch.Pp
51f00e21baSJoerg WunschThe device abstraction generally provides a common set of system calls
52f00e21baSJoerg Wunschlayered on top of them, which are dispatched to the corresponding
53b5e7e999SRuslan Ermilovdevice driver by the upper layers of the kernel.
54b5e7e999SRuslan ErmilovThe set of system
55f00e21baSJoerg Wunschcalls available for devices is chosen from
56f00e21baSJoerg Wunsch.Xr open 2 ,
57f00e21baSJoerg Wunsch.Xr close 2 ,
58f00e21baSJoerg Wunsch.Xr read 2 ,
59f00e21baSJoerg Wunsch.Xr write 2 ,
60f00e21baSJoerg Wunsch.Xr ioctl 2 ,
61f00e21baSJoerg Wunsch.Xr select 2 ,
62f00e21baSJoerg Wunschand
63f00e21baSJoerg Wunsch.Xr mmap 2 .
64f00e21baSJoerg WunschNot all drivers implement all system calls, for example, calling
65f00e21baSJoerg Wunsch.Xr mmap 2
664057c9f0SDima Dorfmanon terminal devices is likely to be not useful at all.
67f00e21baSJoerg Wunsch.Ss Accessing Devices
68faf1a4f7SRuslan ErmilovMost of the devices in a
69faf1a4f7SRuslan Ermilov.Ux Ns
70faf1a4f7SRuslan Ermilov-like operating system are accessed
71f00e21baSJoerg Wunschthrough so-called
72f00e21baSJoerg Wunsch.Em device nodes ,
73f00e21baSJoerg Wunschsometimes also called
74f00e21baSJoerg Wunsch.Em special files .
75f00e21baSJoerg WunschThey are usually located under the directory
76f00e21baSJoerg Wunsch.Pa /dev
77f00e21baSJoerg Wunschin the file system hierarchy
78c4d9468eSRuslan Ermilov(see also
79c4d9468eSRuslan Ermilov.Xr hier 7 ) .
80f00e21baSJoerg Wunsch.Pp
81f00e21baSJoerg WunschNote that this could lead to an inconsistent state, where either there
82f00e21baSJoerg Wunschare device nodes that do not have a configured driver associated with
83f00e21baSJoerg Wunschthem, or there may be drivers that have successfully probed for their
84f00e21baSJoerg Wunschdevices, but cannot be accessed since the corresponding device node is
85b5e7e999SRuslan Ermilovstill missing.
86b5e7e999SRuslan ErmilovIn 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
89b92a189eSRuslan Ermilov.Er 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
974057c9f0SDima Dorfmandevices, or to use better terms, buffered and unbuffered
98c4d9468eSRuslan Ermilov(raw)
99b5e7e999SRuslan Ermilovdevices.
100b5e7e999SRuslan ErmilovThe traditional names are reflected by the letters
101f00e21baSJoerg Wunsch.Ql b
102f00e21baSJoerg Wunschand
103f00e21baSJoerg Wunsch.Ql c
104f00e21baSJoerg Wunschas the file type identification in the output of
105f00e21baSJoerg Wunsch.Ql ls -l .
106f00e21baSJoerg WunschBuffered devices are being accessed through the buffer cache of the
107f00e21baSJoerg Wunschoperating system, and they are solely intended to layer a file system
108b5e7e999SRuslan Ermilovon top of them.
109b5e7e999SRuslan ErmilovThey are normally implemented for disks and disk-like
1104057c9f0SDima Dorfmandevices only and, for historical reasons, for tape devices.
111f00e21baSJoerg Wunsch.Pp
112f00e21baSJoerg WunschRaw devices are available for all drivers, including those that also
113b5e7e999SRuslan Ermilovimplement a buffered device.
114b5e7e999SRuslan ErmilovFor the latter group of devices, the
11584a6ebdcSBill Fumeroladifferentiation is conventionally done by prepending the letter
116f00e21baSJoerg Wunsch.Ql r
117f00e21baSJoerg Wunschto the path name of the device node, for example
11893a4ebf3SRobert Nordier.Pa /dev/rda0
119f00e21baSJoerg Wunschdenotes the raw device for the first SCSI disk, while
12093a4ebf3SRobert Nordier.Pa /dev/da0
121f00e21baSJoerg Wunschis the corresponding device node for the buffered device.
122f00e21baSJoerg Wunsch.Pp
123f00e21baSJoerg WunschUnbuffered devices should be used for all actions that are not related
124f00e21baSJoerg Wunschto file system operations, even if the device in question is a disk
125b5e7e999SRuslan Ermilovdevice.
126b5e7e999SRuslan ErmilovThis includes making backups of entire disk partitions, or
127f00e21baSJoerg Wunschto
128f00e21baSJoerg Wunsch.Em raw
129f00e21baSJoerg Wunschfloppy disks
130c4d9468eSRuslan Ermilov(i.e. those used like tapes).
131f00e21baSJoerg Wunsch.Pp
1324057c9f0SDima DorfmanAccess restrictions to device nodes are usually subject to the regular
1334057c9f0SDima Dorfmanfile permissions of the device node entry, instead of being enforced
134f00e21baSJoerg Wunschdirectly by the drivers in the kernel.
135f00e21baSJoerg Wunsch.Ss Drivers without device nodes
136f00e21baSJoerg WunschDrivers for network devices do not use device nodes in order to be
137b5e7e999SRuslan Ermilovaccessed.
138b5e7e999SRuslan ErmilovTheir selection is based on other decisions inside the
139f00e21baSJoerg Wunschkernel, and instead of calling
140f00e21baSJoerg Wunsch.Xr open 2 ,
141f00e21baSJoerg Wunschuse of a network device is generally introduced by using the system
142f00e21baSJoerg Wunschcall
143f00e21baSJoerg Wunsch.Xr socket 2 .
144f00e21baSJoerg Wunsch.Ss Configuring a driver into the kernel
145f00e21baSJoerg WunschFor each kernel, there is a configuration file that is used as a base
146f00e21baSJoerg Wunschto select the facilities and drivers for that kernel, and to tune
147b5e7e999SRuslan Ermilovseveral options.
148b5e7e999SRuslan ErmilovSee
149f00e21baSJoerg Wunsch.Xr config 8
150b5e7e999SRuslan Ermilovfor a detailed description of the files involved.
151b5e7e999SRuslan ErmilovThe individual manual pages in this section provide a sample line for the
152f00e21baSJoerg Wunschconfiguration file in their synopsis portion.  See also the sample
153f00e21baSJoerg Wunschconfig file
154f00e21baSJoerg Wunsch.Pa /sys/i386/conf/LINT
155c4d9468eSRuslan Ermilov(for the
156f00e21baSJoerg Wunsch.Em i386
157c4d9468eSRuslan Ermilovarchitecture).
158f00e21baSJoerg Wunsch.Sh SEE ALSO
159f00e21baSJoerg Wunsch.Xr close 2 ,
160f00e21baSJoerg Wunsch.Xr ioctl 2 ,
161f00e21baSJoerg Wunsch.Xr mmap 2 ,
1620b992c1dSWolfram Schneider.Xr open 2 ,
1630b992c1dSWolfram Schneider.Xr read 2 ,
1640b992c1dSWolfram Schneider.Xr select 2 ,
165f00e21baSJoerg Wunsch.Xr socket 2 ,
1660b992c1dSWolfram Schneider.Xr write 2 ,
1674e11acf8SMike Pritchard.Xr devfs 5 ,
168f00e21baSJoerg Wunsch.Xr hier 7 ,
169494a5dabSGiorgos Keramidas.Xr config 8
170b5e7e999SRuslan Ermilov.Sh HISTORY
171b5e7e999SRuslan ErmilovThis manual page first appeared in
172b5e7e999SRuslan Ermilov.Fx 2.1 .
173f00e21baSJoerg Wunsch.Sh AUTHORS
174f4d874a1SRuslan Ermilov.An -nosplit
175f00e21baSJoerg WunschThis man page has been written by
176726b61abSRuslan Ermilov.An J\(:org Wunsch
177aaf1f16eSPhilippe Charnierwith initial input by
178aaf1f16eSPhilippe Charnier.An David E. O'Brien .
179