1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>Using uio_dmem_genirq for platform devices</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="custom_kernel_module.html" title="Chapter 3. Writing your own kernel module"><link rel="prev" href="using_uio_pdrv_genirq.html" title="Using uio_pdrv_genirq for platform devices"><link rel="next" href="userspace_driver.html" title="Chapter 4. Writing a driver in userspace"></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">Using uio_dmem_genirq for platform devices</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="using_uio_pdrv_genirq.html">Prev</a> </td><th width="60%" align="center">Chapter 3. Writing your own kernel module</th><td width="20%" align="right"> <a accesskey="n" href="userspace_driver.html">Next</a></td></tr></table><hr></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="using-uio_dmem_genirq"></a>Using uio_dmem_genirq for platform devices</h2></div></div></div><p> 2 In addition to statically allocated memory ranges, they may also be 3 a desire to use dynamically allocated regions in a user space driver. 4 In particular, being able to access memory made available through the 5 dma-mapping API, may be particularly useful. The 6 <code class="varname">uio_dmem_genirq</code> driver provides a way to accomplish 7 this. 8 </p><p> 9 This driver is used in a similar manner to the 10 <code class="varname">"uio_pdrv_genirq"</code> driver with respect to interrupt 11 configuration and handling. 12 </p><p> 13 Set the <code class="varname">.name</code> element of 14 <code class="varname">struct platform_device</code> to 15 <code class="varname">"uio_dmem_genirq"</code> to use this driver. 16 </p><p> 17 When using this driver, fill in the <code class="varname">.platform_data</code> 18 element of <code class="varname">struct platform_device</code>, which is of type 19 <code class="varname">struct uio_dmem_genirq_pdata</code> and which contains the 20 following elements: 21 </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><code class="varname">struct uio_info uioinfo</code>: The same 22 structure used as the <code class="varname">uio_pdrv_genirq</code> platform 23 data</p></li><li class="listitem"><p><code class="varname">unsigned int *dynamic_region_sizes</code>: 24 Pointer to list of sizes of dynamic memory regions to be mapped into 25 user space. 26 </p></li><li class="listitem"><p><code class="varname">unsigned int num_dynamic_regions</code>: 27 Number of elements in <code class="varname">dynamic_region_sizes</code> array. 28 </p></li></ul></div><p> 29 The dynamic regions defined in the platform data will be appended to 30 the <code class="varname"> mem[] </code> array after the platform device 31 resources, which implies that the total number of static and dynamic 32 memory regions cannot exceed <code class="varname">MAX_UIO_MAPS</code>. 33 </p><p> 34 The dynamic memory regions will be allocated when the UIO device file, 35 <code class="varname">/dev/uioX</code> is opened. 36 Similar to static memory resources, the memory region information for 37 dynamic regions is then visible via sysfs at 38 <code class="varname">/sys/class/uio/uioX/maps/mapY/*</code>. 39 The dynamic memory regions will be freed when the UIO device file is 40 closed. When no processes are holding the device file open, the address 41 returned to userspace is ~0. 42 </p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="using_uio_pdrv_genirq.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="custom_kernel_module.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="userspace_driver.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Using uio_pdrv_genirq for platform devices </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 4. Writing a driver in userspace</td></tr></table></div></body></html> 43