Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is subject to the terms and conditions of the GNU General Public |
| 3 | * License. See the file "COPYING" in the main directory of this archive |
| 4 | * for more details. |
| 5 | * |
| 6 | * Copyright (C) 1996, 1998 by Ralf Baechle |
| 7 | * |
| 8 | * Multi-arch abstraction and asm macros for easier reading: |
Justin P. Mattock | 79add62 | 2011-04-04 14:15:29 -0700 | [diff] [blame] | 9 | * Copyright (C) 1996 David S. Miller (davem@davemloft.net) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * |
| 11 | * Further modifications to make this work: |
| 12 | * Copyright (c) 1998 Harald Koerfgen |
| 13 | */ |
| 14 | #include <asm/asm.h> |
| 15 | #include <asm/errno.h> |
| 16 | #include <asm/fpregdef.h> |
| 17 | #include <asm/mipsregs.h> |
Sam Ravnborg | 048eb58 | 2005-09-09 22:32:31 +0200 | [diff] [blame] | 18 | #include <asm/asm-offsets.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <asm/regdef.h> |
| 20 | |
| 21 | #define EX(a,b) \ |
| 22 | 9: a,##b; \ |
| 23 | .section __ex_table,"a"; \ |
Maciej W. Rozycki | 35938a0 | 2016-10-31 16:25:44 +0000 | [diff] [blame] | 24 | PTR 9b,fault; \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | .previous |
| 26 | |
Maciej W. Rozycki | f92722d | 2016-10-31 16:27:40 +0000 | [diff] [blame^] | 27 | #define EX2(a,b) \ |
| 28 | 9: a,##b; \ |
| 29 | .section __ex_table,"a"; \ |
| 30 | PTR 9b,bad_stack; \ |
| 31 | PTR 9b+4,bad_stack; \ |
| 32 | .previous |
| 33 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | .set noreorder |
| 35 | .set mips1 |
Maciej W. Rozycki | 758ef0a | 2016-10-31 16:27:01 +0000 | [diff] [blame] | 36 | |
| 37 | /** |
| 38 | * _save_fp_context() - save FP context from the FPU |
| 39 | * @a0 - pointer to fpregs field of sigcontext |
| 40 | * @a1 - pointer to fpc_csr field of sigcontext |
| 41 | * |
| 42 | * Save FP context, including the 32 FP data registers and the FP |
| 43 | * control & status register, from the FPU to signal context. |
| 44 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | LEAF(_save_fp_context) |
Manuel Lauss | 842dfc1 | 2014-11-07 14:13:54 +0100 | [diff] [blame] | 46 | .set push |
| 47 | SET_HARDFLOAT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | li v0, 0 # assume success |
Maciej W. Rozycki | 758ef0a | 2016-10-31 16:27:01 +0000 | [diff] [blame] | 49 | cfc1 t1, fcr31 |
Maciej W. Rozycki | f92722d | 2016-10-31 16:27:40 +0000 | [diff] [blame^] | 50 | EX2(s.d $f0, 0(a0)) |
| 51 | EX2(s.d $f2, 16(a0)) |
| 52 | EX2(s.d $f4, 32(a0)) |
| 53 | EX2(s.d $f6, 48(a0)) |
| 54 | EX2(s.d $f8, 64(a0)) |
| 55 | EX2(s.d $f10, 80(a0)) |
| 56 | EX2(s.d $f12, 96(a0)) |
| 57 | EX2(s.d $f14, 112(a0)) |
| 58 | EX2(s.d $f16, 128(a0)) |
| 59 | EX2(s.d $f18, 144(a0)) |
| 60 | EX2(s.d $f20, 160(a0)) |
| 61 | EX2(s.d $f22, 176(a0)) |
| 62 | EX2(s.d $f24, 192(a0)) |
| 63 | EX2(s.d $f26, 208(a0)) |
| 64 | EX2(s.d $f28, 224(a0)) |
| 65 | EX2(s.d $f30, 240(a0)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | jr ra |
Maciej W. Rozycki | 758ef0a | 2016-10-31 16:27:01 +0000 | [diff] [blame] | 67 | EX(sw t1, (a1)) |
Manuel Lauss | 842dfc1 | 2014-11-07 14:13:54 +0100 | [diff] [blame] | 68 | .set pop |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | END(_save_fp_context) |
| 70 | |
Maciej W. Rozycki | 758ef0a | 2016-10-31 16:27:01 +0000 | [diff] [blame] | 71 | /** |
| 72 | * _restore_fp_context() - restore FP context to the FPU |
| 73 | * @a0 - pointer to fpregs field of sigcontext |
| 74 | * @a1 - pointer to fpc_csr field of sigcontext |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | * |
Maciej W. Rozycki | 758ef0a | 2016-10-31 16:27:01 +0000 | [diff] [blame] | 76 | * Restore FP context, including the 32 FP data registers and the FP |
| 77 | * control & status register, from signal context to the FPU. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | */ |
| 79 | LEAF(_restore_fp_context) |
Manuel Lauss | 842dfc1 | 2014-11-07 14:13:54 +0100 | [diff] [blame] | 80 | .set push |
| 81 | SET_HARDFLOAT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | li v0, 0 # assume success |
Maciej W. Rozycki | 758ef0a | 2016-10-31 16:27:01 +0000 | [diff] [blame] | 83 | EX(lw t0, (a1)) |
Maciej W. Rozycki | f92722d | 2016-10-31 16:27:40 +0000 | [diff] [blame^] | 84 | EX2(l.d $f0, 0(a0)) |
| 85 | EX2(l.d $f2, 16(a0)) |
| 86 | EX2(l.d $f4, 32(a0)) |
| 87 | EX2(l.d $f6, 48(a0)) |
| 88 | EX2(l.d $f8, 64(a0)) |
| 89 | EX2(l.d $f10, 80(a0)) |
| 90 | EX2(l.d $f12, 96(a0)) |
| 91 | EX2(l.d $f14, 112(a0)) |
| 92 | EX2(l.d $f16, 128(a0)) |
| 93 | EX2(l.d $f18, 144(a0)) |
| 94 | EX2(l.d $f20, 160(a0)) |
| 95 | EX2(l.d $f22, 176(a0)) |
| 96 | EX2(l.d $f24, 192(a0)) |
| 97 | EX2(l.d $f26, 208(a0)) |
| 98 | EX2(l.d $f28, 224(a0)) |
| 99 | EX2(l.d $f30, 240(a0)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | jr ra |
Maciej W. Rozycki | 758ef0a | 2016-10-31 16:27:01 +0000 | [diff] [blame] | 101 | ctc1 t0, fcr31 |
Manuel Lauss | 842dfc1 | 2014-11-07 14:13:54 +0100 | [diff] [blame] | 102 | .set pop |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | END(_restore_fp_context) |
| 104 | .set reorder |
| 105 | |
Daniel Sanders | 51ff5d7 | 2016-02-23 10:29:20 +0000 | [diff] [blame] | 106 | .type fault, @function |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | .ent fault |
| 108 | fault: li v0, -EFAULT |
| 109 | jr ra |
| 110 | .end fault |