doc: regenerate
[xenomai-head.git] / doc / generated / html / api / rtdm__driver_8h_source.html
blob2847f5fc7f7971dcbcbfc85c01211af2de79a54d
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
5 <title>Xenomai API: include/rtdm/rtdm_driver.h Source File</title>
6 <link href="tabs.css" rel="stylesheet" type="text/css"/>
7 <link href="doxygen.css" rel="stylesheet" type="text/css"/>
8 </head>
9 <body>
10 <!-- Generated by Doxygen 1.7.1 -->
11 <div class="navigation" id="top">
12 <div class="tabs">
13 <ul class="tablist">
14 <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
15 <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
16 <li><a href="modules.html"><span>Modules</span></a></li>
17 <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
18 <li class="current"><a href="files.html"><span>Files</span></a></li>
19 <li><a href="examples.html"><span>Examples</span></a></li>
20 </ul>
21 </div>
22 <div class="tabs2">
23 <ul class="tablist">
24 <li><a href="files.html"><span>File&nbsp;List</span></a></li>
25 <li><a href="globals.html"><span>Globals</span></a></li>
26 </ul>
27 </div>
28 <div class="header">
29 <div class="headertitle">
30 <h1>include/rtdm/rtdm_driver.h</h1> </div>
31 </div>
32 <div class="contents">
33 <a href="rtdm__driver_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001
34 <a name="l00026"></a>00026 <span class="preprocessor">#ifndef _RTDM_DRIVER_H</span>
35 <a name="l00027"></a>00027 <span class="preprocessor"></span><span class="preprocessor">#define _RTDM_DRIVER_H</span>
36 <a name="l00028"></a>00028 <span class="preprocessor"></span>
37 <a name="l00029"></a>00029 <span class="preprocessor">#ifndef __KERNEL__</span>
38 <a name="l00030"></a>00030 <span class="preprocessor"></span><span class="preprocessor">#error This header is for kernel space usage only. \</span>
39 <a name="l00031"></a>00031 <span class="preprocessor"> You are likely looking for rtdm/rtdm.h...</span>
40 <a name="l00032"></a>00032 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* !__KERNEL__ */</span>
41 <a name="l00033"></a>00033
42 <a name="l00034"></a>00034 <span class="preprocessor">#include &lt;asm/atomic.h&gt;</span>
43 <a name="l00035"></a>00035 <span class="preprocessor">#include &lt;linux/list.h&gt;</span>
44 <a name="l00036"></a>00036
45 <a name="l00037"></a>00037 <span class="preprocessor">#include &lt;nucleus/xenomai.h&gt;</span>
46 <a name="l00038"></a>00038 <span class="preprocessor">#include &lt;nucleus/heap.h&gt;</span>
47 <a name="l00039"></a>00039 <span class="preprocessor">#include &lt;<a class="code" href="pod_8h.html" title="Real-time pod interface header.">nucleus/pod.h</a>&gt;</span>
48 <a name="l00040"></a>00040 <span class="preprocessor">#include &lt;nucleus/synch.h&gt;</span>
49 <a name="l00041"></a>00041 <span class="preprocessor">#include &lt;<a class="code" href="select_8h.html" title="file descriptors events multiplexing header.">nucleus/select.h</a>&gt;</span>
50 <a name="l00042"></a>00042 <span class="preprocessor">#include &lt;<a class="code" href="vfile_8h.html" title="This file is part of the Xenomai project.">nucleus/vfile.h</a>&gt;</span>
51 <a name="l00043"></a>00043 <span class="preprocessor">#include &lt;<a class="code" href="rtdm_8h.html" title="Real-Time Driver Model for Xenomai, user API header.">rtdm/rtdm.h</a>&gt;</span>
52 <a name="l00044"></a>00044
53 <a name="l00045"></a>00045 <span class="comment">/* debug support */</span>
54 <a name="l00046"></a>00046 <span class="preprocessor">#include &lt;nucleus/assert.h&gt;</span>
55 <a name="l00047"></a>00047 <span class="preprocessor">#ifdef CONFIG_PCI</span>
56 <a name="l00048"></a>00048 <span class="preprocessor"></span><span class="preprocessor">#include &lt;asm-generic/xenomai/pci_ids.h&gt;</span>
57 <a name="l00049"></a>00049 <span class="preprocessor">#endif </span><span class="comment">/* CONFIG_PCI */</span>
58 <a name="l00050"></a>00050
59 <a name="l00051"></a>00051 <span class="preprocessor">#ifndef CONFIG_XENO_OPT_DEBUG_RTDM</span>
60 <a name="l00052"></a>00052 <span class="preprocessor"></span><span class="preprocessor">#define CONFIG_XENO_OPT_DEBUG_RTDM 0</span>
61 <a name="l00053"></a>00053 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
62 <a name="l00054"></a>00054 <span class="preprocessor"></span>
63 <a name="l00055"></a>00055 <span class="keyword">struct </span><a class="code" href="structrtdm__dev__context.html" title="Device context.">rtdm_dev_context</a>;
64 <a name="l00056"></a>00056 <span class="keyword">typedef</span> <span class="keyword">struct </span>xnselector rtdm_selector_t;
65 <a name="l00057"></a>00057 <span class="keyword">enum</span> rtdm_selecttype;
66 <a name="l00058"></a>00058
67 <a name="l00071"></a><a class="code" href="group__devregister.html#ga7c66ec8f269c701237437177af0704e8">00071</a> <span class="preprocessor">#define RTDM_EXCLUSIVE 0x0001</span>
68 <a name="l00072"></a>00072 <span class="preprocessor"></span>
69 <a name="l00074"></a><a class="code" href="group__devregister.html#ga7651188ca1c05f7e68b36517874138b7">00074</a> <span class="preprocessor">#define RTDM_NAMED_DEVICE 0x0010</span>
70 <a name="l00075"></a>00075 <span class="preprocessor"></span>
71 <a name="l00078"></a><a class="code" href="group__devregister.html#ga43ced044106ae9c1f5500d0041307d8f">00078</a> <span class="preprocessor">#define RTDM_PROTOCOL_DEVICE 0x0020</span>
72 <a name="l00079"></a>00079 <span class="preprocessor"></span>
73 <a name="l00081"></a><a class="code" href="group__devregister.html#gafdb542eb46679916b0100969e1033bfc">00081</a> <span class="preprocessor">#define RTDM_DEVICE_TYPE_MASK 0x00F0</span>
74 <a name="l00082"></a>00082 <span class="preprocessor"></span>
75 <a name="l00091"></a><a class="code" href="group__devregister.html#gaa6f17915089145982b04c51f202d950c">00091</a> <span class="preprocessor">#define RTDM_CREATED_IN_NRT 0</span>
76 <a name="l00092"></a>00092 <span class="preprocessor"></span>
77 <a name="l00094"></a><a class="code" href="group__devregister.html#ga24b993fed8dae26b6597ba37f3f92eac">00094</a> <span class="preprocessor">#define RTDM_CLOSING 1</span>
78 <a name="l00095"></a>00095 <span class="preprocessor"></span>
79 <a name="l00097"></a><a class="code" href="group__devregister.html#ga187778f8d7b6e5f0b459a526e6323471">00097</a> <span class="preprocessor">#define RTDM_USER_CONTEXT_FLAG 8 </span><span class="comment">/* first user-definable flag */</span>
80 <a name="l00098"></a>00098
81 <a name="l00107"></a><a class="code" href="group__devregister.html#gab0f99b00be17869d5c9cd844825766f4">00107</a> <span class="preprocessor">#define RTDM_DEVICE_STRUCT_VER 5</span>
82 <a name="l00108"></a>00108 <span class="preprocessor"></span>
83 <a name="l00110"></a><a class="code" href="group__devregister.html#gab127a755cab544c5b318d4f4a3578e9f">00110</a> <span class="preprocessor">#define RTDM_CONTEXT_STRUCT_VER 3</span>
84 <a name="l00111"></a>00111 <span class="preprocessor"></span>
85 <a name="l00113"></a><a class="code" href="group__devregister.html#gadea320d3993937f37edc6fa39a29d379">00113</a> <span class="preprocessor">#define RTDM_SECURE_DEVICE 0x80000000</span>
86 <a name="l00114"></a>00114 <span class="preprocessor"></span>
87 <a name="l00116"></a><a class="code" href="group__devregister.html#gaeddd03e63cdce1692edcc497a44756c2">00116</a> <span class="preprocessor">#define RTDM_DRIVER_VER(major, minor, patch) \</span>
88 <a name="l00117"></a>00117 <span class="preprocessor"> (((major &amp; 0xFF) &lt;&lt; 16) | ((minor &amp; 0xFF) &lt;&lt; 8) | (patch &amp; 0xFF))</span>
89 <a name="l00118"></a>00118 <span class="preprocessor"></span>
90 <a name="l00120"></a><a class="code" href="group__devregister.html#ga4df977587f67fefde551a437848b9514">00120</a> <span class="preprocessor">#define RTDM_DRIVER_MAJOR_VER(ver) (((ver) &gt;&gt; 16) &amp; 0xFF)</span>
91 <a name="l00121"></a>00121 <span class="preprocessor"></span>
92 <a name="l00123"></a><a class="code" href="group__devregister.html#ga1c2cb29427406f0febbb1c143f76497f">00123</a> <span class="preprocessor">#define RTDM_DRIVER_MINOR_VER(ver) (((ver) &gt;&gt; 8) &amp; 0xFF)</span>
93 <a name="l00124"></a>00124 <span class="preprocessor"></span>
94 <a name="l00126"></a><a class="code" href="group__devregister.html#ga606a1554fc17b5b8d6c0fa8d6dbb8f9b">00126</a> <span class="preprocessor">#define RTDM_DRIVER_PATCH_VER(ver) ((ver) &amp; 0xFF)</span>
95 <a name="l00127"></a>00127 <span class="preprocessor"></span>
96 <a name="l00139"></a><a class="code" href="group__rtdmsync.html#gae18228df8c70c9da1f90f61b01e92501">00139</a> <span class="keyword">enum</span> <a class="code" href="group__rtdmsync.html#gae18228df8c70c9da1f90f61b01e92501">rtdm_selecttype</a> {
97 <a name="l00141"></a><a class="code" href="group__rtdmsync.html#ggae18228df8c70c9da1f90f61b01e92501a3ddb0fbad9f52ad3646be2e5a6ba8b2b">00141</a> <a class="code" href="group__rtdmsync.html#ggae18228df8c70c9da1f90f61b01e92501a3ddb0fbad9f52ad3646be2e5a6ba8b2b" title="Select input data availability events.">RTDM_SELECTTYPE_READ</a> = XNSELECT_READ,
98 <a name="l00142"></a>00142
99 <a name="l00144"></a><a class="code" href="group__rtdmsync.html#ggae18228df8c70c9da1f90f61b01e92501a37819f609dee2b20852001e9b7ecd462">00144</a> <a class="code" href="group__rtdmsync.html#ggae18228df8c70c9da1f90f61b01e92501a37819f609dee2b20852001e9b7ecd462" title="Select ouput buffer availability events.">RTDM_SELECTTYPE_WRITE</a> = XNSELECT_WRITE,
100 <a name="l00145"></a>00145
101 <a name="l00147"></a><a class="code" href="group__rtdmsync.html#ggae18228df8c70c9da1f90f61b01e92501a2dd10c612a9e3c7e5134ee122ee3de74">00147</a> <a class="code" href="group__rtdmsync.html#ggae18228df8c70c9da1f90f61b01e92501a2dd10c612a9e3c7e5134ee122ee3de74" title="Select exceptional events.">RTDM_SELECTTYPE_EXCEPT</a> = XNSELECT_EXCEPT
102 <a name="l00148"></a>00148 };
103 <a name="l00172"></a><a class="code" href="group__devregister.html#gaf987b1139579bdb16b4541ea76121fa6">00172</a> <span class="keyword">typedef</span> int (*<a class="code" href="group__devregister.html#gaf987b1139579bdb16b4541ea76121fa6" title="Named device open handler.">rtdm_open_handler_t</a>)(<span class="keyword">struct </span><a class="code" href="structrtdm__dev__context.html" title="Device context.">rtdm_dev_context</a> *context,
104 <a name="l00173"></a>00173 rtdm_user_info_t *user_info, <span class="keywordtype">int</span> oflag);
105 <a name="l00174"></a>00174
106 <a name="l00189"></a><a class="code" href="group__devregister.html#ga07b8dc34cfc42f6203c510d1e982edc5">00189</a> <span class="keyword">typedef</span> int (*<a class="code" href="group__devregister.html#ga07b8dc34cfc42f6203c510d1e982edc5" title="Socket creation handler for protocol devices.">rtdm_socket_handler_t</a>)(<span class="keyword">struct </span><a class="code" href="structrtdm__dev__context.html" title="Device context.">rtdm_dev_context</a> *context,
107 <a name="l00190"></a>00190 rtdm_user_info_t *user_info, <span class="keywordtype">int</span> protocol);
108 <a name="l00191"></a>00191
109 <a name="l00212"></a><a class="code" href="group__devregister.html#ga6bd6c0761590d59f67b2c1e87fdd8440">00212</a> <span class="keyword">typedef</span> int (*<a class="code" href="group__devregister.html#ga6bd6c0761590d59f67b2c1e87fdd8440" title="Close handler.">rtdm_close_handler_t</a>)(<span class="keyword">struct </span><a class="code" href="structrtdm__dev__context.html" title="Device context.">rtdm_dev_context</a> *context,
110 <a name="l00213"></a>00213 rtdm_user_info_t *user_info);
111 <a name="l00214"></a>00214
112 <a name="l00230"></a><a class="code" href="group__devregister.html#ga3adab7928c65ee8ffd06c82c705d4804">00230</a> <span class="keyword">typedef</span> int (*<a class="code" href="group__devregister.html#ga3adab7928c65ee8ffd06c82c705d4804" title="IOCTL handler.">rtdm_ioctl_handler_t</a>)(<span class="keyword">struct </span><a class="code" href="structrtdm__dev__context.html" title="Device context.">rtdm_dev_context</a> *context,
113 <a name="l00231"></a>00231 rtdm_user_info_t *user_info,
114 <a name="l00232"></a>00232 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> request, <span class="keywordtype">void</span> __user *arg);
115 <a name="l00233"></a>00233
116 <a name="l00247"></a><a class="code" href="group__devregister.html#ga462c61f19f6bc6a0ef93a57ab6b218bf">00247</a> <span class="keyword">typedef</span> int (*<a class="code" href="group__devregister.html#ga462c61f19f6bc6a0ef93a57ab6b218bf" title="Select binding handler.">rtdm_select_bind_handler_t</a>)(<span class="keyword">struct </span><a class="code" href="structrtdm__dev__context.html" title="Device context.">rtdm_dev_context</a> *context,
117 <a name="l00248"></a>00248 rtdm_selector_t *selector,
118 <a name="l00249"></a>00249 <span class="keyword">enum</span> <a class="code" href="group__rtdmsync.html#gae18228df8c70c9da1f90f61b01e92501">rtdm_selecttype</a> type,
119 <a name="l00250"></a>00250 <span class="keywordtype">unsigned</span> fd_index);
120 <a name="l00251"></a>00251
121 <a name="l00267"></a><a class="code" href="group__devregister.html#ga1a2f92a5ebe9f4d46fb6722ed5da047c">00267</a> <span class="keyword">typedef</span> ssize_t (*<a class="code" href="group__devregister.html#ga1a2f92a5ebe9f4d46fb6722ed5da047c" title="Read handler.">rtdm_read_handler_t</a>)(<span class="keyword">struct </span><a class="code" href="structrtdm__dev__context.html" title="Device context.">rtdm_dev_context</a> *context,
122 <a name="l00268"></a>00268 rtdm_user_info_t *user_info,
123 <a name="l00269"></a>00269 <span class="keywordtype">void</span> *buf, <span class="keywordtype">size_t</span> nbyte);
124 <a name="l00270"></a>00270
125 <a name="l00286"></a><a class="code" href="group__devregister.html#gaa2b3421e29ae63cf49622765a5bc9cee">00286</a> <span class="keyword">typedef</span> ssize_t (*<a class="code" href="group__devregister.html#gaa2b3421e29ae63cf49622765a5bc9cee" title="Write handler.">rtdm_write_handler_t</a>)(<span class="keyword">struct </span><a class="code" href="structrtdm__dev__context.html" title="Device context.">rtdm_dev_context</a> *context,
126 <a name="l00287"></a>00287 rtdm_user_info_t *user_info,
127 <a name="l00288"></a>00288 <span class="keyword">const</span> <span class="keywordtype">void</span> *buf, <span class="keywordtype">size_t</span> nbyte);
128 <a name="l00289"></a>00289
129 <a name="l00306"></a><a class="code" href="group__devregister.html#ga8e592853e1072c8b32e2263557990a66">00306</a> <span class="keyword">typedef</span> ssize_t (*<a class="code" href="group__devregister.html#ga8e592853e1072c8b32e2263557990a66" title="Receive message handler.">rtdm_recvmsg_handler_t</a>)(<span class="keyword">struct </span><a class="code" href="structrtdm__dev__context.html" title="Device context.">rtdm_dev_context</a> *context,
130 <a name="l00307"></a>00307 rtdm_user_info_t *user_info,
131 <a name="l00308"></a>00308 <span class="keyword">struct </span>msghdr *msg, <span class="keywordtype">int</span> flags);
132 <a name="l00309"></a>00309
133 <a name="l00326"></a><a class="code" href="group__devregister.html#ga2f142d15145b97e837f5e26775a4b0f1">00326</a> <span class="keyword">typedef</span> ssize_t (*<a class="code" href="group__devregister.html#ga2f142d15145b97e837f5e26775a4b0f1" title="Transmit message handler.">rtdm_sendmsg_handler_t</a>)(<span class="keyword">struct </span><a class="code" href="structrtdm__dev__context.html" title="Device context.">rtdm_dev_context</a> *context,
134 <a name="l00327"></a>00327 rtdm_user_info_t *user_info,
135 <a name="l00328"></a>00328 <span class="keyword">const</span> <span class="keyword">struct </span>msghdr *msg, <span class="keywordtype">int</span> flags);
136 <a name="l00331"></a>00331 <span class="keyword">typedef</span> int (*rtdm_rt_handler_t)(<span class="keyword">struct </span><a class="code" href="structrtdm__dev__context.html" title="Device context.">rtdm_dev_context</a> *context,
137 <a name="l00332"></a>00332 rtdm_user_info_t *user_info, <span class="keywordtype">void</span> *arg);
138 <a name="l00336"></a><a class="code" href="structrtdm__operations.html">00336</a> <span class="keyword">struct </span><a class="code" href="structrtdm__operations.html" title="Device operations.">rtdm_operations</a> {
139 <a name="l00341"></a><a class="code" href="structrtdm__operations.html#a23a81aa4c48d55c937c2763c27c8372c">00341</a> <a class="code" href="group__devregister.html#ga6bd6c0761590d59f67b2c1e87fdd8440" title="Close handler.">rtdm_close_handler_t</a> <a class="code" href="structrtdm__operations.html#a23a81aa4c48d55c937c2763c27c8372c" title="Close handler for real-time contexts (optional, deprecated).">close_rt</a>;
140 <a name="l00343"></a><a class="code" href="structrtdm__operations.html#a218dceb0ad1125f2c1c3e3e95a8d4894">00343</a> <a class="code" href="group__devregister.html#ga6bd6c0761590d59f67b2c1e87fdd8440" title="Close handler.">rtdm_close_handler_t</a> <a class="code" href="structrtdm__operations.html#a218dceb0ad1125f2c1c3e3e95a8d4894" title="Close handler for non-real-time contexts (required).">close_nrt</a>;
141 <a name="l00344"></a>00344
142 <a name="l00346"></a><a class="code" href="structrtdm__operations.html#ab49e368d71fd6647b0e74a6105d63528">00346</a> <a class="code" href="group__devregister.html#ga3adab7928c65ee8ffd06c82c705d4804" title="IOCTL handler.">rtdm_ioctl_handler_t</a> <a class="code" href="structrtdm__operations.html#ab49e368d71fd6647b0e74a6105d63528" title="IOCTL from real-time context (optional).">ioctl_rt</a>;
143 <a name="l00348"></a><a class="code" href="structrtdm__operations.html#a1b34c77998c6795f3d26047f323ca470">00348</a> <a class="code" href="group__devregister.html#ga3adab7928c65ee8ffd06c82c705d4804" title="IOCTL handler.">rtdm_ioctl_handler_t</a> <a class="code" href="structrtdm__operations.html#a1b34c77998c6795f3d26047f323ca470" title="IOCTL from non-real-time context (optional).">ioctl_nrt</a>;
144 <a name="l00349"></a>00349
145 <a name="l00351"></a><a class="code" href="structrtdm__operations.html#aa052e237d48e04bfb777fde1b6eb83e7">00351</a> <a class="code" href="group__devregister.html#ga462c61f19f6bc6a0ef93a57ab6b218bf" title="Select binding handler.">rtdm_select_bind_handler_t</a> <a class="code" href="structrtdm__operations.html#aa052e237d48e04bfb777fde1b6eb83e7" title="Select binding handler for any context (optional).">select_bind</a>;
146 <a name="l00357"></a><a class="code" href="structrtdm__operations.html#ad3c519ed6779656dbd926f3c92cd9cfe">00357</a> <a class="code" href="group__devregister.html#ga1a2f92a5ebe9f4d46fb6722ed5da047c" title="Read handler.">rtdm_read_handler_t</a> <a class="code" href="structrtdm__operations.html#ad3c519ed6779656dbd926f3c92cd9cfe" title="Read handler for real-time context (optional).">read_rt</a>;
147 <a name="l00359"></a><a class="code" href="structrtdm__operations.html#acd37d3ca267df2944400fedeca9de653">00359</a> <a class="code" href="group__devregister.html#ga1a2f92a5ebe9f4d46fb6722ed5da047c" title="Read handler.">rtdm_read_handler_t</a> <a class="code" href="structrtdm__operations.html#acd37d3ca267df2944400fedeca9de653" title="Read handler for non-real-time context (optional).">read_nrt</a>;
148 <a name="l00360"></a>00360
149 <a name="l00362"></a><a class="code" href="structrtdm__operations.html#a6497c11edeab09f8f1b09cc0cb30de24">00362</a> <a class="code" href="group__devregister.html#gaa2b3421e29ae63cf49622765a5bc9cee" title="Write handler.">rtdm_write_handler_t</a> <a class="code" href="structrtdm__operations.html#a6497c11edeab09f8f1b09cc0cb30de24" title="Write handler for real-time context (optional).">write_rt</a>;
150 <a name="l00364"></a><a class="code" href="structrtdm__operations.html#a6554db3606e4fbe4b3cfbd4ee6c8f4d3">00364</a> <a class="code" href="group__devregister.html#gaa2b3421e29ae63cf49622765a5bc9cee" title="Write handler.">rtdm_write_handler_t</a> <a class="code" href="structrtdm__operations.html#a6554db3606e4fbe4b3cfbd4ee6c8f4d3" title="Write handler for non-real-time context (optional).">write_nrt</a>;
151 <a name="l00370"></a><a class="code" href="structrtdm__operations.html#a0c4eecce6bd0ca7e42c31ab832d0c040">00370</a> <a class="code" href="group__devregister.html#ga8e592853e1072c8b32e2263557990a66" title="Receive message handler.">rtdm_recvmsg_handler_t</a> <a class="code" href="structrtdm__operations.html#a0c4eecce6bd0ca7e42c31ab832d0c040" title="Receive message handler for real-time context (optional).">recvmsg_rt</a>;
152 <a name="l00372"></a><a class="code" href="structrtdm__operations.html#aa8bf96cf72a3606f395aede8124bedbb">00372</a> <a class="code" href="group__devregister.html#ga8e592853e1072c8b32e2263557990a66" title="Receive message handler.">rtdm_recvmsg_handler_t</a> <a class="code" href="structrtdm__operations.html#aa8bf96cf72a3606f395aede8124bedbb" title="Receive message handler for non-real-time context (optional).">recvmsg_nrt</a>;
153 <a name="l00373"></a>00373
154 <a name="l00375"></a><a class="code" href="structrtdm__operations.html#a59b5f137bf6cabb076c39e375f053ed3">00375</a> <a class="code" href="group__devregister.html#ga2f142d15145b97e837f5e26775a4b0f1" title="Transmit message handler.">rtdm_sendmsg_handler_t</a> <a class="code" href="structrtdm__operations.html#a59b5f137bf6cabb076c39e375f053ed3" title="Transmit message handler for real-time context (optional).">sendmsg_rt</a>;
155 <a name="l00377"></a><a class="code" href="structrtdm__operations.html#acba25b7a9180b7891e118b3f8568bdf7">00377</a> <a class="code" href="group__devregister.html#ga2f142d15145b97e837f5e26775a4b0f1" title="Transmit message handler.">rtdm_sendmsg_handler_t</a> <a class="code" href="structrtdm__operations.html#acba25b7a9180b7891e118b3f8568bdf7" title="Transmit message handler for non-real-time context (optional).">sendmsg_nrt</a>;
156 <a name="l00379"></a>00379 };
157 <a name="l00380"></a>00380
158 <a name="l00381"></a>00381 <span class="keyword">struct </span>rtdm_devctx_reserved {
159 <a name="l00382"></a>00382 <span class="keywordtype">void</span> *owner;
160 <a name="l00383"></a>00383 <span class="keyword">struct </span>list_head cleanup;
161 <a name="l00384"></a>00384 };
162 <a name="l00385"></a>00385
163 <a name="l00397"></a><a class="code" href="structrtdm__dev__context.html">00397</a> <span class="keyword">struct </span><a class="code" href="structrtdm__dev__context.html" title="Device context.">rtdm_dev_context</a> {
164 <a name="l00399"></a><a class="code" href="structrtdm__dev__context.html#aed55a77fa767c4915ee1a317130b8d09">00399</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="structrtdm__dev__context.html#aed55a77fa767c4915ee1a317130b8d09" title="Context flags, see Context Flags for details.">context_flags</a>;
165 <a name="l00400"></a>00400
166 <a name="l00402"></a><a class="code" href="structrtdm__dev__context.html#a3347d4133672fb9dc161736105fcf251">00402</a> <span class="keywordtype">int</span> <a class="code" href="structrtdm__dev__context.html#a3347d4133672fb9dc161736105fcf251" title="Associated file descriptor.">fd</a>;
167 <a name="l00403"></a>00403
168 <a name="l00406"></a><a class="code" href="structrtdm__dev__context.html#adca0cb98487cc1a5947e5ff76f62109a">00406</a> atomic_t <a class="code" href="structrtdm__dev__context.html#adca0cb98487cc1a5947e5ff76f62109a" title="Lock counter of context, held while structure is referenced by an operation handler.">close_lock_count</a>;
169 <a name="l00407"></a>00407
170 <a name="l00409"></a><a class="code" href="structrtdm__dev__context.html#a91420e832bc08338b0d84b12edff9e88">00409</a> <span class="keyword">struct </span><a class="code" href="structrtdm__operations.html" title="Device operations.">rtdm_operations</a> *<a class="code" href="structrtdm__dev__context.html#a91420e832bc08338b0d84b12edff9e88" title="Set of active device operation handlers.">ops</a>;
171 <a name="l00410"></a>00410
172 <a name="l00412"></a><a class="code" href="structrtdm__dev__context.html#a8fea6f19169a166aa183d2e9da09df51">00412</a> <span class="keyword">struct </span><a class="code" href="structrtdm__device.html" title="RTDM device.">rtdm_device</a> *<a class="code" href="structrtdm__dev__context.html#a8fea6f19169a166aa183d2e9da09df51" title="Reference to owning device.">device</a>;
173 <a name="l00413"></a>00413
174 <a name="l00415"></a><a class="code" href="structrtdm__dev__context.html#a35602d44d821195ba42acb1e280a4851">00415</a> <span class="keyword">struct </span>rtdm_devctx_reserved <a class="code" href="structrtdm__dev__context.html#a35602d44d821195ba42acb1e280a4851" title="Data stored by RTDM inside a device context (internal use only).">reserved</a>;
175 <a name="l00416"></a>00416
176 <a name="l00418"></a><a class="code" href="structrtdm__dev__context.html#a720bc9395d80f0dea40c7ac3e449ea25">00418</a> <span class="keywordtype">char</span> <a class="code" href="structrtdm__dev__context.html#a720bc9395d80f0dea40c7ac3e449ea25" title="Begin of driver defined context data structure.">dev_private</a>[0];
177 <a name="l00419"></a>00419 };
178 <a name="l00420"></a>00420
179 <a name="l00429"></a>00429 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> *
180 <a name="l00430"></a><a class="code" href="group__devregister.html#ga765ab311ea9024a7ff210e963acd7a14">00430</a> <a class="code" href="group__devregister.html#ga765ab311ea9024a7ff210e963acd7a14" title="Locate the driver private area associated to a device context structure.">rtdm_context_to_private</a>(<span class="keyword">struct</span> <a class="code" href="structrtdm__dev__context.html" title="Device context.">rtdm_dev_context</a> *context)
181 <a name="l00431"></a>00431 {
182 <a name="l00432"></a>00432 <span class="keywordflow">return</span> (<span class="keywordtype">void</span> *)context-&gt;<a class="code" href="structrtdm__dev__context.html#a720bc9395d80f0dea40c7ac3e449ea25" title="Begin of driver defined context data structure.">dev_private</a>;
183 <a name="l00433"></a>00433 }
184 <a name="l00434"></a>00434
185 <a name="l00443"></a>00443 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keyword">struct </span><a class="code" href="structrtdm__dev__context.html" title="Device context.">rtdm_dev_context</a> *
186 <a name="l00444"></a><a class="code" href="group__devregister.html#gacc982b978fc3967b0e9d6d308f79c6ee">00444</a> <a class="code" href="group__devregister.html#gacc982b978fc3967b0e9d6d308f79c6ee" title="Locate a device context structure from its driver private area.">rtdm_private_to_context</a>(<span class="keywordtype">void</span> *<a class="code" href="structrtdm__dev__context.html#a720bc9395d80f0dea40c7ac3e449ea25" title="Begin of driver defined context data structure.">dev_private</a>)
187 <a name="l00445"></a>00445 {
188 <a name="l00446"></a>00446 <span class="keywordflow">return</span> container_of(dev_private, <span class="keyword">struct</span> <a class="code" href="structrtdm__dev__context.html" title="Device context.">rtdm_dev_context</a>, dev_private);
189 <a name="l00447"></a>00447 }
190 <a name="l00448"></a>00448
191 <a name="l00449"></a>00449 <span class="keyword">struct </span>rtdm_dev_reserved {
192 <a name="l00450"></a>00450 <span class="keyword">struct </span>list_head entry;
193 <a name="l00451"></a>00451 atomic_t refcount;
194 <a name="l00452"></a>00452 <span class="keyword">struct </span><a class="code" href="structrtdm__dev__context.html" title="Device context.">rtdm_dev_context</a> *exclusive_context;
195 <a name="l00453"></a>00453 };
196 <a name="l00454"></a>00454
197 <a name="l00462"></a><a class="code" href="structrtdm__device.html">00462</a> <span class="keyword">struct </span><a class="code" href="structrtdm__device.html" title="RTDM device.">rtdm_device</a> {
198 <a name="l00465"></a><a class="code" href="structrtdm__device.html#aaa2844f98d874f16d802b4e0b693e4e2">00465</a> <span class="keywordtype">int</span> <a class="code" href="structrtdm__device.html#aaa2844f98d874f16d802b4e0b693e4e2" title="Revision number of this structure, see Driver Versioning defines.">struct_version</a>;
199 <a name="l00466"></a>00466
200 <a name="l00468"></a><a class="code" href="structrtdm__device.html#af459bf86f0d037c99bb669f627d78764">00468</a> <span class="keywordtype">int</span> <a class="code" href="structrtdm__device.html#af459bf86f0d037c99bb669f627d78764" title="Device flags, see Device Flags for details.">device_flags</a>;
201 <a name="l00470"></a><a class="code" href="structrtdm__device.html#a48d67f835c341c5d27bc5886920a11da">00470</a> <span class="keywordtype">size_t</span> <a class="code" href="structrtdm__device.html#a48d67f835c341c5d27bc5886920a11da" title="Size of driver defined appendix to struct rtdm_dev_context.">context_size</a>;
202 <a name="l00471"></a>00471
203 <a name="l00473"></a><a class="code" href="structrtdm__device.html#a376a833e95ff75eb9c8033895bc5e102">00473</a> <span class="keywordtype">char</span> <a class="code" href="structrtdm__device.html#a376a833e95ff75eb9c8033895bc5e102" title="Named device identification (orthogonal to Linux device name space).">device_name</a>[RTDM_MAX_DEVNAME_LEN + 1];
204 <a name="l00474"></a>00474
205 <a name="l00476"></a><a class="code" href="structrtdm__device.html#ae58c050e09a79b277f718d796eda2072">00476</a> <span class="keywordtype">int</span> <a class="code" href="structrtdm__device.html#ae58c050e09a79b277f718d796eda2072" title="Protocol device identification: protocol family (PF_xxx).">protocol_family</a>;
206 <a name="l00478"></a><a class="code" href="structrtdm__device.html#a02552f2d91052bd801576b3a132ba3f9">00478</a> <span class="keywordtype">int</span> <a class="code" href="structrtdm__device.html#a02552f2d91052bd801576b3a132ba3f9" title="Protocol device identification: socket type (SOCK_xxx).">socket_type</a>;
207 <a name="l00479"></a>00479
208 <a name="l00484"></a><a class="code" href="structrtdm__device.html#af05d59487bedf7d79dc6b1858c0353c9">00484</a> <a class="code" href="group__devregister.html#gaf987b1139579bdb16b4541ea76121fa6" title="Named device open handler.">rtdm_open_handler_t</a> <a class="code" href="structrtdm__device.html#af05d59487bedf7d79dc6b1858c0353c9" title="Named device instance creation for real-time contexts, optional (but deprecated) if open_nrt is non-N...">open_rt</a>;
209 <a name="l00487"></a><a class="code" href="structrtdm__device.html#a948b25a417f5ca6f3737402b60df05d2">00487</a> <a class="code" href="group__devregister.html#gaf987b1139579bdb16b4541ea76121fa6" title="Named device open handler.">rtdm_open_handler_t</a> <a class="code" href="structrtdm__device.html#a948b25a417f5ca6f3737402b60df05d2" title="Named device instance creation for non-real-time contexts, optional if open_rt is non-NULL...">open_nrt</a>;
210 <a name="l00488"></a>00488
211 <a name="l00494"></a><a class="code" href="structrtdm__device.html#ad83a8dff6e8705e442f9a7d352556267">00494</a> <a class="code" href="group__devregister.html#ga07b8dc34cfc42f6203c510d1e982edc5" title="Socket creation handler for protocol devices.">rtdm_socket_handler_t</a> <a class="code" href="structrtdm__device.html#ad83a8dff6e8705e442f9a7d352556267" title="Protocol socket creation for real-time contexts, optional (but deprecated) if socket_nrt is non-NULL...">socket_rt</a>;
212 <a name="l00497"></a><a class="code" href="structrtdm__device.html#adbba71fe2c5bbc2e3abb8cd505e088a0">00497</a> <a class="code" href="group__devregister.html#ga07b8dc34cfc42f6203c510d1e982edc5" title="Socket creation handler for protocol devices.">rtdm_socket_handler_t</a> <a class="code" href="structrtdm__device.html#adbba71fe2c5bbc2e3abb8cd505e088a0" title="Protocol socket creation for non-real-time contexts, optional if socket_rt is non-NULL, ignored for named devices.">socket_nrt</a>;
213 <a name="l00498"></a>00498
214 <a name="l00500"></a><a class="code" href="structrtdm__device.html#a5f92064ba1e7eb351b00277b17d513ef">00500</a> <span class="keyword">struct </span><a class="code" href="structrtdm__operations.html" title="Device operations.">rtdm_operations</a> <a class="code" href="structrtdm__device.html#a5f92064ba1e7eb351b00277b17d513ef" title="Default operations on newly opened device instance.">ops</a>;
215 <a name="l00501"></a>00501
216 <a name="l00503"></a><a class="code" href="structrtdm__device.html#a94aa3100258b43c812c5240b55777f07">00503</a> <span class="keywordtype">int</span> <a class="code" href="structrtdm__device.html#a94aa3100258b43c812c5240b55777f07" title="Device class ID, see RTDM_CLASS_xxx.">device_class</a>;
217 <a name="l00506"></a><a class="code" href="structrtdm__device.html#aece6c5135a6256dbb3636f66eb97cb40">00506</a> <span class="keywordtype">int</span> <a class="code" href="structrtdm__device.html#aece6c5135a6256dbb3636f66eb97cb40" title="Device sub-class, see RTDM_SUBCLASS_xxx definition in the Device Profiles.">device_sub_class</a>;
218 <a name="l00508"></a><a class="code" href="structrtdm__device.html#a157db58bb0025b832ca409bc40735ae9">00508</a> <span class="keywordtype">int</span> <a class="code" href="structrtdm__device.html#a157db58bb0025b832ca409bc40735ae9" title="Supported device profile version.">profile_version</a>;
219 <a name="l00510"></a><a class="code" href="structrtdm__device.html#a55d676531831124ae7e8051addde3cdc">00510</a> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="structrtdm__device.html#a55d676531831124ae7e8051addde3cdc" title="Informational driver name (reported via /proc).">driver_name</a>;
220 <a name="l00512"></a><a class="code" href="structrtdm__device.html#aebcb235c789d0698fd821124817e2330">00512</a> <span class="keywordtype">int</span> <a class="code" href="structrtdm__device.html#aebcb235c789d0698fd821124817e2330" title="Driver version, see Driver Versioning defines.">driver_version</a>;
221 <a name="l00515"></a><a class="code" href="structrtdm__device.html#aed46d0d1567069de23a7400ff987610b">00515</a> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="structrtdm__device.html#aed46d0d1567069de23a7400ff987610b" title="Informational peripheral name the device is attached to (reported via /proc).">peripheral_name</a>;
222 <a name="l00517"></a><a class="code" href="structrtdm__device.html#aaacffe6b5bcea62396bf09d6ae2650ba">00517</a> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="structrtdm__device.html#aaacffe6b5bcea62396bf09d6ae2650ba" title="Informational driver provider name (reported via /proc).">provider_name</a>;
223 <a name="l00518"></a>00518
224 <a name="l00520"></a><a class="code" href="structrtdm__device.html#a0df5612d6bfcf6421509345384467392">00520</a> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="structrtdm__device.html#a0df5612d6bfcf6421509345384467392" title="Name of /proc entry for the device, must not be NULL.">proc_name</a>;
225 <a name="l00521"></a>00521 <span class="preprocessor">#ifdef CONFIG_XENO_OPT_VFILE</span>
226 <a name="l00522"></a>00522 <span class="preprocessor"></span>
227 <a name="l00523"></a>00523 <span class="keyword">struct </span>xnvfile_directory vfroot;
228 <a name="l00524"></a>00524 <span class="keyword">struct </span>xnvfile_regular info_vfile;
229 <a name="l00525"></a>00525 <span class="preprocessor">#endif</span>
230 <a name="l00526"></a>00526 <span class="preprocessor"></span>
231 <a name="l00528"></a><a class="code" href="structrtdm__device.html#a13d065b957258e702b0c0526c64b729b">00528</a> <span class="keywordtype">int</span> <a class="code" href="structrtdm__device.html#a13d065b957258e702b0c0526c64b729b" title="Driver definable device ID.">device_id</a>;
232 <a name="l00530"></a><a class="code" href="structrtdm__device.html#a23bedbebe7a0d2e392ca6dce1585edcc">00530</a> <span class="keywordtype">void</span> *<a class="code" href="structrtdm__device.html#a23bedbebe7a0d2e392ca6dce1585edcc" title="Driver definable device data.">device_data</a>;
233 <a name="l00531"></a>00531
234 <a name="l00533"></a><a class="code" href="structrtdm__device.html#a548f89224ffc7146fd46c53a0eb48040">00533</a> <span class="keyword">struct </span>rtdm_dev_reserved <a class="code" href="structrtdm__device.html#a548f89224ffc7146fd46c53a0eb48040" title="Data stored by RTDM inside a registered device (internal use only).">reserved</a>;
235 <a name="l00534"></a>00534 };
236 <a name="l00537"></a>00537 <span class="comment">/* --- device registration --- */</span>
237 <a name="l00538"></a>00538
238 <a name="l00539"></a>00539 <span class="keywordtype">int</span> <a class="code" href="group__devregister.html#ga6a191b3d206680c48cad2047adb9fc98" title="Register a RTDM device.">rtdm_dev_register</a>(<span class="keyword">struct</span> <a class="code" href="structrtdm__device.html" title="RTDM device.">rtdm_device</a> *device);
239 <a name="l00540"></a>00540 <span class="keywordtype">int</span> <a class="code" href="group__devregister.html#ga9cc04a9b6e1710d9ad3860de8d81bf14" title="Unregisters a RTDM device.">rtdm_dev_unregister</a>(<span class="keyword">struct</span> <a class="code" href="structrtdm__device.html" title="RTDM device.">rtdm_device</a> *device, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> poll_delay);
240 <a name="l00541"></a>00541
241 <a name="l00542"></a>00542 <span class="comment">/* --- inter-driver API --- */</span>
242 <a name="l00543"></a>00543
243 <a name="l00544"></a>00544 <span class="preprocessor">#define rtdm_open rt_dev_open</span>
244 <a name="l00545"></a>00545 <span class="preprocessor"></span><span class="preprocessor">#define rtdm_socket rt_dev_socket</span>
245 <a name="l00546"></a>00546 <span class="preprocessor"></span><span class="preprocessor">#define rtdm_close rt_dev_close</span>
246 <a name="l00547"></a>00547 <span class="preprocessor"></span><span class="preprocessor">#define rtdm_ioctl rt_dev_ioctl</span>
247 <a name="l00548"></a>00548 <span class="preprocessor"></span><span class="preprocessor">#define rtdm_read rt_dev_read</span>
248 <a name="l00549"></a>00549 <span class="preprocessor"></span><span class="preprocessor">#define rtdm_write rt_dev_write</span>
249 <a name="l00550"></a>00550 <span class="preprocessor"></span><span class="preprocessor">#define rtdm_recvmsg rt_dev_recvmsg</span>
250 <a name="l00551"></a>00551 <span class="preprocessor"></span><span class="preprocessor">#define rtdm_recv rt_dev_recv</span>
251 <a name="l00552"></a>00552 <span class="preprocessor"></span><span class="preprocessor">#define rtdm_recvfrom rt_dev_recvfrom</span>
252 <a name="l00553"></a>00553 <span class="preprocessor"></span><span class="preprocessor">#define rtdm_sendmsg rt_dev_sendmsg</span>
253 <a name="l00554"></a>00554 <span class="preprocessor"></span><span class="preprocessor">#define rtdm_send rt_dev_send</span>
254 <a name="l00555"></a>00555 <span class="preprocessor"></span><span class="preprocessor">#define rtdm_sendto rt_dev_sendto</span>
255 <a name="l00556"></a>00556 <span class="preprocessor"></span><span class="preprocessor">#define rtdm_bind rt_dev_bind</span>
256 <a name="l00557"></a>00557 <span class="preprocessor"></span><span class="preprocessor">#define rtdm_listen rt_dev_listen</span>
257 <a name="l00558"></a>00558 <span class="preprocessor"></span><span class="preprocessor">#define rtdm_accept rt_dev_accept</span>
258 <a name="l00559"></a>00559 <span class="preprocessor"></span><span class="preprocessor">#define rtdm_getsockopt rt_dev_getsockopt</span>
259 <a name="l00560"></a>00560 <span class="preprocessor"></span><span class="preprocessor">#define rtdm_setsockopt rt_dev_setsockopt</span>
260 <a name="l00561"></a>00561 <span class="preprocessor"></span><span class="preprocessor">#define rtdm_getsockname rt_dev_getsockname</span>
261 <a name="l00562"></a>00562 <span class="preprocessor"></span><span class="preprocessor">#define rtdm_getpeername rt_dev_getpeername</span>
262 <a name="l00563"></a>00563 <span class="preprocessor"></span><span class="preprocessor">#define rtdm_shutdown rt_dev_shutdown</span>
263 <a name="l00564"></a>00564 <span class="preprocessor"></span>
264 <a name="l00565"></a>00565 <span class="keyword">struct </span><a class="code" href="structrtdm__dev__context.html" title="Device context.">rtdm_dev_context</a> *<a class="code" href="group__interdrv.html#ga99e8509f4c8b404f0d5795b575d4c9cb" title="Retrieve and lock a device context.">rtdm_context_get</a>(<span class="keywordtype">int</span> <a class="code" href="structrtdm__dev__context.html#a3347d4133672fb9dc161736105fcf251" title="Associated file descriptor.">fd</a>);
265 <a name="l00566"></a>00566
266 <a name="l00567"></a>00567 <span class="preprocessor">#ifndef DOXYGEN_CPP </span><span class="comment">/* Avoid static inline tags for RTDM in doxygen */</span>
267 <a name="l00568"></a>00568
268 <a name="l00569"></a>00569 <span class="preprocessor">#define CONTEXT_IS_LOCKED(context) \</span>
269 <a name="l00570"></a>00570 <span class="preprocessor"> (atomic_read(&amp;(context)-&gt;close_lock_count) &gt; 1 || \</span>
270 <a name="l00571"></a>00571 <span class="preprocessor"> (test_bit(RTDM_CLOSING, &amp;(context)-&gt;context_flags) &amp;&amp; \</span>
271 <a name="l00572"></a>00572 <span class="preprocessor"> atomic_read(&amp;(context)-&gt;close_lock_count) &gt; 0))</span>
272 <a name="l00573"></a>00573 <span class="preprocessor"></span>
273 <a name="l00574"></a>00574 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group__interdrv.html#ga2a37e9e938db6e8d2f50f66939de7016" title="Increment context reference counter.">rtdm_context_lock</a>(<span class="keyword">struct</span> <a class="code" href="structrtdm__dev__context.html" title="Device context.">rtdm_dev_context</a> *context)
274 <a name="l00575"></a>00575 {
275 <a name="l00576"></a>00576 XENO_ASSERT(RTDM, CONTEXT_IS_LOCKED(context),
276 <a name="l00577"></a>00577 <span class="comment">/* just warn if context was a dangling pointer */</span>);
277 <a name="l00578"></a>00578 atomic_inc(&amp;context-&gt;<a class="code" href="structrtdm__dev__context.html#adca0cb98487cc1a5947e5ff76f62109a" title="Lock counter of context, held while structure is referenced by an operation handler.">close_lock_count</a>);
278 <a name="l00579"></a>00579 }
279 <a name="l00580"></a>00580
280 <a name="l00581"></a>00581 <span class="keyword">extern</span> <span class="keywordtype">int</span> rtdm_apc;
281 <a name="l00582"></a>00582
282 <a name="l00583"></a>00583 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group__interdrv.html#gaa48a3e04fd74cec81691d5d2187d7ef2" title="Decrement context reference counter.">rtdm_context_unlock</a>(<span class="keyword">struct</span> <a class="code" href="structrtdm__dev__context.html" title="Device context.">rtdm_dev_context</a> *context)
283 <a name="l00584"></a>00584 {
284 <a name="l00585"></a>00585 XENO_ASSERT(RTDM, CONTEXT_IS_LOCKED(context),
285 <a name="l00586"></a>00586 <span class="comment">/* just warn if context was a dangling pointer */</span>);
286 <a name="l00587"></a>00587 smp_mb__before_atomic_dec();
287 <a name="l00588"></a>00588 <span class="keywordflow">if</span> (unlikely(atomic_dec_and_test(&amp;context-&gt;<a class="code" href="structrtdm__dev__context.html#adca0cb98487cc1a5947e5ff76f62109a" title="Lock counter of context, held while structure is referenced by an operation handler.">close_lock_count</a>)))
288 <a name="l00589"></a>00589 rthal_apc_schedule(rtdm_apc);
289 <a name="l00590"></a>00590 }
290 <a name="l00591"></a>00591
291 <a name="l00592"></a>00592 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group__interdrv.html#ga05772193e3398e0bc3c9a6e3ed8f90f9" title="Release a device context obtained via rtdm_context_get().">rtdm_context_put</a>(<span class="keyword">struct</span> <a class="code" href="structrtdm__dev__context.html" title="Device context.">rtdm_dev_context</a> *context)
292 <a name="l00593"></a>00593 {
293 <a name="l00594"></a>00594 <a class="code" href="group__interdrv.html#gaa48a3e04fd74cec81691d5d2187d7ef2" title="Decrement context reference counter.">rtdm_context_unlock</a>(context);
294 <a name="l00595"></a>00595 }
295 <a name="l00596"></a>00596
296 <a name="l00597"></a>00597 <span class="comment">/* --- clock services --- */</span>
297 <a name="l00598"></a>00598 <span class="keyword">struct </span>xntbase;
298 <a name="l00599"></a>00599 <span class="keyword">extern</span> <span class="keyword">struct </span>xntbase *rtdm_tbase;
299 <a name="l00600"></a>00600
300 <a name="l00601"></a>00601 <span class="keyword">static</span> <span class="keyword">inline</span> <a class="code" href="group__rtdm.html#gad3b24c25feabadba465f8797d8c7fe27" title="RTDM type for representing absolute dates.">nanosecs_abs_t</a> <a class="code" href="group__clock.html#ga6cca1db0fd4c207ad92cdc9e9442afa5" title="Get system time.">rtdm_clock_read</a>(<span class="keywordtype">void</span>)
301 <a name="l00602"></a>00602 {
302 <a name="l00603"></a>00603 <span class="keywordflow">return</span> xntbase_ticks2ns(rtdm_tbase, <a class="code" href="group__timebase.html#ga5246b53b5b2d1b11d4fab4312fd16fda" title="Get the clock time for a given time base.">xntbase_get_time</a>(rtdm_tbase));
303 <a name="l00604"></a>00604 }
304 <a name="l00605"></a>00605
305 <a name="l00606"></a>00606 <span class="keyword">static</span> <span class="keyword">inline</span> <a class="code" href="group__rtdm.html#gad3b24c25feabadba465f8797d8c7fe27" title="RTDM type for representing absolute dates.">nanosecs_abs_t</a> <a class="code" href="group__clock.html#ga861a79090031b981c627107248cf2d14" title="Get monotonic time.">rtdm_clock_read_monotonic</a>(<span class="keywordtype">void</span>)
306 <a name="l00607"></a>00607 {
307 <a name="l00608"></a>00608 <span class="keywordflow">return</span> xntbase_ticks2ns(rtdm_tbase, xntbase_get_jiffies(rtdm_tbase));
308 <a name="l00609"></a>00609 }
309 <a name="l00610"></a>00610 <span class="preprocessor">#endif </span><span class="comment">/* !DOXYGEN_CPP */</span>
310 <a name="l00611"></a>00611
311 <a name="l00617"></a>00617 <span class="keywordtype">int</span> <a class="code" href="group__rtdmsync.html#ga0f7da4cec7713ed732ffd99040e219e2" title="Bind a selector to specified event types of a given file descriptor.">rtdm_select_bind</a>(<span class="keywordtype">int</span> fd, rtdm_selector_t *selector,
312 <a name="l00618"></a>00618 <span class="keyword">enum</span> <a class="code" href="group__rtdmsync.html#gae18228df8c70c9da1f90f61b01e92501">rtdm_selecttype</a> type, <span class="keywordtype">unsigned</span> fd_index);
313 <a name="l00619"></a>00619
314 <a name="l00620"></a>00620 <span class="comment">/* --- spin lock services --- */</span>
315 <a name="l00658"></a>00658 <span class="preprocessor">#ifdef DOXYGEN_CPP </span><span class="comment">/* Beautify doxygen output */</span>
316 <a name="l00659"></a><a class="code" href="group__rtdmsync.html#gabbaf52632d5dde7fa66e0b70d887493b">00659</a> <span class="preprocessor">#define RTDM_EXECUTE_ATOMICALLY(code_block) \</span>
317 <a name="l00660"></a>00660 <span class="preprocessor">{ \</span>
318 <a name="l00661"></a>00661 <span class="preprocessor"> &lt;ENTER_ATOMIC_SECTION&gt; \</span>
319 <a name="l00662"></a>00662 <span class="preprocessor"> code_block; \</span>
320 <a name="l00663"></a>00663 <span class="preprocessor"> &lt;LEAVE_ATOMIC_SECTION&gt; \</span>
321 <a name="l00664"></a>00664 <span class="preprocessor">}</span>
322 <a name="l00665"></a>00665 <span class="preprocessor"></span><span class="preprocessor">#else </span><span class="comment">/* This is how it really works */</span>
323 <a name="l00666"></a>00666 <span class="preprocessor">#define RTDM_EXECUTE_ATOMICALLY(code_block) \</span>
324 <a name="l00667"></a>00667 <span class="preprocessor">{ \</span>
325 <a name="l00668"></a>00668 <span class="preprocessor"> spl_t __rtdm_s; \</span>
326 <a name="l00669"></a>00669 <span class="preprocessor"> \</span>
327 <a name="l00670"></a>00670 <span class="preprocessor"> xnlock_get_irqsave(&amp;nklock, __rtdm_s); \</span>
328 <a name="l00671"></a>00671 <span class="preprocessor"> code_block; \</span>
329 <a name="l00672"></a>00672 <span class="preprocessor"> xnlock_put_irqrestore(&amp;nklock, __rtdm_s); \</span>
330 <a name="l00673"></a>00673 <span class="preprocessor">}</span>
331 <a name="l00674"></a>00674 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
332 <a name="l00675"></a>00675 <span class="preprocessor"></span>
333 <a name="l00685"></a><a class="code" href="group__rtdmsync.html#ga1dd901a6311b10ef7961b5fce7fa9d41">00685</a> <span class="preprocessor">#define RTDM_LOCK_UNLOCKED RTHAL_SPIN_LOCK_UNLOCKED</span>
334 <a name="l00686"></a>00686 <span class="preprocessor"></span>
335 <a name="l00688"></a><a class="code" href="group__rtdmsync.html#gab6398c5dab6f8614bc8310b2248ae0b6">00688</a> <span class="keyword">typedef</span> rthal_spinlock_t rtdm_lock_t;
336 <a name="l00689"></a>00689
337 <a name="l00691"></a><a class="code" href="group__rtdmsync.html#ga7584217487c323356414e21200a57e63">00691</a> <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> rtdm_lockctx_t;
338 <a name="l00692"></a>00692
339 <a name="l00708"></a><a class="code" href="group__rtdmsync.html#ga6abf985ea7a0b13ec564cf0107fd8cba">00708</a> <span class="preprocessor">#define rtdm_lock_init(lock) rthal_spin_lock_init(lock)</span>
340 <a name="l00709"></a>00709 <span class="preprocessor"></span>
341 <a name="l00726"></a>00726 <span class="preprocessor">#ifdef DOXYGEN_CPP </span><span class="comment">/* Beautify doxygen output */</span>
342 <a name="l00727"></a><a class="code" href="group__rtdmsync.html#ga65a4897268e15bda462b871976cb3909">00727</a> <span class="preprocessor">#define rtdm_lock_get(lock) rthal_spin_lock(lock)</span>
343 <a name="l00728"></a>00728 <span class="preprocessor"></span><span class="preprocessor">#else </span><span class="comment">/* This is how it really works */</span>
344 <a name="l00729"></a>00729 <span class="preprocessor">#define rtdm_lock_get(lock) \</span>
345 <a name="l00730"></a>00730 <span class="preprocessor"> do { \</span>
346 <a name="l00731"></a>00731 <span class="preprocessor"> XENO_BUGON(RTDM, !rthal_local_irq_disabled()); \</span>
347 <a name="l00732"></a>00732 <span class="preprocessor"> rthal_spin_lock(lock); \</span>
348 <a name="l00733"></a>00733 <span class="preprocessor"> } while (0)</span>
349 <a name="l00734"></a>00734 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
350 <a name="l00735"></a>00735 <span class="preprocessor"></span>
351 <a name="l00752"></a><a class="code" href="group__rtdmsync.html#ga963bdb01102d0076cd64f6bc72a347da">00752</a> <span class="preprocessor">#define rtdm_lock_put(lock) rthal_spin_unlock(lock)</span>
352 <a name="l00753"></a>00753 <span class="preprocessor"></span>
353 <a name="l00771"></a><a class="code" href="group__rtdmsync.html#ga985473873f9e32af688fe8a23634693d">00771</a> <span class="preprocessor">#define rtdm_lock_get_irqsave(lock, context) \</span>
354 <a name="l00772"></a>00772 <span class="preprocessor"> rthal_spin_lock_irqsave(lock, context)</span>
355 <a name="l00773"></a>00773 <span class="preprocessor"></span>
356 <a name="l00791"></a><a class="code" href="group__rtdmsync.html#ga4f1f8e33baf33b162636f63dec61aebd">00791</a> <span class="preprocessor">#define rtdm_lock_put_irqrestore(lock, context) \</span>
357 <a name="l00792"></a>00792 <span class="preprocessor"> rthal_spin_unlock_irqrestore(lock, context)</span>
358 <a name="l00793"></a>00793 <span class="preprocessor"></span>
359 <a name="l00810"></a><a class="code" href="group__rtdmsync.html#ga3d563fc5def018f743c55c452e061758">00810</a> <span class="preprocessor">#define rtdm_lock_irqsave(context) \</span>
360 <a name="l00811"></a>00811 <span class="preprocessor"> rthal_local_irq_save(context)</span>
361 <a name="l00812"></a>00812 <span class="preprocessor"></span>
362 <a name="l00829"></a><a class="code" href="group__rtdmsync.html#gae03c387fcae8a55105dd31d7c008bbb4">00829</a> <span class="preprocessor">#define rtdm_lock_irqrestore(context) \</span>
363 <a name="l00830"></a>00830 <span class="preprocessor"> rthal_local_irq_restore(context)</span>
364 <a name="l00831"></a>00831 <span class="preprocessor"></span>
365 <a name="l00835"></a>00835 <span class="comment">/* --- Interrupt management services --- */</span>
366 <a name="l00841"></a>00841 <span class="keyword">typedef</span> xnintr_t rtdm_irq_t;
367 <a name="l00842"></a>00842
368 <a name="l00849"></a><a class="code" href="group__rtdmirq.html#gab26458b2383dd59b4977cd77c948cdfc">00849</a> <span class="preprocessor">#define RTDM_IRQTYPE_SHARED XN_ISR_SHARED</span>
369 <a name="l00850"></a>00850 <span class="preprocessor"></span>
370 <a name="l00852"></a><a class="code" href="group__rtdmirq.html#gaf4e76db13d7f7aac4be2cae59e0097bc">00852</a> <span class="preprocessor">#define RTDM_IRQTYPE_EDGE XN_ISR_EDGE</span>
371 <a name="l00853"></a>00853 <span class="preprocessor"></span>
372 <a name="l00862"></a><a class="code" href="group__rtdmirq.html#gadabd8f3473098ae9128ef449a83fe3c2">00862</a> <span class="keyword">typedef</span> int (*<a class="code" href="group__rtdmirq.html#gadabd8f3473098ae9128ef449a83fe3c2" title="Interrupt handler.">rtdm_irq_handler_t</a>)(rtdm_irq_t *irq_handle);
373 <a name="l00863"></a>00863
374 <a name="l00870"></a><a class="code" href="group__rtdmirq.html#gad7b7593bdac7e1595635f2b372110d22">00870</a> <span class="preprocessor">#define RTDM_IRQ_NONE XN_ISR_NONE</span>
375 <a name="l00871"></a>00871 <span class="preprocessor"></span>
376 <a name="l00872"></a><a class="code" href="group__rtdmirq.html#ga56a2e243364bc9ff0e38c031c4c8ad57">00872</a> <span class="preprocessor">#define RTDM_IRQ_HANDLED XN_ISR_HANDLED</span>
377 <a name="l00873"></a>00873 <span class="preprocessor"></span>
378 <a name="l00892"></a><a class="code" href="group__rtdmirq.html#gac99789fe8b6b48e032ee6c22544968e4">00892</a> <span class="preprocessor">#define rtdm_irq_get_arg(irq_handle, type) ((type *)irq_handle-&gt;cookie)</span>
379 <a name="l00893"></a>00893 <span class="preprocessor"></span>
380 <a name="l00895"></a>00895 <span class="keywordtype">int</span> <a class="code" href="group__rtdmirq.html#ga9bb3d95218ac5261e4033fb0bf695073" title="Register an interrupt handler.">rtdm_irq_request</a>(rtdm_irq_t *irq_handle, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> irq_no,
381 <a name="l00896"></a>00896 <a class="code" href="group__rtdmirq.html#gadabd8f3473098ae9128ef449a83fe3c2" title="Interrupt handler.">rtdm_irq_handler_t</a> handler, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> flags,
382 <a name="l00897"></a>00897 <span class="keyword">const</span> <span class="keywordtype">char</span> *device_name, <span class="keywordtype">void</span> *arg);
383 <a name="l00898"></a>00898
384 <a name="l00899"></a>00899 <span class="preprocessor">#ifndef DOXYGEN_CPP </span><span class="comment">/* Avoid static inline tags for RTDM in doxygen */</span>
385 <a name="l00900"></a>00900 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group__rtdmirq.html#gaf246c0d9fa42a18afbeabd3e3c087c8e" title="Release an interrupt handler.">rtdm_irq_free</a>(rtdm_irq_t *irq_handle)
386 <a name="l00901"></a>00901 {
387 <a name="l00902"></a>00902 <span class="keywordflow">return</span> <a class="code" href="group__intr.html#ga83769b98f398774590e57ad8664925aa" title="Detach an interrupt object.">xnintr_detach</a>(irq_handle);
388 <a name="l00903"></a>00903 }
389 <a name="l00904"></a>00904
390 <a name="l00905"></a>00905 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group__rtdmirq.html#ga231362e861125cfdcbe5b4137fc70680" title="Enable interrupt line.">rtdm_irq_enable</a>(rtdm_irq_t *irq_handle)
391 <a name="l00906"></a>00906 {
392 <a name="l00907"></a>00907 <span class="keywordflow">return</span> <a class="code" href="group__intr.html#ga083e000abd434e4d0fca8f6b6bbd49de" title="Enable an interrupt object.">xnintr_enable</a>(irq_handle);
393 <a name="l00908"></a>00908 }
394 <a name="l00909"></a>00909
395 <a name="l00910"></a>00910 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group__rtdmirq.html#gab34c102e3e8af1f27786b2996247913d" title="Disable interrupt line.">rtdm_irq_disable</a>(rtdm_irq_t *irq_handle)
396 <a name="l00911"></a>00911 {
397 <a name="l00912"></a>00912 <span class="keywordflow">return</span> <a class="code" href="group__intr.html#ga05570451a808b44216140e00b0eae713" title="Disable an interrupt object.">xnintr_disable</a>(irq_handle);
398 <a name="l00913"></a>00913 }
399 <a name="l00914"></a>00914 <span class="preprocessor">#endif </span><span class="comment">/* !DOXYGEN_CPP */</span>
400 <a name="l00915"></a>00915
401 <a name="l00916"></a>00916 <span class="comment">/* --- non-real-time signalling services --- */</span>
402 <a name="l00917"></a>00917
403 <a name="l00923"></a>00923 <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> rtdm_nrtsig_t;
404 <a name="l00924"></a>00924
405 <a name="l00935"></a><a class="code" href="group__nrtsignal.html#ga3c72df92865ad7decadab7c94fa75d0a">00935</a> <span class="keyword">typedef</span> void (*<a class="code" href="group__nrtsignal.html#ga3c72df92865ad7decadab7c94fa75d0a" title="Non-real-time signal handler.">rtdm_nrtsig_handler_t</a>)(rtdm_nrtsig_t nrt_sig, <span class="keywordtype">void</span> *arg);
406 <a name="l00938"></a>00938 <span class="preprocessor">#ifndef DOXYGEN_CPP </span><span class="comment">/* Avoid static inline tags for RTDM in doxygen */</span>
407 <a name="l00939"></a>00939 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group__nrtsignal.html#ga38bd867e104f7e300a03200b1ccc1aae" title="Register a non-real-time signal handler.">rtdm_nrtsig_init</a>(rtdm_nrtsig_t *nrt_sig,
408 <a name="l00940"></a>00940 <a class="code" href="group__nrtsignal.html#ga3c72df92865ad7decadab7c94fa75d0a" title="Non-real-time signal handler.">rtdm_nrtsig_handler_t</a> handler, <span class="keywordtype">void</span> *arg)
409 <a name="l00941"></a>00941 {
410 <a name="l00942"></a>00942 *nrt_sig = rthal_alloc_virq();
411 <a name="l00943"></a>00943
412 <a name="l00944"></a>00944 <span class="keywordflow">if</span> (*nrt_sig == 0)
413 <a name="l00945"></a>00945 <span class="keywordflow">return</span> -EAGAIN;
414 <a name="l00946"></a>00946
415 <a name="l00947"></a>00947 rthal_virtualize_irq(rthal_root_domain, *nrt_sig, handler, arg, NULL,
416 <a name="l00948"></a>00948 IPIPE_HANDLE_MASK);
417 <a name="l00949"></a>00949 <span class="keywordflow">return</span> 0;
418 <a name="l00950"></a>00950 }
419 <a name="l00951"></a>00951
420 <a name="l00952"></a>00952 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group__nrtsignal.html#ga4417c31c4990c3655f8ab4e7de6afa49" title="Release a non-realtime signal handler.">rtdm_nrtsig_destroy</a>(rtdm_nrtsig_t *nrt_sig)
421 <a name="l00953"></a>00953 {
422 <a name="l00954"></a>00954 rthal_free_virq(*nrt_sig);
423 <a name="l00955"></a>00955 }
424 <a name="l00956"></a>00956
425 <a name="l00957"></a>00957 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group__nrtsignal.html#ga80f0f176bdef54a4f3f3e202b156e450" title="Trigger non-real-time signal.">rtdm_nrtsig_pend</a>(rtdm_nrtsig_t *nrt_sig)
426 <a name="l00958"></a>00958 {
427 <a name="l00959"></a>00959 rthal_trigger_irq(*nrt_sig);
428 <a name="l00960"></a>00960 }
429 <a name="l00961"></a>00961 <span class="preprocessor">#endif </span><span class="comment">/* !DOXYGEN_CPP */</span>
430 <a name="l00962"></a>00962
431 <a name="l00963"></a>00963 <span class="comment">/* --- timer services --- */</span>
432 <a name="l00964"></a>00964
433 <a name="l00970"></a>00970 <span class="keyword">typedef</span> xntimer_t rtdm_timer_t;
434 <a name="l00971"></a>00971
435 <a name="l00977"></a><a class="code" href="group__rtdmtimer.html#ga31b7b9a042260702a110bfe2c9bcac61">00977</a> <span class="keyword">typedef</span> void (*<a class="code" href="group__rtdmtimer.html#ga31b7b9a042260702a110bfe2c9bcac61" title="Timer handler.">rtdm_timer_handler_t</a>)(rtdm_timer_t *timer);
436 <a name="l00978"></a>00978
437 <a name="l00984"></a><a class="code" href="group__rtdmtimer.html#gad0bffecd0182d68967ebb5b47df0bcd0">00984</a> <span class="keyword">enum</span> <a class="code" href="group__rtdmtimer.html#gad0bffecd0182d68967ebb5b47df0bcd0">rtdm_timer_mode</a> {
438 <a name="l00986"></a><a class="code" href="group__rtdmtimer.html#ggad0bffecd0182d68967ebb5b47df0bcd0addd5d0b543bebdb1187330b7f52a94f8">00986</a> <a class="code" href="group__rtdmtimer.html#ggad0bffecd0182d68967ebb5b47df0bcd0addd5d0b543bebdb1187330b7f52a94f8" title="Monotonic timer with relative timeout.">RTDM_TIMERMODE_RELATIVE</a> = XN_RELATIVE,
439 <a name="l00987"></a>00987
440 <a name="l00989"></a><a class="code" href="group__rtdmtimer.html#ggad0bffecd0182d68967ebb5b47df0bcd0a77b27da267c09a5a586aab86c9cd22e2">00989</a> <a class="code" href="group__rtdmtimer.html#ggad0bffecd0182d68967ebb5b47df0bcd0a77b27da267c09a5a586aab86c9cd22e2" title="Monotonic timer with absolute timeout.">RTDM_TIMERMODE_ABSOLUTE</a> = XN_ABSOLUTE,
441 <a name="l00990"></a>00990
442 <a name="l00992"></a><a class="code" href="group__rtdmtimer.html#ggad0bffecd0182d68967ebb5b47df0bcd0a8c206cf25cb340fd7ccee4489df6a220">00992</a> <a class="code" href="group__rtdmtimer.html#ggad0bffecd0182d68967ebb5b47df0bcd0a8c206cf25cb340fd7ccee4489df6a220" title="Adjustable timer with absolute timeout.">RTDM_TIMERMODE_REALTIME</a> = XN_REALTIME
443 <a name="l00993"></a>00993 };
444 <a name="l00998"></a>00998 <span class="preprocessor">#ifndef DOXYGEN_CPP </span><span class="comment">/* Avoid broken doxygen output */</span>
445 <a name="l00999"></a>00999 <span class="preprocessor">#define rtdm_timer_init(timer, handler, name) \</span>
446 <a name="l01000"></a>01000 <span class="preprocessor">({ \</span>
447 <a name="l01001"></a>01001 <span class="preprocessor"> xntimer_init((timer), rtdm_tbase, handler); \</span>
448 <a name="l01002"></a>01002 <span class="preprocessor"> xntimer_set_name((timer), (name)); \</span>
449 <a name="l01003"></a>01003 <span class="preprocessor"> 0; \</span>
450 <a name="l01004"></a>01004 <span class="preprocessor">})</span>
451 <a name="l01005"></a>01005 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* !DOXYGEN_CPP */</span>
452 <a name="l01006"></a>01006
453 <a name="l01007"></a>01007 <span class="keywordtype">void</span> <a class="code" href="group__rtdmtimer.html#gac75c6e2f7c838b11d8e261be3a7a0326" title="Destroy a timer.">rtdm_timer_destroy</a>(rtdm_timer_t *timer);
454 <a name="l01008"></a>01008
455 <a name="l01009"></a>01009 <span class="keywordtype">int</span> <a class="code" href="group__rtdmtimer.html#ga429ca4935762583edb6e1ebc955fe958" title="Start a timer.">rtdm_timer_start</a>(rtdm_timer_t *timer, <a class="code" href="group__rtdm.html#gad3b24c25feabadba465f8797d8c7fe27" title="RTDM type for representing absolute dates.">nanosecs_abs_t</a> expiry,
456 <a name="l01010"></a>01010 <a class="code" href="group__rtdm.html#gaededf91e760e3268235351dcc9d9dcda" title="RTDM type for representing relative intervals.">nanosecs_rel_t</a> interval, <span class="keyword">enum</span> <a class="code" href="group__rtdmtimer.html#gad0bffecd0182d68967ebb5b47df0bcd0">rtdm_timer_mode</a> mode);
457 <a name="l01011"></a>01011
458 <a name="l01012"></a>01012 <span class="keywordtype">void</span> <a class="code" href="group__rtdmtimer.html#ga7f2accf693db9ed5a537b86a58bccd94" title="Stop a timer.">rtdm_timer_stop</a>(rtdm_timer_t *timer);
459 <a name="l01013"></a>01013
460 <a name="l01014"></a>01014 <span class="preprocessor">#ifndef DOXYGEN_CPP </span><span class="comment">/* Avoid static inline tags for RTDM in doxygen */</span>
461 <a name="l01015"></a>01015 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group__rtdmtimer.html#gaf585049063aa6ffb2f79511c0a091119" title="Start a timer from inside a timer handler.">rtdm_timer_start_in_handler</a>(rtdm_timer_t *timer,
462 <a name="l01016"></a>01016 <a class="code" href="group__rtdm.html#gad3b24c25feabadba465f8797d8c7fe27" title="RTDM type for representing absolute dates.">nanosecs_abs_t</a> expiry,
463 <a name="l01017"></a>01017 <a class="code" href="group__rtdm.html#gaededf91e760e3268235351dcc9d9dcda" title="RTDM type for representing relative intervals.">nanosecs_rel_t</a> interval,
464 <a name="l01018"></a>01018 <span class="keyword">enum</span> <a class="code" href="group__rtdmtimer.html#gad0bffecd0182d68967ebb5b47df0bcd0">rtdm_timer_mode</a> mode)
465 <a name="l01019"></a>01019 {
466 <a name="l01020"></a>01020 <span class="keywordflow">return</span> <a class="code" href="group__timer.html#ga0ad3c70bed7fe1a45b45ee0875f031ab" title="Arm a timer.">xntimer_start</a>(timer, xntbase_ns2ticks_ceil(rtdm_tbase, expiry),
467 <a name="l01021"></a>01021 xntbase_ns2ticks_ceil(rtdm_tbase, interval),
468 <a name="l01022"></a>01022 (xntmode_t)mode);
469 <a name="l01023"></a>01023 }
470 <a name="l01024"></a>01024
471 <a name="l01025"></a>01025 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group__rtdmtimer.html#gaf76e21cc3429370612b76493fdb6d23e" title="Stop a timer from inside a timer handler.">rtdm_timer_stop_in_handler</a>(rtdm_timer_t *timer)
472 <a name="l01026"></a>01026 {
473 <a name="l01027"></a>01027 <a class="code" href="group__timer.html#ga1244411df9784d63d3e2f99016d62643" title="Disarm a timer.">xntimer_stop</a>(timer);
474 <a name="l01028"></a>01028 }
475 <a name="l01029"></a>01029 <span class="preprocessor">#endif </span><span class="comment">/* !DOXYGEN_CPP */</span>
476 <a name="l01030"></a>01030
477 <a name="l01031"></a>01031 <span class="comment">/* --- task services --- */</span>
478 <a name="l01037"></a>01037 <span class="keyword">typedef</span> xnthread_t rtdm_task_t;
479 <a name="l01038"></a>01038
480 <a name="l01044"></a><a class="code" href="group__rtdmtask.html#gaa3cb481ab12462f5e54ff6fee12813e5">01044</a> <span class="keyword">typedef</span> void (*<a class="code" href="group__rtdmtask.html#gaa3cb481ab12462f5e54ff6fee12813e5" title="Real-time task procedure.">rtdm_task_proc_t</a>)(<span class="keywordtype">void</span> *arg);
481 <a name="l01045"></a>01045
482 <a name="l01050"></a>01050 <span class="preprocessor">#define RTDM_TASK_LOWEST_PRIORITY XNSCHED_LOW_PRIO</span>
483 <a name="l01051"></a>01051 <span class="preprocessor"></span><span class="preprocessor">#define RTDM_TASK_HIGHEST_PRIORITY XNSCHED_HIGH_PRIO</span>
484 <a name="l01052"></a>01052 <span class="preprocessor"></span>
485 <a name="l01058"></a>01058 <span class="preprocessor">#define RTDM_TASK_RAISE_PRIORITY (+1)</span>
486 <a name="l01059"></a>01059 <span class="preprocessor"></span><span class="preprocessor">#define RTDM_TASK_LOWER_PRIORITY (-1)</span>
487 <a name="l01060"></a>01060 <span class="preprocessor"></span>
488 <a name="l01064"></a>01064 <span class="keywordtype">int</span> <a class="code" href="group__rtdmtask.html#ga44b0701b6c28fa8035711f800fdcd371" title="Intialise and start a real-time task.">rtdm_task_init</a>(rtdm_task_t *task, <span class="keyword">const</span> <span class="keywordtype">char</span> *name,
489 <a name="l01065"></a>01065 <a class="code" href="group__rtdmtask.html#gaa3cb481ab12462f5e54ff6fee12813e5" title="Real-time task procedure.">rtdm_task_proc_t</a> task_proc, <span class="keywordtype">void</span> *arg,
490 <a name="l01066"></a>01066 <span class="keywordtype">int</span> priority, <a class="code" href="group__rtdm.html#gaededf91e760e3268235351dcc9d9dcda" title="RTDM type for representing relative intervals.">nanosecs_rel_t</a> period);
491 <a name="l01067"></a>01067 <span class="keywordtype">int</span> __rtdm_task_sleep(xnticks_t timeout, xntmode_t mode);
492 <a name="l01068"></a>01068 <span class="keywordtype">void</span> <a class="code" href="group__rtdmtask.html#gaa3940cfff7cc72d7bc064a3e279d74ac" title="Busy-wait a specified amount of time.">rtdm_task_busy_sleep</a>(<a class="code" href="group__rtdm.html#gaededf91e760e3268235351dcc9d9dcda" title="RTDM type for representing relative intervals.">nanosecs_rel_t</a> delay);
493 <a name="l01069"></a>01069
494 <a name="l01070"></a>01070 <span class="preprocessor">#ifndef DOXYGEN_CPP </span><span class="comment">/* Avoid static inline tags for RTDM in doxygen */</span>
495 <a name="l01071"></a>01071 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group__rtdmtask.html#ga7b5581febb2732127736817ca44e86e3" title="Destroy a real-time task.">rtdm_task_destroy</a>(rtdm_task_t *task)
496 <a name="l01072"></a>01072 {
497 <a name="l01073"></a>01073 <a class="code" href="group__pod.html#gad2b761fb70cad30339f092edb4a89587" title="Delete a thread.">xnpod_delete_thread</a>(task);
498 <a name="l01074"></a>01074 }
499 <a name="l01075"></a>01075
500 <a name="l01076"></a>01076 <span class="keywordtype">void</span> <a class="code" href="group__rtdmtask.html#ga8a60a2a7ba5fec7dac5336b3e8f256cc" title="Wait on a real-time task to terminate.">rtdm_task_join_nrt</a>(rtdm_task_t *task, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> poll_delay);
501 <a name="l01077"></a>01077
502 <a name="l01078"></a>01078 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group__rtdmtask.html#ga286f2d3ff73b3e9c5f24d5a1122a57d2" title="Adjust real-time task priority.">rtdm_task_set_priority</a>(rtdm_task_t *task, <span class="keywordtype">int</span> priority)
503 <a name="l01079"></a>01079 {
504 <a name="l01080"></a>01080 <span class="keyword">union </span>xnsched_policy_param param = { .rt = { .prio = priority } };
505 <a name="l01081"></a>01081 <a class="code" href="group__pod.html#ga6d535ef9821e98fd7f257b50a3c8d595" title="Change the base scheduling parameters of a thread.">xnpod_set_thread_schedparam</a>(task, &amp;xnsched_class_rt, &amp;param);
506 <a name="l01082"></a>01082 <a class="code" href="group__pod.html#gacf5b53f0405351327b89b0cc4976b962" title="Rescheduling procedure entry point.">xnpod_schedule</a>();
507 <a name="l01083"></a>01083 }
508 <a name="l01084"></a>01084
509 <a name="l01085"></a>01085 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group__rtdmtask.html#gaa5b32e7ff35bda7c6d929f8a894149b3" title="Adjust real-time task period.">rtdm_task_set_period</a>(rtdm_task_t *task,
510 <a name="l01086"></a>01086 <a class="code" href="group__rtdm.html#gaededf91e760e3268235351dcc9d9dcda" title="RTDM type for representing relative intervals.">nanosecs_rel_t</a> period)
511 <a name="l01087"></a>01087 {
512 <a name="l01088"></a>01088 <span class="keywordflow">if</span> (period &lt; 0)
513 <a name="l01089"></a>01089 period = 0;
514 <a name="l01090"></a>01090 <span class="keywordflow">return</span> <a class="code" href="group__pod.html#gaed5776a428e7c59b52b1da76f0d765fa" title="Make a thread periodic.">xnpod_set_thread_periodic</a>(task, XN_INFINITE,
515 <a name="l01091"></a>01091 xntbase_ns2ticks_ceil
516 <a name="l01092"></a>01092 (xnthread_time_base(task), period));
517 <a name="l01093"></a>01093 }
518 <a name="l01094"></a>01094
519 <a name="l01095"></a>01095 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group__rtdmtask.html#gae52cca97ebaf78eec2e31553a4dacd5e" title="Activate a blocked real-time task.">rtdm_task_unblock</a>(rtdm_task_t *task)
520 <a name="l01096"></a>01096 {
521 <a name="l01097"></a>01097 <span class="keywordtype">int</span> res = <a class="code" href="group__pod.html#gae5f0d19e7a499b9b262f68a43ab545dd" title="Unblock a thread.">xnpod_unblock_thread</a>(task);
522 <a name="l01098"></a>01098
523 <a name="l01099"></a>01099 <a class="code" href="group__pod.html#gacf5b53f0405351327b89b0cc4976b962" title="Rescheduling procedure entry point.">xnpod_schedule</a>();
524 <a name="l01100"></a>01100 <span class="keywordflow">return</span> res;
525 <a name="l01101"></a>01101 }
526 <a name="l01102"></a>01102
527 <a name="l01103"></a>01103 <span class="keyword">static</span> <span class="keyword">inline</span> rtdm_task_t *<a class="code" href="group__rtdmtask.html#gafd58b762de7269549d1e54699ceebc0d" title="Get current real-time task.">rtdm_task_current</a>(<span class="keywordtype">void</span>)
528 <a name="l01104"></a>01104 {
529 <a name="l01105"></a>01105 <span class="keywordflow">return</span> xnpod_current_thread();
530 <a name="l01106"></a>01106 }
531 <a name="l01107"></a>01107
532 <a name="l01108"></a>01108 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group__rtdmtask.html#ga577886a7588cdceac10f1b7b6ffcd1c7" title="Wait on next real-time task period.">rtdm_task_wait_period</a>(<span class="keywordtype">void</span>)
533 <a name="l01109"></a>01109 {
534 <a name="l01110"></a>01110 XENO_ASSERT(RTDM, !xnpod_unblockable_p(), <span class="keywordflow">return</span> -EPERM;);
535 <a name="l01111"></a>01111 <span class="keywordflow">return</span> <a class="code" href="group__pod.html#gaf836996e4a3378928f2a9f93a4915cfa" title="Wait for the next periodic release point.">xnpod_wait_thread_period</a>(NULL);
536 <a name="l01112"></a>01112 }
537 <a name="l01113"></a>01113
538 <a name="l01114"></a>01114 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group__rtdmtask.html#gabfae53746165a83a75965b7b0f6710a0" title="Sleep a specified amount of time.">rtdm_task_sleep</a>(<a class="code" href="group__rtdm.html#gaededf91e760e3268235351dcc9d9dcda" title="RTDM type for representing relative intervals.">nanosecs_rel_t</a> delay)
539 <a name="l01115"></a>01115 {
540 <a name="l01116"></a>01116 <span class="keywordflow">return</span> __rtdm_task_sleep(delay, XN_RELATIVE);
541 <a name="l01117"></a>01117 }
542 <a name="l01118"></a>01118
543 <a name="l01119"></a>01119 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span>
544 <a name="l01120"></a>01120 <a class="code" href="group__rtdmtask.html#ga1763346568d041f9c66d68224816d15b" title="Sleep until a specified absolute time.">rtdm_task_sleep_abs</a>(<a class="code" href="group__rtdm.html#gad3b24c25feabadba465f8797d8c7fe27" title="RTDM type for representing absolute dates.">nanosecs_abs_t</a> wakeup_date, <span class="keyword">enum</span> <a class="code" href="group__rtdmtimer.html#gad0bffecd0182d68967ebb5b47df0bcd0">rtdm_timer_mode</a> mode)
545 <a name="l01121"></a>01121 {
546 <a name="l01122"></a>01122 <span class="comment">/* For the sake of a consistent API usage... */</span>
547 <a name="l01123"></a>01123 <span class="keywordflow">if</span> (mode != <a class="code" href="group__rtdmtimer.html#ggad0bffecd0182d68967ebb5b47df0bcd0a77b27da267c09a5a586aab86c9cd22e2" title="Monotonic timer with absolute timeout.">RTDM_TIMERMODE_ABSOLUTE</a> &amp;&amp; mode != <a class="code" href="group__rtdmtimer.html#ggad0bffecd0182d68967ebb5b47df0bcd0a8c206cf25cb340fd7ccee4489df6a220" title="Adjustable timer with absolute timeout.">RTDM_TIMERMODE_REALTIME</a>)
548 <a name="l01124"></a>01124 <span class="keywordflow">return</span> -EINVAL;
549 <a name="l01125"></a>01125 <span class="keywordflow">return</span> __rtdm_task_sleep(wakeup_date, (xntmode_t)mode);
550 <a name="l01126"></a>01126 }
551 <a name="l01127"></a>01127
552 <a name="l01128"></a>01128 <span class="comment">/* rtdm_task_sleep_abs shall be used instead */</span>
553 <a name="l01129"></a>01129 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> __deprecated <a class="code" href="group__rtdmtask.html#ga741998821c05483db33f17d77c733d99" title="Sleep until a specified absolute time.">rtdm_task_sleep_until</a>(<a class="code" href="group__rtdm.html#gad3b24c25feabadba465f8797d8c7fe27" title="RTDM type for representing absolute dates.">nanosecs_abs_t</a> wakeup_time)
554 <a name="l01130"></a>01130 {
555 <a name="l01131"></a>01131 <span class="keywordflow">return</span> __rtdm_task_sleep(wakeup_time, XN_REALTIME);
556 <a name="l01132"></a>01132 }
557 <a name="l01133"></a>01133 <span class="preprocessor">#endif </span><span class="comment">/* !DOXYGEN_CPP */</span>
558 <a name="l01134"></a>01134
559 <a name="l01135"></a>01135 <span class="comment">/* --- timeout sequences */</span>
560 <a name="l01136"></a>01136
561 <a name="l01137"></a>01137 <span class="keyword">typedef</span> <a class="code" href="group__rtdm.html#gad3b24c25feabadba465f8797d8c7fe27" title="RTDM type for representing absolute dates.">nanosecs_abs_t</a> rtdm_toseq_t;
562 <a name="l01138"></a>01138
563 <a name="l01139"></a>01139 <span class="keywordtype">void</span> <a class="code" href="group__rtdmsync.html#ga531ddf80690059302409f760bd7f14d4" title="Initialise a timeout sequence.">rtdm_toseq_init</a>(rtdm_toseq_t *timeout_seq, <a class="code" href="group__rtdm.html#gaededf91e760e3268235351dcc9d9dcda" title="RTDM type for representing relative intervals.">nanosecs_rel_t</a> timeout);
564 <a name="l01140"></a>01140
565 <a name="l01141"></a>01141 <span class="comment">/* --- event services --- */</span>
566 <a name="l01142"></a>01142
567 <a name="l01143"></a>01143 <span class="keyword">typedef</span> <span class="keyword">struct </span>{
568 <a name="l01144"></a>01144 xnsynch_t synch_base;
569 <a name="l01145"></a>01145 DECLARE_XNSELECT(select_block);
570 <a name="l01146"></a>01146 } rtdm_event_t;
571 <a name="l01147"></a>01147
572 <a name="l01148"></a>01148 <span class="preprocessor">#define RTDM_EVENT_PENDING XNSYNCH_SPARE1</span>
573 <a name="l01149"></a>01149 <span class="preprocessor"></span>
574 <a name="l01150"></a>01150 <span class="keywordtype">void</span> <a class="code" href="group__rtdmsync.html#gaddf08d8ba5a44668bb360070a114fb19" title="Initialise an event.">rtdm_event_init</a>(rtdm_event_t *event, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> pending);
575 <a name="l01151"></a>01151 <span class="preprocessor">#ifdef CONFIG_XENO_OPT_RTDM_SELECT</span>
576 <a name="l01152"></a>01152 <span class="preprocessor"></span><span class="keywordtype">int</span> <a class="code" href="group__rtdmsync.html#ga839656c781d87069dd1bf1c84c38e9d9" title="Bind a selector to an event.">rtdm_event_select_bind</a>(rtdm_event_t *event, rtdm_selector_t *selector,
577 <a name="l01153"></a>01153 <span class="keyword">enum</span> <a class="code" href="group__rtdmsync.html#gae18228df8c70c9da1f90f61b01e92501">rtdm_selecttype</a> type, <span class="keywordtype">unsigned</span> fd_index);
578 <a name="l01154"></a>01154 <span class="preprocessor">#else </span><span class="comment">/* !CONFIG_XENO_OPT_RTDM_SELECT */</span>
579 <a name="l01155"></a>01155 <span class="preprocessor">#define rtdm_event_select_bind(e, s, t, i) ({ (void)(e); -EBADF; })</span>
580 <a name="l01156"></a>01156 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* !CONFIG_XENO_OPT_RTDM_SELECT */</span>
581 <a name="l01157"></a>01157 <span class="keywordtype">int</span> <a class="code" href="group__rtdmsync.html#ga1c433b50c53d49d164b084751861e855" title="Wait on event occurrence.">rtdm_event_wait</a>(rtdm_event_t *event);
582 <a name="l01158"></a>01158 <span class="keywordtype">int</span> <a class="code" href="group__rtdmsync.html#gaf76f858a3951ca2e20d3b1e00afa17e0" title="Wait on event occurrence with timeout.">rtdm_event_timedwait</a>(rtdm_event_t *event, <a class="code" href="group__rtdm.html#gaededf91e760e3268235351dcc9d9dcda" title="RTDM type for representing relative intervals.">nanosecs_rel_t</a> timeout,
583 <a name="l01159"></a>01159 rtdm_toseq_t *timeout_seq);
584 <a name="l01160"></a>01160 <span class="keywordtype">void</span> <a class="code" href="group__rtdmsync.html#ga1217402b82034b26fe25c26f1e5b32c9" title="Signal an event occurrence.">rtdm_event_signal</a>(rtdm_event_t *event);
585 <a name="l01161"></a>01161
586 <a name="l01162"></a>01162 <span class="keywordtype">void</span> <a class="code" href="group__rtdmsync.html#ga732fe3cf3370df0f296f06fc4ac7f925" title="Clear event state.">rtdm_event_clear</a>(rtdm_event_t *event);
587 <a name="l01163"></a>01163
588 <a name="l01164"></a>01164 <span class="preprocessor">#ifndef DOXYGEN_CPP </span><span class="comment">/* Avoid static inline tags for RTDM in doxygen */</span>
589 <a name="l01165"></a>01165 <span class="keywordtype">void</span> __rtdm_synch_flush(xnsynch_t *synch, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> reason);
590 <a name="l01166"></a>01166
591 <a name="l01167"></a>01167 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group__rtdmsync.html#ga7c9745d1db8e6de244a6c2690cbb8b22" title="Signal an event occurrence to currently listening waiters.">rtdm_event_pulse</a>(rtdm_event_t *event)
592 <a name="l01168"></a>01168 {
593 <a name="l01169"></a>01169 trace_mark(xn_rtdm, event_pulse, <span class="stringliteral">&quot;event %p&quot;</span>, event);
594 <a name="l01170"></a>01170 __rtdm_synch_flush(&amp;event-&gt;synch_base, 0);
595 <a name="l01171"></a>01171 }
596 <a name="l01172"></a>01172
597 <a name="l01173"></a>01173 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group__rtdmsync.html#ga7b27d0206027a07958d4a09017e8a3fe" title="Destroy an event.">rtdm_event_destroy</a>(rtdm_event_t *event)
598 <a name="l01174"></a>01174 {
599 <a name="l01175"></a>01175 trace_mark(xn_rtdm, event_destroy, <span class="stringliteral">&quot;event %p&quot;</span>, event);
600 <a name="l01176"></a>01176 __rtdm_synch_flush(&amp;event-&gt;synch_base, <a class="code" href="group__nucleus__info__flags.html#gab07d9dea73645dbba353dc2452c15b40" title="Pending on a removed resource.">XNRMID</a>);
601 <a name="l01177"></a>01177 <a class="code" href="group__select.html#ga56e4b5bf3e35dd80c23e95cad8fa1614" title="Destroy the xnselect structure associated with a file descriptor.">xnselect_destroy</a>(&amp;event-&gt;select_block);
602 <a name="l01178"></a>01178 }
603 <a name="l01179"></a>01179 <span class="preprocessor">#endif </span><span class="comment">/* !DOXYGEN_CPP */</span>
604 <a name="l01180"></a>01180
605 <a name="l01181"></a>01181 <span class="comment">/* --- semaphore services --- */</span>
606 <a name="l01182"></a>01182
607 <a name="l01183"></a>01183 <span class="keyword">typedef</span> <span class="keyword">struct </span>{
608 <a name="l01184"></a>01184 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> value;
609 <a name="l01185"></a>01185 xnsynch_t synch_base;
610 <a name="l01186"></a>01186 DECLARE_XNSELECT(select_block);
611 <a name="l01187"></a>01187 } rtdm_sem_t;
612 <a name="l01188"></a>01188
613 <a name="l01189"></a>01189 <span class="keywordtype">void</span> <a class="code" href="group__rtdmsync.html#gae1172824e463d7705ed3033e8aea133d" title="Initialise a semaphore.">rtdm_sem_init</a>(rtdm_sem_t *sem, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> value);
614 <a name="l01190"></a>01190 <span class="preprocessor">#ifdef CONFIG_XENO_OPT_RTDM_SELECT</span>
615 <a name="l01191"></a>01191 <span class="preprocessor"></span><span class="keywordtype">int</span> <a class="code" href="group__rtdmsync.html#gaf61f576b0ff06f99399b27725aef0ae1" title="Bind a selector to a semaphore.">rtdm_sem_select_bind</a>(rtdm_sem_t *sem, rtdm_selector_t *selector,
616 <a name="l01192"></a>01192 <span class="keyword">enum</span> <a class="code" href="group__rtdmsync.html#gae18228df8c70c9da1f90f61b01e92501">rtdm_selecttype</a> type, <span class="keywordtype">unsigned</span> fd_index);
617 <a name="l01193"></a>01193 <span class="preprocessor">#else </span><span class="comment">/* !CONFIG_XENO_OPT_RTDM_SELECT */</span>
618 <a name="l01194"></a>01194 <span class="preprocessor">#define rtdm_sem_select_bind(s, se, t, i) ({ (void)(s); -EBADF; })</span>
619 <a name="l01195"></a>01195 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* !CONFIG_XENO_OPT_RTDM_SELECT */</span>
620 <a name="l01196"></a>01196 <span class="keywordtype">int</span> <a class="code" href="group__rtdmsync.html#ga59da1b60b7279c1fc4355e2e0b2cc77c" title="Decrement a semaphore.">rtdm_sem_down</a>(rtdm_sem_t *sem);
621 <a name="l01197"></a>01197 <span class="keywordtype">int</span> <a class="code" href="group__rtdmsync.html#ga8aadb120a93df5dfd717c5bac6d4c1a9" title="Decrement a semaphore with timeout.">rtdm_sem_timeddown</a>(rtdm_sem_t *sem, <a class="code" href="group__rtdm.html#gaededf91e760e3268235351dcc9d9dcda" title="RTDM type for representing relative intervals.">nanosecs_rel_t</a> timeout,
622 <a name="l01198"></a>01198 rtdm_toseq_t *timeout_seq);
623 <a name="l01199"></a>01199 <span class="keywordtype">void</span> <a class="code" href="group__rtdmsync.html#ga829dbd8c5709d798ed06947b27001fed" title="Increment a semaphore.">rtdm_sem_up</a>(rtdm_sem_t *sem);
624 <a name="l01200"></a>01200
625 <a name="l01201"></a>01201 <span class="preprocessor">#ifndef DOXYGEN_CPP </span><span class="comment">/* Avoid static inline tags for RTDM in doxygen */</span>
626 <a name="l01202"></a>01202 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group__rtdmsync.html#gaf16f45217e54201ff3f24753982c41f8" title="Destroy a semaphore.">rtdm_sem_destroy</a>(rtdm_sem_t *sem)
627 <a name="l01203"></a>01203 {
628 <a name="l01204"></a>01204 trace_mark(xn_rtdm, <a class="code" href="group__posix__sem.html#ga6dbe34606b393161567a658a32be87af" title="Destroy an unnamed semaphore.">sem_destroy</a>, <span class="stringliteral">&quot;sem %p&quot;</span>, sem);
629 <a name="l01205"></a>01205 __rtdm_synch_flush(&amp;sem-&gt;synch_base, <a class="code" href="group__nucleus__info__flags.html#gab07d9dea73645dbba353dc2452c15b40" title="Pending on a removed resource.">XNRMID</a>);
630 <a name="l01206"></a>01206 <a class="code" href="group__select.html#ga56e4b5bf3e35dd80c23e95cad8fa1614" title="Destroy the xnselect structure associated with a file descriptor.">xnselect_destroy</a>(&amp;sem-&gt;select_block);
631 <a name="l01207"></a>01207 }
632 <a name="l01208"></a>01208 <span class="preprocessor">#endif </span><span class="comment">/* !DOXYGEN_CPP */</span>
633 <a name="l01209"></a>01209
634 <a name="l01210"></a>01210 <span class="comment">/* --- mutex services --- */</span>
635 <a name="l01211"></a>01211
636 <a name="l01212"></a>01212 <span class="keyword">typedef</span> <span class="keyword">struct </span>{
637 <a name="l01213"></a>01213 xnsynch_t synch_base;
638 <a name="l01214"></a>01214 } rtdm_mutex_t;
639 <a name="l01215"></a>01215
640 <a name="l01216"></a>01216 <span class="keywordtype">void</span> <a class="code" href="group__rtdmsync.html#ga8d58a144bf71df7b38bb887d036cbbb5" title="Initialise a mutex.">rtdm_mutex_init</a>(rtdm_mutex_t *mutex);
641 <a name="l01217"></a>01217 <span class="keywordtype">int</span> <a class="code" href="group__rtdmsync.html#ga67c8f85c844df1aeed806e343a1b6437" title="Request a mutex.">rtdm_mutex_lock</a>(rtdm_mutex_t *mutex);
642 <a name="l01218"></a>01218 <span class="keywordtype">int</span> <a class="code" href="group__rtdmsync.html#ga0789968300701ba2a940f5fe8b1fd4d8" title="Request a mutex with timeout.">rtdm_mutex_timedlock</a>(rtdm_mutex_t *mutex, <a class="code" href="group__rtdm.html#gaededf91e760e3268235351dcc9d9dcda" title="RTDM type for representing relative intervals.">nanosecs_rel_t</a> timeout,
643 <a name="l01219"></a>01219 rtdm_toseq_t *timeout_seq);
644 <a name="l01220"></a>01220
645 <a name="l01221"></a>01221 <span class="preprocessor">#ifndef DOXYGEN_CPP </span><span class="comment">/* Avoid static inline tags for RTDM in doxygen */</span>
646 <a name="l01222"></a>01222 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group__rtdmsync.html#gab40ed579324d8cc76387a0e06dd0f82a" title="Release a mutex.">rtdm_mutex_unlock</a>(rtdm_mutex_t *mutex)
647 <a name="l01223"></a>01223 {
648 <a name="l01224"></a>01224 XENO_ASSERT(RTDM, !xnpod_asynch_p(), <span class="keywordflow">return</span>;);
649 <a name="l01225"></a>01225
650 <a name="l01226"></a>01226 trace_mark(xn_rtdm, mutex_unlock, <span class="stringliteral">&quot;mutex %p&quot;</span>, mutex);
651 <a name="l01227"></a>01227
652 <a name="l01228"></a>01228 <span class="keywordflow">if</span> (unlikely(<a class="code" href="group__synch.html#ga1208abb6b3d0017a4e0c43b9baff8cfb" title="Give the resource ownership to the next waiting thread.">xnsynch_release</a>(&amp;mutex-&gt;synch_base) != NULL))
653 <a name="l01229"></a>01229 <a class="code" href="group__pod.html#gacf5b53f0405351327b89b0cc4976b962" title="Rescheduling procedure entry point.">xnpod_schedule</a>();
654 <a name="l01230"></a>01230 }
655 <a name="l01231"></a>01231
656 <a name="l01232"></a>01232 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group__rtdmsync.html#gad13170b569d0a4cdb46072e1e3a45527" title="Destroy a mutex.">rtdm_mutex_destroy</a>(rtdm_mutex_t *mutex)
657 <a name="l01233"></a>01233 {
658 <a name="l01234"></a>01234 trace_mark(xn_rtdm, mutex_destroy, <span class="stringliteral">&quot;mutex %p&quot;</span>, mutex);
659 <a name="l01235"></a>01235
660 <a name="l01236"></a>01236 __rtdm_synch_flush(&amp;mutex-&gt;synch_base, <a class="code" href="group__nucleus__info__flags.html#gab07d9dea73645dbba353dc2452c15b40" title="Pending on a removed resource.">XNRMID</a>);
661 <a name="l01237"></a>01237 }
662 <a name="l01238"></a>01238 <span class="preprocessor">#endif </span><span class="comment">/* !DOXYGEN_CPP */</span>
663 <a name="l01239"></a>01239
664 <a name="l01240"></a>01240 <span class="comment">/* --- utility functions --- */</span>
665 <a name="l01241"></a>01241
666 <a name="l01242"></a>01242 <span class="preprocessor">#define rtdm_printk(format, ...) printk(format, ##__VA_ARGS__)</span>
667 <a name="l01243"></a>01243 <span class="preprocessor"></span>
668 <a name="l01244"></a>01244 <span class="preprocessor">#ifndef DOXYGEN_CPP </span><span class="comment">/* Avoid static inline tags for RTDM in doxygen */</span>
669 <a name="l01245"></a>01245 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> *<a class="code" href="group__util.html#ga34dfd5c060c67acc684eb4b4256cd4ba" title="Allocate memory block in real-time context.">rtdm_malloc</a>(<span class="keywordtype">size_t</span> size)
670 <a name="l01246"></a>01246 {
671 <a name="l01247"></a>01247 <span class="keywordflow">return</span> xnmalloc(size);
672 <a name="l01248"></a>01248 }
673 <a name="l01249"></a>01249
674 <a name="l01250"></a>01250 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group__util.html#ga8d15b2cbb2fbf35b88362491af4e6a36" title="Release real-time memory block.">rtdm_free</a>(<span class="keywordtype">void</span> *ptr)
675 <a name="l01251"></a>01251 {
676 <a name="l01252"></a>01252 xnfree(ptr);
677 <a name="l01253"></a>01253 }
678 <a name="l01254"></a>01254
679 <a name="l01255"></a>01255 <span class="preprocessor">#ifdef CONFIG_XENO_OPT_PERVASIVE</span>
680 <a name="l01256"></a>01256 <span class="preprocessor"></span><span class="keywordtype">int</span> <a class="code" href="group__util.html#gadf5ddcdee106f1eaf4b93b2d633da441" title="Map a kernel memory range into the address space of the user.">rtdm_mmap_to_user</a>(rtdm_user_info_t *user_info,
681 <a name="l01257"></a>01257 <span class="keywordtype">void</span> *src_addr, <span class="keywordtype">size_t</span> len,
682 <a name="l01258"></a>01258 <span class="keywordtype">int</span> prot, <span class="keywordtype">void</span> **pptr,
683 <a name="l01259"></a>01259 <span class="keyword">struct</span> vm_operations_struct *vm_ops,
684 <a name="l01260"></a>01260 <span class="keywordtype">void</span> *vm_private_data);
685 <a name="l01261"></a>01261 <span class="keywordtype">int</span> <a class="code" href="group__util.html#gaa49b4fbd57a98a9ccda1f243b40bc519" title="Map an I/O memory range into the address space of the user.">rtdm_iomap_to_user</a>(rtdm_user_info_t *user_info,
686 <a name="l01262"></a>01262 phys_addr_t src_addr, <span class="keywordtype">size_t</span> len,
687 <a name="l01263"></a>01263 <span class="keywordtype">int</span> prot, <span class="keywordtype">void</span> **pptr,
688 <a name="l01264"></a>01264 <span class="keyword">struct</span> vm_operations_struct *vm_ops,
689 <a name="l01265"></a>01265 <span class="keywordtype">void</span> *vm_private_data);
690 <a name="l01266"></a>01266 <span class="keywordtype">int</span> <a class="code" href="group__util.html#gaa6a363aa6e2e017d3493a9c175755fa5" title="Unmap a user memory range.">rtdm_munmap</a>(rtdm_user_info_t *user_info, <span class="keywordtype">void</span> *ptr, <span class="keywordtype">size_t</span> len);
691 <a name="l01267"></a>01267
692 <a name="l01268"></a>01268 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group__util.html#ga341dedfbeeb511848ba5f5a9535cc0a7" title="Check if read access to user-space memory block is safe.">rtdm_read_user_ok</a>(rtdm_user_info_t *user_info,
693 <a name="l01269"></a>01269 <span class="keyword">const</span> <span class="keywordtype">void</span> __user *ptr, <span class="keywordtype">size_t</span> size)
694 <a name="l01270"></a>01270 {
695 <a name="l01271"></a>01271 <span class="keywordflow">return</span> access_rok(ptr, size);
696 <a name="l01272"></a>01272 }
697 <a name="l01273"></a>01273
698 <a name="l01274"></a>01274 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group__util.html#ga6cecee5411773e81c83d04824864a62d" title="Check if read/write access to user-space memory block is safe.">rtdm_rw_user_ok</a>(rtdm_user_info_t *user_info,
699 <a name="l01275"></a>01275 <span class="keyword">const</span> <span class="keywordtype">void</span> __user *ptr, <span class="keywordtype">size_t</span> size)
700 <a name="l01276"></a>01276 {
701 <a name="l01277"></a>01277 <span class="keywordflow">return</span> access_wok(ptr, size);
702 <a name="l01278"></a>01278 }
703 <a name="l01279"></a>01279
704 <a name="l01280"></a>01280 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group__util.html#ga99abc944640745604b4a77204d2d0777" title="Copy user-space memory block to specified buffer.">rtdm_copy_from_user</a>(rtdm_user_info_t *user_info,
705 <a name="l01281"></a>01281 <span class="keywordtype">void</span> *dst, <span class="keyword">const</span> <span class="keywordtype">void</span> __user *src,
706 <a name="l01282"></a>01282 <span class="keywordtype">size_t</span> size)
707 <a name="l01283"></a>01283 {
708 <a name="l01284"></a>01284 <span class="keywordflow">return</span> __xn_copy_from_user(dst, src, size) ? -EFAULT : 0;
709 <a name="l01285"></a>01285 }
710 <a name="l01286"></a>01286
711 <a name="l01287"></a>01287 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group__util.html#ga8e2ada3a5665c1366cd2c91f304bfa34" title="Check if read access to user-space memory block and copy it to specified buffer.">rtdm_safe_copy_from_user</a>(rtdm_user_info_t *user_info,
712 <a name="l01288"></a>01288 <span class="keywordtype">void</span> *dst, <span class="keyword">const</span> <span class="keywordtype">void</span> __user *src,
713 <a name="l01289"></a>01289 <span class="keywordtype">size_t</span> size)
714 <a name="l01290"></a>01290 {
715 <a name="l01291"></a>01291 <span class="keywordflow">return</span> (!access_rok(src, size) ||
716 <a name="l01292"></a>01292 __xn_copy_from_user(dst, src, size)) ? -EFAULT : 0;
717 <a name="l01293"></a>01293 }
718 <a name="l01294"></a>01294
719 <a name="l01295"></a>01295 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group__util.html#gab19ad9751ca1c56a53aafeb7ce8a6faf" title="Copy specified buffer to user-space memory block.">rtdm_copy_to_user</a>(rtdm_user_info_t *user_info,
720 <a name="l01296"></a>01296 <span class="keywordtype">void</span> __user *dst, <span class="keyword">const</span> <span class="keywordtype">void</span> *src,
721 <a name="l01297"></a>01297 <span class="keywordtype">size_t</span> size)
722 <a name="l01298"></a>01298 {
723 <a name="l01299"></a>01299 <span class="keywordflow">return</span> __xn_copy_to_user(dst, src, size) ? -EFAULT : 0;
724 <a name="l01300"></a>01300 }
725 <a name="l01301"></a>01301
726 <a name="l01302"></a>01302 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group__util.html#ga53f7bacd08774bfd26e13798cbfb21b8" title="Check if read/write access to user-space memory block is safe and copy specified buffer to it...">rtdm_safe_copy_to_user</a>(rtdm_user_info_t *user_info,
727 <a name="l01303"></a>01303 <span class="keywordtype">void</span> __user *dst, <span class="keyword">const</span> <span class="keywordtype">void</span> *src,
728 <a name="l01304"></a>01304 <span class="keywordtype">size_t</span> size)
729 <a name="l01305"></a>01305 {
730 <a name="l01306"></a>01306 <span class="keywordflow">return</span> (!access_wok(dst, size) ||
731 <a name="l01307"></a>01307 __xn_copy_to_user(dst, src, size)) ? -EFAULT : 0;
732 <a name="l01308"></a>01308 }
733 <a name="l01309"></a>01309
734 <a name="l01310"></a>01310 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group__util.html#ga9512ab3a85bea45a47bd033bad8b4828" title="Copy user-space string to specified buffer.">rtdm_strncpy_from_user</a>(rtdm_user_info_t *user_info,
735 <a name="l01311"></a>01311 <span class="keywordtype">char</span> *dst,
736 <a name="l01312"></a>01312 <span class="keyword">const</span> <span class="keywordtype">char</span> __user *src, <span class="keywordtype">size_t</span> count)
737 <a name="l01313"></a>01313 {
738 <a name="l01314"></a>01314 <span class="keywordflow">if</span> (unlikely(!access_rok(src, 1)))
739 <a name="l01315"></a>01315 <span class="keywordflow">return</span> -EFAULT;
740 <a name="l01316"></a>01316 <span class="keywordflow">return</span> __xn_strncpy_from_user(dst, src, count);
741 <a name="l01317"></a>01317 }
742 <a name="l01318"></a>01318
743 <a name="l01319"></a>01319 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group__util.html#ga321a8c48467a6268fa201c16833524db" title="Test if the caller is capable of running in real-time context.">rtdm_rt_capable</a>(rtdm_user_info_t *user_info)
744 <a name="l01320"></a>01320 {
745 <a name="l01321"></a>01321 XENO_ASSERT(RTDM, !xnpod_asynch_p(), <span class="keywordflow">return</span> 0;);
746 <a name="l01322"></a>01322
747 <a name="l01323"></a>01323 <span class="keywordflow">return</span> (user_info ? xnshadow_thread(user_info) != NULL
748 <a name="l01324"></a>01324 : !xnpod_root_p());
749 <a name="l01325"></a>01325 }
750 <a name="l01326"></a>01326
751 <a name="l01327"></a>01327 <span class="preprocessor">#else </span><span class="comment">/* !CONFIG_XENO_OPT_PERVASIVE */</span>
752 <a name="l01328"></a>01328 <span class="comment">/* Define void user&lt;-&gt;kernel services that simply fail */</span>
753 <a name="l01329"></a>01329 <span class="preprocessor">#define rtdm_mmap_to_user(...) ({ -ENOSYS; })</span>
754 <a name="l01330"></a>01330 <span class="preprocessor"></span><span class="preprocessor">#define rtdm_munmap(...) ({ -ENOSYS; })</span>
755 <a name="l01331"></a>01331 <span class="preprocessor"></span><span class="preprocessor">#define rtdm_read_user_ok(...) ({ 0; })</span>
756 <a name="l01332"></a>01332 <span class="preprocessor"></span><span class="preprocessor">#define rtdm_rw_user_ok(...) ({ 0; })</span>
757 <a name="l01333"></a>01333 <span class="preprocessor"></span><span class="preprocessor">#define rtdm_copy_from_user(...) ({ -ENOSYS; })</span>
758 <a name="l01334"></a>01334 <span class="preprocessor"></span><span class="preprocessor">#define rtdm_safe_copy_from_user(...) ({ -ENOSYS; })</span>
759 <a name="l01335"></a>01335 <span class="preprocessor"></span><span class="preprocessor">#define rtdm_copy_to_user(...) ({ -ENOSYS; })</span>
760 <a name="l01336"></a>01336 <span class="preprocessor"></span><span class="preprocessor">#define rtdm_safe_copy_to_user(...) ({ -ENOSYS; })</span>
761 <a name="l01337"></a>01337 <span class="preprocessor"></span><span class="preprocessor">#define rtdm_strncpy_from_user(...) ({ -ENOSYS; })</span>
762 <a name="l01338"></a>01338 <span class="preprocessor"></span>
763 <a name="l01339"></a>01339 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group__util.html#ga321a8c48467a6268fa201c16833524db" title="Test if the caller is capable of running in real-time context.">rtdm_rt_capable</a>(rtdm_user_info_t *user_info)
764 <a name="l01340"></a>01340 {
765 <a name="l01341"></a>01341 XENO_ASSERT(RTDM, !xnpod_asynch_p(), <span class="keywordflow">return</span> 0;);
766 <a name="l01342"></a>01342
767 <a name="l01343"></a>01343 <span class="keywordflow">return</span> !xnpod_root_p();
768 <a name="l01344"></a>01344 }
769 <a name="l01345"></a>01345
770 <a name="l01346"></a>01346 <span class="preprocessor">#endif </span><span class="comment">/* CONFIG_XENO_OPT_PERVASIVE */</span>
771 <a name="l01347"></a>01347
772 <a name="l01348"></a>01348 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group__util.html#ga8f9fcd0e274324096628dfede6fb10f2" title="Test if running in a real-time task.">rtdm_in_rt_context</a>(<span class="keywordtype">void</span>)
773 <a name="l01349"></a>01349 {
774 <a name="l01350"></a>01350 <span class="keywordflow">return</span> (rthal_current_domain != rthal_root_domain);
775 <a name="l01351"></a>01351 }
776 <a name="l01352"></a>01352
777 <a name="l01353"></a>01353 <span class="preprocessor">#endif </span><span class="comment">/* !DOXYGEN_CPP */</span>
778 <a name="l01354"></a>01354
779 <a name="l01355"></a>01355 <span class="keywordtype">int</span> rtdm_exec_in_rt(<span class="keyword">struct</span> <a class="code" href="structrtdm__dev__context.html" title="Device context.">rtdm_dev_context</a> *context,
780 <a name="l01356"></a>01356 rtdm_user_info_t *user_info, <span class="keywordtype">void</span> *arg,
781 <a name="l01357"></a>01357 rtdm_rt_handler_t handler);
782 <a name="l01358"></a>01358
783 <a name="l01359"></a>01359 <span class="preprocessor">#endif </span><span class="comment">/* _RTDM_DRIVER_H */</span>
784 </pre></div></div>
785 </div>
786 <hr class="footer"/><address class="footer"><small>Generated on Wed Nov 2 2011 18:01:06 for Xenomai API by&nbsp;
787 <a href="http://www.doxygen.org/index.html">
788 <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.1 </small></address>
789 </body>
790 </html>