File: group__bufd.html

package info (click to toggle)
xenomai 2.5.4-3squeeze1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 36,140 kB
  • ctags: 35,509
  • sloc: ansic: 109,084; sh: 11,745; makefile: 2,205; xml: 1,356; asm: 613; php: 316; perl: 155
file content (739 lines) | stat: -rw-r--r-- 44,435 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Xenomai API: Buffer descriptors.</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.6 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="examples.html"><span>Examples</span></a></li>
    <li>
      <form action="search.php" method="get">
        <table cellspacing="0" cellpadding="0" border="0">
          <tr>
            <td><label>&nbsp;<u>S</u>earch&nbsp;for&nbsp;</label></td>
            <td><input type="text" name="query" value="" size="20" accesskey="s"/></td>
          </tr>
        </table>
      </form>
    </li>
    </ul>
  </div>
</div>
<div class="contents">
<h1>Buffer descriptors.<br>
<small>
[<a class="el" href="group__nucleus.html">Xenomai nucleus.</a>]</small>
</h1>
<p>
<div class="dynheader">
Collaboration diagram for Buffer descriptors.:</div>
<div class="dynsection">
<center><table><tr><td><img src="group__bufd.png" border="0" alt="" usemap="#group____bufd_map">
<map name="group____bufd_map">
<area shape="rect" href="group__nucleus.html" title="Xenomai nucleus." alt="" coords="5,5,141,32"></map></td></tr></table></center>
</div>
<hr><a name="_details"></a><h2>Detailed Description</h2>
A buffer descriptor is a simple abstraction dealing with copy operations to/from memory buffers which may belong to different address spaces.<p>
To this end, the buffer descriptor library provides a small set of copy routines which are aware of address space restrictions when moving data, and a generic container type which can hold a reference to - or cover - a particular memory area, either present in kernel space, or in any of the existing user memory contexts.<p>
The goal of the buffer descriptor abstraction is to hide address space specifics from Xenomai services dealing with memory areas, allowing them to operate on multiple address spaces seamlessly.<p>
The common usage patterns are as follows:<p>
<ul>
<li>Implementing a Xenomai syscall returning a bulk of data to the caller, which may have to be copied back to either kernel or user space:</li></ul>
<p>
<div class="fragment"><pre class="fragment">   [Syscall implementation]
   ssize_t rt_bulk_read_inner(<span class="keyword">struct</span> xnbufd *bufd)
   {
       ssize_t ret;
       <span class="keywordtype">size_t</span> len;
       <span class="keywordtype">void</span> *bulk;

       bulk = get_next_readable_bulk(&amp;len);
       ret = <a class="code" href="group__bufd.html#g626f17350a3f93fb3f8010bc6c16b560" title="Copy kernel memory to the area covered by a buffer descriptor.">xnbufd_copy_from_kmem</a>(bufd, bulk, min(bufd-&gt;b_len, len));
       free_bulk(bulk);

       ret = this_may_fail();
       <span class="keywordflow">if</span> (ret)
               <a class="code" href="group__bufd.html#gd2c63d67c47dd4f7f4d2eef19ba7ca5c" title="Invalidate a buffer descriptor.">xnbufd_invalidate</a>(bufd);

       <span class="keywordflow">return</span> ret;
   }

   [Kernel wrapper <span class="keywordflow">for</span> in-kernel calls]
   <span class="keywordtype">int</span> rt_bulk_read(<span class="keywordtype">void</span> *ptr, <span class="keywordtype">size_t</span> len)
   {
       <span class="keyword">struct </span>xnbufd bufd;
       ssize_t ret;

       <a class="code" href="group__bufd.html#g92fac02a07f5a847c332b6df98f20062" title="Initialize a buffer descriptor for writing to kernel memory.">xnbufd_map_kwrite</a>(&amp;bufd, ptr, len);
       ret = rt_bulk_read_inner(&amp;bufd);
       <a class="code" href="group__bufd.html#gae53741b014081f950351ad91298c304" title="Finalize a buffer descriptor obtained from xnbufd_map_kwrite().">xnbufd_unmap_kwrite</a>(&amp;bufd);

       <span class="keywordflow">return</span> ret;
   }

   [Userland trampoline <span class="keywordflow">for</span> user syscalls]
   <span class="keywordtype">int</span> __rt_bulk_read(<span class="keyword">struct</span> pt_regs *regs)
   {
       <span class="keyword">struct </span>xnbufd bufd;
       <span class="keywordtype">void</span> __user *ptr;
       ssize_t ret;
       <span class="keywordtype">size_t</span> len;

       ptr = (<span class="keywordtype">void</span> __user *)__xn_reg_arg1(regs);
       len = __xn_reg_arg2(regs);

       <a class="code" href="group__bufd.html#gbb2641def7f1e258f2aa1efdcb112746" title="Initialize a buffer descriptor for writing to user memory.">xnbufd_map_uwrite</a>(&amp;bufd, ptr, len);
       ret = rt_bulk_read_inner(&amp;bufd);
       <a class="code" href="group__bufd.html#g018218c68a27436fc90b1d5486ab1c71" title="Finalize a buffer descriptor obtained from xnbufd_map_uwrite().">xnbufd_unmap_uwrite</a>(&amp;bufd);

       <span class="keywordflow">return</span> ret;
   }
