base/include/asm-ppc/rtai_fpu.h

Go to the documentation of this file.
00001 /*
00002 COPYRIGHT (C) 2000-2007  Paolo Mantegazza (mantegazza@aero.polimi.it)
00003 
00004 This library is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU Lesser General Public
00006 License as published by the Free Software Foundation; either
00007 version 2 of the License, or (at your option) any later version.
00008 
00009 This library is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 Lesser General Public License for more details.
00013 
00014 You should have received a copy of the GNU Lesser General Public
00015 License along with this library; if not, write to the Free Software
00016 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
00017 */
00018 
00019 #ifndef _RTAI_ASM_PPC_FPU_H_
00020 #define _RTAI_ASM_PPC_FPU_H_
00021 
00022 #include <asm/processor.h>
00023 
00024 typedef struct ppc_fpu_env { unsigned long fpu_reg[66]; } FPU_ENV;
00025 
00026 #ifdef CONFIG_RTAI_FPU_SUPPORT
00027 /*
00028  * Saving/restoring the FPU environment in PPC is like eating a cake, very simple. Just save/restore all of the floating 
00029  * point registers, recall they are always 64 bits long, and the floating point state register. Remark: at task init we
00030  * always enable FP, i.e. MSR flag FP set to 1, for real time tasks and accept default actions for faulty FLOPs, i.e. MSR 
00031  * flags FE0 and FE1 are set to zero.
00032  */
00033 
00034 #define save_fpcr_and_enable_fpu(cr0) \
00035     do {  \
00036         __asm__ __volatile__ ("mfmsr %0": "=r"(cr0)); \
00037         __asm__ __volatile__ ("mtmsr %0":         : "r"(cr0 | MSR_FP): "memory"); \
00038     } while (0)
00039 
00040 #define restore_fpcr(cr0) \
00041     do { __asm__ __volatile__ ("mtmsr %0": : "r"(cr0)); } while (0)
00042 
00043 extern void __save_fpenv(void *fpenv);
00044 #define save_fpenv(x) __save_fpenv(&(x))
00045 
00046 extern void __restore_fpenv(void *fpenv);
00047 #define restore_fpenv(x) __restore_fpenv(&(x))
00048 
00049 #define restore_task_fpenv(t) \
00050         do { \ restore_fpenv((t)->thread.fpr); \ } while (0)
00051 
00052 #define restore_fpenv_lxrt(t) restore_task_fpenv(t)
00053 
00054 #define restore_fpu(tsk) \
00055         do { \
00056         giveup_fpu(last_task_used_math); \
00057         __restore_fpenv((tsk)->thread.fpr); \
00058         last_task_used_math = tsk; \
00059     } while (0)
00060 
00061 #define init_fpu(tsk) \
00062         do { restore_fpu(tsk); } while(0)
00063 
00064 //#define lnxtsk_uses_fpu(lnxtsk)  (1)
00065 
00066 #else
00067 
00068 #define enable_fpu()
00069 #define save_fpcr_and_enable_fpu(x)
00070 #define restore_fpcr(x)
00071 #define save_fpenv(x)
00072 #define restore_fpenv(x)
00073 #define restore_task_fpenv(t)
00074 #define restore_fpenv_lxrt(t)
00075 #define restore_fpu(tsk)
00076 #define init_fpu(tsk)
00077 //#define lnxtsk_uses_fpu(lnxtsk)  (0)
00078 
00079 #endif
00080 
00081 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
00082 
00083 #define clear_lnxtsk_uses_fpu(lnxtsk) \
00084     do { (lnxtsk)->used_math = 0; } while(0)
00085 #define lnxtsk_uses_fpu(lnxtsk)  ((lnxtsk)->used_math)
00086 
00087 #else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) */
00088 
00089 #define clear_lnxtsk_uses_fpu(lnxtsk) \
00090         do { clear_stopped_child_used_math(lnxtsk); } while(0)
00091 #define lnxtsk_uses_fpu(lnxtsk)  (tsk_used_math(lnxtsk))
00092 
00093 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) */
00094 
00095 #define set_tsk_used_fpu(t)  do {  } while(0)
00096 
00097 #define init_hard_fpu(lnxtsk)  restore_fpu(lnxtsk)
00098 
00099 #endif

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