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