</pre></div><p>
<ul>
<li>Implementing a Xenomai syscall receiving a bulk of data from the caller, which may have to be read from either kernel or user space:</li></ul>
<p>
<div class="fragment"><pre class="fragment">   [Syscall implementation]
   ssize_t rt_bulk_write_inner(<span class="keyword">struct</span> xnbufd *bufd)
   {
       <span class="keywordtype">void</span> *bulk = get_free_bulk(bufd-&gt;b_len);
       <span class="keywordflow">return</span> <a class="code" href="group__bufd.html#g709e59aa0c61033bcd9f43cf42501dfe" title="Copy memory covered by a buffer descriptor to kernel memory.">xnbufd_copy_to_kmem</a>(bulk, bufd, bufd-&gt;b_len);
   }

   [Kernel wrapper <span class="keywordflow">for</span> in-kernel calls]
   <span class="keywordtype">int</span> rt_bulk_write(<span class="keyword">const</span> <span class="keywordtype">void</span> *ptr, <span class="keywordtype">size_t</span> len)
   {
       <span class="keyword">struct </span>xnbufd bufd;
       ssize_t ret;

       <a class="code" href="group__bufd.html#g81c887741b713f58c732626e209663e1" title="Initialize a buffer descriptor for reading from kernel memory.">xnbufd_map_kread</a>(&amp;bufd, ptr, len);
       ret = rt_bulk_write_inner(&amp;bufd);
       <a class="code" href="group__bufd.html#g26c4848d4354c10ece65202120da0e36" title="Finalize a buffer descriptor obtained from xnbufd_map_kread().">xnbufd_unmap_kread</a>(&amp;bufd);

       <span class="keywordflow">return</span> ret;
   }

   [Userland trampoline <span class="keywordflow">for</span> user syscalls]
   <span class="keywordtype">int</span> __rt_bulk_write(<span class="keyword">struct</span> pt_regs *regs)
   {
       <span class="keyword">struct </span>xnbufd bufd;
       <span class="keywordtype">void</span> __user *ptr;
       ssize_t ret;
       <span class="keywordtype">size_t</span> len;

       ptr = (<span class="keywordtype">void</span> __user *)__xn_reg_arg1(regs);
       len = __xn_reg_arg2(regs);

       <a class="code" href="group__bufd.html#g950caf2ab80994dcd8fa8710f8f5b971" title="Initialize a buffer descriptor for reading from user memory.">xnbufd_map_uread</a>(&amp;bufd, ptr, len);
       ret = rt_bulk_write_inner(&amp;bufd);
       <a class="code" href="group__bufd.html#gf6f7858e18500662fcd0ff3ff4777a74" title="Finalize a buffer descriptor obtained from xnbufd_map_uread().">xnbufd_unmap_uread</a>(&amp;bufd);

       <span class="keywordflow">return</span> ret;
   }
</pre></div> 
<p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Files</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">file &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="bufd_8c.html">bufd.c</a></td></tr>

