/usr/share/doc/libcomedi-dev/html/driverwriting.html is in libcomedi-dev 0.10.2-4build7.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>6. Writing a Comedi driver</title><link rel="stylesheet" type="text/css" href="comedilib.css"><meta name="generator" content="DocBook XSL Stylesheets V1.79.1"><link rel="home" href="index.html" title="Comedi"><link rel="up" href="index.html" title="Comedi"><link rel="prev" href="lowleveldrivers.html" title="5.6. Kernel drivers"><link rel="next" href="comedikernelgeneric.html" title="6.2. Generic functionality"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">6.
Writing a <acronym class="acronym">Comedi</acronym> driver
</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="lowleveldrivers.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="comedikernelgeneric.html">Next</a></td></tr></table><hr></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="driverwriting"></a>6.
Writing a <a class="ulink" href="http://www.comedi.org" target="_top"><acronym class="acronym">Comedi</acronym></a> driver
</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="section"><a href="driverwriting.html#userkernelhow">6.1.
Communication user-space — kernel-space
</a></span></dt><dt><span class="section"><a href="comedikernelgeneric.html">6.2.
Generic functionality
</a></span></dt><dt><span class="section"><a href="boardspecific.html">6.3.
Board-specific functionality
</a></span></dt><dt><span class="section"><a href="drivercallbacks.html">6.4.
Callbacks, events and interrupts
</a></span></dt><dt><span class="section"><a href="drivercaveats.html">6.5.
Device driver caveats
</a></span></dt><dt><span class="section"><a href="integratingdriver.html">6.6.
Integrating the driver in the <acronym class="acronym">Comedi</acronym> library
</a></span></dt></dl></div><p>
This section explains the most important implementations aspects of
the <a class="ulink" href="http://www.comedi.org" target="_top"><acronym class="acronym">Comedi</acronym></a> device drivers. It tries to give the interested device
driver writer an overview of the different steps required to write a
new device driver.
</p><p>
This section does <span class="emphasis"><em>not</em></span> explain all implementation
details of the <a class="ulink" href="http://www.comedi.org" target="_top"><acronym class="acronym">Comedi</acronym></a> software itself: <a class="ulink" href="http://www.comedi.org" target="_top"><acronym class="acronym">Comedi</acronym></a> has once and for
all solved lots of boring but indispensable infrastructural things,
such as: timers, management of which drivers
are active, memory management for drivers and buffers, wrapping
of RTOS-specific interfaces, interrupt handler management, general
error handling, the <code class="filename">/proc</code>
interface, etc. So,
the device driver writers can concentrate on the interesting stuff:
implementing their specific interface card's DAQ functionalities.
</p><p>
In order to make a decent <a class="ulink" href="http://www.comedi.org" target="_top"><acronym class="acronym">Comedi</acronym></a> device driver, you must
know the answers to the following questions:
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
How does the
<a class="link" href="driverwriting.html#userkernelhow" title="6.1. Communication user-space — kernel-space">communication</a> between user-space
and kernel-space work?
</p></li><li class="listitem"><p>
What functionality is provided by the
<a class="link" href="comedikernelgeneric.html" title="6.2. Generic functionality">generic</a> kernel-space
<a class="ulink" href="http://www.comedi.org" target="_top"><acronym class="acronym">Comedi</acronym></a> functions, and what must be provided for each
<a class="link" href="boardspecific.html" title="6.3. Board-specific functionality">specific new driver</a>?
</p></li><li class="listitem"><p>
How to use <a class="link" href="drivercallbacks.html" title="6.4. Callbacks, events and interrupts">DMA and interrupts</a>?
</p></li><li class="listitem"><p>
What are the addresses and meanings of all the card's registers?
</p><p>
This information is to be found in the so-called <span class="quote">“<span class="quote">register level
manual</span>”</span> of the card. Without it, coding a device driver is close
to hopeless. It is also something that <a class="ulink" href="http://www.comedi.org" target="_top"><acronym class="acronym">Comedi</acronym></a> (and hence also this
handbook) cannot give any support or information for: board
manufacturers all use their own design and nomenclature.
</p></li></ul></div><p>
</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="userkernelhow"></a>6.1.
Communication user-space — kernel-space
</h3></div></div></div><p>
In user-space, you interact with the functions implemented in the
Comedilib library.
Most of the device driver core of the Comedilib library is found in
<code class="filename">lib</code> subdirectory.
</p><p>
All user-space <a class="ulink" href="http://www.comedi.org" target="_top"><acronym class="acronym">Comedi</acronym></a>
<a class="link" href="instructions.html" title="4.2. Instructions for multiple acquisitions">instructions</a> and
<a class="link" href="commandsstreaming.html" title="4.5. Commands for streaming acquisition">commands</a>
are transmitted to kernel space through a traditional
<code class="function">ioctl</code> system call.
(See <code class="filename">lib/ioctl.c</code> in Comedilib.)
The user-space information command is <span class="emphasis"><em>encoded</em></span> as
a number in the <code class="function">ioctl</code> call, and decoded in the
kernel-space library. There, they are executed by their kernel-space
counterparts. This is done in the
<code class="filename">comedi_fops.c</code> file in the Comedi sources: the
<code class="function">comedi_unlocked_ioctl</code> function processes the results of
the <code class="function">ioctl</code> system call, interprets its contents,
and then calls the corresponding kernel-space
<code class="function">do_…_ioctl</code> function(s).
For example, a <a class="ulink" href="http://www.comedi.org" target="_top"><acronym class="acronym">Comedi</acronym></a>
<a class="link" href="instructions.html" title="4.2. Instructions for multiple acquisitions">instruction</a> is further processed
by the <code class="function">do_insn_ioctl</code> function. (Which, in turn,
uses <code class="function">parse_insn</code> for further detailed processing.)
</p><p>
The data corresponding to instructions and commands is transmitted
with the <code class="function">copy_from_user</code> function;
acquisition data captured by the interface card passes the
kernel/user-space boundary with the help of a <code class="function">copy_to_user</code>
function.
</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="lowleveldrivers.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="comedikernelgeneric.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">5.6.
Kernel drivers
</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 6.2.
Generic functionality
</td></tr></table></div></body></html>
|