of: Remove duplicate fields from of_platform_driver
[safe/jmp/linux-2.6] / arch / powerpc / kernel / fpu.S
index 4d6001f..fc8f5b1 100644 (file)
@@ -2,6 +2,11 @@
  *  FPU support code, moved here from head.S so that it can be used
  *  by chips which use other head-whatever.S files.
  *
+ *    Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
+ *    Copyright (C) 1996 Cort Dougan <cort@cs.nmt.edu>
+ *    Copyright (C) 1996 Paul Mackerras.
+ *    Copyright (C) 1997 Dan Malek (dmalek@jlc.net).
+ *
  *  This program is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU General Public License
  *  as published by the Free Software Foundation; either version
@@ -9,7 +14,6 @@
  *
  */
 
-#include <linux/config.h>
 #include <asm/reg.h>
 #include <asm/page.h>
 #include <asm/mmu.h>
 #include <asm/ppc_asm.h>
 #include <asm/asm-offsets.h>
 
+#ifdef CONFIG_VSX
+#define REST_32FPVSRS(n,c,base)                                                \
+BEGIN_FTR_SECTION                                                      \
+       b       2f;                                                     \
+END_FTR_SECTION_IFSET(CPU_FTR_VSX);                                    \
+       REST_32FPRS(n,base);                                            \
+       b       3f;                                                     \
+2:     REST_32VSRS(n,c,base);                                          \
+3:
+
+#define SAVE_32FPVSRS(n,c,base)                                                \
+BEGIN_FTR_SECTION                                                      \
+       b       2f;                                                     \
+END_FTR_SECTION_IFSET(CPU_FTR_VSX);                                    \
+       SAVE_32FPRS(n,base);                                            \
+       b       3f;                                                     \
+2:     SAVE_32VSRS(n,c,base);                                          \
+3:
+#else
+#define REST_32FPVSRS(n,b,base)        REST_32FPRS(n, base)
+#define SAVE_32FPVSRS(n,b,base)        SAVE_32FPRS(n, base)
+#endif
+
 /*
  * This task wants to use the FPU now.
  * On UP, disable FP for the task which had the FPU previously,
 _GLOBAL(load_up_fpu)
        mfmsr   r5
        ori     r5,r5,MSR_FP
+#ifdef CONFIG_VSX
+BEGIN_FTR_SECTION
+       oris    r5,r5,MSR_VSX@h
+END_FTR_SECTION_IFSET(CPU_FTR_VSX)
+#endif
        SYNC
        MTMSRD(r5)                      /* enable use of fpu now */
        isync
@@ -39,49 +71,49 @@ _GLOBAL(load_up_fpu)
  * to another.  Instead we call giveup_fpu in switch_to.
  */
 #ifndef CONFIG_SMP
-       LOADBASE(r3, last_task_used_math)
+       LOAD_REG_ADDRBASE(r3, last_task_used_math)
        toreal(r3)
-       LDL     r4,OFF(last_task_used_math)(r3)
-       CMPI    0,r4,0
+       PPC_LL  r4,ADDROFF(last_task_used_math)(r3)
+       PPC_LCMPI       0,r4,0
        beq     1f
        toreal(r4)
        addi    r4,r4,THREAD            /* want last_task_used_math->thread */
-       SAVE_32FPRS(0, r4)
+       SAVE_32FPVSRS(0, r5, r4)
        mffs    fr0
        stfd    fr0,THREAD_FPSCR(r4)
-       LDL     r5,PT_REGS(r4)
+       PPC_LL  r5,PT_REGS(r4)
        toreal(r5)
-       LDL     r4,_MSR-STACK_FRAME_OVERHEAD(r5)
+       PPC_LL  r4,_MSR-STACK_FRAME_OVERHEAD(r5)
        li      r10,MSR_FP|MSR_FE0|MSR_FE1
        andc    r4,r4,r10               /* disable FP for previous task */
-       STL     r4,_MSR-STACK_FRAME_OVERHEAD(r5)
+       PPC_STL r4,_MSR-STACK_FRAME_OVERHEAD(r5)
 1:
 #endif /* CONFIG_SMP */
        /* enable use of FP after return */
 #ifdef CONFIG_PPC32
