base/include/asm-arm/rtai_lxrt.h

Go to the documentation of this file.
00001 /*
00002  * Stuff related to hard-realtime in user-space.
00003  *
00004  * Original RTAI/x86 layer implementation:
00005  *   Copyright (c) 2000 Paolo Mantegazza (mantegazza@aero.polimi.it)
00006  *   Copyright (c) 2000 Steve Papacharalambous (stevep@zentropix.com)
00007  *   Copyright (c) 2000 Stuart Hughes
00008  *   and others.
00009  *
00010  * RTAI/x86 rewrite over Adeos:
00011  *   Copyright (c) 2002 Philippe Gerum (rpm@xenomai.org)
00012  *
00013  * Original RTAI/ARM RTHAL implementation:
00014  *   Copyright (c) 2000 Pierre Cloutier (pcloutier@poseidoncontrols.com)
00015  *   Copyright (c) 2001 Alex Züpke, SYSGO RTS GmbH (azu@sysgo.de)
00016  *   Copyright (c) 2002 Guennadi Liakhovetski DSA GmbH (gl@dsa-ac.de)
00017  *   Copyright (c) 2002 Steve Papacharalambous (stevep@zentropix.com)
00018  *   Copyright (c) 2002 Wolfgang Müller (wolfgang.mueller@dsa-ac.de)
00019  *   Copyright (c) 2003 Bernard Haible, Marconi Communications
00020  *   Copyright (c) 2003 Thomas Gleixner (tglx@linutronix.de)
00021  *   Copyright (c) 2003 Philippe Gerum (rpm@xenomai.org)
00022  *
00023  * RTAI/ARM over Adeos rewrite:
00024  *   Copyright (c) 2004-2005 Michael Neuhauser, Firmix Software GmbH (mike@firmix.at)
00025  *
00026  *
00027  * This library is free software; you can redistribute it and/or modify it under
00028  * the terms of the GNU Lesser General Public License as published by the Free
00029  * Software Foundation; either version 2 of the License, or (at your option) any
00030  * later version.
00031  *
00032  * This library is distributed in the hope that it will be useful, but WITHOUT
00033  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00034  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00035  * details. You should have received a copy of the GNU Lesser General Public
00036  * License along with this library; if not, write to the Free Software
00037  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
00038  */
00039 #ifndef _RTAI_ASM_ARM_LXRT_H
00040 #define _RTAI_ASM_ARM_LXRT_H
00041 
00042 /* define registers (pt_regs) that hold syscall related information for
00043  * lxrt_intercept_syscall_prologue() (see entry-common.S:vector_swi &
00044  * adeos.c:__adeos_enter_syscall() in linux/arch/arm/kernel) */
00045 
00046 #define RTAI_SYSCALL_NR      0x70000000     /* syscall number */
00047 
00048 #define RTAI_SYSCALL_ARGS    ARM_r0     /* syscall argument */
00049 #define SET_LXRT_RETVAL_IN_SYSCALL(retval)  /* set long long syscall return value */ \
00050     (*(long long)&r->r0 = (retval))
00051 
00052 #define LINUX_SYSCALL_NR      ARM_ip
00053 #define LINUX_SYSCALL_REG1    ARM_r0
00054 #define LINUX_SYSCALL_REG2    ARM_r1
00055 #define LINUX_SYSCALL_REG3    ARM_r2
00056 #define LINUX_SYSCALL_REG4    ARM_r3
00057 #define LINUX_SYSCALL_REG5    ARM_r4
00058 #define LINUX_SYSCALL_REG6    ARM_r5
00059 #define LINUX_SYSCALL_RETREG  ARM_r0
00060 
00061 #define NR_syscalls 322
00062 
00063 #define LXRT_DO_IMMEDIATE_LINUX_SYSCALL(regs) \
00064         do { /* NOP */ } while (0)
00065 
00066 /* endianess */
00067 #define LOW  0
00068 #define HIGH 1
00069 
00070 /* for scheduler */
00071 #define USE_LINUX_TIMER
00072 #define TIMER_NAME          RTAI_TIMER_NAME
00073 #define TIMER_FREQ          RTAI_TIMER_FREQ
00074 #define TIMER_LATENCY           RTAI_TIMER_LATENCY
00075 #define TIMER_SETUP_TIME        RTAI_TIMER_SETUP_TIME
00076 #define ONESHOT_SPAN \
00077     (((long long)RTAI_TIMER_MAXVAL * RTAI_TSC_FREQ) / RTAI_TIMER_FREQ)
00078 
00079 #define update_linux_timer(cpuid) \
00080 do { \
00081     if (!IS_FUSION_TIMER_RUNNING()) { \
00082         hal_pend_uncond(__ipipe_mach_timerint, cpuid); \
00083     } \
00084 } while (0)     
00085 
00086 /* Adeos/ARM calls all event handlers with hw-interrupts enabled (both in threaded
00087  * and unthreaded mode), so there is no need for RTAI to do it again. */
00088 #define IN_INTERCEPT_IRQ_ENABLE()   do { /* nop */ } while (0)
00089 #define IN_INTERCEPT_IRQ_DISABLE()  do { /* nop */ } while (0)
00090 
00091 union rtai_lxrt_t {
00092     RTIME rt;
00093     int i[2];
00094     void *v[2];
00095 };
00096 
00097 #ifdef __cplusplus
00098 extern "C" {
00099 #endif /* __cplusplus */
00100 
00101 #ifdef __KERNEL__
00102 
00103 #include <asm/system.h>
00104 #include <asm/mmu_context.h>
00105 
00106 /* use "extern inline" to force inlining (gcc 3.3.2 does not inline it into
00107  * lxrt_context_switch() if "static inline" is used) */
00108 extern inline void
00109 _lxrt_context_switch(struct task_struct *prev, struct task_struct *next, int cpuid)
00110 {
00111     extern void context_switch(void *, void *, void *);
00112     context_switch(0, prev, next);
00113 }
00114 
00115 static inline void kthread_fun_set_jump(struct task_struct *lnxtsk)  { }
00116 static inline void kthread_fun_long_jump(struct task_struct *lnxtsk) { }
00117 
00118 #define rt_copy_from_user(a, b, c)  \
00119     ( { int ret = __copy_from_user_inatomic(a, b, c); ret; } )
00120 
00121 #define rt_copy_to_user(a, b, c)  \
00122     ( { int ret = __copy_to_user_inatomic(a, b, c); ret; } )
00123 
00124 #define rt_put_user  __put_user
00125 #define rt_get_user  __get_user
00126 
00127 #define rt_strncpy_from_user(a, b, c)  \
00128     ( { int ret = strncpy_from_user(a, b, c); ret; } )
00129 
00130 #else /* !__KERNEL__ */
00131 
00132 #ifdef CONFIG_RTAI_LXRT_USE_LINUX_SYSCALL
00133 #define USE_LINUX_SYSCALL
00134 #include <unistd.h>
00135 #else
00136 #undef USE_LINUX_SYSCALL
00137 #include <asm/rtai_vectors.h>
00138 #endif
00139 
00140 #define RTAI_SRQ_SYSCALL_NR 0x70000000
00141 
00142 static inline long long _rtai_lxrt(long srq, void *args)
00143 {
00144     long long retval;
00145 #ifdef USE_LINUX_SYSCALL
00146         syscall(RTAI_SRQ_SYSCALL_NR, srq, args, &retval);
00147 #else
00148 #warning "RTAI_DO_SWI is not working yet. Please configure RTAI with --enable-lxrt-use-linux-syscall."
00149     retval = RTAI_DO_SWI(RTAI_SYS_VECTOR, (srq), (args));
00150 #endif
00151     return retval;
00152 }
00153 
00154 static inline union rtai_lxrt_t
00155 rtai_lxrt(short int dynx, short int lsize, int srq, void *arg)
00156 {
00157     union rtai_lxrt_t retval;
00158     retval.rt = _rtai_lxrt(ENCODE_LXRT_REQ(dynx, srq, lsize), arg);
00159     return retval;
00160 }
00161 
00162 #define rtai_iopl()  do { /* nop */ } while (0)
00163 
00164 #endif /* __KERNEL__ */
00165 
00166 #ifdef __cplusplus
00167 }
00168 #endif /* __cplusplus */
00169 
00170 #endif /* !_RTAI_ASM_ARM_LXRT_H */

Generated on Tue Feb 2 17:46:04 2010 for RTAI API by  doxygen 1.4.7