Xenomai API  2.6.5
bufd.h
Go to the documentation of this file.
1 
23 #ifndef _XENO_NUCLEUS_BUFD_H
24 #define _XENO_NUCLEUS_BUFD_H
25 
29 #include <nucleus/types.h>
30 
31 #ifdef CONFIG_XENO_OPT_PERVASIVE
32 
33 struct mm_struct;
34 
35 struct xnbufd {
36  caddr_t b_ptr; /* src/dst buffer address */
37  size_t b_len; /* total length of buffer */
38  off_t b_off; /* # of bytes read/written */
39  struct mm_struct *b_mm; /* src/dst address space */
40  caddr_t b_carry; /* pointer to carry over area */
41  char b_buf[64]; /* fast carry over area */
42 };
43 
44 void xnbufd_map_umem(struct xnbufd *bufd,
45  void __user *ptr, size_t len);
46 
47 static inline void xnbufd_map_uread(struct xnbufd *bufd,
48  const void __user *ptr, size_t len)
49 {
50  xnbufd_map_umem(bufd, (void __user *)ptr, len);
51 }
52 
53 static inline void xnbufd_map_uwrite(struct xnbufd *bufd,
54  void __user *ptr, size_t len)
55 {
56  xnbufd_map_umem(bufd, ptr, len);
57 }
58 
59 ssize_t xnbufd_unmap_uread(struct xnbufd *bufd);
60 
61 ssize_t xnbufd_unmap_uwrite(struct xnbufd *bufd);
62 
63 #else /* !CONFIG_XENO_OPT_PERVASIVE */
64 
65 struct xnbufd {
66  caddr_t b_ptr; /* src/dst buffer address */
67  size_t b_len; /* total length of buffer */
68  off_t b_off; /* # of bytes read/written */
69 };
70 
71 #endif /* !CONFIG_XENO_OPT_PERVASIVE */
72 
73 void xnbufd_map_kmem(struct xnbufd *bufd,
74  void *ptr, size_t len);
75 
76 static inline void xnbufd_map_kread(struct xnbufd *bufd,
77  const void *ptr, size_t len)
78 {
79  xnbufd_map_kmem(bufd, (void *)ptr, len);
80 }
81 
82 static inline void xnbufd_map_kwrite(struct xnbufd *bufd,
83  void *ptr, size_t len)
84 {
85  xnbufd_map_kmem(bufd, ptr, len);
86 }
87 
88 ssize_t xnbufd_unmap_kread(struct xnbufd *bufd);
89 
90 ssize_t xnbufd_unmap_kwrite(struct xnbufd *bufd);
91 
92 ssize_t xnbufd_copy_to_kmem(void *ptr,
93  struct xnbufd *bufd, size_t len);
94 
95 ssize_t xnbufd_copy_from_kmem(struct xnbufd *bufd,
96  void *from, size_t len);
97 
98 void xnbufd_invalidate(struct xnbufd *bufd);
99 
100 static inline void xnbufd_reset(struct xnbufd *bufd)
101 {
102  bufd->b_off = 0;
103 }
104 
107 #endif /* !_XENO_NUCLEUS_BUFD_H */
void xnbufd_invalidate(struct xnbufd *bufd)
Invalidate a buffer descriptor.
Definition: bufd.c:678
ssize_t xnbufd_unmap_kread(struct xnbufd *bufd)
Finalize a buffer descriptor obtained from xnbufd_map_kread().
Definition: bufd.c:760
static void xnbufd_map_kwrite(struct xnbufd *bufd, void *ptr, size_t len)
Initialize a buffer descriptor for writing to kernel memory.
Definition: bufd.h:82
ssize_t xnbufd_unmap_kwrite(struct xnbufd *bufd)
Finalize a buffer descriptor obtained from xnbufd_map_kwrite().
Definition: bufd.c:792
ssize_t xnbufd_unmap_uwrite(struct xnbufd *bufd)
Finalize a buffer descriptor obtained from xnbufd_map_uwrite().
Definition: bufd.c:596
ssize_t xnbufd_unmap_uread(struct xnbufd *bufd)
Finalize a buffer descriptor obtained from xnbufd_map_uread().
Definition: bufd.c:552
ssize_t xnbufd_copy_to_kmem(void *ptr, struct xnbufd *bufd, size_t len)
Copy memory covered by a buffer descriptor to kernel memory.
Definition: bufd.c:339
static void xnbufd_reset(struct xnbufd *bufd)
Reset a buffer descriptor.
Definition: bufd.h:100
static void xnbufd_map_uwrite(struct xnbufd *bufd, void __user *ptr, size_t len)
Initialize a buffer descriptor for writing to user memory.
Definition: bufd.h:53
static void xnbufd_map_uread(struct xnbufd *bufd, const void __user *ptr, size_t len)
Initialize a buffer descriptor for reading from user memory.
Definition: bufd.h:47
ssize_t xnbufd_copy_from_kmem(struct xnbufd *bufd, void *from, size_t len)
Copy kernel memory to the area covered by a buffer descriptor.
Definition: bufd.c:453
static void xnbufd_map_kread(struct xnbufd *bufd, const void *ptr, size_t len)
Initialize a buffer descriptor for reading from kernel memory.
Definition: bufd.h:76