Xenomai API
2.5.6.1
|
00001 00022 #ifndef _XENO_PPD_H 00023 #define _XENO_PPD_H 00024 00025 #include <nucleus/pod.h> 00026 #include <nucleus/ppd.h> 00027 #include <nucleus/heap.h> 00028 00029 typedef struct xeno_resource_holder { 00030 00031 xnshadow_ppd_t ppd; 00032 00033 #define ppd2rholder(a) container_of(a, struct xeno_resource_holder, ppd) 00034 00035 xnqueue_t alarmq; 00036 xnqueue_t condq; 00037 xnqueue_t eventq; 00038 xnqueue_t heapq; 00039 xnqueue_t intrq; 00040 xnqueue_t mutexq; 00041 xnqueue_t pipeq; 00042 xnqueue_t queueq; 00043 xnqueue_t semq; 00044 xnqueue_t ioregionq; 00045 xnqueue_t bufferq; 00046 00047 } xeno_rholder_t; 00048 00049 extern xeno_rholder_t __native_global_rholder; 00050 00051 #ifdef CONFIG_XENO_OPT_PERVASIVE 00052 00053 extern int __native_muxid; 00054 00055 static inline xeno_rholder_t *xeno_get_rholder(void) 00056 { 00057 xnshadow_ppd_t *ppd = xnshadow_ppd_get(__native_muxid); 00058 00059 if (ppd == NULL) 00060 return &__native_global_rholder; 00061 00062 return ppd2rholder(ppd); 00063 } 00064 00065 #define __xeno_release_obj(obj) \ 00066 do { \ 00067 if ((obj)->cpid) \ 00068 xnfree(obj); \ 00069 } while(0) 00070 00071 #else /* !CONFIG_XENO_OPT_PERVASIVE */ 00072 00073 static inline xeno_rholder_t *xeno_get_rholder(void) 00074 { 00075 return &__native_global_rholder; 00076 } 00077 00078 #define __xeno_release_obj(obj) do { } while(0) 00079 00080 #endif /* !CONFIG_XENO_OPT_PERVASIVE */ 00081 00082 #if XENO_DEBUG(NATIVE) 00083 #define __xeno_trace_release(__name, __obj, __err) \ 00084 xnprintf("native: cleaning up %s \"%s\" (ret=%d).\n", \ 00085 __name, (__obj)->name, __err) 00086 #else /* !XENO_DEBUG(NATIVE) */ 00087 #define __xeno_trace_release(__name, __obj, __err) 00088 #endif /* !XENO_DEBUG(NATIVE) */ 00089 00090 #define __xeno_flush_rq(__type, __rq, __name, __release) \ 00091 do { \ 00092 int rt_##__name##_delete(__type *); \ 00093 xnholder_t *holder, *nholder; \ 00094 __type *obj; \ 00095 int err; \ 00096 spl_t s; \ 00097 xnlock_get_irqsave(&nklock, s); \ 00098 nholder = getheadq(__rq); \ 00099 while ((holder = nholder) != NULL) { \ 00100 nholder = nextq((__rq), holder); \ 00101 xnlock_put_irqrestore(&nklock, s); \ 00102 obj = rlink2##__name(holder); \ 00103 err = rt_##__name##_delete(obj); \ 00104 __xeno_trace_release(#__name, obj, err); \ 00105 if (unlikely(err)) { \ 00106 if ((__rq) != &__native_global_rholder.__name##q) { \ 00107 xnlock_get_irqsave(&nklock, s); \ 00108 nholder = popq((__rq), holder); \ 00109 appendq(&__native_global_rholder.__name##q, holder); \ 00110 obj->rqueue = &__native_global_rholder.__name##q; \ 00111 } \ 00112 } else { \ 00113 if (__release) \ 00114 __xeno_release_obj(obj); \ 00115 xnlock_get_irqsave(&nklock, s); \ 00116 } \ 00117 } \ 00118 xnlock_put_irqrestore(&nklock, s); \ 00119 } while(0) 00120 00121 #define xeno_flush_rq(__type, __rq, __name) \ 00122 __xeno_flush_rq(__type, __rq, __name, 1) 00123 00124 #define xeno_flush_rq_norelease(__type, __rq, __name) \ 00125 __xeno_flush_rq(__type, __rq, __name, 0) 00126 00127 #endif /* !_XENO_PPD_H */