<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">static void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bufd.html#g950caf2ab80994dcd8fa8710f8f5b971">xnbufd_map_uread</a> (struct xnbufd *bufd, const void __user *ptr, size_t len)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Initialize a buffer descriptor for reading from user memory.  <a href="#g950caf2ab80994dcd8fa8710f8f5b971"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">static void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bufd.html#gbb2641def7f1e258f2aa1efdcb112746">xnbufd_map_uwrite</a> (struct xnbufd *bufd, void __user *ptr, size_t len)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Initialize a buffer descriptor for writing to user memory.  <a href="#gbb2641def7f1e258f2aa1efdcb112746"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">ssize_t&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bufd.html#gf6f7858e18500662fcd0ff3ff4777a74">xnbufd_unmap_uread</a> (struct xnbufd *bufd)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Finalize a buffer descriptor obtained from <a class="el" href="group__bufd.html#g950caf2ab80994dcd8fa8710f8f5b971" title="Initialize a buffer descriptor for reading from user memory.">xnbufd_map_uread()</a>.  <a href="#gf6f7858e18500662fcd0ff3ff4777a74"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">ssize_t&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bufd.html#g018218c68a27436fc90b1d5486ab1c71">xnbufd_unmap_uwrite</a> (struct xnbufd *bufd)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Finalize a buffer descriptor obtained from <a class="el" href="group__bufd.html#gbb2641def7f1e258f2aa1efdcb112746" title="Initialize a buffer descriptor for writing to user memory.">xnbufd_map_uwrite()</a>.  <a href="#g018218c68a27436fc90b1d5486ab1c71"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">static void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bufd.html#g81c887741b713f58c732626e209663e1">xnbufd_map_kread</a> (struct xnbufd *bufd, const void *ptr, size_t len)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Initialize a buffer descriptor for reading from kernel memory.  <a href="#g81c887741b713f58c732626e209663e1"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">static void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bufd.html#g92fac02a07f5a847c332b6df98f20062">xnbufd_map_kwrite</a> (struct xnbufd *bufd, void *ptr, size_t len)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Initialize a buffer descriptor for writing to kernel memory.  <a href="#g92fac02a07f5a847c332b6df98f20062"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">ssize_t&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bufd.html#g26c4848d4354c10ece65202120da0e36">xnbufd_unmap_kread</a> (struct xnbufd *bufd)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Finalize a buffer descriptor obtained from <a class="el" href="group__bufd.html#g81c887741b713f58c732626e209663e1" title="Initialize a buffer descriptor for reading from kernel memory.">xnbufd_map_kread()</a>.  <a href="#g26c4848d4354c10ece65202120da0e36"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">ssize_t&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bufd.html#gae53741b014081f950351ad91298c304">xnbufd_unmap_kwrite</a> (struct xnbufd *bufd)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Finalize a buffer descriptor obtained from <a class="el" href="group__bufd.html#g92fac02a07f5a847c332b6df98f20062" title="Initialize a buffer descriptor for writing to kernel memory.">xnbufd_map_kwrite()</a>.  <a href="#gae53741b014081f950351ad91298c304"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">ssize_t&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bufd.html#g709e59aa0c61033bcd9f43cf42501dfe">xnbufd_copy_to_kmem</a> (void *ptr, struct xnbufd *bufd, size_t len)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Copy memory covered by a buffer descriptor to kernel memory.  <a href="#g709e59aa0c61033bcd9f43cf42501dfe"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">ssize_t&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bufd.html#g626f17350a3f93fb3f8010bc6c16b560">xnbufd_copy_from_kmem</a> (struct xnbufd *bufd, void *from, size_t len)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Copy kernel memory to the area covered by a buffer descriptor.  <a href="#g626f17350a3f93fb3f8010bc6c16b560"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bufd.html#gd2c63d67c47dd4f7f4d2eef19ba7ca5c">xnbufd_invalidate</a> (struct xnbufd *bufd)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Invalidate a buffer descriptor.  <a href="#gd2c63d67c47dd4f7f4d2eef19ba7ca5c"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">static void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bufd.html#g27038f6845854a80c6cb8b922e9b2fca">xnbufd_reset</a> (struct xnbufd *bufd)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Reset a buffer descriptor.  <a href="#g27038f6845854a80c6cb8b922e9b2fca"></a><br></td></tr>
</table>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="g626f17350a3f93fb3f8010bc6c16b560"></a><!-- doxytag: member="bufd.h::xnbufd_copy_from_kmem" ref="g626f17350a3f93fb3f8010bc6c16b560" args="(struct xnbufd *bufd, void *from, size_t len)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">ssize_t xnbufd_copy_from_kmem           </td>
          <td>(</td>
          <td class="paramtype">struct xnbufd *&nbsp;</td>
          <td class="paramname"> <em>bufd</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&nbsp;</td>
          <td class="paramname"> <em>from</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&nbsp;</td>
          <td class="paramname"> <em>len</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Copy kernel memory to the area covered by a buffer descriptor. 
<p>
This routine copies <em>len</em> bytes from the kernel memory starting at <em>from</em> to the area referred to by the buffer descriptor <em>bufd</em>. <a class="el" href="group__bufd.html#g626f17350a3f93fb3f8010bc6c16b560" title="Copy kernel memory to the area covered by a buffer descriptor.">xnbufd_copy_from_kmem()</a> tracks the write offset within the destination memory internally, so that it may be called several times in a loop, until the entire memory area is stored.<p>
The destination address space is dealt with, according to the following rules:<p>
<ul>
<li>if <em>bufd</em> refers to a writable kernel area (i.e. see <a class="el" href="group__bufd.html#g92fac02a07f5a847c332b6df98f20062" title="Initialize a buffer descriptor for writing to kernel memory.">xnbufd_map_kwrite()</a>), the copy is immediatly and fully performed with no restriction.</li></ul>
<p>
<ul>
<li>if <em>bufd</em> refers to a writable user area (i.e. see <a class="el" href="group__bufd.html#gbb2641def7f1e258f2aa1efdcb112746" title="Initialize a buffer descriptor for writing to user memory.">xnbufd_map_uwrite()</a>), the copy is performed only if that area lives in the currently active address space, and only if the caller may sleep Linux-wise to process any potential page fault which may arise while writing to that memory.</li></ul>
<p>
<ul>
<li>if <em>bufd</em> refers to a user area which may not be immediately written to from the current context, the copy is postponed until <a class="el" href="group__bufd.html#g018218c68a27436fc90b1d5486ab1c71" title="Finalize a buffer descriptor obtained from xnbufd_map_uwrite().">xnbufd_unmap_uwrite()</a> is invoked for <em>ubufd</em>, at which point the copy will take place. In such a case, the source memory is transferred to a carry over buffer allocated internally; this operation may lead to request dynamic memory from the nucleus heap if <em>len</em> is greater than 64 bytes.</li></ul>
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>bufd</em>&nbsp;</td><td>The address of the buffer descriptor covering the user memory to copy data to.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>from</em>&nbsp;</td><td>The start address of the kernel memory to copy from.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>len</em>&nbsp;</td><td>The length of the kernel memory to copy to <em>bufd</em>.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>The number of bytes written so far to the memory area covered by <em>ubufd</em>. Otherwise,</dd></dl>
<ul>
<li>-ENOMEM is returned when no memory is available from the nucleus heap to allocate the carry over buffer.</li></ul>
<p>
Environments:<p>
This service can be called from:<p>
<ul>
<li>Kernel code (including from primary mode) except Xenomai kernel-based task and interrupt service routines.</li></ul>
<p>
Rescheduling: may switch the caller to secondary mode if a page fault occurs while writing to the user area. For that reason, <a class="el" href="group__bufd.html#g626f17350a3f93fb3f8010bc6c16b560" title="Copy kernel memory to the area covered by a buffer descriptor.">xnbufd_copy_from_kmem()</a> may only be called from a preemptible section (Linux-wise).<p>
<dl class="note" compact><dt><b>Note:</b></dt><dd>Holding the nklock or running real-time interrupts disabled is invalid when calling this routine, and doing so would trigger a debug assertion. </dd></dl>

</div>
</div><p>
<a class="anchor" name="g709e59aa0c61033bcd9f43cf42501dfe"></a><!-- doxytag: member="bufd.h::xnbufd_copy_to_kmem" ref="g709e59aa0c61033bcd9f43cf42501dfe" args="(void *ptr, struct xnbufd *bufd, size_t len)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">ssize_t xnbufd_copy_to_kmem           </td>
          <td>(</td>
          <td class="paramtype">void *&nbsp;</td>
          <td class="paramname"> <em>to</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct xnbufd *&nbsp;</td>
          <td class="paramname"> <em>bufd</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&nbsp;</td>
          <td class="paramname"> <em>len</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Copy memory covered by a buffer descriptor to kernel memory. 
<p>
This routine copies <em>len</em> bytes from the area referred to by the buffer descriptor <em>bufd</em> to the kernel memory area <em>to</em>. <a class="el" href="group__bufd.html#g709e59aa0c61033bcd9f43cf42501dfe" title="Copy memory covered by a buffer descriptor to kernel memory.">xnbufd_copy_to_kmem()</a> tracks the read offset within the source memory internally, so that it may be called several times in a loop, until the entire memory area is loaded.<p>
The source address space is dealt with, according to the following rules:<p>
<ul>
<li>if <em>bufd</em> refers to readable kernel area (i.e. see <a class="el" href="group__bufd.html#g81c887741b713f58c732626e209663e1" title="Initialize a buffer descriptor for reading from kernel memory.">xnbufd_map_kread()</a>), the copy is immediately and fully performed with no restriction.</li></ul>
<p>
<ul>
<li>if <em>bufd</em> refers to a readable user area (i.e. see <a class="el" href="group__bufd.html#g950caf2ab80994dcd8fa8710f8f5b971" title="Initialize a buffer descriptor for reading from user memory.">xnbufd_map_uread()</a>), the copy is performed only if that area lives in the currently active address space, and only if the caller may sleep Linux-wise to process any potential page fault which may arise while reading from that memory.</li></ul>
<p>
<ul>
<li>any attempt to read from <em>bufd</em> from a non-suitable context is considered as a bug, and will raise a panic assertion when the nucleus is compiled in debug mode.</li></ul>
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>to</em>&nbsp;</td><td>The start address of the kernel memory to copy to.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>bufd</em>&nbsp;</td><td>The address of the buffer descriptor covering the user memory to copy data from.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>len</em>&nbsp;</td><td>The length of the user memory to copy from <em>bufd</em>.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>The number of bytes read so far from the memory area covered by <em>ubufd</em>. Otherwise:</dd></dl>
<ul>
<li>-EINVAL is returned upon attempt to read from the user area from an invalid context. This error is only returned when the debug mode is disabled; otherwise a panic assertion is raised.</li></ul>
<p>
Environments:<p>
This service can be called from:<p>
<ul>
<li>Kernel code (including from primary mode) except Xenomai kernel-based task and interrupt service routines.</li></ul>
<p>
Rescheduling: may switch the caller to secondary mode if a page fault occurs while reading from the user area. For that reason, <a class="el" href="group__bufd.html#g709e59aa0c61033bcd9f43cf42501dfe" title="Copy memory covered by a buffer descriptor to kernel memory.">xnbufd_copy_to_kmem()</a> may only be called from a preemptible section (Linux-wise).<p>
<dl class="note" compact><dt><b>Note:</b></dt><dd>Holding the nklock or running real-time interrupts disabled is invalid when calling this routine, and doing so would trigger a debug assertion. </dd></dl>

</div>
</div><p>
<a class="anchor" name="gd2c63d67c47dd4f7f4d2eef19ba7ca5c"></a><!-- doxytag: member="bufd.h::xnbufd_invalidate" ref="gd2c63d67c47dd4f7f4d2eef19ba7ca5c" args="(struct xnbufd *bufd)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void xnbufd_invalidate           </td>
          <td>(</td>
          <td class="paramtype">struct xnbufd *&nbsp;</td>
          <td class="paramname"> <em>bufd</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Invalidate a buffer descriptor. 
<p>
The buffer descriptor is invalidated, making it unusable for further copy operations. If an outstanding carry over buffer was allocated by a previous call to <a class="el" href="group__bufd.html#g626f17350a3f93fb3f8010bc6c16b560" title="Copy kernel memory to the area covered by a buffer descriptor.">xnbufd_copy_from_kmem()</a>, it is immediately freed so that no data transfer will happen when the descriptor is finalized.<p>
The only action that may subsequently be performed on an invalidated descriptor is calling the relevant unmapping routine for it. For that reason, <a class="el" href="group__bufd.html#gd2c63d67c47dd4f7f4d2eef19ba7ca5c" title="Invalidate a buffer descriptor.">xnbufd_invalidate()</a> should be invoked on the error path when data may have been transferred to the carry over buffer.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>bufd</em>&nbsp;</td><td>The address of the buffer descriptor to invalidate.</td></tr>
  </table>
</dl>
Environments:<p>
This service can be called from:<p>
<ul>
<li>Kernel code (including from primary mode)</li><li>Kernel-based task</li><li>Interrupt service routine</li></ul>
<p>
Rescheduling: never. 
</div>
</div><p>
<a class="anchor" name="g81c887741b713f58c732626e209663e1"></a><!-- doxytag: member="bufd.h::xnbufd_map_kread" ref="g81c887741b713f58c732626e209663e1" args="(struct xnbufd *bufd, const void *ptr, size_t len)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void xnbufd_map_kread           </td>
          <td>(</td>
          <td class="paramtype">struct xnbufd *&nbsp;</td>
          <td class="paramname"> <em>bufd</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const void *&nbsp;</td>
          <td class="paramname"> <em>ptr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&nbsp;</td>
          <td class="paramname"> <em>len</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td><code> [inline, static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Initialize a buffer descriptor for reading from kernel memory. 
<p>
The new buffer descriptor may be used to copy data from kernel memory. This routine should be used in pair with <a class="el" href="group__bufd.html#g26c4848d4354c10ece65202120da0e36" title="Finalize a buffer descriptor obtained from xnbufd_map_kread().">xnbufd_unmap_kread()</a>.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>bufd</em>&nbsp;</td><td>The address of the buffer descriptor which will map a <em>len</em> bytes kernel memory area, starting from <em>ptr</em>.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>ptr</em>&nbsp;</td><td>The start of the kernel buffer to map.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>len</em>&nbsp;</td><td>The length of the kernel buffer starting at <em>ptr</em>.</td></tr>
  </table>
</dl>
Environments:<p>
This service can be called from:<p>
<ul>
<li>Kernel code (including from primary mode)</li><li>Kernel-based task</li><li>Interrupt service routine</li></ul>
<p>
Rescheduling: never. 
<p>Referenced by <a class="el" href="ksrc_2skins_2native_2buffer_8c-source.html#l00713">rt_buffer_write()</a>, and <a class="el" href="ksrc_2skins_2native_2buffer_8c-source.html#l00794">rt_buffer_write_until()</a>.</p>

</div>
</div><p>
<a class="anchor" name="g92fac02a07f5a847c332b6df98f20062"></a><!-- doxytag: member="bufd.h::xnbufd_map_kwrite" ref="g92fac02a07f5a847c332b6df98f20062" args="(struct xnbufd *bufd, void *ptr, size_t len)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void xnbufd_map_kwrite           </td>
          <td>(</td>
          <td class="paramtype">struct xnbufd *&nbsp;</td>
          <td class="paramname"> <em>bufd</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&nbsp;</td>
          <td class="paramname"> <em>ptr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&nbsp;</td>
          <td class="paramname"> <em>len</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td><code> [inline, static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Initialize a buffer descriptor for writing to kernel memory. 
<p>
The new buffer descriptor may be used to copy data to kernel memory. This routine should be used in pair with <a class="el" href="group__bufd.html#gae53741b014081f950351ad91298c304" title="Finalize a buffer descriptor obtained from xnbufd_map_kwrite().">xnbufd_unmap_kwrite()</a>.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>bufd</em>&nbsp;</td><td>The address of the buffer descriptor which will map a <em>len</em> bytes kernel memory area, starting from <em>ptr</em>.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>ptr</em>&nbsp;</td><td>The start of the kernel buffer to map.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>len</em>&nbsp;</td><td>The length of the kernel buffer starting at <em>ptr</em>.</td></tr>
  </table>
</dl>
Environments:<p>
This service can be called from:<p>
<ul>
<li>Kernel code (including from primary mode)</li><li>Kernel-based task</li><li>Interrupt service routine</li></ul>
<p>
Rescheduling: never. 
<p>Referenced by <a class="el" href="ksrc_2skins_2native_2buffer_8c-source.html#l00900">rt_buffer_read()</a>.</p>

</div>
</div><p>
<a class="anchor" name="g950caf2ab80994dcd8fa8710f8f5b971"></a><!-- doxytag: member="bufd.h::xnbufd_map_uread" ref="g950caf2ab80994dcd8fa8710f8f5b971" args="(struct xnbufd *bufd, const void __user *ptr, size_t len)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void xnbufd_map_uread           </td>
          <td>(</td>
          <td class="paramtype">struct xnbufd *&nbsp;</td>
          <td class="paramname"> <em>bufd</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const void __user *&nbsp;</td>
          <td class="paramname"> <em>ptr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&nbsp;</td>
          <td class="paramname"> <em>len</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td><code> [inline, static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Initialize a buffer descriptor for reading from user memory. 
<p>
The new buffer descriptor may be used to copy data from user memory. This routine should be used in pair with <a class="el" href="group__bufd.html#gf6f7858e18500662fcd0ff3ff4777a74" title="Finalize a buffer descriptor obtained from xnbufd_map_uread().">xnbufd_unmap_uread()</a>.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>bufd</em>&nbsp;</td><td>The address of the buffer descriptor which will map a <em>len</em> bytes user memory area, starting from <em>ptr</em>. <em>ptr</em> is never dereferenced directly, since it may refer to a buffer that lives in another address space.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>ptr</em>&nbsp;</td><td>The start of the user buffer to map.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>len</em>&nbsp;</td><td>The length of the user buffer starting at <em>ptr</em>.</td></tr>
  </table>
</dl>
Environments:<p>
This service can be called from:<p>
<ul>
<li>Kernel code (including from primary mode) except Xenomai kernel-based task and interrupt service routines.</li></ul>
<p>
Rescheduling: never. 
</div>
</div><p>
<a class="anchor" name="gbb2641def7f1e258f2aa1efdcb112746"></a><!-- doxytag: member="bufd.h::xnbufd_map_uwrite" ref="gbb2641def7f1e258f2aa1efdcb112746" args="(struct xnbufd *bufd, void __user *ptr, size_t len)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void xnbufd_map_uwrite           </td>
          <td>(</td>
          <td class="paramtype">struct xnbufd *&nbsp;</td>
          <td class="paramname"> <em>bufd</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void __user *&nbsp;</td>
          <td class="paramname"> <em>ptr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&nbsp;</td>
          <td class="paramname"> <em>len</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td><code> [inline, static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Initialize a buffer descriptor for writing to user memory. 
<p>
The new buffer descriptor may be used to copy data to user memory. This routine should be used in pair with <a class="el" href="group__bufd.html#g018218c68a27436fc90b1d5486ab1c71" title="Finalize a buffer descriptor obtained from xnbufd_map_uwrite().">xnbufd_unmap_uwrite()</a>.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>bufd</em>&nbsp;</td><td>The address of the buffer descriptor which will map a <em>len</em> bytes user memory area, starting from <em>ptr</em>. <em>ptr</em> is never dereferenced directly, since it may refer to a buffer that lives in another address space.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>ptr</em>&nbsp;</td><td>The start of the user buffer to map.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>len</em>&nbsp;</td><td>The length of the user buffer starting at <em>ptr</em>.</td></tr>
  </table>
</dl>
Environments:<p>
This service can be called from:<p>
<ul>
<li>Kernel code (including from primary mode) except Xenomai kernel-based task and interrupt service routines.</li></ul>
<p>
Rescheduling: never. 
</div>
</div><p>
<a class="anchor" name="g27038f6845854a80c6cb8b922e9b2fca"></a><!-- doxytag: member="bufd.h::xnbufd_reset" ref="g27038f6845854a80c6cb8b922e9b2fca" args="(struct xnbufd *bufd)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void xnbufd_reset           </td>
          <td>(</td>
          <td class="paramtype">struct xnbufd *&nbsp;</td>
          <td class="paramname"> <em>bufd</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td><code> [inline, static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Reset a buffer descriptor. 
<p>
The buffer descriptor is reset, so that all data already copied is forgotten. Any carry over buffer allocated is kept, though.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>bufd</em>&nbsp;</td><td>The address of the buffer descriptor to reset.</td></tr>
  </table>
</dl>
Environments:<p>
This service can be called from:<p>
<ul>
<li>Kernel code (including from primary mode)</li><li>Kernel-based task</li><li>Interrupt service routine</li></ul>
<p>
Rescheduling: never. 
</div>
</div><p>
<a class="anchor" name="g26c4848d4354c10ece65202120da0e36"></a><!-- doxytag: member="bufd.h::xnbufd_unmap_kread" ref="g26c4848d4354c10ece65202120da0e36" args="(struct xnbufd *bufd)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">ssize_t xnbufd_unmap_kread           </td>
          <td>(</td>
          <td class="paramtype">struct xnbufd *&nbsp;</td>
          <td class="paramname"> <em>bufd</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Finalize a buffer descriptor obtained from <a class="el" href="group__bufd.html#g81c887741b713f58c732626e209663e1" title="Initialize a buffer descriptor for reading from kernel memory.">xnbufd_map_kread()</a>. 
<p>
This routine finalizes a buffer descriptor previously initialized by a call to <a class="el" href="group__bufd.html#g81c887741b713f58c732626e209663e1" title="Initialize a buffer descriptor for reading from kernel memory.">xnbufd_map_kread()</a>, to read data from a kernel area.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>bufd</em>&nbsp;</td><td>The address of the buffer descriptor to finalize.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>The number of bytes read so far from the memory area covered by <em>ubufd</em>.</dd></dl>
Environments:<p>
This service can be called from:<p>
<ul>
<li>Kernel code (including from primary mode)</li><li>Kernel-based task</li><li>Interrupt service routine</li></ul>
<p>
Rescheduling: never. 
<p>Referenced by <a class="el" href="ksrc_2skins_2native_2buffer_8c-source.html#l00713">rt_buffer_write()</a>, and <a class="el" href="ksrc_2skins_2native_2buffer_8c-source.html#l00794">rt_buffer_write_until()</a>.</p>

</div>
</div><p>
<a class="anchor" name="gae53741b014081f950351ad91298c304"></a><!-- doxytag: member="bufd.h::xnbufd_unmap_kwrite" ref="gae53741b014081f950351ad91298c304" args="(struct xnbufd *bufd)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">ssize_t xnbufd_unmap_kwrite           </td>
          <td>(</td>
          <td class="paramtype">struct xnbufd *&nbsp;</td>
          <td class="paramname"> <em>bufd</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Finalize a buffer descriptor obtained from <a class="el" href="group__bufd.html#g92fac02a07f5a847c332b6df98f20062" title="Initialize a buffer descriptor for writing to kernel memory.">xnbufd_map_kwrite()</a>. 
<p>
This routine finalizes a buffer descriptor previously initialized by a call to <a class="el" href="group__bufd.html#g92fac02a07f5a847c332b6df98f20062" title="Initialize a buffer descriptor for writing to kernel memory.">xnbufd_map_kwrite()</a>, to write data to a kernel area.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>bufd</em>&nbsp;</td><td>The address of the buffer descriptor to finalize.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>The number of bytes written so far to the memory area covered by <em>ubufd</em>.</dd></dl>
Environments:<p>
This service can be called from:<p>
<ul>
<li>Kernel code (including from primary mode)</li><li>Kernel-based task</li><li>Interrupt service routine</li></ul>
<p>
Rescheduling: never. 
<p>Referenced by <a class="el" href="ksrc_2skins_2native_2buffer_8c-source.html#l00900">rt_buffer_read()</a>.</p>

</div>
</div><p>
<a class="anchor" name="gf6f7858e18500662fcd0ff3ff4777a74"></a><!-- doxytag: member="bufd.h::xnbufd_unmap_uread" ref="gf6f7858e18500662fcd0ff3ff4777a74" args="(struct xnbufd *bufd)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">ssize_t xnbufd_unmap_uread           </td>
          <td>(</td>
          <td class="paramtype">struct xnbufd *&nbsp;</td>
          <td class="paramname"> <em>bufd</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Finalize a buffer descriptor obtained from <a class="el" href="group__bufd.html#g950caf2ab80994dcd8fa8710f8f5b971" title="Initialize a buffer descriptor for reading from user memory.">xnbufd_map_uread()</a>. 
<p>
This routine finalizes a buffer descriptor previously initialized by a call to <a class="el" href="group__bufd.html#g950caf2ab80994dcd8fa8710f8f5b971" title="Initialize a buffer descriptor for reading from user memory.">xnbufd_map_uread()</a>, to read data from a user area.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>bufd</em>&nbsp;</td><td>The address of the buffer descriptor to finalize.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>The number of bytes read so far from the memory area covered by <em>ubufd</em>.</dd></dl>
Environments:<p>
This service can be called from:<p>
<ul>
<li>Kernel code (including from primary mode) except Xenomai kernel-based task and interrupt service routines.</li></ul>
<p>
Rescheduling: never.<p>
<dl class="note" compact><dt><b>Note:</b></dt><dd>Holding the nklock or running real-time interrupts disabled is invalid when calling this routine, and doing so would trigger a debug assertion. </dd></dl>

</div>
</div><p>
<a class="anchor" name="g018218c68a27436fc90b1d5486ab1c71"></a><!-- doxytag: member="bufd.h::xnbufd_unmap_uwrite" ref="g018218c68a27436fc90b1d5486ab1c71" args="(struct xnbufd *bufd)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">ssize_t xnbufd_unmap_uwrite           </td>
          <td>(</td>
          <td class="paramtype">struct xnbufd *&nbsp;</td>
          <td class="paramname"> <em>bufd</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Finalize a buffer descriptor obtained from <a class="el" href="group__bufd.html#gbb2641def7f1e258f2aa1efdcb112746" title="Initialize a buffer descriptor for writing to user memory.">xnbufd_map_uwrite()</a>. 
<p>
This routine finalizes a buffer descriptor previously initialized by a call to <a class="el" href="group__bufd.html#gbb2641def7f1e258f2aa1efdcb112746" title="Initialize a buffer descriptor for writing to user memory.">xnbufd_map_uwrite()</a>, to write data to a user area.<p>
The main action taken is to write the contents of the kernel memory area passed to <a class="el" href="group__bufd.html#g626f17350a3f93fb3f8010bc6c16b560" title="Copy kernel memory to the area covered by a buffer descriptor.">xnbufd_copy_from_kmem()</a> whenever the copy operation was postponed at that time; the carry over buffer is eventually released as needed. If <a class="el" href="group__bufd.html#g626f17350a3f93fb3f8010bc6c16b560" title="Copy kernel memory to the area covered by a buffer descriptor.">xnbufd_copy_from_kmem()</a> was allowed to copy to the destination user memory at once, then <a class="el" href="group__bufd.html#g018218c68a27436fc90b1d5486ab1c71" title="Finalize a buffer descriptor obtained from xnbufd_map_uwrite().">xnbufd_unmap_uwrite()</a> leads to a no-op.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>bufd</em>&nbsp;</td><td>The address of the buffer descriptor to finalize.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>The number of bytes written so far to the memory area covered by <em>ubufd</em>.</dd></dl>
Environments:<p>
This service can be called from:<p>
<ul>
<li>Kernel code (including from primary mode) except Xenomai kernel-based task and interrupt service routines.</li></ul>
<p>
Rescheduling: never.<p>
<dl class="note" compact><dt><b>Note:</b></dt><dd>Holding the nklock or running real-time interrupts disabled is invalid when calling this routine, and doing so would trigger a debug assertion. </dd></dl>

</div>
</div><p>
</div>
<hr size="1"><address style="text-align: right;"><small>Generated on Mon Aug 2 12:48:37 2010 for Xenomai API by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address>
</body>
</html>