1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>Chapter&#160;5.&#160;Generic PCI UIO driver</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="The Userspace I/O HOWTO"><link rel="up" href="index.html" title="The Userspace I/O HOWTO"><link rel="prev" href="wait_for_interrupts.html" title="Waiting for interrupts"><link rel="next" href="uio_pci_generic_internals.html" title="Things to know about uio_pci_generic"></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">Chapter&#160;5.&#160;Generic PCI UIO driver</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="wait_for_interrupts.html">Prev</a>&#160;</td><th width="60%" align="center">&#160;</th><td width="20%" align="right">&#160;<a accesskey="n" href="uio_pci_generic_internals.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="uio_pci_generic"></a>Chapter&#160;5.&#160;Generic PCI UIO driver</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="sect1"><a href="uio_pci_generic.html#uio_pci_generic_binding">Making the driver recognize the device</a></span></dt><dt><span class="sect1"><a href="uio_pci_generic_internals.html">Things to know about uio_pci_generic</a></span></dt><dt><span class="sect1"><a href="uio_pci_generic_userspace.html">Writing userspace driver using uio_pci_generic</a></span></dt><dt><span class="sect1"><a href="uio_pci_generic_example.html">Example code using uio_pci_generic</a></span></dt></dl></div><p>
2	The generic driver is a kernel module named uio_pci_generic.
3	It can work with any device compliant to PCI 2.3 (circa 2002) and
4	any compliant PCI Express device. Using this, you only need to
5        write the userspace driver, removing the need to write
6        a hardware-specific kernel module.
7	</p><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="uio_pci_generic_binding"></a>Making the driver recognize the device</h2></div></div></div><p>
8Since the driver does not declare any device ids, it will not get loaded
9automatically and will not automatically bind to any devices, you must load it
10and allocate id to the driver yourself. For example:
11	</p><pre class="programlisting">
12 modprobe uio_pci_generic
13 echo "8086 10f5" &gt; /sys/bus/pci/drivers/uio_pci_generic/new_id
14	</pre><p>
15	</p><p>
16If there already is a hardware specific kernel driver for your device, the
17generic driver still won't bind to it, in this case if you want to use the
18generic driver (why would you?) you'll have to manually unbind the hardware
19specific driver and bind the generic driver, like this:
20	</p><pre class="programlisting">
21    echo -n 0000:00:19.0 &gt; /sys/bus/pci/drivers/e1000e/unbind
22    echo -n 0000:00:19.0 &gt; /sys/bus/pci/drivers/uio_pci_generic/bind
23	</pre><p>
24	</p><p>
25You can verify that the device has been bound to the driver
26by looking for it in sysfs, for example like the following:
27	</p><pre class="programlisting">
28    ls -l /sys/bus/pci/devices/0000:00:19.0/driver
29	</pre><p>
30Which if successful should print
31	</p><pre class="programlisting">
32  .../0000:00:19.0/driver -&gt; ../../../bus/pci/drivers/uio_pci_generic
33	</pre><p>
34Note that the generic driver will not bind to old PCI 2.2 devices.
35If binding the device failed, run the following command:
36	</p><pre class="programlisting">
37  dmesg
38	</pre><p>
39and look in the output for failure reasons
40	</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="wait_for_interrupts.html">Prev</a>&#160;</td><td width="20%" align="center">&#160;</td><td width="40%" align="right">&#160;<a accesskey="n" href="uio_pci_generic_internals.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Waiting for interrupts&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;Things to know about uio_pci_generic</td></tr></table></div></body></html>
41