<?xml version="1.0" encoding="ANSI_X3.4-1968" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968" /><title>Chapter 5. Generic PCI UIO driver</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.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><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 5. Generic PCI UIO driver</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="wait_for_interrupts.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="uio_pci_generic_internals.html">Next</a></td></tr></table><hr /></div><div class="chapter" title="Chapter 5. Generic PCI UIO driver"><div class="titlepage"><div><div><h2 class="title"><a id="uio_pci_generic"></a>Chapter 5. Generic PCI UIO driver</h2></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl><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> The generic driver is a kernel module named uio_pci_generic. It can work with any device compliant to PCI 2.3 (circa 2002) and any compliant PCI Express device. Using this, you only need to write the userspace driver, removing the need to write a hardware-specific kernel module. </p><div class="sect1" title="Making the driver recognize the device"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="uio_pci_generic_binding"></a>Making the driver recognize the device</h2></div></div></div><p> Since the driver does not declare any device ids, it will not get loaded automatically and will not automatically bind to any devices, you must load it and allocate id to the driver yourself. For example: </p><pre class="programlisting"> modprobe uio_pci_generic echo "8086 10f5" > /sys/bus/pci/drivers/uio_pci_generic/new_id </pre><p> </p><p> If there already is a hardware specific kernel driver for your device, the generic driver still won't bind to it, in this case if you want to use the generic driver (why would you?) you'll have to manually unbind the hardware specific driver and bind the generic driver, like this: </p><pre class="programlisting"> echo -n 0000:00:19.0 > /sys/bus/pci/drivers/e1000e/unbind echo -n 0000:00:19.0 > /sys/bus/pci/drivers/uio_pci_generic/bind </pre><p> </p><p> You can verify that the device has been bound to the driver by looking for it in sysfs, for example like the following: </p><pre class="programlisting"> ls -l /sys/bus/pci/devices/0000:00:19.0/driver </pre><p> Which if successful should print </p><pre class="programlisting"> .../0000:00:19.0/driver -> ../../../bus/pci/drivers/uio_pci_generic </pre><p> Note that the generic driver will not bind to old PCI 2.2 devices. If binding the device failed, run the following command: </p><pre class="programlisting"> dmesg </pre><p> and look in the output for failure reasons </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> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="uio_pci_generic_internals.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Waiting for interrupts </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Things to know about uio_pci_generic</td></tr></table></div></body></html>