€•fŒsphinx.addnodes”Œdocument”“”)�”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)�”}”(hhh]”(hŒ pending_xref”“”)�”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…”�”}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ(/translations/zh_CN/driver-api/uio-howto”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)�”}”(hhh]”hŒChinese (Traditional)”…”�”}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ(/translations/zh_TW/driver-api/uio-howto”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒItalian”…”�”}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ(/translations/it_IT/driver-api/uio-howto”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒJapanese”…”�”}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ(/translations/ja_JP/driver-api/uio-howto”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒKorean”…”�”}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ(/translations/ko_KR/driver-api/uio-howto”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒPortuguese (Brazilian)”…”�”}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ(/translations/pt_BR/driver-api/uio-howto”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒSpanish”…”�”}”hh–sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ(/translations/sp_SP/driver-api/uio-howto”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒsection”“”)�”}”(hhh]”(hŒtitle”“”)�”}”(hŒThe Userspace I/O HOWTO”h]”hŒThe Userspace I/O HOWTO”…”�”}”(hh¼h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhh·h²hh³ŒB/var/lib/git/docbuild/linux/Documentation/driver-api/uio-howto.rst”h´KubhŒ field_list”“”)�”}”(hhh]”(hŒfield”“”)�”}”(hhh]”(hŒ field_name”“”)�”}”(hŒAuthor”h]”hŒAuthor”…”�”}”(hh×h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÕhhÒh³hÊh´KubhŒ field_body”“”)�”}”(hŒ-Hans-Jürgen Koch Linux developer, Linutronix”h]”hŒ paragraph”“”)�”}”(hhéh]”hŒ-Hans-Jürgen Koch Linux developer, Linutronix”…”�”}”(hhíh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Khhçubah}”(h]”h ]”h"]”h$]”h&]”uh1håhhÒubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÐh³hÊh´KhhÍh²hubhÑ)�”}”(hhh]”(hÖ)�”}”(hŒDate”h]”hŒDate”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÕhjh³hÊh´Kubhæ)�”}”(hŒ 2006-12-11 ”h]”hì)�”}”(hŒ 2006-12-11”h]”hŒ 2006-12-11”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Khjubah}”(h]”h ]”h"]”h$]”h&]”uh1håhjubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÐh³hÊh´KhhÍh²hubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËhh·h²hh³hÊh´Kubh¶)�”}”(hhh]”(h»)�”}”(hŒAbout this document”h]”hŒAbout this document”…”�”}”(hj>h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj;h²hh³hÊh´K ubh¶)�”}”(hhh]”(h»)�”}”(hŒ Translations”h]”hŒ Translations”…”�”}”(hjOh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjLh²hh³hÊh´K ubhì)�”}”(hŒ}If you know of any translations for this document, or you are interested in translating it, please email me hjk@hansjkoch.de.”h]”(hŒlIf you know of any translations for this document, or you are interested in translating it, please email me ”…”�”}”(hj]h²hh³Nh´NubhŒ reference”“”)�”}”(hŒhjk@hansjkoch.de”h]”hŒhjk@hansjkoch.de”…”�”}”(hjgh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œrefuri”Œmailto:hjk@hansjkoch.de”uh1jehj]ubhŒ.”…”�”}”(hj]h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´KhjLh²hubeh}”(h]”Œ translations”ah ]”h"]”Œ translations”ah$]”h&]”uh1hµhj;h²hh³hÊh´K ubh¶)�”}”(hhh]”(h»)�”}”(hŒPreface”h]”hŒPreface”…”�”}”(hjŒh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj‰h²hh³hÊh´Kubhì)�”}”(hXÄFor many types of devices, creating a Linux kernel driver is overkill. All that is really needed is some way to handle an interrupt and provide access to the memory space of the device. The logic of controlling the device does not necessarily have to be within the kernel, as the device does not need to take advantage of any of other resources that the kernel provides. One such common class of devices that are like this are for industrial I/O cards.”h]”hXÄFor many types of devices, creating a Linux kernel driver is overkill. All that is really needed is some way to handle an interrupt and provide access to the memory space of the device. The logic of controlling the device does not necessarily have to be within the kernel, as the device does not need to take advantage of any of other resources that the kernel provides. One such common class of devices that are like this are for industrial I/O cards.”…”�”}”(hjšh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Khj‰h²hubhì)�”}”(hX!To address this situation, the userspace I/O system (UIO) was designed. For typical industrial I/O cards, only a very small kernel module is needed. The main part of the driver will run in user space. This simplifies development and reduces the risk of serious bugs within a kernel module.”h]”hX!To address this situation, the userspace I/O system (UIO) was designed. For typical industrial I/O cards, only a very small kernel module is needed. The main part of the driver will run in user space. This simplifies development and reduces the risk of serious bugs within a kernel module.”…”�”}”(hj¨h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Khj‰h²hubhì)�”}”(hXPlease note that UIO is not an universal driver interface. Devices that are already handled well by other kernel subsystems (like networking or serial or USB) are no candidates for an UIO driver. Hardware that is ideally suited for an UIO driver fulfills all of the following:”h]”hXPlease note that UIO is not an universal driver interface. Devices that are already handled well by other kernel subsystems (like networking or serial or USB) are no candidates for an UIO driver. Hardware that is ideally suited for an UIO driver fulfills all of the following:”…”�”}”(hj¶h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K"hj‰h²hubhŒ bullet_list”“”)�”}”(hhh]”(hŒ list_item”“”)�”}”(hŒmThe device has memory that can be mapped. The device can be controlled completely by writing to this memory. ”h]”hì)�”}”(hŒlThe device has memory that can be mapped. The device can be controlled completely by writing to this memory.”h]”hŒlThe device has memory that can be mapped. The device can be controlled completely by writing to this memory.”…”�”}”(hjÏh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K'hjËubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhjÆh²hh³hÊh´NubjÊ)�”}”(hŒ)The device usually generates interrupts. ”h]”hì)�”}”(hŒ(The device usually generates interrupts.”h]”hŒ(The device usually generates interrupts.”…”�”}”(hjçh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K*hjãubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhjÆh²hh³hÊh´NubjÊ)�”}”(hŒDThe device does not fit into one of the standard kernel subsystems. ”h]”hì)�”}”(hŒCThe device does not fit into one of the standard kernel subsystems.”h]”hŒCThe device does not fit into one of the standard kernel subsystems.”…”�”}”(hjÿh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K,hjûubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhjÆh²hh³hÊh´Nubeh}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ-”uh1jÄh³hÊh´K'hj‰h²hubeh}”(h]”Œpreface”ah ]”h"]”Œpreface”ah$]”h&]”uh1hµhj;h²hh³hÊh´Kubh¶)�”}”(hhh]”(h»)�”}”(hŒAcknowledgments”h]”hŒAcknowledgments”…”�”}”(hj&h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj#h²hh³hÊh´K/ubhì)�”}”(hŒÓI'd like to thank Thomas Gleixner and Benedikt Spranger of Linutronix, who have not only written most of the UIO code, but also helped greatly writing this HOWTO by giving me all kinds of background information.”h]”hŒÕI’d like to thank Thomas Gleixner and Benedikt Spranger of Linutronix, who have not only written most of the UIO code, but also helped greatly writing this HOWTO by giving me all kinds of background information.”…”�”}”(hj4h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K1hj#h²hubeh}”(h]”Œacknowledgments”ah ]”h"]”Œacknowledgments”ah$]”h&]”uh1hµhj;h²hh³hÊh´K/ubh¶)�”}”(hhh]”(h»)�”}”(hŒFeedback”h]”hŒFeedback”…”�”}”(hjMh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjJh²hh³hÊh´K6ubhì)�”}”(hŒŠFind something wrong with this document? (Or perhaps something right?) I would love to hear from you. Please email me at hjk@hansjkoch.de.”h]”(hŒyFind something wrong with this document? (Or perhaps something right?) I would love to hear from you. Please email me at ”…”�”}”(hj[h²hh³Nh´Nubjf)�”}”(hŒhjk@hansjkoch.de”h]”hŒhjk@hansjkoch.de”…”�”}”(hjch²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œrefuri”Œmailto:hjk@hansjkoch.de”uh1jehj[ubhŒ.”…”�”}”(hj[h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K8hjJh²hubeh}”(h]”Œfeedback”ah ]”h"]”Œfeedback”ah$]”h&]”uh1hµhj;h²hh³hÊh´K6ubeh}”(h]”Œabout-this-document”ah ]”h"]”Œabout this document”ah$]”h&]”uh1hµhh·h²hh³hÊh´K ubh¶)�”}”(hhh]”(h»)�”}”(hŒ About UIO”h]”hŒ About UIO”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj�h²hh³hÊh´Khj�h²hubjÅ)�”}”(hhh]”(jÊ)�”}”(hŒ4only one small kernel module to write and maintain. ”h]”hì)�”}”(hŒ3only one small kernel module to write and maintain.”h]”hŒ3only one small kernel module to write and maintain.”…”�”}”(hj³h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K@hj¯ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhj¬h²hh³hÊh´NubjÊ)�”}”(hŒedevelop the main part of your driver in user space, with all the tools and libraries you're used to. ”h]”hì)�”}”(hŒddevelop the main part of your driver in user space, with all the tools and libraries you're used to.”h]”hŒfdevelop the main part of your driver in user space, with all the tools and libraries you’re used to.”…”�”}”(hjËh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´KBhjÇubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhj¬h²hh³hÊh´NubjÊ)�”}”(hŒ,bugs in your driver won't crash the kernel. ”h]”hì)�”}”(hŒ+bugs in your driver won't crash the kernel.”h]”hŒ-bugs in your driver won’t crash the kernel.”…”�”}”(hjãh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´KEhjßubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhj¬h²hh³hÊh´NubjÊ)�”}”(hŒFupdates of your driver can take place without recompiling the kernel. ”h]”hì)�”}”(hŒEupdates of your driver can take place without recompiling the kernel.”h]”hŒEupdates of your driver can take place without recompiling the kernel.”…”�”}”(hjûh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´KGhj÷ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhj¬h²hh³hÊh´Nubeh}”(h]”h ]”h"]”h$]”h&]”jjuh1jÄh³hÊh´K@hj�h²hubh¶)�”}”(hhh]”(h»)�”}”(hŒ How UIO works”h]”hŒ How UIO works”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjh²hh³hÊh´KJubhì)�”}”(hŒÚEach UIO device is accessed through a device file and several sysfs attribute files. The device file will be called ``/dev/uio0`` for the first device, and ``/dev/uio1``, ``/dev/uio2`` and so on for subsequent devices.”h]”(hŒtEach UIO device is accessed through a device file and several sysfs attribute files. The device file will be called ”…”�”}”(hj&h²hh³Nh´NubhŒliteral”“”)�”}”(hŒ ``/dev/uio0``”h]”hŒ /dev/uio0”…”�”}”(hj0h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj&ubhŒ for the first device, and ”…”�”}”(hj&h²hh³Nh´Nubj/)�”}”(hŒ ``/dev/uio1``”h]”hŒ /dev/uio1”…”�”}”(hjBh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj&ubhŒ, ”…”�”}”(hj&h²hh³Nh´Nubj/)�”}”(hŒ ``/dev/uio2``”h]”hŒ /dev/uio2”…”�”}”(hjTh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj&ubhŒ" and so on for subsequent devices.”…”�”}”(hj&h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´KLhjh²hubhì)�”}”(hŒ‹``/dev/uioX`` is used to access the address space of the card. Just use :c:func:`mmap()` to access registers or RAM locations of your card.”h]”(j/)�”}”(hŒ ``/dev/uioX``”h]”hŒ /dev/uioX”…”�”}”(hjph²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjlubhŒ; is used to access the address space of the card. Just use ”…”�”}”(hjlh²hh³Nh´Nubh)�”}”(hŒ:c:func:`mmap()`”h]”j/)�”}”(hj„h]”hŒmmap()”…”�”}”(hj†h²hh³Nh´Nubah}”(h]”h ]”(Œxref”Œc”Œc-func”eh"]”h$]”h&]”uh1j.hj‚ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”Œdriver-api/uio-howto”Œ refdomain”j‘Œreftype”Œfunc”Œ refexplicit”‰Œrefwarn”‰Œ reftarget”Œmmap”uh1hh³hÊh´KQhjlubhŒ3 to access registers or RAM locations of your card.”…”�”}”(hjlh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´KQhjh²hubhì)�”}”(hXtInterrupts are handled by reading from ``/dev/uioX``. A blocking :c:func:`read()` from ``/dev/uioX`` will return as soon as an interrupt occurs. You can also use :c:func:`select()` on ``/dev/uioX`` to wait for an interrupt. The integer value read from ``/dev/uioX`` represents the total interrupt count. You can use this number to figure out if you missed some interrupts.”h]”(hŒ'Interrupts are handled by reading from ”…”�”}”(hj¯h²hh³Nh´Nubj/)�”}”(hŒ ``/dev/uioX``”h]”hŒ /dev/uioX”…”�”}”(hj·h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj¯ubhŒ . A blocking ”…”�”}”(hj¯h²hh³Nh´Nubh)�”}”(hŒ:c:func:`read()`”h]”j/)�”}”(hjËh]”hŒread()”…”�”}”(hjÍh²hh³Nh´Nubah}”(h]”h ]”(j�j‘Œc-func”eh"]”h$]”h&]”uh1j.hjÉubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j�Œ refdomain”j‘Œreftype”Œfunc”Œ refexplicit”‰Œrefwarn”‰j£Œread”uh1hh³hÊh´KThj¯ubhŒ from ”…”�”}”(hj¯h²hh³Nh´Nubj/)�”}”(hŒ ``/dev/uioX``”h]”hŒ /dev/uioX”…”�”}”(hjìh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj¯ubhŒ> will return as soon as an interrupt occurs. You can also use ”…”�”}”(hj¯h²hh³Nh´Nubh)�”}”(hŒ:c:func:`select()`”h]”j/)�”}”(hjh]”hŒselect()”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”(j�j‘Œc-func”eh"]”h$]”h&]”uh1j.hjþubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j�Œ refdomain”j‘Œreftype”Œfunc”Œ refexplicit”‰Œrefwarn”‰j£Œselect”uh1hh³hÊh´KThj¯ubhŒ on ”…”�”}”(hj¯h²hh³Nh´Nubj/)�”}”(hŒ ``/dev/uioX``”h]”hŒ /dev/uioX”…”�”}”(hj!h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj¯ubhŒ7 to wait for an interrupt. The integer value read from ”…”�”}”(hj¯h²hh³Nh´Nubj/)�”}”(hŒ ``/dev/uioX``”h]”hŒ /dev/uioX”…”�”}”(hj3h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj¯ubhŒk represents the total interrupt count. You can use this number to figure out if you missed some interrupts.”…”�”}”(hj¯h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´KThjh²hubhì)�”}”(hX«For some hardware that has more than one interrupt source internally, but not separate IRQ mask and status registers, there might be situations where userspace cannot determine what the interrupt source was if the kernel handler disables them by writing to the chip's IRQ register. In such a case, the kernel has to disable the IRQ completely to leave the chip's register untouched. Now the userspace part can determine the cause of the interrupt, but it cannot re-enable interrupts. Another cornercase is chips where re-enabling interrupts is a read-modify-write operation to a combined IRQ status/acknowledge register. This would be racy if a new interrupt occurred simultaneously.”h]”hX¯For some hardware that has more than one interrupt source internally, but not separate IRQ mask and status registers, there might be situations where userspace cannot determine what the interrupt source was if the kernel handler disables them by writing to the chip’s IRQ register. In such a case, the kernel has to disable the IRQ completely to leave the chip’s register untouched. Now the userspace part can determine the cause of the interrupt, but it cannot re-enable interrupts. Another cornercase is chips where re-enabling interrupts is a read-modify-write operation to a combined IRQ status/acknowledge register. This would be racy if a new interrupt occurred simultaneously.”…”�”}”(hjKh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K[hjh²hubhì)�”}”(hXTo address these problems, UIO also implements a write() function. It is normally not used and can be ignored for hardware that has only a single interrupt source or has separate IRQ mask and status registers. If you need it, however, a write to ``/dev/uioX`` will call the :c:func:`irqcontrol()` function implemented by the driver. You have to write a 32-bit value that is usually either 0 or 1 to disable or enable interrupts. If a driver does not implement :c:func:`irqcontrol()`, :c:func:`write()` will return with ``-ENOSYS``.”h]”(hŒöTo address these problems, UIO also implements a write() function. It is normally not used and can be ignored for hardware that has only a single interrupt source or has separate IRQ mask and status registers. If you need it, however, a write to ”…”�”}”(hjYh²hh³Nh´Nubj/)�”}”(hŒ ``/dev/uioX``”h]”hŒ /dev/uioX”…”�”}”(hjah²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjYubhŒ will call the ”…”�”}”(hjYh²hh³Nh´Nubh)�”}”(hŒ:c:func:`irqcontrol()`”h]”j/)�”}”(hjuh]”hŒ irqcontrol()”…”�”}”(hjwh²hh³Nh´Nubah}”(h]”h ]”(j�j‘Œc-func”eh"]”h$]”h&]”uh1j.hjsubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j�Œ refdomain”j‘Œreftype”Œfunc”Œ refexplicit”‰Œrefwarn”‰j£Œ irqcontrol”uh1hh³hÊh´KfhjYubhŒ¤ function implemented by the driver. You have to write a 32-bit value that is usually either 0 or 1 to disable or enable interrupts. If a driver does not implement ”…”�”}”(hjYh²hh³Nh´Nubh)�”}”(hŒ:c:func:`irqcontrol()`”h]”j/)�”}”(hj˜h]”hŒ irqcontrol()”…”�”}”(hjšh²hh³Nh´Nubah}”(h]”h ]”(j�j‘Œc-func”eh"]”h$]”h&]”uh1j.hj–ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j�Œ refdomain”j‘Œreftype”Œfunc”Œ refexplicit”‰Œrefwarn”‰j£Œ irqcontrol”uh1hh³hÊh´KfhjYubhŒ, ”…”�”}”(hjYh²hh³Nh´Nubh)�”}”(hŒ:c:func:`write()`”h]”j/)�”}”(hj»h]”hŒwrite()”…”�”}”(hj½h²hh³Nh´Nubah}”(h]”h ]”(j�j‘Œc-func”eh"]”h$]”h&]”uh1j.hj¹ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j�Œ refdomain”j‘Œreftype”Œfunc”Œ refexplicit”‰Œrefwarn”‰j£Œwrite”uh1hh³hÊh´KfhjYubhŒ will return with ”…”�”}”(hjYh²hh³Nh´Nubj/)�”}”(hŒ ``-ENOSYS``”h]”hŒ-ENOSYS”…”�”}”(hjÜh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjYubhŒ.”…”�”}”(hjYh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Kfhjh²hubhì)�”}”(hŒ˜To handle interrupts properly, your custom kernel module can provide its own interrupt handler. It will automatically be called by the built-in handler.”h]”hŒ˜To handle interrupts properly, your custom kernel module can provide its own interrupt handler. It will automatically be called by the built-in handler.”…”�”}”(hjôh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Kphjh²hubhì)�”}”(hXFor cards that don't generate interrupts but need to be polled, there is the possibility to set up a timer that triggers the interrupt handler at configurable time intervals. This interrupt simulation is done by calling :c:func:`uio_event_notify()` from the timer's event handler.”h]”(hŒÞFor cards that don’t generate interrupts but need to be polled, there is the possibility to set up a timer that triggers the interrupt handler at configurable time intervals. This interrupt simulation is done by calling ”…”�”}”(hjh²hh³Nh´Nubh)�”}”(hŒ:c:func:`uio_event_notify()`”h]”j/)�”}”(hj h]”hŒuio_event_notify()”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”(j�j‘Œc-func”eh"]”h$]”h&]”uh1j.hj ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j�Œ refdomain”j‘Œreftype”Œfunc”Œ refexplicit”‰Œrefwarn”‰j£Œuio_event_notify”uh1hh³hÊh´KthjubhŒ" from the timer’s event handler.”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Kthjh²hubhì)�”}”(hXVEach driver provides attributes that are used to read or write variables. These attributes are accessible through sysfs files. A custom kernel driver module can add its own attributes to the device owned by the uio driver, but not added to the UIO device itself at this time. This might change in the future if it would be found to be useful.”h]”hXVEach driver provides attributes that are used to read or write variables. These attributes are accessible through sysfs files. A custom kernel driver module can add its own attributes to the device owned by the uio driver, but not added to the UIO device itself at this time. This might change in the future if it would be found to be useful.”…”�”}”(hj3h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Kzhjh²hubhì)�”}”(hŒDThe following standard attributes are provided by the UIO framework:”h]”hŒDThe following standard attributes are provided by the UIO framework:”…”�”}”(hjAh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K€hjh²hubjÅ)�”}”(hhh]”(jÊ)�”}”(hŒe``name``: The name of your device. It is recommended to use the name of your kernel module for this. ”h]”hì)�”}”(hŒd``name``: The name of your device. It is recommended to use the name of your kernel module for this.”h]”(j/)�”}”(hŒ``name``”h]”hŒname”…”�”}”(hjZh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjVubhŒ\: The name of your device. It is recommended to use the name of your kernel module for this.”…”�”}”(hjVh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K‚hjRubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhjOh²hh³hÊh´NubjÊ)�”}”(hŒ›``version``: A version string defined by your driver. This allows the user space part of your driver to deal with different versions of the kernel module. ”h]”hì)�”}”(hŒš``version``: A version string defined by your driver. This allows the user space part of your driver to deal with different versions of the kernel module.”h]”(j/)�”}”(hŒ ``version``”h]”hŒversion”…”�”}”(hj€h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj|ubhŒ�: A version string defined by your driver. This allows the user space part of your driver to deal with different versions of the kernel module.”…”�”}”(hj|h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K…hjxubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhjOh²hh³hÊh´NubjÊ)�”}”(hŒn``event``: The total number of interrupts handled by the driver since the last time the device node was read. ”h]”hì)�”}”(hŒm``event``: The total number of interrupts handled by the driver since the last time the device node was read.”h]”(j/)�”}”(hŒ ``event``”h]”hŒevent”…”�”}”(hj¦h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj¢ubhŒd: The total number of interrupts handled by the driver since the last time the device node was read.”…”�”}”(hj¢h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K‰hjžubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhjOh²hh³hÊh´Nubeh}”(h]”h ]”h"]”h$]”h&]”jjuh1jÄh³hÊh´K‚hjh²hubhì)�”}”(hŒÓThese attributes appear under the ``/sys/class/uio/uioX`` directory. Please note that this directory might be a symlink, and not a real directory. Any userspace code that accesses it must be able to handle this.”h]”(hŒ"These attributes appear under the ”…”�”}”(hjÊh²hh³Nh´Nubj/)�”}”(hŒ``/sys/class/uio/uioX``”h]”hŒ/sys/class/uio/uioX”…”�”}”(hjÒh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjÊubhŒš directory. Please note that this directory might be a symlink, and not a real directory. Any userspace code that accesses it must be able to handle this.”…”�”}”(hjÊh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´KŒhjh²hubhì)�”}”(hŒÄEach UIO device can make one or more memory regions available for memory mapping. This is necessary because some industrial I/O cards require access to more than one PCI memory region in a driver.”h]”hŒÄEach UIO device can make one or more memory regions available for memory mapping. This is necessary because some industrial I/O cards require access to more than one PCI memory region in a driver.”…”�”}”(hjêh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K‘hjh²hubhì)�”}”(hŒýEach mapping has its own directory in sysfs, the first mapping appears as ``/sys/class/uio/uioX/maps/map0/``. Subsequent mappings create directories ``map1/``, ``map2/``, and so on. These directories will only appear if the size of the mapping is not 0.”h]”(hŒJEach mapping has its own directory in sysfs, the first mapping appears as ”…”�”}”(hjøh²hh³Nh´Nubj/)�”}”(hŒ"``/sys/class/uio/uioX/maps/map0/``”h]”hŒ/sys/class/uio/uioX/maps/map0/”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjøubhŒ). Subsequent mappings create directories ”…”�”}”(hjøh²hh³Nh´Nubj/)�”}”(hŒ ``map1/``”h]”hŒmap1/”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjøubhŒ, ”…”�”}”(hjøh²hh³Nh´Nubj/)�”}”(hŒ ``map2/``”h]”hŒmap2/”…”�”}”(hj$h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjøubhŒT, and so on. These directories will only appear if the size of the mapping is not 0.”…”�”}”(hjøh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K•hjh²hubhì)�”}”(hŒZEach ``mapX/`` directory contains four read-only files that show attributes of the memory:”h]”(hŒEach ”…”�”}”(hj<h²hh³Nh´Nubj/)�”}”(hŒ ``mapX/``”h]”hŒmapX/”…”�”}”(hjDh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj<ubhŒL directory contains four read-only files that show attributes of the memory:”…”�”}”(hj<h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Kšhjh²hubjÅ)�”}”(hhh]”(jÊ)�”}”(hŒ­``name``: A string identifier for this mapping. This is optional, the string can be empty. Drivers can set this to make it easier for userspace to find the correct mapping. ”h]”hì)�”}”(hŒ¬``name``: A string identifier for this mapping. This is optional, the string can be empty. Drivers can set this to make it easier for userspace to find the correct mapping.”h]”(j/)�”}”(hŒ``name``”h]”hŒname”…”�”}”(hjgh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjcubhŒ¤: A string identifier for this mapping. This is optional, the string can be empty. Drivers can set this to make it easier for userspace to find the correct mapping.”…”�”}”(hjch²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K�hj_ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhj\h²hh³hÊh´NubjÊ)�”}”(hŒ4``addr``: The address of memory that can be mapped. ”h]”hì)�”}”(hŒ3``addr``: The address of memory that can be mapped.”h]”(j/)�”}”(hŒ``addr``”h]”hŒaddr”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj‰ubhŒ+: The address of memory that can be mapped.”…”�”}”(hj‰h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K¡hj…ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhj\h²hh³hÊh´NubjÊ)�”}”(hŒ@``size``: The size, in bytes, of the memory pointed to by addr. ”h]”hì)�”}”(hŒ?``size``: The size, in bytes, of the memory pointed to by addr.”h]”(j/)�”}”(hŒ``size``”h]”hŒsize”…”�”}”(hj³h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj¯ubhŒ7: The size, in bytes, of the memory pointed to by addr.”…”�”}”(hj¯h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K£hj«ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhj\h²hh³hÊh´NubjÊ)�”}”(hXA``offset``: The offset, in bytes, that has to be added to the pointer returned by :c:func:`mmap()` to get to the actual device memory. This is important if the device's memory is not page aligned. Remember that pointers returned by :c:func:`mmap()` are always page aligned, so it is good style to always add this offset. ”h]”hì)�”}”(hX@``offset``: The offset, in bytes, that has to be added to the pointer returned by :c:func:`mmap()` to get to the actual device memory. This is important if the device's memory is not page aligned. Remember that pointers returned by :c:func:`mmap()` are always page aligned, so it is good style to always add this offset.”h]”(j/)�”}”(hŒ ``offset``”h]”hŒoffset”…”�”}”(hjÙh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjÕubhŒH: The offset, in bytes, that has to be added to the pointer returned by ”…”�”}”(hjÕh²hh³Nh´Nubh)�”}”(hŒ:c:func:`mmap()`”h]”j/)�”}”(hjíh]”hŒmmap()”…”�”}”(hjïh²hh³Nh´Nubah}”(h]”h ]”(j�j‘Œc-func”eh"]”h$]”h&]”uh1j.hjëubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j�Œ refdomain”j‘Œreftype”Œfunc”Œ refexplicit”‰Œrefwarn”‰j£Œmmap”uh1hh³hÊh´K¥hjÕubhŒˆ to get to the actual device memory. This is important if the device’s memory is not page aligned. Remember that pointers returned by ”…”�”}”(hjÕh²hh³Nh´Nubh)�”}”(hŒ:c:func:`mmap()`”h]”j/)�”}”(hjh]”hŒmmap()”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”(j�j‘Œc-func”eh"]”h$]”h&]”uh1j.hjubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j�Œ refdomain”j‘Œreftype”Œfunc”Œ refexplicit”‰Œrefwarn”‰j£Œmmap”uh1hh³hÊh´K¥hjÕubhŒH are always page aligned, so it is good style to always add this offset.”…”�”}”(hjÕh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K¥hjÑubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhj\h²hh³hÊh´Nubeh}”(h]”h ]”h"]”h$]”h&]”jjuh1jÄh³hÊh´K�hjh²hubhì)�”}”(hŒÓFrom userspace, the different mappings are distinguished by adjusting the ``offset`` parameter of the :c:func:`mmap()` call. To map the memory of mapping N, you have to use N times the page size as your offset::”h]”(hŒJFrom userspace, the different mappings are distinguished by adjusting the ”…”�”}”(hjCh²hh³Nh´Nubj/)�”}”(hŒ ``offset``”h]”hŒoffset”…”�”}”(hjKh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjCubhŒ parameter of the ”…”�”}”(hjCh²hh³Nh´Nubh)�”}”(hŒ:c:func:`mmap()`”h]”j/)�”}”(hj_h]”hŒmmap()”…”�”}”(hjah²hh³Nh´Nubah}”(h]”h ]”(j�j‘Œc-func”eh"]”h$]”h&]”uh1j.hj]ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j�Œ refdomain”j‘Œreftype”Œfunc”Œ refexplicit”‰Œrefwarn”‰j£Œmmap”uh1hh³hÊh´K«hjCubhŒ\ call. To map the memory of mapping N, you have to use N times the page size as your offset:”…”�”}”(hjCh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K«hjh²hubhŒ literal_block”“”)�”}”(hŒoffset = N * getpagesize();”h]”hŒoffset = N * getpagesize();”…”�”}”hjˆsbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1j†h³hÊh´K°hjh²hubhì)�”}”(hXhSometimes there is hardware with memory-like regions that can not be mapped with the technique described here, but there are still ways to access them from userspace. The most common example are x86 ioports. On x86 systems, userspace can access these ioports using :c:func:`ioperm()`, :c:func:`iopl()`, :c:func:`inb()`, :c:func:`outb()`, and similar functions.”h]”(hX Sometimes there is hardware with memory-like regions that can not be mapped with the technique described here, but there are still ways to access them from userspace. The most common example are x86 ioports. On x86 systems, userspace can access these ioports using ”…”�”}”(hj˜h²hh³Nh´Nubh)�”}”(hŒ:c:func:`ioperm()`”h]”j/)�”}”(hj¢h]”hŒioperm()”…”�”}”(hj¤h²hh³Nh´Nubah}”(h]”h ]”(j�j‘Œc-func”eh"]”h$]”h&]”uh1j.hj ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j�Œ refdomain”j‘Œreftype”Œfunc”Œ refexplicit”‰Œrefwarn”‰j£Œioperm”uh1hh³hÊh´K²hj˜ubhŒ, ”…”�”}”(hj˜h²hh³Nh´Nubh)�”}”(hŒ:c:func:`iopl()`”h]”j/)�”}”(hjÅh]”hŒiopl()”…”�”}”(hjÇh²hh³Nh´Nubah}”(h]”h ]”(j�j‘Œc-func”eh"]”h$]”h&]”uh1j.hjÃubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j�Œ refdomain”j‘Œreftype”Œfunc”Œ refexplicit”‰Œrefwarn”‰j£Œiopl”uh1hh³hÊh´K²hj˜ubhŒ, ”…”�”}”hj˜sbh)�”}”(hŒ:c:func:`inb()`”h]”j/)�”}”(hjèh]”hŒinb()”…”�”}”(hjêh²hh³Nh´Nubah}”(h]”h ]”(j�j‘Œc-func”eh"]”h$]”h&]”uh1j.hjæubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j�Œ refdomain”j‘Œreftype”Œfunc”Œ refexplicit”‰Œrefwarn”‰j£Œinb”uh1hh³hÊh´K²hj˜ubhŒ, ”…”�”}”(hj˜h²hh³Nh´Nubh)�”}”(hŒ:c:func:`outb()`”h]”j/)�”}”(hj h]”hŒoutb()”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”(j�j‘Œc-func”eh"]”h$]”h&]”uh1j.hj ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j�Œ refdomain”j‘Œreftype”Œfunc”Œ refexplicit”‰Œrefwarn”‰j£Œoutb”uh1hh³hÊh´K²hj˜ubhŒ, and similar functions.”…”�”}”(hj˜h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K²hjh²hubhì)�”}”(hX@Since these ioport regions can not be mapped, they will not appear under ``/sys/class/uio/uioX/maps/`` like the normal memory described above. Without information about the port regions a hardware has to offer, it becomes difficult for the userspace part of the driver to find out which ports belong to which UIO device.”h]”(hŒISince these ioport regions can not be mapped, they will not appear under ”…”�”}”(hj2h²hh³Nh´Nubj/)�”}”(hŒ``/sys/class/uio/uioX/maps/``”h]”hŒ/sys/class/uio/uioX/maps/”…”�”}”(hj:h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj2ubhŒÚ like the normal memory described above. Without information about the port regions a hardware has to offer, it becomes difficult for the userspace part of the driver to find out which ports belong to which UIO device.”…”�”}”(hj2h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K¹hjh²hubhì)�”}”(hX>To address this situation, the new directory ``/sys/class/uio/uioX/portio/`` was added. It only exists if the driver wants to pass information about one or more port regions to userspace. If that is the case, subdirectories named ``port0``, ``port1``, and so on, will appear underneath ``/sys/class/uio/uioX/portio/``.”h]”(hŒ-To address this situation, the new directory ”…”�”}”(hjRh²hh³Nh´Nubj/)�”}”(hŒ``/sys/class/uio/uioX/portio/``”h]”hŒ/sys/class/uio/uioX/portio/”…”�”}”(hjZh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjRubhŒš was added. It only exists if the driver wants to pass information about one or more port regions to userspace. If that is the case, subdirectories named ”…”�”}”(hjRh²hh³Nh´Nubj/)�”}”(hŒ ``port0``”h]”hŒport0”…”�”}”(hjlh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjRubhŒ, ”…”�”}”(hjRh²hh³Nh´Nubj/)�”}”(hŒ ``port1``”h]”hŒport1”…”�”}”(hj~h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjRubhŒ$, and so on, will appear underneath ”…”�”}”(hjRh²hh³Nh´Nubj/)�”}”(hŒ``/sys/class/uio/uioX/portio/``”h]”hŒ/sys/class/uio/uioX/portio/”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjRubhŒ.”…”�”}”(hjRh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K¿hjh²hubhì)�”}”(hŒqEach ``portX/`` directory contains four read-only files that show name, start, size, and type of the port region:”h]”(hŒEach ”…”�”}”(hj¨h²hh³Nh´Nubj/)�”}”(hŒ ``portX/``”h]”hŒportX/”…”�”}”(hj°h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj¨ubhŒb directory contains four read-only files that show name, start, size, and type of the port region:”…”�”}”(hj¨h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´KÅhjh²hubjÅ)�”}”(hhh]”(jÊ)�”}”(hŒ¯``name``: A string identifier for this port region. The string is optional and can be empty. Drivers can set it to make it easier for userspace to find a certain port region. ”h]”hì)�”}”(hŒ®``name``: A string identifier for this port region. The string is optional and can be empty. Drivers can set it to make it easier for userspace to find a certain port region.”h]”(j/)�”}”(hŒ``name``”h]”hŒname”…”�”}”(hjÓh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjÏubhŒ¦: A string identifier for this port region. The string is optional and can be empty. Drivers can set it to make it easier for userspace to find a certain port region.”…”�”}”(hjÏh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´KÈhjËubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhjÈh²hh³hÊh´NubjÊ)�”}”(hŒ*``start``: The first port of this region. ”h]”hì)�”}”(hŒ)``start``: The first port of this region.”h]”(j/)�”}”(hŒ ``start``”h]”hŒstart”…”�”}”(hjùh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjõubhŒ : The first port of this region.”…”�”}”(hjõh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´KÌhjñubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhjÈh²hh³hÊh´NubjÊ)�”}”(hŒ.``size``: The number of ports in this region. ”h]”hì)�”}”(hŒ-``size``: The number of ports in this region.”h]”(j/)�”}”(hŒ``size``”h]”hŒsize”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj ubhŒ%: The number of ports in this region.”…”�”}”(hj h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´KÎhj ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhjÈh²hh³hÊh´NubjÊ)�”}”(hŒ4``porttype``: A string describing the type of port. ”h]”hì)�”}”(hŒ3``porttype``: A string describing the type of port.”h]”(j/)�”}”(hŒ ``porttype``”h]”hŒporttype”…”�”}”(hjE h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjA ubhŒ': A string describing the type of port.”…”�”}”(hjA h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´KÐhj= ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhjÈh²hh³hÊh´Nubeh}”(h]”h ]”h"]”h$]”h&]”jjuh1jÄh³hÊh´KÈhjh²hubeh}”(h]”Œ how-uio-works”ah ]”h"]”Œ how uio works”ah$]”h&]”uh1hµhj�h²hh³hÊh´KJubeh}”(h]”Œ about-uio”ah ]”h"]”Œ about uio”ah$]”h&]”uh1hµhh·h²hh³hÊh´K``int (*release)(struct uio_info *info, struct inode *inode)``”h]”hŒ:int (*release)(struct uio_info *info, struct inode *inode)”…”�”}”(hj2 h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj. ubhŒ#: Optional. If you define your own ”…”�”}”(hj. h²hh³Nh´Nubh)�”}”(hŒ:c:func:`open()`”h]”j/)�”}”(hjF h]”hŒopen()”…”�”}”(hjH h²hh³Nh´Nubah}”(h]”h ]”(j�j‘Œc-func”eh"]”h$]”h&]”uh1j.hjD ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j�Œ refdomain”j‘Œreftype”Œfunc”Œ refexplicit”‰Œrefwarn”‰j£Œopen”uh1hh³hÊh´Mhj. ubhŒ', you will probably also want a custom ”…”�”}”(hj. h²hh³Nh´Nubh)�”}”(hŒ:c:func:`release()`”h]”j/)�”}”(hji h]”hŒ release()”…”�”}”(hjk h²hh³Nh´Nubah}”(h]”h ]”(j�j‘Œc-func”eh"]”h$]”h&]”uh1j.hjg ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j�Œ refdomain”j‘Œreftype”Œfunc”Œ refexplicit”‰Œrefwarn”‰j£Œrelease”uh1hh³hÊh´Mhj. ubhŒ function.”…”�”}”(hj. h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Mhj* ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhjÉ h²hh³hÊh´NubjÊ)�”}”(hX``int (*irqcontrol)(struct uio_info *info, s32 irq_on)``: Optional. If you need to be able to enable or disable interrupts from userspace by writing to ``/dev/uioX``, you can implement this function. The parameter ``irq_on`` will be 0 to disable interrupts and 1 to enable them. ”h]”hì)�”}”(hX``int (*irqcontrol)(struct uio_info *info, s32 irq_on)``: Optional. If you need to be able to enable or disable interrupts from userspace by writing to ``/dev/uioX``, you can implement this function. The parameter ``irq_on`` will be 0 to disable interrupts and 1 to enable them.”h]”(j/)�”}”(hŒ8``int (*irqcontrol)(struct uio_info *info, s32 irq_on)``”h]”hŒ4int (*irqcontrol)(struct uio_info *info, s32 irq_on)”…”�”}”(hjž h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjš ubhŒ`: Optional. If you need to be able to enable or disable interrupts from userspace by writing to ”…”�”}”(hjš h²hh³Nh´Nubj/)�”}”(hŒ ``/dev/uioX``”h]”hŒ /dev/uioX”…”�”}”(hj° h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjš ubhŒ1, you can implement this function. The parameter ”…”�”}”(hjš h²hh³Nh´Nubj/)�”}”(hŒ ``irq_on``”h]”hŒirq_on”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjš ubhŒ6 will be 0 to disable interrupts and 1 to enable them.”…”�”}”(hjš h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Mhj– ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhjÉ h²hh³hÊh´Nubeh}”(h]”h ]”h"]”h$]”h&]”jjuh1jÄh³hÊh´KÞhjª h²hubhì)�”}”(hŒæUsually, your device will have one or more memory regions that can be mapped to user space. For each region, you have to set up a ``struct uio_mem`` in the ``mem[]`` array. Here's a description of the fields of ``struct uio_mem``:”h]”(hŒ‚Usually, your device will have one or more memory regions that can be mapped to user space. For each region, you have to set up a ”…”�”}”(hjæ h²hh³Nh´Nubj/)�”}”(hŒ``struct uio_mem``”h]”hŒstruct uio_mem”…”�”}”(hjî h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjæ ubhŒ in the ”…”�”}”(hjæ h²hh³Nh´Nubj/)�”}”(hŒ ``mem[]``”h]”hŒmem[]”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjæ ubhŒ0 array. Here’s a description of the fields of ”…”�”}”(hjæ h²hh³Nh´Nubj/)�”}”(hŒ``struct uio_mem``”h]”hŒstruct uio_mem”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjæ ubhŒ:”…”�”}”(hjæ h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M hjª h²hubjÅ)�”}”(hhh]”(jÊ)�”}”(hŒ~``const char *name``: Optional. Set this to help identify the memory region, it will show up in the corresponding sysfs node. ”h]”hì)�”}”(hŒ}``const char *name``: Optional. Set this to help identify the memory region, it will show up in the corresponding sysfs node.”h]”(j/)�”}”(hŒ``const char *name``”h]”hŒconst char *name”…”�”}”(hj5 h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj1 ubhŒi: Optional. Set this to help identify the memory region, it will show up in the corresponding sysfs node.”…”�”}”(hj1 h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Mhj- ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhj* h²hh³hÊh´NubjÊ)�”}”(hX,``int memtype``: Required if the mapping is used. Set this to ``UIO_MEM_PHYS`` if you have physical memory on your card to be mapped. Use ``UIO_MEM_LOGICAL`` for logical memory (e.g. allocated with :c:func:`__get_free_pages()` but not kmalloc()). There's also ``UIO_MEM_VIRTUAL`` for virtual memory. ”h]”hì)�”}”(hX+``int memtype``: Required if the mapping is used. Set this to ``UIO_MEM_PHYS`` if you have physical memory on your card to be mapped. Use ``UIO_MEM_LOGICAL`` for logical memory (e.g. allocated with :c:func:`__get_free_pages()` but not kmalloc()). There's also ``UIO_MEM_VIRTUAL`` for virtual memory.”h]”(j/)�”}”(hŒ``int memtype``”h]”hŒ int memtype”…”�”}”(hj[ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjW ubhŒ/: Required if the mapping is used. Set this to ”…”�”}”(hjW h²hh³Nh´Nubj/)�”}”(hŒ``UIO_MEM_PHYS``”h]”hŒ UIO_MEM_PHYS”…”�”}”(hjm h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjW ubhŒ< if you have physical memory on your card to be mapped. Use ”…”�”}”(hjW h²hh³Nh´Nubj/)�”}”(hŒ``UIO_MEM_LOGICAL``”h]”hŒUIO_MEM_LOGICAL”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjW ubhŒ) for logical memory (e.g. allocated with ”…”�”}”(hjW h²hh³Nh´Nubh)�”}”(hŒ:c:func:`__get_free_pages()`”h]”j/)�”}”(hj“ h]”hŒ__get_free_pages()”…”�”}”(hj• h²hh³Nh´Nubah}”(h]”h ]”(j�j‘Œc-func”eh"]”h$]”h&]”uh1j.hj‘ ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j�Œ refdomain”j‘Œreftype”Œfunc”Œ refexplicit”‰Œrefwarn”‰j£Œ__get_free_pages”uh1hh³hÊh´MhjW ubhŒ$ but not kmalloc()). There’s also ”…”�”}”(hjW h²hh³Nh´Nubj/)�”}”(hŒ``UIO_MEM_VIRTUAL``”h]”hŒUIO_MEM_VIRTUAL”…”�”}”(hj´ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjW ubhŒ for virtual memory.”…”�”}”(hjW h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´MhjS ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhj* h²hh³hÊh´NubjÊ)�”}”(hŒ�``phys_addr_t addr``: Required if the mapping is used. Fill in the address of your memory block. This address is the one that appears in sysfs. ”h]”hì)�”}”(hŒ�``phys_addr_t addr``: Required if the mapping is used. Fill in the address of your memory block. This address is the one that appears in sysfs.”h]”(j/)�”}”(hŒ``phys_addr_t addr``”h]”hŒphys_addr_t addr”…”�”}”(hjÚ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjÖ ubhŒ{: Required if the mapping is used. Fill in the address of your memory block. This address is the one that appears in sysfs.”…”�”}”(hjÖ h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´MhjÒ ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhj* h²hh³hÊh´NubjÊ)�”}”(hŒÛ``resource_size_t size``: Fill in the size of the memory block that ``addr`` points to. If ``size`` is zero, the mapping is considered unused. Note that you *must* initialize ``size`` with zero for all unused mappings. ”h]”hì)�”}”(hŒÚ``resource_size_t size``: Fill in the size of the memory block that ``addr`` points to. If ``size`` is zero, the mapping is considered unused. Note that you *must* initialize ``size`` with zero for all unused mappings.”h]”(j/)�”}”(hŒ``resource_size_t size``”h]”hŒresource_size_t size”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjü ubhŒ,: Fill in the size of the memory block that ”…”�”}”(hjü h²hh³Nh´Nubj/)�”}”(hŒ``addr``”h]”hŒaddr”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjü ubhŒ points to. If ”…”�”}”(hjü h²hh³Nh´Nubj/)�”}”(hŒ``size``”h]”hŒsize”…”�”}”(hj$h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjü ubhŒ: is zero, the mapping is considered unused. Note that you ”…”�”}”(hjü h²hh³Nh´NubhŒemphasis”“”)�”}”(hŒ*must*”h]”hŒmust”…”�”}”(hj8h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j6hjü ubhŒ initialize ”…”�”}”(hjü h²hh³Nh´Nubj/)�”}”(hŒ``size``”h]”hŒsize”…”�”}”(hjJh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjü ubhŒ# with zero for all unused mappings.”…”�”}”(hjü h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Mhjø ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhj* h²hh³hÊh´NubjÊ)�”}”(hXW``void *internal_addr``: If you have to access this memory region from within your kernel module, you will want to map it internally by using something like :c:func:`ioremap()`. Addresses returned by this function cannot be mapped to user space, so you must not store it in ``addr``. Use ``internal_addr`` instead to remember such an address. ”h]”hì)�”}”(hXV``void *internal_addr``: If you have to access this memory region from within your kernel module, you will want to map it internally by using something like :c:func:`ioremap()`. Addresses returned by this function cannot be mapped to user space, so you must not store it in ``addr``. Use ``internal_addr`` instead to remember such an address.”h]”(j/)�”}”(hŒ``void *internal_addr``”h]”hŒvoid *internal_addr”…”�”}”(hjph²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjlubhŒ†: If you have to access this memory region from within your kernel module, you will want to map it internally by using something like ”…”�”}”(hjlh²hh³Nh´Nubh)�”}”(hŒ:c:func:`ioremap()`”h]”j/)�”}”(hj„h]”hŒ ioremap()”…”�”}”(hj†h²hh³Nh´Nubah}”(h]”h ]”(j�j‘Œc-func”eh"]”h$]”h&]”uh1j.hj‚ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j�Œ refdomain”j‘Œreftype”Œfunc”Œ refexplicit”‰Œrefwarn”‰j£Œioremap”uh1hh³hÊh´M#hjlubhŒb. Addresses returned by this function cannot be mapped to user space, so you must not store it in ”…”�”}”(hjlh²hh³Nh´Nubj/)�”}”(hŒ``addr``”h]”hŒaddr”…”�”}”(hj¥h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjlubhŒ. Use ”…”�”}”(hjlh²hh³Nh´Nubj/)�”}”(hŒ``internal_addr``”h]”hŒ internal_addr”…”�”}”(hj·h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjlubhŒ% instead to remember such an address.”…”�”}”(hjlh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M#hjhubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhj* h²hh³hÊh´Nubeh}”(h]”h ]”h"]”h$]”h&]”jjuh1jÄh³hÊh´Mhjª h²hubhì)�”}”(hŒ�Please do not touch the ``map`` element of ``struct uio_mem``! It is used by the UIO framework to set up sysfs files for this mapping. Simply leave it alone.”h]”(hŒPlease do not touch the ”…”�”}”(hjÛh²hh³Nh´Nubj/)�”}”(hŒ``map``”h]”hŒmap”…”�”}”(hjãh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjÛubhŒ element of ”…”�”}”(hjÛh²hh³Nh´Nubj/)�”}”(hŒ``struct uio_mem``”h]”hŒstruct uio_mem”…”�”}”(hjõh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjÛubhŒ`! It is used by the UIO framework to set up sysfs files for this mapping. Simply leave it alone.”…”�”}”(hjÛh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M*hjª h²hubhì)�”}”(hX}Sometimes, your device can have one or more port regions which can not be mapped to userspace. But if there are other possibilities for userspace to access these ports, it makes sense to make information about the ports available in sysfs. For each region, you have to set up a ``struct uio_port`` in the ``port[]`` array. Here's a description of the fields of ``struct uio_port``:”h]”(hXSometimes, your device can have one or more port regions which can not be mapped to userspace. But if there are other possibilities for userspace to access these ports, it makes sense to make information about the ports available in sysfs. For each region, you have to set up a ”…”�”}”(hj h²hh³Nh´Nubj/)�”}”(hŒ``struct uio_port``”h]”hŒstruct uio_port”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj ubhŒ in the ”…”�”}”(hj h²hh³Nh´Nubj/)�”}”(hŒ ``port[]``”h]”hŒport[]”…”�”}”(hj'h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj ubhŒ0 array. Here’s a description of the fields of ”…”�”}”(hj h²hh³Nh´Nubj/)�”}”(hŒ``struct uio_port``”h]”hŒstruct uio_port”…”�”}”(hj9h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj ubhŒ:”…”�”}”(hj h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M.hjª h²hubjÅ)�”}”(hhh]”(jÊ)�”}”(hŒŒ``char *porttype``: Required. Set this to one of the predefined constants. Use ``UIO_PORT_X86`` for the ioports found in x86 architectures. ”h]”hì)�”}”(hŒ‹``char *porttype``: Required. Set this to one of the predefined constants. Use ``UIO_PORT_X86`` for the ioports found in x86 architectures.”h]”(j/)�”}”(hŒ``char *porttype``”h]”hŒchar *porttype”…”�”}”(hj\h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjXubhŒ=: Required. Set this to one of the predefined constants. Use ”…”�”}”(hjXh²hh³Nh´Nubj/)�”}”(hŒ``UIO_PORT_X86``”h]”hŒ UIO_PORT_X86”…”�”}”(hjnh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjXubhŒ, for the ioports found in x86 architectures.”…”�”}”(hjXh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M5hjTubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhjQh²hh³hÊh´NubjÊ)�”}”(hŒs``unsigned long start``: Required if the port region is used. Fill in the number of the first port of this region. ”h]”hì)�”}”(hŒr``unsigned long start``: Required if the port region is used. Fill in the number of the first port of this region.”h]”(j/)�”}”(hŒ``unsigned long start``”h]”hŒunsigned long start”…”�”}”(hj”h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj�ubhŒ[: Required if the port region is used. Fill in the number of the first port of this region.”…”�”}”(hj�h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M9hjŒubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhjQh²hh³hÊh´NubjÊ)�”}”(hŒÅ``unsigned long size``: Fill in the number of ports in this region. If ``size`` is zero, the region is considered unused. Note that you *must* initialize ``size`` with zero for all unused regions. ”h]”hì)�”}”(hŒÄ``unsigned long size``: Fill in the number of ports in this region. If ``size`` is zero, the region is considered unused. Note that you *must* initialize ``size`` with zero for all unused regions.”h]”(j/)�”}”(hŒ``unsigned long size``”h]”hŒunsigned long size”…”�”}”(hjºh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj¶ubhŒ1: Fill in the number of ports in this region. If ”…”�”}”(hj¶h²hh³Nh´Nubj/)�”}”(hŒ``size``”h]”hŒsize”…”�”}”(hjÌh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj¶ubhŒ9 is zero, the region is considered unused. Note that you ”…”�”}”(hj¶h²hh³Nh´Nubj7)�”}”(hŒ*must*”h]”hŒmust”…”�”}”(hjÞh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j6hj¶ubhŒ initialize ”…”�”}”(hj¶h²hh³Nh´Nubj/)�”}”(hŒ``size``”h]”hŒsize”…”�”}”(hjðh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj¶ubhŒ" with zero for all unused regions.”…”�”}”(hj¶h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M<hj²ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhjQh²hh³hÊh´Nubeh}”(h]”h ]”h"]”h$]”h&]”jjuh1jÄh³hÊh´M5hjª h²hubhì)�”}”(hŒ«Please do not touch the ``portio`` element of ``struct uio_port``! It is used internally by the UIO framework to set up sysfs files for this region. Simply leave it alone.”h]”(hŒPlease do not touch the ”…”�”}”(hjh²hh³Nh´Nubj/)�”}”(hŒ ``portio``”h]”hŒportio”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjubhŒ element of ”…”�”}”(hjh²hh³Nh´Nubj/)�”}”(hŒ``struct uio_port``”h]”hŒstruct uio_port”…”�”}”(hj.h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjubhŒj! It is used internally by the UIO framework to set up sysfs files for this region. Simply leave it alone.”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M@hjª h²hubeh}”(h]”Œstruct-uio-info”ah ]”h"]”Œstruct uio_info”ah$]”h&]”uh1hµhjy h²hh³hÊh´KÙubh¶)�”}”(hhh]”(h»)�”}”(hŒAdding an interrupt handler”h]”hŒAdding an interrupt handler”…”�”}”(hjQh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjNh²hh³hÊh´MEubhì)�”}”(hX-What you need to do in your interrupt handler depends on your hardware and on how you want to handle it. You should try to keep the amount of code in your kernel interrupt handler low. If your hardware requires no action that you *have* to perform after each interrupt, then your handler can be empty.”h]”(hŒæWhat you need to do in your interrupt handler depends on your hardware and on how you want to handle it. You should try to keep the amount of code in your kernel interrupt handler low. If your hardware requires no action that you ”…”�”•Üä}”(hj_h²hh³Nh´Nubj7)�”}”(hŒ*have*”h]”hŒhave”…”�”}”(hjgh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j6hj_ubhŒA to perform after each interrupt, then your handler can be empty.”…”�”}”(hj_h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´MGhjNh²hubhì)�”}”(hXZIf, on the other hand, your hardware *needs* some action to be performed after each interrupt, then you *must* do it in your kernel module. Note that you cannot rely on the userspace part of your driver. Your userspace program can terminate at any time, possibly leaving your hardware in a state where proper interrupt handling is still required.”h]”(hŒ%If, on the other hand, your hardware ”…”�”}”(hjh²hh³Nh´Nubj7)�”}”(hŒ*needs*”h]”hŒneeds”…”�”}”(hj‡h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j6hjubhŒ< some action to be performed after each interrupt, then you ”…”�”}”(hjh²hh³Nh´Nubj7)�”}”(hŒ*must*”h]”hŒmust”…”�”}”(hj™h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j6hjubhŒì do it in your kernel module. Note that you cannot rely on the userspace part of your driver. Your userspace program can terminate at any time, possibly leaving your hardware in a state where proper interrupt handling is still required.”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´MMhjNh²hubhì)�”}”(hXThere might also be applications where you want to read data from your hardware at each interrupt and buffer it in a piece of kernel memory you've allocated for that purpose. With this technique you could avoid loss of data if your userspace program misses an interrupt.”h]”hXThere might also be applications where you want to read data from your hardware at each interrupt and buffer it in a piece of kernel memory you’ve allocated for that purpose. With this technique you could avoid loss of data if your userspace program misses an interrupt.”…”�”}”(hj±h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´MShjNh²hubhì)�”}”(hXDA note on shared interrupts: Your driver should support interrupt sharing whenever this is possible. It is possible if and only if your driver can detect whether your hardware has triggered the interrupt or not. This is usually done by looking at an interrupt status register. If your driver sees that the IRQ bit is actually set, it will perform its actions, and the handler returns IRQ_HANDLED. If the driver detects that it was not your hardware that caused the interrupt, it will do nothing and return IRQ_NONE, allowing the kernel to call the next possible interrupt handler.”h]”hXDA note on shared interrupts: Your driver should support interrupt sharing whenever this is possible. It is possible if and only if your driver can detect whether your hardware has triggered the interrupt or not. This is usually done by looking at an interrupt status register. If your driver sees that the IRQ bit is actually set, it will perform its actions, and the handler returns IRQ_HANDLED. If the driver detects that it was not your hardware that caused the interrupt, it will do nothing and return IRQ_NONE, allowing the kernel to call the next possible interrupt handler.”…”�”}”(hj¿h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´MXhjNh²hubhì)�”}”(hŒáIf you decide not to support shared interrupts, your card won't work in computers with no free interrupts. As this frequently happens on the PC platform, you can save yourself a lot of trouble by supporting interrupt sharing.”h]”hŒãIf you decide not to support shared interrupts, your card won’t work in computers with no free interrupts. As this frequently happens on the PC platform, you can save yourself a lot of trouble by supporting interrupt sharing.”…”�”}”(hjÍh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´MbhjNh²hubeh}”(h]”Œadding-an-interrupt-handler”ah ]”h"]”Œadding an interrupt handler”ah$]”h&]”uh1hµhjy h²hh³hÊh´MEubh¶)�”}”(hhh]”(h»)�”}”(hŒ#Using uio_pdrv for platform devices”h]”hŒ#Using uio_pdrv for platform devices”…”�”}”(hjæh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjãh²hh³hÊh´Mhubhì)�”}”(hXJIn many cases, UIO drivers for platform devices can be handled in a generic way. In the same place where you define your ``struct platform_device``, you simply also implement your interrupt handler and fill your ``struct uio_info``. A pointer to this ``struct uio_info`` is then used as ``platform_data`` for your platform device.”h]”(hŒyIn many cases, UIO drivers for platform devices can be handled in a generic way. In the same place where you define your ”…”�”}”(hjôh²hh³Nh´Nubj/)�”}”(hŒ``struct platform_device``”h]”hŒstruct platform_device”…”�”}”(hjüh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjôubhŒA, you simply also implement your interrupt handler and fill your ”…”�”}”(hjôh²hh³Nh´Nubj/)�”}”(hŒ``struct uio_info``”h]”hŒstruct uio_info”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjôubhŒ. A pointer to this ”…”�”}”(hjôh²hh³Nh´Nubj/)�”}”(hŒ``struct uio_info``”h]”hŒstruct uio_info”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjôubhŒ is then used as ”…”�”}”(hjôh²hh³Nh´Nubj/)�”}”(hŒ``platform_data``”h]”hŒ platform_data”…”�”}”(hj2h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjôubhŒ for your platform device.”…”�”}”(hjôh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Mjhjãh²hubhì)�”}”(hŒïYou also need to set up an array of ``struct resource`` containing addresses and sizes of your memory mappings. This information is passed to the driver using the ``.resource`` and ``.num_resources`` elements of ``struct platform_device``.”h]”(hŒ$You also need to set up an array of ”…”�”}”(hjJh²hh³Nh´Nubj/)�”}”(hŒ``struct resource``”h]”hŒstruct resource”…”�”}”(hjRh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjJubhŒl containing addresses and sizes of your memory mappings. This information is passed to the driver using the ”…”�”}”(hjJh²hh³Nh´Nubj/)�”}”(hŒ ``.resource``”h]”hŒ .resource”…”�”}”(hjdh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjJubhŒ and ”…”�”}”(hjJh²hh³Nh´Nubj/)�”}”(hŒ``.num_resources``”h]”hŒ.num_resources”…”�”}”(hjvh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjJubhŒ elements of ”…”�”}”(hjJh²hh³Nh´Nubj/)�”}”(hŒ``struct platform_device``”h]”hŒstruct platform_device”…”�”}”(hjˆh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjJubhŒ.”…”�”}”(hjJh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Mqhjãh²hubhì)�”}”(hŒíYou now have to set the ``.name`` element of ``struct platform_device`` to ``"uio_pdrv"`` to use the generic UIO platform device driver. This driver will fill the ``mem[]`` array according to the resources given, and register the device.”h]”(hŒYou now have to set the ”…”�”}”(hj h²hh³Nh´Nubj/)�”}”(hŒ ``.name``”h]”hŒ.name”…”�”}”(hj¨h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj ubhŒ element of ”…”�”}”(hj h²hh³Nh´Nubj/)�”}”(hŒ``struct platform_device``”h]”hŒstruct platform_device”…”�”}”(hjºh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj ubhŒ to ”…”�”}”(hj h²hh³Nh´Nubj/)�”}”(hŒ``"uio_pdrv"``”h]”hŒ "uio_pdrv"”…”�”}”(hjÌh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj ubhŒJ to use the generic UIO platform device driver. This driver will fill the ”…”�”}”(hj h²hh³Nh´Nubj/)�”}”(hŒ ``mem[]``”h]”hŒmem[]”…”�”}”(hjÞh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj ubhŒA array according to the resources given, and register the device.”…”�”}”(hj h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Mvhjãh²hubhì)�”}”(hŒ‡The advantage of this approach is that you only have to edit a file you need to edit anyway. You do not have to create an extra driver.”h]”hŒ‡The advantage of this approach is that you only have to edit a file you need to edit anyway. You do not have to create an extra driver.”…”�”}”(hjöh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M{hjãh²hubeh}”(h]”Œ#using-uio-pdrv-for-platform-devices”ah ]”h"]”Œ#using uio_pdrv for platform devices”ah$]”h&]”uh1hµhjy h²hh³hÊh´Mhubh¶)�”}”(hhh]”(h»)�”}”(hŒ*Using uio_pdrv_genirq for platform devices”h]”hŒ*Using uio_pdrv_genirq for platform devices”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj h²hh³hÊh´Mubhì)�”}”(hXEEspecially in embedded devices, you frequently find chips where the irq pin is tied to its own dedicated interrupt line. In such cases, where you can be really sure the interrupt is not shared, we can take the concept of ``uio_pdrv`` one step further and use a generic interrupt handler. That's what ``uio_pdrv_genirq`` does.”h]”(hŒÝEspecially in embedded devices, you frequently find chips where the irq pin is tied to its own dedicated interrupt line. In such cases, where you can be really sure the interrupt is not shared, we can take the concept of ”…”�”}”(hjh²hh³Nh´Nubj/)�”}”(hŒ ``uio_pdrv``”h]”hŒuio_pdrv”…”�”}”(hj%h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjubhŒE one step further and use a generic interrupt handler. That’s what ”…”�”}”(hjh²hh³Nh´Nubj/)�”}”(hŒ``uio_pdrv_genirq``”h]”hŒuio_pdrv_genirq”…”�”}”(hj7h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjubhŒ does.”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M�hj h²hubhì)�”}”(hXThe setup for this driver is the same as described above for ``uio_pdrv``, except that you do not implement an interrupt handler. The ``.handler`` element of ``struct uio_info`` must remain ``NULL``. The ``.irq_flags`` element must not contain ``IRQF_SHARED``.”h]”(hŒ=The setup for this driver is the same as described above for ”…”�”}”(hjOh²hh³Nh´Nubj/)�”}”(hŒ ``uio_pdrv``”h]”hŒuio_pdrv”…”�”}”(hjWh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjOubhŒ=, except that you do not implement an interrupt handler. The ”…”�”}”(hjOh²hh³Nh´Nubj/)�”}”(hŒ ``.handler``”h]”hŒ.handler”…”�”}”(hjih²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjOubhŒ element of ”…”�”}”(hjOh²hh³Nh´Nubj/)�”}”(hŒ``struct uio_info``”h]”hŒstruct uio_info”…”�”}”(hj{h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjOubhŒ must remain ”…”�”}”(hjOh²hh³Nh´Nubj/)�”}”(hŒ``NULL``”h]”hŒNULL”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjOubhŒ. The ”…”�”}”(hjOh²hh³Nh´Nubj/)�”}”(hŒ``.irq_flags``”h]”hŒ .irq_flags”…”�”}”(hjŸh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjOubhŒ element must not contain ”…”�”}”(hjOh²hh³Nh´Nubj/)�”}”(hŒ``IRQF_SHARED``”h]”hŒ IRQF_SHARED”…”�”}”(hj±h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjOubhŒ.”…”�”}”(hjOh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M‡hj h²hubhì)�”}”(hŒmYou will set the ``.name`` element of ``struct platform_device`` to ``"uio_pdrv_genirq"`` to use this driver.”h]”(hŒYou will set the ”…”�”}”(hjÉh²hh³Nh´Nubj/)�”}”(hŒ ``.name``”h]”hŒ.name”…”�”}”(hjÑh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjÉubhŒ element of ”…”�”}”(hjÉh²hh³Nh´Nubj/)�”}”(hŒ``struct platform_device``”h]”hŒstruct platform_device”…”�”}”(hjãh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjÉubhŒ to ”…”�”}”(hjÉh²hh³Nh´Nubj/)�”}”(hŒ``"uio_pdrv_genirq"``”h]”hŒ"uio_pdrv_genirq"”…”�”}”(hjõh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjÉubhŒ to use this driver.”…”�”}”(hjÉh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´MŒhj h²hubhì)�”}”(hX[The generic interrupt handler of ``uio_pdrv_genirq`` will simply disable the interrupt line using :c:func:`disable_irq_nosync()`. After doing its work, userspace can reenable the interrupt by writing 0x00000001 to the UIO device file. The driver already implements an :c:func:`irq_control()` to make this possible, you must not implement your own.”h]”(hŒ!The generic interrupt handler of ”…”�”}”(hj h²hh³Nh´Nubj/)�”}”(hŒ``uio_pdrv_genirq``”h]”hŒuio_pdrv_genirq”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj ubhŒ. will simply disable the interrupt line using ”…”�”}”(hj h²hh³Nh´Nubh)�”}”(hŒ:c:func:`disable_irq_nosync()`”h]”j/)�”}”(hj)h]”hŒdisable_irq_nosync()”…”�”}”(hj+h²hh³Nh´Nubah}”(h]”h ]”(j�j‘Œc-func”eh"]”h$]”h&]”uh1j.hj'ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j�Œ refdomain”j‘Œreftype”Œfunc”Œ refexplicit”‰Œrefwarn”‰j£Œdisable_irq_nosync”uh1hh³hÊh´M�hj ubhŒŒ. After doing its work, userspace can reenable the interrupt by writing 0x00000001 to the UIO device file. The driver already implements an ”…”�”}”(hj h²hh³Nh´Nubh)�”}”(hŒ:c:func:`irq_control()`”h]”j/)�”}”(hjLh]”hŒ irq_control()”…”�”}”(hjNh²hh³Nh´Nubah}”(h]”h ]”(j�j‘Œc-func”eh"]”h$]”h&]”uh1j.hjJubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j�Œ refdomain”j‘Œreftype”Œfunc”Œ refexplicit”‰Œrefwarn”‰j£Œ irq_control”uh1hh³hÊh´M�hj ubhŒ8 to make this possible, you must not implement your own.”…”�”}”(hj h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M�hj h²hubhì)�”}”(hXUsing ``uio_pdrv_genirq`` not only saves a few lines of interrupt handler code. You also do not need to know anything about the chip's internal registers to create the kernel part of the driver. All you need to know is the irq number of the pin the chip is connected to.”h]”(hŒUsing ”…”�”}”(hjsh²hh³Nh´Nubj/)�”}”(hŒ``uio_pdrv_genirq``”h]”hŒuio_pdrv_genirq”…”�”}”(hj{h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjsubhŒ÷ not only saves a few lines of interrupt handler code. You also do not need to know anything about the chip’s internal registers to create the kernel part of the driver. All you need to know is the irq number of the pin the chip is connected to.”…”�”}”(hjsh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M–hj h²hubhì)�”}”(hX‡When used in a device-tree enabled system, the driver needs to be probed with the ``"of_id"`` module parameter set to the ``"compatible"`` string of the node the driver is supposed to handle. By default, the node's name (without the unit address) is exposed as name for the UIO device in userspace. To set a custom name, a property named ``"linux,uio-name"`` may be specified in the DT node.”h]”(hŒRWhen used in a device-tree enabled system, the driver needs to be probed with the ”…”�”}”(hj“h²hh³Nh´Nubj/)�”}”(hŒ ``"of_id"``”h]”hŒ"of_id"”…”�”}”(hj›h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj“ubhŒ module parameter set to the ”…”�”}”(hj“h²hh³Nh´Nubj/)�”}”(hŒ``"compatible"``”h]”hŒ "compatible"”…”�”}”(hj­h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj“ubhŒÊ string of the node the driver is supposed to handle. By default, the node’s name (without the unit address) is exposed as name for the UIO device in userspace. To set a custom name, a property named ”…”�”}”(hj“h²hh³Nh´Nubj/)�”}”(hŒ``"linux,uio-name"``”h]”hŒ"linux,uio-name"”…”�”}”(hj¿h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj“ubhŒ! may be specified in the DT node.”…”�”}”(hj“h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M›hj h²hubeh}”(h]”Œ*using-uio-pdrv-genirq-for-platform-devices”ah ]”h"]”Œ*using uio_pdrv_genirq for platform devices”ah$]”h&]”uh1hµhjy h²hh³hÊh´Mubh¶)�”}”(hhh]”(h»)�”}”(hŒ*Using uio_dmem_genirq for platform devices”h]”hŒ*Using uio_dmem_genirq for platform devices”…”�”}”(hjâh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjßh²hh³hÊh´M£ubhì)�”}”(hX>In addition to statically allocated memory ranges, they may also be a desire to use dynamically allocated regions in a user space driver. In particular, being able to access memory made available through the dma-mapping API, may be particularly useful. The ``uio_dmem_genirq`` driver provides a way to accomplish this.”h]”(hXIn addition to statically allocated memory ranges, they may also be a desire to use dynamically allocated regions in a user space driver. In particular, being able to access memory made available through the dma-mapping API, may be particularly useful. The ”…”�”}”(hjðh²hh³Nh´Nubj/)�”}”(hŒ``uio_dmem_genirq``”h]”hŒuio_dmem_genirq”…”�”}”(hjøh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjðubhŒ* driver provides a way to accomplish this.”…”�”}”(hjðh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M¥hjßh²hubhì)�”}”(hŒ�This driver is used in a similar manner to the ``"uio_pdrv_genirq"`` driver with respect to interrupt configuration and handling.”h]”(hŒ/This driver is used in a similar manner to the ”…”�”}”(hjh²hh³Nh´Nubj/)�”}”(hŒ``"uio_pdrv_genirq"``”h]”hŒ"uio_pdrv_genirq"”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjubhŒ= driver with respect to interrupt configuration and handling.”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M«hjßh²hubhì)�”}”(hŒdSet the ``.name`` element of ``struct platform_device`` to ``"uio_dmem_genirq"`` to use this driver.”h]”(hŒSet the ”…”�”}”(hj0h²hh³Nh´Nubj/)�”}”(hŒ ``.name``”h]”hŒ.name”…”�”}”(hj8h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj0ubhŒ element of ”…”�”}”(hj0h²hh³Nh´Nubj/)�”}”(hŒ``struct platform_device``”h]”hŒstruct platform_device”…”�”}”(hjJh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj0ubhŒ to ”…”�”}”(hj0h²hh³Nh´Nubj/)�”}”(hŒ``"uio_dmem_genirq"``”h]”hŒ"uio_dmem_genirq"”…”�”}”(hj\h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj0ubhŒ to use this driver.”…”�”}”(hj0h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M®hjßh²hubhì)�”}”(hŒºWhen using this driver, fill in the ``.platform_data`` element of ``struct platform_device``, which is of type ``struct uio_dmem_genirq_pdata`` and which contains the following elements:”h]”(hŒ$When using this driver, fill in the ”…”�”}”(hjth²hh³Nh´Nubj/)�”}”(hŒ``.platform_data``”h]”hŒ.platform_data”…”�”}”(hj|h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjtubhŒ element of ”…”�”}”(hjth²hh³Nh´Nubj/)�”}”(hŒ``struct platform_device``”h]”hŒstruct platform_device”…”�”}”(hjŽh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjtubhŒ, which is of type ”…”�”}”(hjth²hh³Nh´Nubj/)�”}”(hŒ ``struct uio_dmem_genirq_pdata``”h]”hŒstruct uio_dmem_genirq_pdata”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjtubhŒ+ and which contains the following elements:”…”�”}”(hjth²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M±hjßh²hubjÅ)�”}”(hhh]”(jÊ)�”}”(hŒ^``struct uio_info uioinfo``: The same structure used as the ``uio_pdrv_genirq`` platform data ”h]”hì)�”}”(hŒ]``struct uio_info uioinfo``: The same structure used as the ``uio_pdrv_genirq`` platform data”h]”(j/)�”}”(hŒ``struct uio_info uioinfo``”h]”hŒstruct uio_info uioinfo”…”�”}”(hjÃh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj¿ubhŒ!: The same structure used as the ”…”�”}”(hj¿h²hh³Nh´Nubj/)�”}”(hŒ``uio_pdrv_genirq``”h]”hŒuio_pdrv_genirq”…”�”}”(hjÕh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj¿ubhŒ platform data”…”�”}”(hj¿h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M¶hj»ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhj¸h²hh³hÊh´NubjÊ)�”}”(hŒy``unsigned int *dynamic_region_sizes``: Pointer to list of sizes of dynamic memory regions to be mapped into user space. ”h]”hì)�”}”(hŒx``unsigned int *dynamic_region_sizes``: Pointer to list of sizes of dynamic memory regions to be mapped into user space.”h]”(j/)�”}”(hŒ&``unsigned int *dynamic_region_sizes``”h]”hŒ"unsigned int *dynamic_region_sizes”…”�”}”(hjûh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj÷ubhŒR: Pointer to list of sizes of dynamic memory regions to be mapped into user space.”…”�”}”(hj÷h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M¹hjóubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhj¸h²hh³hÊh´NubjÊ)�”}”(hŒ\``unsigned int num_dynamic_regions``: Number of elements in ``dynamic_region_sizes`` array. ”h]”hì)�”}”(hŒ[``unsigned int num_dynamic_regions``: Number of elements in ``dynamic_region_sizes`` array.”h]”(j/)�”}”(hŒ$``unsigned int num_dynamic_regions``”h]”hŒ unsigned int num_dynamic_regions”…”�”}”(hj!h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjubhŒ: Number of elements in ”…”�”}”(hjh²hh³Nh´Nubj/)�”}”(hŒ``dynamic_region_sizes``”h]”hŒdynamic_region_sizes”…”�”}”(hj3h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjubhŒ array.”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M¼hjubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhj¸h²hh³hÊh´Nubeh}”(h]”h ]”h"]”h$]”h&]”jjuh1jÄh³hÊh´M¶hjßh²hubhì)�”}”(hŒèThe dynamic regions defined in the platform data will be appended to the `` mem[] `` array after the platform device resources, which implies that the total number of static and dynamic memory regions cannot exceed ``MAX_UIO_MAPS``.”h]”(hŒ×The dynamic regions defined in the platform data will be appended to the `` mem[] `` array after the platform device resources, which implies that the total number of static and dynamic memory regions cannot exceed ”…”�”}”(hjWh²hh³Nh´Nubj/)�”}”(hŒ``MAX_UIO_MAPS``”h]”hŒ MAX_UIO_MAPS”…”�”}”(hj_h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjWubhŒ.”…”�”}”(hjWh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M¿hjßh²hubhì)�”}”(hX¡The dynamic memory regions will be allocated when the UIO device file, ``/dev/uioX`` is opened. Similar to static memory resources, the memory region information for dynamic regions is then visible via sysfs at ``/sys/class/uio/uioX/maps/mapY/*``. The dynamic memory regions will be freed when the UIO device file is closed. When no processes are holding the device file open, the address returned to userspace is ~0.”h]”(hŒGThe dynamic memory regions will be allocated when the UIO device file, ”…”�”}”(hjwh²hh³Nh´Nubj/)�”}”(hŒ ``/dev/uioX``”h]”hŒ /dev/uioX”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjwubhŒ is opened. Similar to static memory resources, the memory region information for dynamic regions is then visible via sysfs at ”…”�”}”(hjwh²hh³Nh´Nubj/)�”}”(hŒ#``/sys/class/uio/uioX/maps/mapY/*``”h]”hŒ/sys/class/uio/uioX/maps/mapY/*”…”�”}”(hj‘h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjwubhŒ«. The dynamic memory regions will be freed when the UIO device file is closed. When no processes are holding the device file open, the address returned to userspace is ~0.”…”�”}”(hjwh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´MÄhjßh²hubeh}”(h]”Œ*using-uio-dmem-genirq-for-platform-devices”ah ]”h"]”Œ*using uio_dmem_genirq for platform devices”ah$]”h&]”uh1hµhjy h²hh³hÊh´M£ubeh}”(h]”Œwriting-your-own-kernel-module”ah ]”h"]”Œwriting your own kernel module”ah$]”h&]”uh1hµhh·h²hh³hÊh´KÓubh¶)�”}”(hhh]”(h»)�”}”(hŒWriting a driver in userspace”h]”hŒWriting a driver in userspace”…”�”}”(hj¼h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj¹h²hh³hÊh´MÌubhì)�”}”(hX^Once you have a working kernel module for your hardware, you can write the userspace part of your driver. You don't need any special libraries, your driver can be written in any reasonable language, you can use floating point numbers and so on. In short, you can use all the tools and libraries you'd normally use for writing a userspace application.”h]”hXbOnce you have a working kernel module for your hardware, you can write the userspace part of your driver. You don’t need any special libraries, your driver can be written in any reasonable language, you can use floating point numbers and so on. In short, you can use all the tools and libraries you’d normally use for writing a userspace application.”…”�”}”(hjÊh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´MÎhj¹h²hubh¶)�”}”(hhh]”(h»)�”}”(hŒ)Getting information about your UIO device”h]”hŒ)Getting information about your UIO device”…”�”}”(hjÛh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjØh²hh³hÊh´MÕubhì)�”}”(hŒîInformation about all UIO devices is available in sysfs. The first thing you should do in your driver is check ``name`` and ``version`` to make sure you're talking to the right device and that its kernel driver has the version you expect.”h]”(hŒoInformation about all UIO devices is available in sysfs. The first thing you should do in your driver is check ”…”�”}”(hjéh²hh³Nh´Nubj/)�”}”(hŒ``name``”h]”hŒname”…”�”}”(hjñh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjéubhŒ and ”…”�”}”(hjéh²hh³Nh´Nubj/)�”}”(hŒ ``version``”h]”hŒversion”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjéubhŒi to make sure you’re talking to the right device and that its kernel driver has the version you expect.”…”�”}”(hjéh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M×hjØh²hubhì)�”}”(hŒ^You should also make sure that the memory mapping you need exists and has the size you expect.”h]”hŒ^You should also make sure that the memory mapping you need exists and has the size you expect.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´MÜhjØh²hubhì)�”}”(hŒcThere is a tool called ``lsuio`` that lists UIO devices and their attributes. It is available here:”h]”(hŒThere is a tool called ”…”�”}”(hj)h²hh³Nh´Nubj/)�”}”(hŒ ``lsuio``”h]”hŒlsuio”…”�”}”(hj1h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj)ubhŒC that lists UIO devices and their attributes. It is available here:”…”�”}”(hj)h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´MßhjØh²hubhì)�”}”(hŒ1http://www.osadl.org/projects/downloads/UIO/user/”h]”jf)�”}”(hjKh]”hŒ1http://www.osadl.org/projects/downloads/UIO/user/”…”�”}”(hjMh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œrefuri”jKuh1jehjIubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´MâhjØh²hubhì)�”}”(hŒ�With ``lsuio`` you can quickly check if your kernel module is loaded and which attributes it exports. Have a look at the manpage for details.”h]”(hŒWith ”…”�”}”(hjah²hh³Nh´Nubj/)�”}”(hŒ ``lsuio``”h]”hŒlsuio”…”�”}”(hjih²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjaubhŒ you can quickly check if your kernel module is loaded and which attributes it exports. Have a look at the manpage for details.”…”�”}”(hjah²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´MähjØh²hubhì)�”}”(hŒÄThe source code of ``lsuio`` can serve as an example for getting information about an UIO device. The file ``uio_helper.c`` contains a lot of functions you could use in your userspace driver code.”h]”(hŒThe source code of ”…”�”}”(hj�h²hh³Nh´Nubj/)�”}”(hŒ ``lsuio``”h]”hŒlsuio”…”�”}”(hj‰h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj�ubhŒO can serve as an example for getting information about an UIO device. The file ”…”�”}”(hj�h²hh³Nh´Nubj/)�”}”(hŒ``uio_helper.c``”h]”hŒ uio_helper.c”…”�”}”(hj›h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj�ubhŒI contains a lot of functions you could use in your userspace driver code.”…”�”}”(hj�h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´MçhjØh²hubeh}”(h]”Œ)getting-information-about-your-uio-device”ah ]”h"]”Œ)getting information about your uio device”ah$]”h&]”uh1hµhj¹h²hh³hÊh´MÕubh¶)�”}”(hhh]”(h»)�”}”(hŒmmap() device memory”h]”hŒmmap() device memory”…”�”}”(hj¾h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj»h²hh³hÊh´Mìubhì)�”}”(hŒªAfter you made sure you've got the right device with the memory mappings you need, all you have to do is to call :c:func:`mmap()` to map the device's memory to userspace.”h]”(hŒsAfter you made sure you’ve got the right device with the memory mappings you need, all you have to do is to call ”…”�”}”(hjÌh²hh³Nh´Nubh)�”}”(hŒ:c:func:`mmap()`”h]”j/)�”}”(hjÖh]”hŒmmap()”…”�”}”(hjØh²hh³Nh´Nubah}”(h]”h ]”(j�j‘Œc-func”eh"]”h$]”h&]”uh1j.hjÔubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j�Œ refdomain”j‘Œreftype”Œfunc”Œ refexplicit”‰Œrefwarn”‰j£Œmmap”uh1hh³hÊh´MîhjÌubhŒ+ to map the device’s memory to userspace.”…”�”}”(hjÌh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Mîhj»h²hubhì)�”}”(hŒöThe parameter ``offset`` of the :c:func:`mmap()` call has a special meaning for UIO devices: It is used to select which mapping of your device you want to map. To map the memory of mapping N, you have to use N times the page size as your offset::”h]”(hŒThe parameter ”…”�”}”(hjýh²hh³Nh´Nubj/)�”}”(hŒ ``offset``”h]”hŒoffset”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjýubhŒ of the ”…”�”}”(hjýh²hh³Nh´Nubh)�”}”(hŒ:c:func:`mmap()`”h]”j/)�”}”(hjh]”hŒmmap()”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”(j�j‘Œc-func”eh"]”h$]”h&]”uh1j.hjubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j�Œ refdomain”j‘Œreftype”Œfunc”Œ refexplicit”‰Œrefwarn”‰j£Œmmap”uh1hh³hÊh´MòhjýubhŒÅ call has a special meaning for UIO devices: It is used to select which mapping of your device you want to map. To map the memory of mapping N, you have to use N times the page size as your offset:”…”�”}”(hjýh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Mòhj»h²hubj‡)�”}”(hŒoffset = N * getpagesize();”h]”hŒoffset = N * getpagesize();”…”�”}”hj@sbah}”(h]”h ]”h"]”h$]”h&]”j–j—uh1j†h³hÊh´M÷hj»h²hubhì)�”}”(hŒµN starts from zero, so if you've got only one memory range to map, set ``offset = 0``. A drawback of this technique is that memory is always mapped beginning with its start address.”h]”(hŒIN starts from zero, so if you’ve got only one memory range to map, set ”…”�”}”(hjNh²hh³Nh´Nubj/)�”}”(hŒ``offset = 0``”h]”hŒ offset = 0”…”�”}”(hjVh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hjNubhŒ`. A drawback of this technique is that memory is always mapped beginning with its start address.”…”�”}”(hjNh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Mùhj»h²hubeh}”(h]”Œmmap-device-memory”ah ]”h"]”Œmmap() device memory”ah$]”h&]”uh1hµhj¹h²hh³hÊh´Mìubh¶)�”}”(hhh]”(h»)�”}”(hŒWaiting for interrupts”h]”hŒWaiting for interrupts”…”�”}”(hjyh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjvh²hh³hÊh´Mþubhì)�”}”(hX9After you successfully mapped your devices memory, you can access it like an ordinary array. Usually, you will perform some initialization. After that, your hardware starts working and will generate an interrupt as soon as it's finished, has some data available, or needs your attention because an error occurred.”h]”hX;After you successfully mapped your devices memory, you can access it like an ordinary array. Usually, you will perform some initialization. After that, your hardware starts working and will generate an interrupt as soon as it’s finished, has some data available, or needs your attention because an error occurred.”…”�”}”(hj‡h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Mhjvh²hubhì)�”}”(hXû``/dev/uioX`` is a read-only file. A :c:func:`read()` will always block until an interrupt occurs. There is only one legal value for the ``count`` parameter of :c:func:`read()`, and that is the size of a signed 32 bit integer (4). Any other value for ``count`` causes :c:func:`read()` to fail. The signed 32 bit integer read is the interrupt count of your device. If the value is one more than the value you read the last time, everything is OK. If the difference is greater than one, you missed interrupts.”h]”(j/)�”}”(hŒ ``/dev/uioX``”h]”hŒ /dev/uioX”…”�”}”(hj™h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj•ubhŒ is a read-only file. A ”…”�”}”(hj•h²hh³Nh´Nubh)�”}”(hŒ:c:func:`read()`”h]”j/)�”}”(hj­h]”hŒread()”…”�”}”(hj¯h²hh³Nh´Nubah}”(h]”h ]”(j�j‘Œc-func”eh"]”h$]”h&]”uh1j.hj«ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j�Œ refdomain”j‘Œreftype”Œfunc”Œ refexplicit”‰Œrefwarn”‰j£Œread”uh1hh³hÊh´Mhj•ubhŒT will always block until an interrupt occurs. There is only one legal value for the ”…”�”}”(hj•h²hh³Nh´Nubj/)�”}”(hŒ ``count``”h]”hŒcount”…”�”}”(hjÎh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj•ubhŒ parameter of ”…”�”}”(hj•h²hh³Nh´Nubh)�”}”(hŒ:c:func:`read()`”h]”j/)�”}”(hjâh]”hŒread()”…”�”}”(hjäh²hh³Nh´Nubah}”(h]”h ]”(j�j‘Œc-func”eh"]”h$]”h&]”uh1j.hjàubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j�Œ refdomain”j‘Œreftype”Œfunc”Œ refexplicit”‰Œrefwarn”‰j£Œread”uh1hh³hÊh´Mhj•ubhŒK, and that is the size of a signed 32 bit integer (4). Any other value for ”…”�”}”(hj•h²hh³Nh´Nubj/)�”}”(hŒ ``count``”h]”hŒcount”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj•ubhŒ causes ”…”�”}”(hj•h²hh³Nh´Nubh)�”}”(hŒ:c:func:`read()`”h]”j/)�”}”(hjh]”hŒread()”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”(j�j‘Œc-func”eh"]”h$]”h&]”uh1j.hjubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j�Œ refdomain”j‘Œreftype”Œfunc”Œ refexplicit”‰Œrefwarn”‰j£Œread”uh1hh³hÊh´Mhj•ubhŒß to fail. The signed 32 bit integer read is the interrupt count of your device. If the value is one more than the value you read the last time, everything is OK. If the difference is greater than one, you missed interrupts.”…”�”}”(hj•h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Mhjvh²hubhì)�”}”(hŒ5You can also use :c:func:`select()` on ``/dev/uioX``.”h]”(hŒYou can also use ”…”�”}”(hj>h²hh³Nh´Nubh)�”}”(hŒ:c:func:`select()`”h]”j/)�”}”(hjHh]”hŒselect()”…”�”}”(hjJh²hh³Nh´Nubah}”(h]”h ]”(j�j‘Œc-func”eh"]”h$]”h&]”uh1j.hjFubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j�Œ refdomain”j‘Œreftype”Œfunc”Œ refexplicit”‰Œrefwarn”‰j£Œselect”uh1hh³hÊh´Mhj>ubhŒ on ”…”�”}”(hj>h²hh³Nh´Nubj/)�”}”(hŒ ``/dev/uioX``”h]”hŒ /dev/uioX”…”�”}”(hjih²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j.hj>ubhŒ.”…”�”}”(hj>h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Mhjvh²hubeh}”(h]”Œwaiting-for-interrupts”ah ]”h"]”Œwaiting for interrupts”ah$]”h&]”uh1hµhj¹h²hh³hÊh´Mþubeh}”(h]”Œwriting-a-driver-in-userspace”ah ]”h"]”Œwriting a driver in userspace”ah$]”h&]”uh1hµhh·h²hh³hÊh´MÌubh¶)�”}”(hhh]”(h»)�”}”(hŒGeneric PCI UIO driver”h]”hŒGeneric PCI UIO driver”…”�”}”(hj”h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj‘h²hh³hÊh´Mubhì)�”}”(hXThe 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.”h]”hXThe 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.”…”�”}”(hj¢h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Mhj‘h²hubh¶)�”}”(hhh]”(h»)�”}”(hŒ&Making the driver recognize the device”h]”hŒ&Making the driver recognize the device”…”�”}”(hj³h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj°h²hh³hÊh´Mubhì)�”}”(hŒÍ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::”h]”hŒÌ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:”…”�”}”(hjÁh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Mhj°h²hubj‡)�”}”(hŒWmodprobe uio_pci_generic echo "8086 10f5" > /sys/bus/pci/drivers/uio_pci_generic/new_id”h]”hŒWmodprobe uio_pci_generic echo "8086 10f5" > /sys/bus/pci/drivers/uio_pci_generic/new_id”…”�”}”hjÏsbah}”(h]”h ]”h"]”h$]”h&]”j–j—uh1j†h³hÊh´M hj°h²hubhì)�”}”(hXIf 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::”h]”hXIf 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:”…”�”}”(hjÝh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M#hj°h²hubj‡)�”}”(hŒzecho -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”h]”hŒzecho -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”…”�”}”hjësbah}”(h]”h ]”h"]”h$]”h&]”j–j—uh1j†h³hÊh´M(hj°h²hubhì)�”}”(hŒxYou can verify that the device has been bound to the driver by looking for it in sysfs, for example like the following::”h]”hŒwYou can verify that the device has been bound to the driver by looking for it in sysfs, for example like the following:”…”�”}”(hjùh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M+hj°h²hubj‡)�”}”(hŒ.ls -l /sys/bus/pci/devices/0000:00:19.0/driver”h]”hŒ.ls -l /sys/bus/pci/devices/0000:00:19.0/driver”…”�”}”hjsbah}”(h]”h ]”h"]”h$]”h&]”j–j—uh1j†h³hÊh´M.hj°h²hubhì)�”}”(hŒ"Which if successful should print::”h]”hŒ!Which if successful should print:”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M0hj°h²hubj‡)�”}”(hŒC.../0000:00:19.0/driver -> ../../../bus/pci/drivers/uio_pci_generic”h]”hŒC.../0000:00:19.0/driver -> ../../../bus/pci/drivers/uio_pci_generic”…”�”}”hj#sbah}”(h]”h ]”h"]”h$]”h&]”j–j—uh1j†h³hÊh´M2hj°h²hubhì)�”}”(hŒ|Note that the generic driver will not bind to old PCI 2.2 devices. If binding the device failed, run the following command::”h]”hŒ{Note that the generic driver will not bind to old PCI 2.2 devices. If binding the device failed, run the following command:”…”�”}”(hj1h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M4hj°h²hubj‡)�”}”(hŒdmesg”h]”hŒdmesg”…”�”}”hj?sbah}”(h]”h ]”h"]”h$]”h&]”j–j—uh1j†h³hÊh´M7hj°h²hubhì)�”}”(hŒ+and look in the output for failure reasons.”h]”hŒ+and look in the output for failure reasons.”…”�”}”(hjMh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M9hj°h²hubeh}”(h]”Œ&making-the-driver-recognize-the-device”ah ]”h"]”h$]”Œ&making the driver recognize the device”ah&]”uh1hµhj‘h²hh³hÊh´MŒ referenced”Kubh¶)�”}”(hhh]”(h»)�”}”(hŒ$Things to know about uio_pci_generic”h]”hŒ$Things to know about uio_pci_generic”…”�”}”(hjgh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjdh²hh³hÊh´M<ubhì)�”}”(hX~Interrupts are handled using the Interrupt Disable bit in the PCI command register and Interrupt Status bit in the PCI status register. All devices compliant to PCI 2.3 (circa 2002) and all compliant PCI Express devices should support these bits. uio_pci_generic detects this support, and won't bind to devices which do not support the Interrupt Disable Bit in the command register.”h]”hX€Interrupts are handled using the Interrupt Disable bit in the PCI command register and Interrupt Status bit in the PCI status register. All devices compliant to PCI 2.3 (circa 2002) and all compliant PCI Express devices should support these bits. uio_pci_generic detects this support, and won’t bind to devices which do not support the Interrupt Disable Bit in the command register.”…”�”}”(hjuh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M>hjdh²hubhì)�”}”(hŒôOn each interrupt, uio_pci_generic sets the Interrupt Disable bit. This prevents the device from generating further interrupts until the bit is cleared. The userspace driver should clear this bit before blocking and waiting for more interrupts.”h]”hŒôOn each interrupt, uio_pci_generic sets the Interrupt Disable bit. This prevents the device from generating further interrupts until the bit is cleared. The userspace driver should clear this bit before blocking and waiting for more interrupts.”…”�”}”(hjƒh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´MEhjdh²hubeh}”(h]”Œ$things-to-know-about-uio-pci-generic”ah ]”h"]”Œ$things to know about uio_pci_generic”ah$]”h&]”uh1hµhj‘h²hh³hÊh´M<ubh¶)�”}”(hhh]”(h»)�”}”(hŒ.Writing userspace driver using uio_pci_generic”h]”hŒ.Writing userspace driver using uio_pci_generic”…”�”}”(hjœh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj™h²hh³hÊh´MKubhì)�”}”(hŒ¨Userspace driver can use pci sysfs interface, or the libpci library that wraps it, to talk to the device and to re-enable interrupts by writing to the command register.”h]”hŒ¨Userspace driver can use pci sysfs interface, or the libpci library that wraps it, to talk to the device and to re-enable interrupts by writing to the command register.”…”�”}”(hjªh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´MMhj™h²hubeh}”(h]”Œ.writing-userspace-driver-using-uio-pci-generic”ah ]”h"]”Œ.writing userspace driver using uio_pci_generic”ah$]”h&]”uh1hµhj‘h²hh³hÊh´MKubh¶)�”}”(hhh]”(h»)�”}”(hŒ"Example code using uio_pci_generic”h]”hŒ"Example code using uio_pci_generic”…”�”}”(hjÃh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjÀh²hh³hÊh´MRubhì)�”}”(hŒAHere is some sample userspace driver code using uio_pci_generic::”h]”hŒ@Here is some sample userspace driver code using uio_pci_generic:”…”�”}”(hjÑh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´MThjÀh²hubj‡)�”}”(hXò#include #include #include #include #include #include #include int main() { int uiofd; int configfd; int err; int i; unsigned icount; unsigned char command_high; uiofd = open("/dev/uio0", O_RDONLY); if (uiofd < 0) { perror("uio open:"); return errno; } configfd = open("/sys/class/uio/uio0/device/config", O_RDWR); if (configfd < 0) { perror("config open:"); return errno; } /* Read and cache command value */ err = pread(configfd, &command_high, 1, 5); if (err != 1) { perror("command config read:"); return errno; } command_high &= ~0x4; for(i = 0;; ++i) { /* Print out a message, for debugging. */ if (i == 0) fprintf(stderr, "Started uio test driver.\n"); else fprintf(stderr, "Interrupts: %d\n", icount); /****************************************/ /* Here we got an interrupt from the device. Do something to it. */ /****************************************/ /* Re-enable interrupts. */ err = pwrite(configfd, &command_high, 1, 5); if (err != 1) { perror("config write:"); break; } /* Wait for next interrupt. */ err = read(uiofd, &icount, 4); if (err != 4) { perror("uio read:"); break; } } return errno; }”h]”hXò#include #include #include #include #include #include #include int main() { int uiofd; int configfd; int err; int i; unsigned icount; unsigned char command_high; uiofd = open("/dev/uio0", O_RDONLY); if (uiofd < 0) { perror("uio open:"); return errno; } configfd = open("/sys/class/uio/uio0/device/config", O_RDWR); if (configfd < 0) { perror("config open:"); return errno; } /* Read and cache command value */ err = pread(configfd, &command_high, 1, 5); if (err != 1) { perror("command config read:"); return errno; } command_high &= ~0x4; for(i = 0;; ++i) { /* Print out a message, for debugging. */ if (i == 0) fprintf(stderr, "Started uio test driver.\n"); else fprintf(stderr, "Interrupts: %d\n", icount); /****************************************/ /* Here we got an interrupt from the device. Do something to it. */ /****************************************/ /* Re-enable interrupts. */ err = pwrite(configfd, &command_high, 1, 5); if (err != 1) { perror("config write:"); break; } /* Wait for next interrupt. */ err = read(uiofd, &icount, 4); if (err != 4) { perror("uio read:"); break; } } return errno; }”…”�”}”hjßsbah}”(h]”h ]”h"]”h$]”h&]”j–j—uh1j†h³hÊh´MVhjÀh²hubeh}”(h]”Œ"example-code-using-uio-pci-generic”ah ]”h"]”Œ"example code using uio_pci_generic”ah$]”h&]”uh1hµhj‘h²hh³hÊh´MRubeh}”(h]”Œgeneric-pci-uio-driver”ah ]”h"]”Œgeneric pci uio driver”ah$]”h&]”uh1hµhh·h²hh³hÊh´Mubh¶)�”}”(hhh]”(h»)�”}”(hŒGeneric Hyper-V UIO driver”h]”hŒGeneric Hyper-V UIO driver”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjýh²hh³hÊh´M™ubhì)�”}”(hŒ‹The generic driver is a kernel module named uio_hv_generic. It supports devices on the Hyper-V VMBus similar to uio_pci_generic on PCI bus.”h]”hŒ‹The generic driver is a kernel module named uio_hv_generic. It supports devices on the Hyper-V VMBus similar to uio_pci_generic on PCI bus.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M›hjýh²hubh¶)�”}”(hhh]”(h»)�”}”(hŒ&Making the driver recognize the device”h]”hŒ&Making the driver recognize the device”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjh²hh³hÊh´M ubhì)�”}”(hŒöSince the driver does not declare any device GUID's, 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, to use the network device class GUID::”h]”hŒ÷Since the driver does not declare any device GUID’s, 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, to use the network device class GUID:”…”�”}”(hj-h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M¢hjh²hubj‡)�”}”(hŒrmodprobe uio_hv_generic echo "f8615163-df3e-46c5-913f-f2d2f965ed0e" > /sys/bus/vmbus/drivers/uio_hv_generic/new_id”h]”hŒrmodprobe uio_hv_generic echo "f8615163-df3e-46c5-913f-f2d2f965ed0e" > /sys/bus/vmbus/drivers/uio_hv_generic/new_id”…”�”}”hj;sbah}”(h]”h ]”h"]”h$]”h&]”j–j—uh1j†h³hÊh´M§hjh²hubhì)�”}”(hX?If there already is a hardware specific kernel driver for the device, the generic driver still won't bind to it, in this case if you want to use the generic driver for a userspace library you'll have to manually unbind the hardware specific driver and bind the generic driver, using the device specific GUID like this::”h]”hXBIf there already is a hardware specific kernel driver for the device, the generic driver still won’t bind to it, in this case if you want to use the generic driver for a userspace library you’ll have to manually unbind the hardware specific driver and bind the generic driver, using the device specific GUID like this:”…”�”}”(hjIh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Mªhjh²hubj‡)�”}”(hŒ°echo -n ed963694-e847-4b2a-85af-bc9cfc11d6f3 > /sys/bus/vmbus/drivers/hv_netvsc/unbind echo -n ed963694-e847-4b2a-85af-bc9cfc11d6f3 > /sys/bus/vmbus/drivers/uio_hv_generic/bind”h]”hŒ°echo -n ed963694-e847-4b2a-85af-bc9cfc11d6f3 > /sys/bus/vmbus/drivers/hv_netvsc/unbind echo -n ed963694-e847-4b2a-85af-bc9cfc11d6f3 > /sys/bus/vmbus/drivers/uio_hv_generic/bind”…”�”}”hjWsbah}”(h]”h ]”h"]”h$]”h&]”j–j—uh1j†h³hÊh´M°hjh²hubhì)�”}”(hŒxYou can verify that the device has been bound to the driver by looking for it in sysfs, for example like the following::”h]”hŒwYou can verify that the device has been bound to the driver by looking for it in sysfs, for example like the following:”…”�”}”(hjeh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M³hjh²hubj‡)�”}”(hŒHls -l /sys/bus/vmbus/devices/ed963694-e847-4b2a-85af-bc9cfc11d6f3/driver”h]”hŒHls -l /sys/bus/vmbus/devices/ed963694-e847-4b2a-85af-bc9cfc11d6f3/driver”…”�”}”hjssbah}”(h]”h ]”h"]”h$]”h&]”j–j—uh1j†h³hÊh´M¶hjh²hubhì)�”}”(hŒ"Which if successful should print::”h]”hŒ!Which if successful should print:”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M¸hjh²hubj‡)�”}”(hŒ\.../ed963694-e847-4b2a-85af-bc9cfc11d6f3/driver -> ../../../bus/vmbus/drivers/uio_hv_generic”h]”hŒ\.../ed963694-e847-4b2a-85af-bc9cfc11d6f3/driver -> ../../../bus/vmbus/drivers/uio_hv_generic”…”�”}”hj�sbah}”(h]”h ]”h"]”h$]”h&]”j–j—uh1j†h³hÊh´Mºhjh²hubeh}”(h]”Œid1”ah ]”h"]”h$]”jaah&]”uh1hµhjýh²hh³hÊh´M jcKubh¶)�”}”(hhh]”(h»)�”}”(hŒ#Things to know about uio_hv_generic”h]”hŒ#Things to know about uio_hv_generic”…”�”}”(hj§h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj¤h²hh³hÊh´M½ubhì)�”}”(hŒóOn each interrupt, uio_hv_generic sets the Interrupt Disable bit. This prevents the device from generating further interrupts until the bit is cleared. The userspace driver should clear this bit before blocking and waiting for more interrupts.”h]”hŒóOn each interrupt, uio_hv_generic sets the Interrupt Disable bit. This prevents the device from generating further interrupts until the bit is cleared. The userspace driver should clear this bit before blocking and waiting for more interrupts.”…”�”}”(hjµh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M¿hj¤h²hubhì)�”}”(hŒÄWhen host rescinds a device, the interrupt file descriptor is marked down and any reads of the interrupt file descriptor will return -EIO. Similar to a closed socket or disconnected serial device.”h]”hŒÄWhen host rescinds a device, the interrupt file descriptor is marked down and any reads of the interrupt file descriptor will return -EIO. Similar to a closed socket or disconnected serial device.”…”�”}”(hjÃh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´MÄhj¤h²hubhŒdefinition_list”“”)�”}”(hhh]”hŒdefinition_list_item”“”)�”}”(hXThe vmbus device regions are mapped into uio device resources: 0) Channel ring buffers: guest to host and host to guest 1) Guest to host interrupt signalling pages 2) Guest to host monitor page 3) Network receive buffer region 4) Network send buffer region ”h]”(hŒterm”“”)�”}”(hŒ>The vmbus device regions are mapped into uio device resources:”h]”hŒ>The vmbus device regions are mapped into uio device resources:”…”�”}”(hjÞh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jÜh³hÊh´MÍhjØubhŒ definition”“”)�”}”(hhh]”hŒenumerated_list”“”)�”}”(hhh]”(jÊ)�”}”(hŒ5Channel ring buffers: guest to host and host to guest”h]”hì)�”}”(hjøh]”hŒ5Channel ring buffers: guest to host and host to guest”…”�”}”(hjúh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´MÉhjöubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhjóubjÊ)�”}”(hŒ(Guest to host interrupt signalling pages”h]”hì)�”}”(hjh]”hŒ(Guest to host interrupt signalling pages”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´MÊhj ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhjóubjÊ)�”}”(hŒGuest to host monitor page”h]”hì)�”}”(hj&h]”hŒGuest to host monitor page”…”�”}”(hj(h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´MËhj$ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhjóubjÊ)�”}”(hŒNetwork receive buffer region”h]”hì)�”}”(hj=h]”hŒNetwork receive buffer region”…”�”}”(hj?h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´MÌhj;ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhjóubjÊ)�”}”(hŒNetwork send buffer region ”h]”hì)�”}”(hŒNetwork send buffer region”h]”hŒNetwork send buffer region”…”�”}”(hjVh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´MÍhjRubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhjóubeh}”(h]”h ]”h"]”h$]”h&]”Œenumtype”Œarabic”Œprefix”hŒsuffix”Œ)”Œstart”Kuh1jñhjîubah}”(h]”h ]”h"]”h$]”h&]”uh1jìhjØubeh}”(h]”h ]”h"]”h$]”h&]”uh1jÖh³hÊh´MÍhjÓubah}”(h]”h ]”h"]”h$]”h&]”uh1jÑhj¤h²hh³Nh´Nubhì)�”}”(hŒ¥If a subchannel is created by a request to host, then the uio_hv_generic device driver will create a sysfs binary file for the per-channel ring buffer. For example::”h]”hŒ¤If a subchannel is created by a request to host, then the uio_hv_generic device driver will create a sysfs binary file for the per-channel ring buffer. For example:”…”�”}”(hjˆh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´MÏhj¤h²hubj‡)�”}”(hŒL/sys/bus/vmbus/devices/3811fe4d-0fa0-4b62-981a-74fc1084c757/channels/21/ring”h]”hŒL/sys/bus/vmbus/devices/3811fe4d-0fa0-4b62-981a-74fc1084c757/channels/21/ring”…”�”}”hj–sbah}”(h]”h ]”h"]”h$]”h&]”j–j—uh1j†h³hÊh´MÓhj¤h²hubeh}”(h]”Œ#things-to-know-about-uio-hv-generic”ah ]”h"]”Œ#things to know about uio_hv_generic”ah$]”h&]”uh1hµhjýh²hh³hÊh´M½ubeh}”(h]”Œgeneric-hyper-v-uio-driver”ah ]”h"]”Œgeneric hyper-v uio driver”ah$]”h&]”uh1hµhh·h²hh³hÊh´M™ubh¶)�”}”(hhh]”(h»)�”}”(hŒFurther information”h]”hŒFurther information”…”�”}”(hj·h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj´h²hh³hÊh´MÖubjÅ)�”}”(hhh]”(jÊ)�”}”(hŒ*`OSADL homepage. `_ ”h]”hì)�”}”(hŒ)`OSADL homepage. `_”h]”(jf)�”}”(hjÎh]”hŒOSADL homepage.”…”�”}”(hjÐh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œname”ŒOSADL homepage.”Œrefuri”Œhttp://www.osadl.org”uh1jehjÌubhŒtarget”“”)�”}”(hŒ ”h]”h}”(h]”Œosadl-homepage”ah ]”h"]”Œosadl homepage.”ah$]”h&]”Œrefuri”jàuh1jájcKhjÌubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´MØhjÈubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhjÅh²hh³hÊh´NubjÊ)�”}”(hŒ2`Linutronix homepage. `_”h]”hì)�”}”(hjþh]”(jf)�”}”(hjþh]”hŒLinutronix homepage.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œname”ŒLinutronix homepage.”jߌhttp://www.linutronix.de”uh1jehjubjâ)�”}”(hŒ ”h]”h}”(h]”Œlinutronix-homepage”ah ]”h"]”Œlinutronix homepage.”ah$]”h&]”Œrefuri”juh1jájcKhjubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´MÚhjüubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉhjÅh²hh³hÊh´Nubeh}”(h]”h ]”h"]”h$]”h&]”jjuh1jÄh³hÊh´MØhj´h²hubeh}”(h]”Œfurther-information”ah ]”h"]”Œfurther information”ah$]”h&]”uh1hµhh·h²hh³hÊh´MÖubeh}”(h]”Œthe-userspace-i-o-howto”ah ]”h"]”Œthe userspace i/o howto”ah$]”h&]”uh1hµhhh²hh³hÊh´Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”hÊuh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)�”}”(hºNŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”jeŒerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”hÊŒ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”Œnameids”}”(j?j<jŠj‡j†jƒj jjGjDj‚jjv js jn jk j¶j³jKjHjàjÝj jjÜjÙj®j«jŽj‹j¸jµjsjpj†jƒjúj÷Œ&making the driver recognize the device”Nj–j“j½jºjòjïj±j®j©j¦j7j4jìjéjjuŒ nametypes”}”(j?‰jЉj†‰j ‰jG‰j‚‰jv ‰jn ‰j¶‰jK‰jà‰j ‰j܉j®‰jމj¸‰js‰j†‰jú‰j©‰j–‰j½‰jò‰j±‰j©‰j7‰jìˆjˆuh}”(j<h·j‡j;jƒjLjj‰jDj#jjJjs j�jk jj³jy jHjª jÝjNjjãjÙj j«jßj‹j¹jµjØjpj»jƒjvj÷j‘j]j°j“jdjºj™jïjÀj®jýjŸjj¦j¤j4j´jéjãjjuŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”jsKs…”R”Œparse_messages”]”(hŒsystem_message”“”)�”}”(hhh]”hì)�”}”(hŒIDuplicate implicit target name: "making the driver recognize the device".”h]”hŒMDuplicate implicit target name: “making the driver recognize the deviceâ€�.”…”�”}”(hjÍh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëhjÊubah}”(h]”h ]”h"]”h$]”h&]”jŸaŒlevel”KŒtype”ŒINFO”Œsource”hÊŒline”M uh1jÈhjh²hh³hÊh´M ubjÉ)�”}”(hhh]”hì)�”}”(hŒ:Enumerated list start value not ordinal-1: "0" (ordinal 0)”h]”hŒ>Enumerated list start value not ordinal-1: “0â€� (ordinal 0)”…”�”}”(hjéh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëhjæubah}”(h]”h ]”h"]”h$]”h&]”Œlevel”KŒtype”jãŒsource”hÊŒline”Kuh1jÈhjîubeŒtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nh²hub.