Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * r6000_fpu.S: Save/restore floating point context for signal handlers. |
| 3 | * |
| 4 | * This file is subject to the terms and conditions of the GNU General Public |
| 5 | * License. See the file "COPYING" in the main directory of this archive |
| 6 | * for more details. |
| 7 | * |
| 8 | * Copyright (C) 1996 by Ralf Baechle |
| 9 | * |
| 10 | * Multi-arch abstraction and asm macros for easier reading: |
Justin P. Mattock | 79add62 | 2011-04-04 14:15:29 -0700 | [diff] [blame] | 11 | * Copyright (C) 1996 David S. Miller (davem@davemloft.net) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | */ |
| 13 | #include <asm/asm.h> |
| 14 | #include <asm/fpregdef.h> |
| 15 | #include <asm/mipsregs.h> |
Sam Ravnborg | 048eb58 | 2005-09-09 22:32:31 +0200 | [diff] [blame] | 16 | #include <asm/asm-offsets.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include <asm/regdef.h> |
| 18 | |
| 19 | .set noreorder |
| 20 | .set mips2 |
Manuel Lauss | 842dfc1 | 2014-11-07 14:13:54 +0100 | [diff] [blame] | 21 | .set push |
| 22 | SET_HARDFLOAT |
| 23 | |
Maciej W. Rozycki | 758ef0a | 2016-10-31 16:27:01 +0000 | [diff] [blame^] | 24 | /** |
| 25 | * _save_fp_context() - save FP context from the FPU |
| 26 | * @a0 - pointer to fpregs field of sigcontext |
| 27 | * @a1 - pointer to fpc_csr field of sigcontext |
| 28 | * |
| 29 | * Save FP context, including the 32 FP data registers and the FP |
| 30 | * control & status register, from the FPU to signal context. |
| 31 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | LEAF(_save_fp_context) |
| 33 | mfc0 t0,CP0_STATUS |
| 34 | sll t0,t0,2 |
| 35 | bgez t0,1f |
| 36 | nop |
| 37 | |
| 38 | cfc1 t1,fcr31 |
| 39 | /* Store the 16 double precision registers */ |
Maciej W. Rozycki | 758ef0a | 2016-10-31 16:27:01 +0000 | [diff] [blame^] | 40 | sdc1 $f0,0(a0) |
| 41 | sdc1 $f2,16(a0) |
| 42 | sdc1 $f4,32(a0) |
| 43 | sdc1 $f6,48(a0) |
| 44 | sdc1 $f8,64(a0) |
| 45 | sdc1 $f10,80(a0) |
| 46 | sdc1 $f12,96(a0) |
| 47 | sdc1 $f14,112(a0) |
| 48 | sdc1 $f16,128(a0) |
| 49 | sdc1 $f18,144(a0) |
| 50 | sdc1 $f20,160(a0) |
| 51 | sdc1 $f22,176(a0) |
| 52 | sdc1 $f24,192(a0) |
| 53 | sdc1 $f26,208(a0) |
| 54 | sdc1 $f28,224(a0) |
| 55 | sdc1 $f30,240(a0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | jr ra |
Maciej W. Rozycki | 758ef0a | 2016-10-31 16:27:01 +0000 | [diff] [blame^] | 57 | sw t0,(a1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | 1: jr ra |
| 59 | nop |
| 60 | END(_save_fp_context) |
| 61 | |
Maciej W. Rozycki | 758ef0a | 2016-10-31 16:27:01 +0000 | [diff] [blame^] | 62 | /** |
| 63 | * _restore_fp_context() - restore FP context to the FPU |
| 64 | * @a0 - pointer to fpregs field of sigcontext |
| 65 | * @a1 - pointer to fpc_csr field of sigcontext |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | * |
Maciej W. Rozycki | 758ef0a | 2016-10-31 16:27:01 +0000 | [diff] [blame^] | 67 | * Restore FP context, including the 32 FP data registers and the FP |
| 68 | * control & status register, from signal context to the FPU. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | */ |
| 70 | LEAF(_restore_fp_context) |
| 71 | mfc0 t0,CP0_STATUS |
| 72 | sll t0,t0,2 |
| 73 | |
| 74 | bgez t0,1f |
Maciej W. Rozycki | 758ef0a | 2016-10-31 16:27:01 +0000 | [diff] [blame^] | 75 | lw t0,(a1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | /* Restore the 16 double precision registers */ |
Maciej W. Rozycki | 758ef0a | 2016-10-31 16:27:01 +0000 | [diff] [blame^] | 77 | ldc1 $f0,0(a0) |
| 78 | ldc1 $f2,16(a0) |
| 79 | ldc1 $f4,32(a0) |
| 80 | ldc1 $f6,48(a0) |
| 81 | ldc1 $f8,64(a0) |
| 82 | ldc1 $f10,80(a0) |
| 83 | ldc1 $f12,96(a0) |
| 84 | ldc1 $f14,112(a0) |
| 85 | ldc1 $f16,128(a0) |
| 86 | ldc1 $f18,144(a0) |
| 87 | ldc1 $f20,160(a0) |
| 88 | ldc1 $f22,176(a0) |
| 89 | ldc1 $f24,192(a0) |
| 90 | ldc1 $f26,208(a0) |
| 91 | ldc1 $f28,224(a0) |
| 92 | ldc1 $f30,240(a0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | jr ra |
| 94 | ctc1 t0,fcr31 |
| 95 | 1: jr ra |
| 96 | nop |
| 97 | END(_restore_fp_context) |
Manuel Lauss | 842dfc1 | 2014-11-07 14:13:54 +0100 | [diff] [blame] | 98 | |
| 99 | .set pop /* SET_HARDFLOAT */ |