00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _XENO_NUCLEUS_TYPES_H
00021 #define _XENO_NUCLEUS_TYPES_H
00022
00023 #ifdef __KERNEL__
00024 #include <linux/errno.h>
00025 #ifdef CONFIG_PREEMPT_RT
00026 #define linux_semaphore compat_semaphore
00027 #else
00028 #define linux_semaphore semaphore
00029 #endif
00030 #else
00031 #include <sys/types.h>
00032 #include <errno.h>
00033 #ifndef BITS_PER_LONG
00034 #include <stdint.h>
00035 #define BITS_PER_LONG __WORDSIZE
00036 #endif
00037 #endif
00038
00039 #include <asm/xenomai/system.h>
00040 #include <nucleus/compiler.h>
00041 #include <nucleus/assert.h>
00042
00043 #if BITS_PER_LONG == 32
00044 #define __natural_word_type int
00045 #else
00046 #define __natural_word_type long
00047 #endif
00048
00049 typedef unsigned long xnsigmask_t;
00050
00051 typedef unsigned long long xnticks_t;
00052
00053 typedef long long xnsticks_t;
00054
00055 typedef unsigned long long xntime_t;
00056
00057 typedef long long xnstime_t;
00058
00059 typedef unsigned long xnhandle_t;
00060
00061 #define XN_NO_HANDLE ((xnhandle_t)0)
00062
00063 struct xnintr;
00064
00065 typedef int (*xnisr_t)(struct xnintr *intr);
00066
00067 typedef int (*xniack_t)(unsigned irq);
00068
00069 #define XN_INFINITE (0)
00070 #define XN_NONBLOCK ((xnticks_t)-1)
00071
00072
00073 typedef enum xntmode {
00074 XN_RELATIVE,
00075 XN_ABSOLUTE,
00076 XN_REALTIME
00077 } xntmode_t;
00078
00079 #define XN_APERIODIC_TICK 0
00080 #define XN_NO_TICK ((xnticks_t)-1)
00081
00082 #define testbits(flags,mask) ((flags) & (mask))
00083 #define setbits(flags,mask) xnarch_atomic_set_mask(&(flags),mask)
00084 #define clrbits(flags,mask) xnarch_atomic_clear_mask(&(flags),mask)
00085 #define __testbits(flags,mask) testbits(flags,mask)
00086 #define __setbits(flags,mask) do { (flags) |= (mask); } while(0)
00087 #define __clrbits(flags,mask) do { (flags) &= ~(mask); } while(0)
00088
00089 typedef atomic_flags_t xnflags_t;
00090
00091 #ifndef NULL
00092 #define NULL 0
00093 #endif
00094
00095 #define XNOBJECT_NAME_LEN 32
00096
00097 static inline void xnobject_copy_name(char *dst, const char *src)
00098 {
00099 if (src)
00100 strncpy(dst, src, XNOBJECT_NAME_LEN);
00101 else
00102 *dst = '\0';
00103 }
00104
00105 #define xnobject_create_name(dst, n, obj) \
00106 snprintf(dst, n, "%p", obj)
00107
00108 #define minval(a,b) ((a) < (b) ? (a) : (b))
00109 #define maxval(a,b) ((a) > (b) ? (a) : (b))
00110
00111 #ifdef __cplusplus
00112 extern "C" {
00113 #endif
00114
00115 const char *xnpod_fatal_helper(const char *format, ...);
00116
00117 int __xeno_user_init(void);
00118
00119 void __xeno_user_exit(void);
00120
00121 #ifdef __cplusplus
00122 }
00123 #endif
00124
00125 #define xnprintf(fmt,args...) xnarch_printf(fmt , ##args)
00126 #define xnloginfo(fmt,args...) xnarch_loginfo(fmt , ##args)
00127 #define xnlogwarn(fmt,args...) xnarch_logwarn(fmt , ##args)
00128 #define xnlogerr(fmt,args...) xnarch_logerr(fmt , ##args)
00129
00130 #define xnpod_fatal(format,args...) \
00131 do { \
00132 const char *panic; \
00133 xnarch_trace_panic_freeze(); \
00134 panic = xnpod_fatal_helper(format,##args); \
00135 xnarch_halt(panic); \
00136 } while (0)
00137
00138 #ifdef __XENO_SIM__
00139 #define SKIN_INIT(name) __xeno_skin_init(void)
00140 #define SKIN_EXIT(name) __xeno_skin_exit(void)
00141 #else
00142 #define SKIN_INIT(name) __ ## name ## _skin_init(void)
00143 #define SKIN_EXIT(name) __ ## name ## _skin_exit(void)
00144 #endif
00145
00146 #define root_thread_init __xeno_user_init
00147 #define root_thread_exit __xeno_user_exit
00148
00149 #endif