rtai-core/include/asm-ppc/rtai_fpu.h

00001 /*
00002 COPYRIGHT (C) 2000  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 #define save_cr0_and_clts(x)
00027 #define restore_cr0(x)
00028 #define enable_fpu()
00029 
00030 #ifdef CONFIG_RTAI_FPU_SUPPORT
00031 /*
00032  * Saving/restoring the FPU environment in PPC is like eating a cake, very simple. Just save/restore all of the floating 
00033  * point registers, recall they are always 64 bits long, and the floating point state register. Remark: at task init we
00034  * 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 
00035  * flags FE0 and FE1 are set to zero.
00036  */
00037 
00038 #define stringize(a) #a
00039 #define str(a) stringize(a)
00040 
00041 extern void __save_fpenv(FPU_ENV *fpenv);
00042 #define save_fpenv(x) __save_fpenv(&(x))
00043 #if 0
00044 // FIXME: it does not work, waiting for cleanup!
00045 static inline void __save_fpenv(FPU_ENV *env)
00046 {
00047         asm(
00048         "stw     0,  -4(1)\n"
00049         "mfmsr    0\n"
00050         "ori      0, 0, " str(MSR_FP) "\n"
00051         "mtmsr    0\n"
00052         "lwz      0,  -4(1)\n"
00053         "isync\n"
00054         "stfd    0, 0*8(3)\n"
00055         "stfd    1, 1*8(3)\n"
00056         "stfd    2, 2*8(3)\n"
00057         "stfd    3, 3*8(3)\n"
00058         "stfd    4, 4*8(3)\n"
00059         "stfd    5, 5*8(3)\n"
00060         "stfd    6, 6*8(3)\n"
00061         "stfd    7, 7*8(3)\n"
00062         "stfd    8, 8*8(3)\n"
00063         "stfd    9, 9*8(3)\n"
00064         "stfd   10,10*8(3)\n"
00065         "stfd   11,11*8(3)\n"
00066         "stfd   12,12*8(3)\n"
00067         "stfd   13,13*8(3)\n"
00068         "stfd   14,14*8(3)\n"
00069         "stfd   15,15*8(3)\n"
00070         "stfd   16,16*8(3)\n"
00071         "stfd   17,17*8(3)\n"
00072         "stfd   18,18*8(3)\n"
00073         "stfd   19,19*8(3)\n"
00074         "stfd   20,20*8(3)\n"
00075         "stfd   21,21*8(3)\n"
00076         "stfd   22,22*8(3)\n"
00077         "stfd   23,23*8(3)\n"
00078         "stfd   24,24*8(3)\n"
00079         "stfd   25,25*8(3)\n"
00080         "stfd   26,26*8(3)\n"
00081         "stfd   27,27*8(3)\n"
00082         "stfd   28,28*8(3)\n"
00083         "stfd   29,29*8(3)\n"
00084         "stfd   30,30*8(3)\n"
00085         "stfd   31,31*8(3)\n"
00086         "mffs    0\n"
00087         "stfd    0,32*8(3)\n");
00088 }
00089 #endif
00090 
00091 extern void __restore_fpenv(FPU_ENV *fpenv);
00092 #define restore_fpenv(x) __restore_fpenv(&(x))
00093 #if 0
00094 // FIXME: it does not work, waiting for cleanup!
00095 static inline void __restore_fpenv(FPU_ENV *env)
00096 {
00097         asm(
00098         "lfd     0, 32*8(3)\n"
00099         "mtfsf   0xFF,0\n"
00100         "lfd     0, 0*8(3)\n"
00101         "lfd     1, 1*8(3)\n"
00102         "lfd     2, 2*8(3)\n"
00103         "lfd     3, 3*8(3)\n"
00104         "lfd     4, 4*8(3)\n"
00105         "lfd     5, 5*8(3)\n"
00106         "lfd     6, 6*8(3)\n"
00107         "lfd     7, 7*8(3)\n"
00108         "lfd     8, 8*8(3)\n"
00109         "lfd     9, 9*8(3)\n"
00110         "lfd    10,10*8(3)\n"
00111         "lfd    11,11*8(3)\n"
00112         "lfd    12,12*8(3)\n"
00113         "lfd    13,13*8(3)\n"
00114         "lfd    14,14*8(3)\n"
00115         "lfd    15,15*8(3)\n"
00116         "lfd    16,16*8(3)\n"
00117         "lfd    17,17*8(3)\n"
00118         "lfd    18,18*8(3)\n"
00119         "lfd    19,19*8(3)\n"
00120         "lfd    20,20*8(3)\n"
00121         "lfd    21,21*8(3)\n"
00122         "lfd    22,22*8(3)\n"
00123         "lfd    23,23*8(3)\n"
00124         "lfd    24,24*8(3)\n"
00125         "lfd    25,25*8(3)\n"
00126         "lfd    26,26*8(3)\n"
00127         "lfd    27,27*8(3)\n"
00128         "lfd    28,28*8(3)\n"
00129         "lfd    29,29*8(3)\n"
00130         "lfd    30,30*8(3)\n"
00131         "lfd    31,31*8(3)\n");
00132 }
00133 #endif
00134 
00135 #else
00136 
00137 #define save_fpenv(x)
00138 #define restore_fpenv(x)
00139 
00140 #endif
00141 
00142 
00143 #endif
00144 

Generated on Sat Jul 24 19:36:02 2004 for RTAI API by doxygen 1.3.4