<commit_before>.\"
.\" Copyright (c) 1996 <NAME>, <NAME>
.\"
.\" 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.
.\"
.\" $Id: intro.4,v 1.10 1998/03/12 07:30:17 charnier Exp $
.\"
.Dd January 20, 1996
.Dt INTRO 4
.Os FreeBSD 2.1
.Sh NAME
.Nm intro
.Nd introduction to devices and device drivers
.Sh DESCRIPTION
This section contains information related to devices, device driver
and miscellaneous hardware.  
.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
keyboard.  There are also so-called
.Em pseudo-devices
where a device driver emulates the behaviour of a device in software
without any particular underlying hardware.  A typical example for
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
device driver by the upper layers of the kernel.  The set of system
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
on a terminal devices is likely to be not useful at all.
.Ss Accessing Devices
Most of the devices in a unix-like operating system are accessed
through so-called
.Em device nodes ,
sometimes also called
.Em special files .
They are usually located under the directory
.Pa /dev
in the file system hierarchy
.Pq see also Xr hier 7 .
.Pp
Until
.Xr devfs 5
is fully functional, each device node must be created statically and
independently of the existence of the associated device driver,
usually by running
.Xr MAKEDEV 8 .
.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
still missing.  In the first case, any attempt to reference the device
through the device node will result in an error, returned by the upper
layers of the kernel, usually
.Ql ENXIO .
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
devices, or by a better name, buffered and unbuffered
.Pq raw
devices.  The traditional names are reflected by the letters
.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
operating system, and they are solely intended to layer a file system
on top of them.  They are normally implemented for disks and disk-like
devices only, for historical reasons also for tape devices.
.Pp
Raw devices are available for all drivers, including those that also
implement a buffered device.  For the latter group of devices, the
differentiation is conventionally done by prepending the latter
.Ql r
to the path name of the device node, for example
.Pa /dev/rda0
denotes the raw device for the first SCSI disk, while
.Pa /dev/da0
is the corresponding device node for the buffered device.
.Pp
Unbuffered devices should be used for all actions that are not related
to file system operations, even if the device in question is a disk
device.  This includes making backups of entire disk partitions, or
to
.Em raw
floppy disks
.Pq i.e. those used like tapes .
.Pp
Access restrictions to device nodes are usually subject of the regular
file permissions of the device node entry, instead of being implied
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
accessed.  Their selection is based on other decisions inside the
kernel, and instead of calling
.Xr open 2 ,
use of a network device is generally introduced by using the system
call<commit_msg>Typo - latter -> letter<commit_after>.\"
.\" Copyright (c) 1996 <NAME>, <NAME>
.\"
.\" 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.
.\"
.\" $Id: intro.4,v 1.11 1998/11/30 17:52:45 rnordier Exp $
.\"
.Dd January 20, 1996
.Dt INTRO 4
.Os FreeBSD 2.1
.Sh NAME
.Nm intro
.Nd introduction to devices and device drivers
.Sh DESCRIPTION
This section contains information related to devices, device driver
and miscellaneous hardware.  
.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
keyboard.  There are also so-called
.Em pseudo-devices
where a device driver emulates the behaviour of a device in software
without any particular underlying hardware.  A typical example for
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
device driver by the upper layers of the kernel.  The set of system
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
on a terminal devices is likely to be not useful at all.
.Ss Accessing Devices
Most of the devices in a unix-like operating system are accessed
through so-called
.Em device nodes ,
sometimes also called
.Em special files .
They are usually located under the directory
.Pa /dev
in the file system hierarchy
.Pq see also Xr hier 7 .
.Pp
Until
.Xr devfs 5
is fully functional, each device node must be created statically and
independently of the existence of the associated device driver,
usually by running
.Xr MAKEDEV 8 .
.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
still missing.  In the first case, any attempt to reference the device
through the device node will result in an error, returned by the upper
layers of the kernel, usually
.Ql ENXIO .
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
devices, or by a better name, buffered and unbuffered
.Pq raw
devices.  The traditional names are reflected by the letters
.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
operating system, and they are solely intended to layer a file system
on top of them.  They are normally implemented for disks and disk-like
devices only, for historical reasons also for tape devices.
.Pp
Raw devices are available for all drivers, including those that also
implement a buffered device.  For the latter group of devices, the
differentiation is conventionally done by prepending the letter
.Ql r
to the path name of the device node, for example
.Pa /dev/rda0
denotes the raw device for the first SCSI disk, while
.Pa /dev/da0
is the corresponding device node for the buffered device.
.Pp
Unbuffered devices should be used for all actions that are not related
to file system operations, even if the device in question is a disk
device.  This includes making backups of entire disk partitions, or
to
.Em raw
floppy disks
.Pq i.e. those used like tapes .
.Pp
Access restrictions to device nodes are usually subject of the regular
file permissions of the device node entry, instead of being implied
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
accessed.  Their selection is based on other decisions inside the
kernel, and instead of calling
.Xr open 2 ,
use of a network device is generally introduced by using the system
call
{'fraction_non_alphanumeric': 0.04981308411214953, 'fraction_numerical': 0.008785046728971962, 'mean_word_length': 3.9795253606328527, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '774767', 'n_tokens_mistral': 2966, 'n_tokens_neox': 2673, 'n_words': 1717}