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