• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

include/nucleus/types.h

00001 /*
00002  * Copyright (C) 2001,2002,2003 Philippe Gerum <rpm@xenomai.org>.
00003  *
00004  * Xenomai is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published
00006  * by the Free Software Foundation; either version 2 of the License,
00007  * or (at your option) any later version.
00008  *
00009  * Xenomai is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with Xenomai; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00017  * 02111-1307, USA.
00018  */
00019 
00020 #ifndef _XENO_NUCLEUS_TYPES_H
00021 #define _XENO_NUCLEUS_TYPES_H
00022 
00023 #ifdef __KERNEL__
00024 #include <linux/errno.h>
00025 #else /* !__KERNEL__ */
00026 #include <stdio.h>
00027 #include <string.h>
00028 #include <sys/types.h>
00029 #include <errno.h>
00030 #ifndef BITS_PER_LONG
00031 #include <stdint.h>
00032 #define BITS_PER_LONG __WORDSIZE
00033 #endif /* !BITS_PER_LONG */
00034 #endif /* __KERNEL__ */
00035 
00036 #include <asm/xenomai/system.h>
00037 #include <nucleus/compiler.h>
00038 #include <nucleus/assert.h>
00039 
00040 #if BITS_PER_LONG == 32
00041 #define __natural_word_type int
00042 #else  /* defaults to long otherwise */
00043 #define __natural_word_type long
00044 #endif
00045 
00046 typedef unsigned long xnsigmask_t;
00047 
00048 typedef unsigned long long xnticks_t;
00049 
00050 typedef long long xnsticks_t;
00051 
00052 typedef unsigned long long xntime_t; /* ns */
00053 
00054 typedef long long xnstime_t;
00055 
00056 typedef unsigned long xnhandle_t;
00057 
00058 #define XN_NO_HANDLE ((xnhandle_t)0)
00059 
00060 #define XN_HANDLE_SPARE0        ((xnhandle_t)0x10000000)
00061 #define XN_HANDLE_SPARE1        ((xnhandle_t)0x20000000)
00062 #define XN_HANDLE_SPARE2        ((xnhandle_t)0x40000000)
00063 #define XN_HANDLE_SPARE3        ((xnhandle_t)0x80000000)
00064 #define XN_HANDLE_SPARE_MASK    ((xnhandle_t)0xf0000000)
00065 
00066 #define xnhandle_mask_spare(handle)  ((handle) & ~XN_HANDLE_SPARE_MASK)
00067 #define xnhandle_test_spare(handle, bits)  (!!((handle) & (bits)))
00068 #define xnhandle_set_spare(handle, bits) \
00069         do { (handle) |= (bits); } while (0)
00070 #define xnhandle_clear_spare(handle, bits) \
00071         do { (handle) &= ~(bits); } while (0)
00072 
00073 struct xnintr;
00074 
00075 typedef int (*xnisr_t)(struct xnintr *intr);
00076 
00077 typedef void (*xniack_t)(unsigned irq, void *arg);
00078 
00079 #define XN_INFINITE   (0)
00080 #define XN_NONBLOCK   ((xnticks_t)-1)
00081 
00082 /* Timer modes */
00083 typedef enum xntmode {
00084         XN_RELATIVE,
00085         XN_ABSOLUTE,
00086         XN_REALTIME
00087 } xntmode_t;
00088 
00089 #define XN_APERIODIC_TICK  0
00090 
00091 #define testbits(flags,mask) ((flags) & (mask))
00092 #define setbits(flags,mask)  xnarch_atomic_set_mask(&(flags),mask)
00093 #define clrbits(flags,mask)  xnarch_atomic_clear_mask(&(flags),mask)
00094 #define __testbits(flags,mask) testbits(flags,mask)
00095 #define __setbits(flags,mask)  do { (flags) |= (mask); } while(0)
00096 #define __clrbits(flags,mask)  do { (flags) &= ~(mask); } while(0)
00097 
00098 typedef atomic_flags_t xnflags_t;
00099 
00100 #ifndef NULL
00101 #define NULL 0
00102 #endif
00103 
00104 #define XNOBJECT_NAME_LEN 32
00105 
00106 #define xnobject_copy_name(dst, src)                                    \
00107         do {                                                            \
00108                 strncpy((dst),                                          \
00109                         ((const char *)(src)) ?: "", XNOBJECT_NAME_LEN-1) \
00110                         [XNOBJECT_NAME_LEN-1] = '\0';                   \
00111         } while (0)
00112 
00113 #define xnobject_create_name(dst, n, obj)       \
00114         snprintf(dst, n, "%p", obj)
00115 
00116 #define minval(a,b) ((a) < (b) ? (a) : (b))
00117 #define maxval(a,b) ((a) > (b) ? (a) : (b))
00118 
00119 #ifdef __cplusplus
00120 extern "C" {
00121 #endif
00122 
00123 void xnpod_fatal_helper(const char *format, ...);
00124 
00125 int __xeno_user_init(void);
00126 
00127 void __xeno_user_exit(void);
00128 
00129 #ifdef __cplusplus
00130 }
00131 #endif
00132 
00133 #define xnprintf(fmt,args...)  xnarch_printf(fmt , ##args)
00134 #define xnloginfo(fmt,args...) xnarch_loginfo(fmt , ##args)
00135 #define xnlogwarn(fmt,args...) xnarch_logwarn(fmt , ##args)
00136 #define xnlogerr(fmt,args...)  xnarch_logerr(fmt , ##args)
00137 #define xnlogerr_noprompt(fmt,args...) xnarch_logerr_noprompt(fmt , ##args)
00138 
00139 #define xnpod_fatal(format,args...) \
00140 do { \
00141         xnarch_begin_panic(); \
00142         xnpod_fatal_helper(format,##args); \
00143         xnarch_halt(); \
00144 } while (0)
00145 
00146 #ifdef __XENO_SIM__
00147 #define SKIN_INIT(name)  __xeno_skin_init(void)
00148 #define SKIN_EXIT(name)  __xeno_skin_exit(void)
00149 #else /* !__XENO_SIM__ */
00150 #define SKIN_INIT(name)  __ ## name ## _skin_init(void)
00151 #define SKIN_EXIT(name)  __ ## name ## _skin_exit(void)
00152 #endif /* __XENO_SIM__ */
00153 
00154 #define root_thread_init __xeno_user_init
00155 #define root_thread_exit __xeno_user_exit
00156 
00157 #endif /* !_XENO_NUCLEUS_TYPES_H */

Generated on Wed Nov 2 2011 18:01:06 for Xenomai API by  doxygen 1.7.1