1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>Waiting for interrupts</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="userspace_driver.html" title="Chapter 4. Writing a driver in userspace"><link rel="prev" href="mmap_device_memory.html" title="mmap() device memory"><link rel="next" href="uio_pci_generic.html" title="Chapter 5. Generic PCI UIO driver"></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">Waiting for interrupts</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="mmap_device_memory.html">Prev</a> </td><th width="60%" align="center">Chapter 4. Writing a driver in userspace</th><td width="20%" align="right"> <a accesskey="n" href="uio_pci_generic.html">Next</a></td></tr></table><hr></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="wait_for_interrupts"></a>Waiting for interrupts</h2></div></div></div><p> 2 After you successfully mapped your devices memory, you 3 can access it like an ordinary array. Usually, you will 4 perform some initialization. After that, your hardware 5 starts working and will generate an interrupt as soon 6 as it's finished, has some data available, or needs your 7 attention because an error occurred. 8 </p><p> 9 <code class="filename">/dev/uioX</code> is a read-only file. A 10 <code class="function">read()</code> will always block until an 11 interrupt occurs. There is only one legal value for the 12 <code class="varname">count</code> parameter of 13 <code class="function">read()</code>, and that is the size of a 14 signed 32 bit integer (4). Any other value for 15 <code class="varname">count</code> causes <code class="function">read()</code> 16 to fail. The signed 32 bit integer read is the interrupt 17 count of your device. If the value is one more than the value 18 you read the last time, everything is OK. If the difference 19 is greater than one, you missed interrupts. 20 </p><p> 21 You can also use <code class="function">select()</code> on 22 <code class="filename">/dev/uioX</code>. 23 </p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="mmap_device_memory.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="userspace_driver.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="uio_pci_generic.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">mmap() device memory </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 5. Generic PCI UIO driver</td></tr></table></div></body></html> 24