blob: 9cc7bfab3419a80e02ae344b6bd154e154370864 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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. Mattock79add622011-04-04 14:15:29 -070011 * Copyright (C) 1996 David S. Miller (davem@davemloft.net)
Linus Torvalds1da177e2005-04-16 15:20:36 -070012 */
13#include <asm/asm.h>
14#include <asm/fpregdef.h>
15#include <asm/mipsregs.h>
Sam Ravnborg048eb582005-09-09 22:32:31 +020016#include <asm/asm-offsets.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <asm/regdef.h>
18
19 .set noreorder
20 .set mips2
Manuel Lauss842dfc12014-11-07 14:13:54 +010021 .set push
22 SET_HARDFLOAT
23
Maciej W. Rozycki758ef0a2016-10-31 16:27:01 +000024/**
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 Torvalds1da177e2005-04-16 15:20:36 -070032 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. Rozycki758ef0a2016-10-31 16:27:01 +000040 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 Torvalds1da177e2005-04-16 15:20:36 -070056 jr ra
Maciej W. Rozycki758ef0a2016-10-31 16:27:01 +000057 sw t0,(a1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581: jr ra
59 nop
60 END(_save_fp_context)
61
Maciej W. Rozycki758ef0a2016-10-31 16:27:01 +000062/**
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 Torvalds1da177e2005-04-16 15:20:36 -070066 *
Maciej W. Rozycki758ef0a2016-10-31 16:27:01 +000067 * Restore FP context, including the 32 FP data registers and the FP
68 * control & status register, from signal context to the FPU.
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 */
70 LEAF(_restore_fp_context)
71 mfc0 t0,CP0_STATUS
72 sll t0,t0,2
73
74 bgez t0,1f
Maciej W. Rozycki758ef0a2016-10-31 16:27:01 +000075 lw t0,(a1)
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 /* Restore the 16 double precision registers */
Maciej W. Rozycki758ef0a2016-10-31 16:27:01 +000077 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 Torvalds1da177e2005-04-16 15:20:36 -070093 jr ra
94 ctc1 t0,fcr31
951: jr ra
96 nop
97 END(_restore_fp_context)
Manuel Lauss842dfc12014-11-07 14:13:54 +010098
99 .set pop /* SET_HARDFLOAT */