Whitespace-only fixes, translators please ignore.

This commit is contained in:
Warren Block 2014-01-14 23:52:09 +00:00
parent 59e35cd682
commit 9bb650e5d4
Notes: svn2git 2020-12-08 03:00:23 +00:00
svn path=/head/; revision=43528

View file

@ -4,16 +4,36 @@
$FreeBSD$
-->
<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0" xml:id="driverbasics">
<info><title>Writing FreeBSD Device Drivers</title>
<chapter xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0"
xml:id="driverbasics">
<info>
<title>Writing FreeBSD Device Drivers</title>
<authorgroup>
<author><personname><firstname>Murray</firstname><surname>Stokely</surname></personname><contrib>Written by </contrib></author>
<author>
<personname>
<firstname>Murray</firstname>
<surname>Stokely</surname>
</personname>
<contrib>Written by </contrib>
</author>
</authorgroup>
<authorgroup>
<author><personname><firstname>J&ouml;rg</firstname><surname>Wunsch</surname></personname><contrib>Based on intro(4) manual page by </contrib></author>
<author>
<personname>
<firstname>J&ouml;rg</firstname>
<surname>Wunsch</surname>
</personname>
<contrib>Based on intro(4) manual page by </contrib>
</author>
</authorgroup>
</info>
<sect1 xml:id="driverbasics-intro">
<title>Introduction</title>
@ -48,8 +68,13 @@
<sect1 xml:id="driverbasics-kld">
<title>Dynamic Kernel Linker Facility - KLD</title>
<indexterm><primary>kernel linking</primary><secondary>dynamic</secondary></indexterm>
<indexterm><primary>kernel loadable modules (KLD)</primary></indexterm>
<indexterm>
<primary>kernel linking</primary>
<secondary>dynamic</secondary>
</indexterm>
<indexterm>
<primary>kernel loadable modules (KLD)</primary>
</indexterm>
<para>The kld interface allows system administrators to
dynamically add and remove functionality from a running system.
@ -61,8 +86,14 @@
<primary>kernel modules</primary>
<secondary>loading</secondary>
</indexterm>
<indexterm><primary>kernel modules</primary><secondary>unloading</secondary></indexterm>
<indexterm><primary>kernel modules</primary><secondary>listing</secondary></indexterm>
<indexterm>
<primary>kernel modules</primary>
<secondary>unloading</secondary>
</indexterm>
<indexterm>
<primary>kernel modules</primary>
<secondary>listing</secondary>
</indexterm>
<para>The kld interface is used through:</para>
@ -130,7 +161,7 @@ DECLARE_MODULE(skeleton, skel_mod, SI_SUB_KLD, SI_ORDER_ANY);</programlisting>
<title>Makefile</title>
<para>&os; provides a system makefile to simplify compiling a
kernel module.</para>
kernel module.</para>
<programlisting>SRCS=skeleton.c
KMOD=skeleton
@ -148,7 +179,9 @@ KMOD=skeleton
<sect1 xml:id="driverbasics-char">
<title>Character Devices</title>
<indexterm><primary>character devices</primary></indexterm>
<indexterm>
<primary>character devices</primary>
</indexterm>
<para>A character device driver is one that transfers data
directly to and from a user process. This is the most common
type of device driver and there are plenty of simple examples in
@ -160,7 +193,7 @@ KMOD=skeleton
<example>
<title>Example of a Sample Echo Pseudo-Device Driver for
&os;&nbsp;10.X</title>
&os;&nbsp;10.X</title>
<programlisting>/*
* Simple Echo pseudo-device KLD
@ -337,7 +370,8 @@ Opened device "echo" successfully.
Test Data
Closing device "echo".</screen>
<para>Real hardware devices are described in the next chapter.</para>
<para>Real hardware devices are described in the next
chapter.</para>
</sect1>
<sect1 xml:id="driverbasics-block">
@ -350,28 +384,30 @@ Closing device "echo".</screen>
for which the kernel provides caching. This caching makes
block-devices almost unusable, or at least dangerously
unreliable. The caching will reorder the sequence of write
operations, depriving the application of the ability to know
the exact disk contents at any one instant in time. This
makes predictable and reliable crash recovery of on-disk data
structures (filesystems, databases etc.) impossible.
Since writes may be delayed, there is no way the kernel can
report to the application which particular write operation
encountered a write error, this further compounds the
consistency problem. For this reason, no serious applications
rely on block devices, and in fact, almost all applications
which access disks directly take great pains to specify that
character (or <quote>raw</quote>) devices should always be
used. Because the implementation of the aliasing of each disk
(partition) to two devices with different semantics significantly
complicated the relevant kernel code &os; dropped support for
cached disk devices as part of the modernization of the disk I/O
operations, depriving the application of the ability to know the
exact disk contents at any one instant in time. This makes
predictable and reliable crash recovery of on-disk data
structures (filesystems, databases etc.) impossible. Since
writes may be delayed, there is no way the kernel can report to
the application which particular write operation encountered a
write error, this further compounds the consistency problem.
For this reason, no serious applications rely on block devices,
and in fact, almost all applications which access disks directly
take great pains to specify that character (or
<quote>raw</quote>) devices should always be used. Because the
implementation of the aliasing of each disk (partition) to two
devices with different semantics significantly complicated the
relevant kernel code &os; dropped support for cached disk
devices as part of the modernization of the disk I/O
infrastructure.</para>
</sect1>
<sect1 xml:id="driverbasics-net">
<title>Network Drivers</title>
<indexterm><primary>network devices</primary></indexterm>
<indexterm>
<primary>network devices</primary>
</indexterm>
<para>Drivers for network devices do not use device nodes in order
to be accessed. Their selection is based on other decisions
made inside the kernel and instead of calling open(), use of a
@ -380,7 +416,5 @@ Closing device "echo".</screen>
<para>For more information see ifnet(9), the source of the
loopback device, and Bill Paul's network drivers.</para>
</sect1>
</chapter>