1996-01-21 14:01:49 +00:00
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 1996 David E. O'Brien, Joerg Wunsch
|
|
|
|
.\"
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
.\"
|
1999-08-28 00:22:10 +00:00
|
|
|
.\" $FreeBSD$
|
1996-01-21 14:01:49 +00:00
|
|
|
.\"
|
|
|
|
.Dd January 20, 1996
|
|
|
|
.Dt INTRO 4
|
2001-07-10 15:31:11 +00:00
|
|
|
.Os
|
1996-01-21 14:01:49 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm intro
|
|
|
|
.Nd introduction to devices and device drivers
|
|
|
|
.Sh DESCRIPTION
|
2002-01-07 06:26:37 +00:00
|
|
|
This section contains information related to devices, device drivers
|
2001-05-01 09:15:30 +00:00
|
|
|
and miscellaneous hardware.
|
1996-01-21 14:01:49 +00:00
|
|
|
.Ss The device abstraction
|
|
|
|
Device is a term used mostly for hardware-related stuff that belongs
|
|
|
|
to the system, like disks, printers, or a graphics display with its
|
2003-06-28 23:53:39 +00:00
|
|
|
keyboard.
|
|
|
|
There are also so-called
|
1996-01-21 14:01:49 +00:00
|
|
|
.Em pseudo-devices
|
|
|
|
where a device driver emulates the behaviour of a device in software
|
2003-06-28 23:53:39 +00:00
|
|
|
without any particular underlying hardware.
|
|
|
|
A typical example for
|
1996-01-21 14:01:49 +00:00
|
|
|
the latter class is
|
|
|
|
.Pa /dev/mem ,
|
|
|
|
a loophole where the physical memory can be accessed using the regular
|
|
|
|
file access semantics.
|
|
|
|
.Pp
|
|
|
|
The device abstraction generally provides a common set of system calls
|
|
|
|
layered on top of them, which are dispatched to the corresponding
|
2003-06-28 23:53:39 +00:00
|
|
|
device driver by the upper layers of the kernel.
|
|
|
|
The set of system
|
1996-01-21 14:01:49 +00:00
|
|
|
calls available for devices is chosen from
|
|
|
|
.Xr open 2 ,
|
|
|
|
.Xr close 2 ,
|
|
|
|
.Xr read 2 ,
|
|
|
|
.Xr write 2 ,
|
|
|
|
.Xr ioctl 2 ,
|
|
|
|
.Xr select 2 ,
|
|
|
|
and
|
|
|
|
.Xr mmap 2 .
|
|
|
|
Not all drivers implement all system calls, for example, calling
|
|
|
|
.Xr mmap 2
|
2002-01-07 06:26:37 +00:00
|
|
|
on terminal devices is likely to be not useful at all.
|
1996-01-21 14:01:49 +00:00
|
|
|
.Ss Accessing Devices
|
2002-03-18 12:38:33 +00:00
|
|
|
Most of the devices in a
|
|
|
|
.Ux Ns
|
|
|
|
-like operating system are accessed
|
1996-01-21 14:01:49 +00:00
|
|
|
through so-called
|
|
|
|
.Em device nodes ,
|
|
|
|
sometimes also called
|
|
|
|
.Em special files .
|
|
|
|
They are usually located under the directory
|
|
|
|
.Pa /dev
|
2002-12-12 17:26:04 +00:00
|
|
|
in the file system hierarchy
|
2001-08-07 15:48:51 +00:00
|
|
|
(see also
|
|
|
|
.Xr hier 7 ) .
|
1996-01-21 14:01:49 +00:00
|
|
|
.Pp
|
|
|
|
Note that this could lead to an inconsistent state, where either there
|
|
|
|
are device nodes that do not have a configured driver associated with
|
|
|
|
them, or there may be drivers that have successfully probed for their
|
|
|
|
devices, but cannot be accessed since the corresponding device node is
|
2003-06-28 23:53:39 +00:00
|
|
|
still missing.
|
|
|
|
In the first case, any attempt to reference the device
|
1996-01-21 14:01:49 +00:00
|
|
|
through the device node will result in an error, returned by the upper
|
|
|
|
layers of the kernel, usually
|
2000-11-22 16:11:48 +00:00
|
|
|
.Er ENXIO .
|
1996-01-21 14:01:49 +00:00
|
|
|
In the second case, the device node needs to be created before the
|
|
|
|
driver and its device will be usable.
|
|
|
|
.Pp
|
|
|
|
Some devices come in two flavors:
|
|
|
|
.Em block
|
|
|
|
and
|
|
|
|
.Em character
|
2002-01-07 06:26:37 +00:00
|
|
|
devices, or to use better terms, buffered and unbuffered
|
2001-08-07 15:48:51 +00:00
|
|
|
(raw)
|
2003-06-28 23:53:39 +00:00
|
|
|
devices.
|
|
|
|
The traditional names are reflected by the letters
|
1996-01-21 14:01:49 +00:00
|
|
|
.Ql b
|
|
|
|
and
|
|
|
|
.Ql c
|
|
|
|
as the file type identification in the output of
|
|
|
|
.Ql ls -l .
|
|
|
|
Buffered devices are being accessed through the buffer cache of the
|
2002-12-12 17:26:04 +00:00
|
|
|
operating system, and they are solely intended to layer a file system
|
2003-06-28 23:53:39 +00:00
|
|
|
on top of them.
|
|
|
|
They are normally implemented for disks and disk-like
|
2002-01-07 06:26:37 +00:00
|
|
|
devices only and, for historical reasons, for tape devices.
|
1996-01-21 14:01:49 +00:00
|
|
|
.Pp
|
|
|
|
Raw devices are available for all drivers, including those that also
|
2003-06-28 23:53:39 +00:00
|
|
|
implement a buffered device.
|
|
|
|
For the latter group of devices, the
|
1999-03-15 02:34:40 +00:00
|
|
|
differentiation is conventionally done by prepending the letter
|
1996-01-21 14:01:49 +00:00
|
|
|
.Ql r
|
|
|
|
to the path name of the device node, for example
|
1998-11-30 17:52:45 +00:00
|
|
|
.Pa /dev/rda0
|
1996-01-21 14:01:49 +00:00
|
|
|
denotes the raw device for the first SCSI disk, while
|
1998-11-30 17:52:45 +00:00
|
|
|
.Pa /dev/da0
|
1996-01-21 14:01:49 +00:00
|
|
|
is the corresponding device node for the buffered device.
|
|
|
|
.Pp
|
|
|
|
Unbuffered devices should be used for all actions that are not related
|
2002-12-12 17:26:04 +00:00
|
|
|
to file system operations, even if the device in question is a disk
|
2003-06-28 23:53:39 +00:00
|
|
|
device.
|
|
|
|
This includes making backups of entire disk partitions, or
|
1996-01-21 14:01:49 +00:00
|
|
|
to
|
|
|
|
.Em raw
|
|
|
|
floppy disks
|
2001-08-07 15:48:51 +00:00
|
|
|
(i.e. those used like tapes).
|
1996-01-21 14:01:49 +00:00
|
|
|
.Pp
|
2002-01-07 06:26:37 +00:00
|
|
|
Access restrictions to device nodes are usually subject to the regular
|
|
|
|
file permissions of the device node entry, instead of being enforced
|
1996-01-21 14:01:49 +00:00
|
|
|
directly by the drivers in the kernel.
|
|
|
|
.Ss Drivers without device nodes
|
|
|
|
Drivers for network devices do not use device nodes in order to be
|
2003-06-28 23:53:39 +00:00
|
|
|
accessed.
|
|
|
|
Their selection is based on other decisions inside the
|
1996-01-21 14:01:49 +00:00
|
|
|
kernel, and instead of calling
|
|
|
|
.Xr open 2 ,
|
|
|
|
use of a network device is generally introduced by using the system
|
|
|
|
call
|
|
|
|
.Xr socket 2 .
|
|
|
|
.Ss Configuring a driver into the kernel
|
|
|
|
For each kernel, there is a configuration file that is used as a base
|
|
|
|
to select the facilities and drivers for that kernel, and to tune
|
2003-06-28 23:53:39 +00:00
|
|
|
several options.
|
|
|
|
See
|
1996-01-21 14:01:49 +00:00
|
|
|
.Xr config 8
|
2003-06-28 23:53:39 +00:00
|
|
|
for a detailed description of the files involved.
|
|
|
|
The individual manual pages in this section provide a sample line for the
|
2003-11-12 02:35:20 +00:00
|
|
|
configuration file in their synopsis portion.
|
|
|
|
See also the sample config file
|
1996-01-21 14:01:49 +00:00
|
|
|
.Pa /sys/i386/conf/LINT
|
2001-08-07 15:48:51 +00:00
|
|
|
(for the
|
1996-01-21 14:01:49 +00:00
|
|
|
.Em i386
|
2001-08-07 15:48:51 +00:00
|
|
|
architecture).
|
1996-01-21 14:01:49 +00:00
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr close 2 ,
|
|
|
|
.Xr ioctl 2 ,
|
|
|
|
.Xr mmap 2 ,
|
1996-12-26 16:16:37 +00:00
|
|
|
.Xr open 2 ,
|
|
|
|
.Xr read 2 ,
|
|
|
|
.Xr select 2 ,
|
1996-01-21 14:01:49 +00:00
|
|
|
.Xr socket 2 ,
|
1996-12-26 16:16:37 +00:00
|
|
|
.Xr write 2 ,
|
1996-12-26 22:16:06 +00:00
|
|
|
.Xr devfs 5 ,
|
1996-01-21 14:01:49 +00:00
|
|
|
.Xr hier 7 ,
|
2003-03-25 12:09:06 +00:00
|
|
|
.Xr config 8
|
2003-06-28 23:53:39 +00:00
|
|
|
.Sh HISTORY
|
|
|
|
This manual page first appeared in
|
|
|
|
.Fx 2.1 .
|
1996-01-21 14:01:49 +00:00
|
|
|
.Sh AUTHORS
|
2000-11-22 09:35:58 +00:00
|
|
|
.An -nosplit
|
1996-01-21 14:01:49 +00:00
|
|
|
This man page has been written by
|
2000-11-10 17:46:15 +00:00
|
|
|
.An J\(:org Wunsch
|
1998-03-12 07:31:21 +00:00
|
|
|
with initial input by
|
|
|
|
.An David E. O'Brien .
|