Xenomai API  2.6.5
ppd.h
Go to the documentation of this file.
1 
22 #ifndef _XENO_PPD_H
23 #define _XENO_PPD_H
24 
25 #include <nucleus/pod.h>
26 #include <nucleus/ppd.h>
27 #include <nucleus/heap.h>
28 
29 typedef struct xeno_resource_holder {
30 
31  xnshadow_ppd_t ppd;
32 
33 #define ppd2rholder(a) container_of(a, struct xeno_resource_holder, ppd)
34 
35  xnqueue_t alarmq;
36  xnqueue_t condq;
37  xnqueue_t eventq;
38  xnqueue_t heapq;
39  xnqueue_t intrq;
40  xnqueue_t mutexq;
41  xnqueue_t pipeq;
42  xnqueue_t queueq;
43  xnqueue_t semq;
44  xnqueue_t ioregionq;
45  xnqueue_t bufferq;
46 
47 } xeno_rholder_t;
48 
49 extern xeno_rholder_t __native_global_rholder;
50 
51 #ifdef CONFIG_XENO_OPT_PERVASIVE
52 
53 extern int __native_muxid;
54 
55 static inline xeno_rholder_t *xeno_get_rholder(void)
56 {
57  xnshadow_ppd_t *ppd = xnshadow_ppd_get(__native_muxid);
58 
59  if (ppd == NULL)
60  return &__native_global_rholder;
61 
62  return ppd2rholder(ppd);
63 }
64 
65 #define __xeno_release_obj(obj) \
66  do { \
67  if ((obj)->cpid) \
68  xnfree(obj); \
69  } while(0)
70 
71 #else /* !CONFIG_XENO_OPT_PERVASIVE */
72 
73 static inline xeno_rholder_t *xeno_get_rholder(void)
74 {
75  return &__native_global_rholder;
76 }
77 
78 #define __xeno_release_obj(obj) do { } while(0)
79 
80 #endif /* !CONFIG_XENO_OPT_PERVASIVE */
81 
82 #if XENO_DEBUG(NATIVE)
83 #define __xeno_trace_release(__name, __obj, __err) \
84  xnprintf("native: cleaning up %s \"%s\" (ret=%d).\n", \
85  __name, (__obj)->name, __err)
86 #else /* !XENO_DEBUG(NATIVE) */
87 #define __xeno_trace_release(__name, __obj, __err)
88 #endif /* !XENO_DEBUG(NATIVE) */
89 
90 #define __xeno_flush_rq(__type, __rq, __name, __release) \
91  do { \
92  int rt_##__name##_delete(__type *); \
93  xnholder_t *holder, *nholder; \
94  __type *obj; \
95  int err; \
96  spl_t s; \
97  xnlock_get_irqsave(&nklock, s); \
98  nholder = getheadq(__rq); \
99  while ((holder = nholder) != NULL) { \
100  nholder = nextq((__rq), holder); \
101  xnlock_put_irqrestore(&nklock, s); \
102  obj = rlink2##__name(holder); \
103  err = rt_##__name##_delete(obj); \
104  __xeno_trace_release(#__name, obj, err); \
105  if (unlikely(err)) { \
106  xnlock_get_irqsave(&nklock, s); \
107  if ((__rq) != &__native_global_rholder.__name##q) { \
108  nholder = popq((__rq), holder); \
109  appendq(&__native_global_rholder.__name##q, holder); \
110  obj->rqueue = &__native_global_rholder.__name##q; \
111  } \
112  } else { \
113  if (__release) \
114  __xeno_release_obj(obj); \
115  xnlock_get_irqsave(&nklock, s); \
116  } \
117  } \
118  xnlock_put_irqrestore(&nklock, s); \
119  } while(0)
120 
121 #define xeno_flush_rq(__type, __rq, __name) \
122  __xeno_flush_rq(__type, __rq, __name, 1)
123 
124 #define xeno_flush_rq_norelease(__type, __rq, __name) \
125  __xeno_flush_rq(__type, __rq, __name, 0)
126 
127 #endif /* !_XENO_PPD_H */
xnshadow_ppd_t * xnshadow_ppd_get(unsigned muxid)
Return the per-process data attached to the calling process.
Definition: shadow.c:3014
Real-time pod interface header.