-       mfspr   r5,SPRN_SPRG3           /* current task's THREAD (phys) */
+       mfspr   r5,SPRN_SPRG_THREAD             /* current task's THREAD (phys) */
        lwz     r4,THREAD_FPEXC_MODE(r5)
        ori     r9,r9,MSR_FP            /* enable FP for current */
        or      r9,r9,r4
 #else
        ld      r4,PACACURRENT(r13)
        addi    r5,r4,THREAD            /* Get THREAD */
-       l     r4,THREAD_FPEXC_MODE(r5)
+       lwz     r4,THREAD_FPEXC_MODE(r5)
        ori     r12,r12,MSR_FP
        or      r12,r12,r4
        std     r12,_MSR(r1)
 #endif
        lfd     fr0,THREAD_FPSCR(r5)
-       mtfsf   0xff,fr0
-       REST_32FPRS(0, r5)
+       MTFSF_L(fr0)
+       REST_32FPVSRS(0, r4, r5)
 #ifndef CONFIG_SMP
        subi    r4,r5,THREAD
        fromreal(r4)
-       STL     r4,OFF(last_task_used_math)(r3)
+       PPC_STL r4,ADDROFF(last_task_used_math)(r3)
 #endif /* CONFIG_SMP */
        /* restore registers and return */
        /* we haven't used ctr or xer or lr */
-       b       fast_exception_return
+       blr
 
 /*
  * giveup_fpu(tsk)
@@ -92,29 +124,39 @@ _GLOBAL(load_up_fpu)
 _GLOBAL(giveup_fpu)
        mfmsr   r5
        ori     r5,r5,MSR_FP
+#ifdef CONFIG_VSX
+BEGIN_FTR_SECTION
+       oris    r5,r5,MSR_VSX@h
+END_FTR_SECTION_IFSET(CPU_FTR_VSX)
+#endif
        SYNC_601
        ISYNC_601
        MTMSRD(r5)                      /* enable use of fpu now */
        SYNC_601
        isync
-       CMPI    0,r3,0
+       PPC_LCMPI       0,r3,0
        beqlr-                          /* if no previous owner, done */
        addi    r3,r3,THREAD            /* want THREAD of task */
-       LDL     r5,PT_REGS(r3)
-       CMPI    0,r5,0
-       SAVE_32FPRS(0, r3)
+       PPC_LL  r5,PT_REGS(r3)
+       PPC_LCMPI       0,r5,0
+       SAVE_32FPVSRS(0, r4 ,r3)
        mffs    fr0
        stfd    fr0,THREAD_FPSCR(r3)
        beq     1f
-       LDL     r4,_MSR-STACK_FRAME_OVERHEAD(r5)
+       PPC_LL  r4,_MSR-STACK_FRAME_OVERHEAD(r5)
        li      r3,MSR_FP|MSR_FE0|MSR_FE1
+#ifdef CONFIG_VSX
+BEGIN_FTR_SECTION
+       oris    r3,r3,MSR_VSX@h
+END_FTR_SECTION_IFSET(CPU_FTR_VSX)
+#endif
        andc    r4,r4,r3                /* disable FP for previous task */
-       STL     r4,_MSR-STACK_FRAME_OVERHEAD(r5)
+       PPC_STL r4,_MSR-STACK_FRAME_OVERHEAD(r5)
 1:
 #ifndef CONFIG_SMP
        li      r5,0
-       LOADBASE(r4,last_task_used_math)
-       STL     r5,OFF(last_task_used_math)(r4)
+       LOAD_REG_ADDRBASE(r4,last_task_used_math)
+       PPC_STL r5,ADDROFF(last_task_used_math)(r4)
 #endif /* CONFIG_SMP */
        blr
 
@@ -127,7 +169,7 @@ _GLOBAL(giveup_fpu)
 
 _GLOBAL(cvt_fd)
        lfd     0,THREAD_FPSCR(r5)      /* load up fpscr value */
-       mtfsf   0xff,0
+       MTFSF_L(0)
        lfs     0,0(r3)
        stfd    0,0(r4)
        mffs    0
@@ -136,7 +178,7 @@ _GLOBAL(cvt_fd)
 
 _GLOBAL(cvt_df)
        lfd     0,THREAD_FPSCR(r5)      /* load up fpscr value */
-       mtfsf   0xff,0
+       MTFSF_L(0)
        lfd     0,0(r3)
        stfs    0,0(r4)
        mffs    0