blob: cbf6db98cfb38ac3e43364eef2cb4bf0d6455b39 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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. Mattock79add622011-04-04 14:15:29 -07009 * Copyright (C) 1996 David S. Miller (davem@davemloft.net)
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * Further modifications to make this work:
12 * Copyright (c) 1998 Harald Koerfgen
13 */
14#include <asm/asm.h>
Paul Burton423fb0d2017-06-05 11:21:29 -070015#include <asm/asmmacro.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <asm/errno.h>
Paul Burton423fb0d2017-06-05 11:21:29 -070017#include <asm/export.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <asm/fpregdef.h>
19#include <asm/mipsregs.h>
Sam Ravnborg048eb582005-09-09 22:32:31 +020020#include <asm/asm-offsets.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <asm/regdef.h>
22
23#define EX(a,b) \
249: a,##b; \
25 .section __ex_table,"a"; \
Maciej W. Rozycki35938a02016-10-31 16:25:44 +000026 PTR 9b,fault; \
Linus Torvalds1da177e2005-04-16 15:20:36 -070027 .previous
28
Maciej W. Rozyckif92722d2016-10-31 16:27:40 +000029#define EX2(a,b) \
309: a,##b; \
31 .section __ex_table,"a"; \
Eric W. Biederman95bf9d62021-10-20 12:43:51 -050032 PTR 9b,fault; \
33 PTR 9b+4,fault; \
Maciej W. Rozyckif92722d2016-10-31 16:27:40 +000034 .previous
35
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 .set mips1
Maciej W. Rozycki758ef0a2016-10-31 16:27:01 +000037
Paul Burton423fb0d2017-06-05 11:21:29 -070038/*
39 * Save a thread's fp context.
40 */
41LEAF(_save_fp)
42EXPORT_SYMBOL(_save_fp)
43 fpu_save_single a0, t1 # clobbers t1
44 jr ra
45 END(_save_fp)
46
47/*
48 * Restore a thread's fp context.
49 */
50LEAF(_restore_fp)
51 fpu_restore_single a0, t1 # clobbers t1
52 jr ra
53 END(_restore_fp)
54
Paul Burton423fb0d2017-06-05 11:21:29 -070055 .set noreorder
56
Maciej W. Rozycki758ef0a2016-10-31 16:27:01 +000057/**
58 * _save_fp_context() - save FP context from the FPU
59 * @a0 - pointer to fpregs field of sigcontext
60 * @a1 - pointer to fpc_csr field of sigcontext
61 *
62 * Save FP context, including the 32 FP data registers and the FP
63 * control & status register, from the FPU to signal context.
64 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070065LEAF(_save_fp_context)
Manuel Lauss842dfc12014-11-07 14:13:54 +010066 .set push
67 SET_HARDFLOAT
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 li v0, 0 # assume success
Maciej W. Rozycki758ef0a2016-10-31 16:27:01 +000069 cfc1 t1, fcr31
Maciej W. Rozyckif92722d2016-10-31 16:27:40 +000070 EX2(s.d $f0, 0(a0))
71 EX2(s.d $f2, 16(a0))
72 EX2(s.d $f4, 32(a0))
73 EX2(s.d $f6, 48(a0))
74 EX2(s.d $f8, 64(a0))
75 EX2(s.d $f10, 80(a0))
76 EX2(s.d $f12, 96(a0))
77 EX2(s.d $f14, 112(a0))
78 EX2(s.d $f16, 128(a0))
79 EX2(s.d $f18, 144(a0))
80 EX2(s.d $f20, 160(a0))
81 EX2(s.d $f22, 176(a0))
82 EX2(s.d $f24, 192(a0))
83 EX2(s.d $f26, 208(a0))
84 EX2(s.d $f28, 224(a0))
85 EX2(s.d $f30, 240(a0))
Linus Torvalds1da177e2005-04-16 15:20:36 -070086 jr ra
Maciej W. Rozycki758ef0a2016-10-31 16:27:01 +000087 EX(sw t1, (a1))
Manuel Lauss842dfc12014-11-07 14:13:54 +010088 .set pop
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 END(_save_fp_context)
90
Maciej W. Rozycki758ef0a2016-10-31 16:27:01 +000091/**
92 * _restore_fp_context() - restore FP context to the FPU
93 * @a0 - pointer to fpregs field of sigcontext
94 * @a1 - pointer to fpc_csr field of sigcontext
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 *
Maciej W. Rozycki758ef0a2016-10-31 16:27:01 +000096 * Restore FP context, including the 32 FP data registers and the FP
97 * control & status register, from signal context to the FPU.
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 */
99LEAF(_restore_fp_context)
Manuel Lauss842dfc12014-11-07 14:13:54 +0100100 .set push
101 SET_HARDFLOAT
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 li v0, 0 # assume success
Maciej W. Rozycki758ef0a2016-10-31 16:27:01 +0000103 EX(lw t0, (a1))
Maciej W. Rozyckif92722d2016-10-31 16:27:40 +0000104 EX2(l.d $f0, 0(a0))
105 EX2(l.d $f2, 16(a0))
106 EX2(l.d $f4, 32(a0))
107 EX2(l.d $f6, 48(a0))
108 EX2(l.d $f8, 64(a0))
109 EX2(l.d $f10, 80(a0))
110 EX2(l.d $f12, 96(a0))
111 EX2(l.d $f14, 112(a0))
112 EX2(l.d $f16, 128(a0))
113 EX2(l.d $f18, 144(a0))
114 EX2(l.d $f20, 160(a0))
115 EX2(l.d $f22, 176(a0))
116 EX2(l.d $f24, 192(a0))
117 EX2(l.d $f26, 208(a0))
118 EX2(l.d $f28, 224(a0))
119 EX2(l.d $f30, 240(a0))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 jr ra
Maciej W. Rozycki758ef0a2016-10-31 16:27:01 +0000121 ctc1 t0, fcr31
Manuel Lauss842dfc12014-11-07 14:13:54 +0100122 .set pop
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 END(_restore_fp_context)
124 .set reorder
125
Daniel Sanders51ff5d72016-02-23 10:29:20 +0000126 .type fault, @function
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 .ent fault
128fault: li v0, -EFAULT
129 jr ra
130 .end fault