aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2007-11-22 03:30:50 -0500
committerPaul Mundt <lethal@linux-sh.org>2008-01-27 23:18:55 -0500
commit332fd57b92d26e2ac6112340b98e92bb76117a41 (patch)
treefbbc00a900299ad91f46a74b8f2d42efaf4809af
parentb6d7b666097e79a8908e3c43fd55fd291a95e133 (diff)
sh: Bring the SH-5 FPU in line with the SH-4 FPU API.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
-rw-r--r--arch/sh/kernel/cpu/sh5/fpu.c16
-rw-r--r--arch/sh/kernel/process_64.c4
-rw-r--r--arch/sh/kernel/ptrace_64.c4
-rw-r--r--arch/sh/kernel/signal_64.c2
-rw-r--r--arch/sh/kernel/traps_64.c4
-rw-r--r--include/asm-sh/fpu.h44
-rw-r--r--include/asm-sh/processor.h2
-rw-r--r--include/asm-sh/processor_32.h26
-rw-r--r--include/asm-sh/processor_64.h16
9 files changed, 59 insertions, 59 deletions
diff --git a/arch/sh/kernel/cpu/sh5/fpu.c b/arch/sh/kernel/cpu/sh5/fpu.c
index d3f5e7468dfe..5a391b1a00e2 100644
--- a/arch/sh/kernel/cpu/sh5/fpu.c
+++ b/arch/sh/kernel/cpu/sh5/fpu.c
@@ -30,12 +30,12 @@
30 30
31static union sh_fpu_union init_fpuregs = { 31static union sh_fpu_union init_fpuregs = {
32 .hard = { 32 .hard = {
33 .fp_regs = { [0 ... 63] = sNAN32 }, 33 .fp_regs = { [0 ... 63] = sNAN32 },
34 .fpscr = FPSCR_INIT 34 .fpscr = FPSCR_INIT
35 } 35 }
36}; 36};
37 37
38inline void fpsave(struct sh_fpu_hard_struct *fpregs) 38void save_fpu(struct task_struct *tsk, struct pt_regs *regs)
39{ 39{
40 asm volatile("fst.p %0, (0*8), fp0\n\t" 40 asm volatile("fst.p %0, (0*8), fp0\n\t"
41 "fst.p %0, (1*8), fp2\n\t" 41 "fst.p %0, (1*8), fp2\n\t"
@@ -73,11 +73,10 @@ inline void fpsave(struct sh_fpu_hard_struct *fpregs)
73 "fgetscr fr63\n\t" 73 "fgetscr fr63\n\t"
74 "fst.s %0, (32*8), fr63\n\t" 74 "fst.s %0, (32*8), fr63\n\t"
75 : /* no output */ 75 : /* no output */
76 : "r" (fpregs) 76 : "r" (&tsk->thread.fpu.hard)
77 : "memory"); 77 : "memory");
78} 78}
79 79
80
81static inline void 80static inline void
82fpload(struct sh_fpu_hard_struct *fpregs) 81fpload(struct sh_fpu_hard_struct *fpregs)
83{ 82{
@@ -153,10 +152,10 @@ do_fpu_state_restore(unsigned long ex, struct pt_regs *regs)
153 return; 152 return;
154 153
155 enable_fpu(); 154 enable_fpu();
156 if (last_task_used_math != NULL) { 155 if (last_task_used_math != NULL)
157 /* Other processes fpu state, save away */ 156 /* Other processes fpu state, save away */
158 fpsave(&last_task_used_math->thread.fpu.hard); 157 save_fpu(last_task_used_math, regs);
159 } 158
160 last_task_used_math = current; 159 last_task_used_math = current;
161 if (used_math()) { 160 if (used_math()) {
162 fpload(&current->thread.fpu.hard); 161 fpload(&current->thread.fpu.hard);
@@ -167,4 +166,3 @@ do_fpu_state_restore(unsigned long ex, struct pt_regs *regs)
167 } 166 }
168 disable_fpu(); 167 disable_fpu();
169} 168}
170
diff --git a/arch/sh/kernel/process_64.c b/arch/sh/kernel/process_64.c
index 2dd97eecb44c..973dd1a3d292 100644
--- a/arch/sh/kernel/process_64.c
+++ b/arch/sh/kernel/process_64.c
@@ -480,7 +480,7 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
480 if (fpvalid) { 480 if (fpvalid) {
481 if (current == last_task_used_math) { 481 if (current == last_task_used_math) {
482 enable_fpu(); 482 enable_fpu();
483 fpsave(&tsk->thread.fpu.hard); 483 save_fpu(tsk, regs);
484 disable_fpu(); 484 disable_fpu();
485 last_task_used_math = 0; 485 last_task_used_math = 0;
486 regs->sr |= SR_FD; 486 regs->sr |= SR_FD;
@@ -507,7 +507,7 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
507#ifdef CONFIG_SH_FPU 507#ifdef CONFIG_SH_FPU
508 if(last_task_used_math == current) { 508 if(last_task_used_math == current) {
509 enable_fpu(); 509 enable_fpu();
510 fpsave(&current->thread.fpu.hard); 510 save_fpu(current, regs);
511 disable_fpu(); 511 disable_fpu();
512 last_task_used_math = NULL; 512 last_task_used_math = NULL;
513 regs->sr |= SR_FD; 513 regs->sr |= SR_FD;
diff --git a/arch/sh/kernel/ptrace_64.c b/arch/sh/kernel/ptrace_64.c
index 51bb546365cb..e9cc6ebd2cea 100644
--- a/arch/sh/kernel/ptrace_64.c
+++ b/arch/sh/kernel/ptrace_64.c
@@ -75,7 +75,7 @@ get_fpu_long(struct task_struct *task, unsigned long addr)
75 75
76 if (last_task_used_math == task) { 76 if (last_task_used_math == task) {
77 enable_fpu(); 77 enable_fpu();
78 fpsave(&task->thread.fpu.hard); 78 save_fpu(task, regs);
79 disable_fpu(); 79 disable_fpu();
80 last_task_used_math = 0; 80 last_task_used_math = 0;
81 regs->sr |= SR_FD; 81 regs->sr |= SR_FD;
@@ -111,7 +111,7 @@ put_fpu_long(struct task_struct *task, unsigned long addr, unsigned long data)
111 set_stopped_child_used_math(task); 111 set_stopped_child_used_math(task);
112 } else if (last_task_used_math == task) { 112 } else if (last_task_used_math == task) {
113 enable_fpu(); 113 enable_fpu();
114 fpsave(&task->thread.fpu.hard); 114 save_fpu(task, regs);
115 disable_fpu(); 115 disable_fpu();
116 last_task_used_math = 0; 116 last_task_used_math = 0;
117 regs->sr |= SR_FD; 117 regs->sr |= SR_FD;
diff --git a/arch/sh/kernel/signal_64.c b/arch/sh/kernel/signal_64.c
index 08f403e23662..922891960c33 100644
--- a/arch/sh/kernel/signal_64.c
+++ b/arch/sh/kernel/signal_64.c
@@ -212,7 +212,7 @@ setup_sigcontext_fpu(struct pt_regs *regs, struct sigcontext __user *sc)
212 212
213 if (current == last_task_used_math) { 213 if (current == last_task_used_math) {
214 enable_fpu(); 214 enable_fpu();
215 fpsave(&current->thread.fpu.hard); 215 save_fpu(current, regs);
216 disable_fpu(); 216 disable_fpu();
217 last_task_used_math = NULL; 217 last_task_used_math = NULL;
218 regs->sr |= SR_FD; 218 regs->sr |= SR_FD;
diff --git a/arch/sh/kernel/traps_64.c b/arch/sh/kernel/traps_64.c
index 0f4ea3ac3e0b..b8020f26b635 100644
--- a/arch/sh/kernel/traps_64.c
+++ b/arch/sh/kernel/traps_64.c
@@ -618,7 +618,7 @@ static int misaligned_fpu_load(struct pt_regs *regs,
618 indexed by register number. */ 618 indexed by register number. */
619 if (last_task_used_math == current) { 619 if (last_task_used_math == current) {
620 enable_fpu(); 620 enable_fpu();
621 fpsave(&current->thread.fpu.hard); 621 save_fpu(current, regs);
622 disable_fpu(); 622 disable_fpu();
623 last_task_used_math = NULL; 623 last_task_used_math = NULL;
624 regs->sr |= SR_FD; 624 regs->sr |= SR_FD;
@@ -691,7 +691,7 @@ static int misaligned_fpu_store(struct pt_regs *regs,
691 indexed by register number. */ 691 indexed by register number. */
692 if (last_task_used_math == current) { 692 if (last_task_used_math == current) {
693 enable_fpu(); 693 enable_fpu();
694 fpsave(&current->thread.fpu.hard); 694 save_fpu(current, regs);
695 disable_fpu(); 695 disable_fpu();
696 last_task_used_math = NULL; 696 last_task_used_math = NULL;
697 regs->sr |= SR_FD; 697 regs->sr |= SR_FD;
diff --git a/include/asm-sh/fpu.h b/include/asm-sh/fpu.h
new file mode 100644
index 000000000000..33db698a6b4d
--- /dev/null
+++ b/include/asm-sh/fpu.h
@@ -0,0 +1,44 @@
1#ifndef __ASM_SH_FPU_H
2#define __ASM_SH_FPU_H
3
4#define SR_FD 0x00008000
5
6#ifndef __ASSEMBLY__
7#include <asm/ptrace.h>
8
9#ifdef CONFIG_SH_FPU
10static inline void release_fpu(struct pt_regs *regs)
11{
12 regs->sr |= SR_FD;
13}
14
15static inline void grab_fpu(struct pt_regs *regs)
16{
17 regs->sr &= ~SR_FD;
18}
19
20struct task_struct;
21
22extern void save_fpu(struct task_struct *__tsk, struct pt_regs *regs);
23#else
24#define release_fpu(regs) do { } while (0)
25#define grab_fpu(regs) do { } while (0)
26#define save_fpu(tsk, regs) do { } while (0)
27#endif
28
29#define unlazy_fpu(tsk, regs) do { \
30 if (test_tsk_thread_flag(tsk, TIF_USEDFPU)) { \
31 save_fpu(tsk, regs); \
32 } \
33} while (0)
34
35#define clear_fpu(tsk, regs) do { \
36 if (test_tsk_thread_flag(tsk, TIF_USEDFPU)) { \
37 clear_tsk_thread_flag(tsk, TIF_USEDFPU); \
38 release_fpu(regs); \
39 } \
40} while (0)
41
42#endif /* __ASSEMBLY__ */
43
44#endif /* __ASM_SH_FPU_H */
diff --git a/include/asm-sh/processor.h b/include/asm-sh/processor.h
index f3bd82e95898..3ae2a1c223f2 100644
--- a/include/asm-sh/processor.h
+++ b/include/asm-sh/processor.h
@@ -2,9 +2,9 @@
2#define __ASM_SH_PROCESSOR_H 2#define __ASM_SH_PROCESSOR_H
3 3
4#include <asm/cpu-features.h> 4#include <asm/cpu-features.h>
5#include <asm/fpu.h>
5 6
6#ifndef __ASSEMBLY__ 7#ifndef __ASSEMBLY__
7
8/* 8/*
9 * CPU type and hardware bug flags. Kept separately for each CPU. 9 * CPU type and hardware bug flags. Kept separately for each CPU.
10 * 10 *
diff --git a/include/asm-sh/processor_32.h b/include/asm-sh/processor_32.h
index 1ad74633c009..a7edaa1a870c 100644
--- a/include/asm-sh/processor_32.h
+++ b/include/asm-sh/processor_32.h
@@ -65,7 +65,6 @@ extern struct sh_cpuinfo cpu_data[];
65 * IMASK-bit: 65 * IMASK-bit:
66 * Interrupt level mask 66 * Interrupt level mask
67 */ 67 */
68#define SR_FD 0x00008000
69#define SR_DSP 0x00001000 68#define SR_DSP 0x00001000
70#define SR_IMASK 0x000000f0 69#define SR_IMASK 0x000000f0
71 70
@@ -178,31 +177,6 @@ static __inline__ void enable_fpu(void)
178 : "r" (~SR_FD)); 177 : "r" (~SR_FD));
179} 178}
180 179
181static __inline__ void release_fpu(struct pt_regs *regs)
182{
183 regs->sr |= SR_FD;
184}
185
186static __inline__ void grab_fpu(struct pt_regs *regs)
187{
188 regs->sr &= ~SR_FD;
189}
190
191extern void save_fpu(struct task_struct *__tsk, struct pt_regs *regs);
192
193#define unlazy_fpu(tsk, regs) do { \
194 if (test_tsk_thread_flag(tsk, TIF_USEDFPU)) { \
195 save_fpu(tsk, regs); \
196 } \
197} while (0)
198
199#define clear_fpu(tsk, regs) do { \
200 if (test_tsk_thread_flag(tsk, TIF_USEDFPU)) { \
201 clear_tsk_thread_flag(tsk, TIF_USEDFPU); \
202 release_fpu(regs); \
203 } \
204} while (0)
205
206/* Double presision, NANS as NANS, rounding to nearest, no exceptions */ 180/* Double presision, NANS as NANS, rounding to nearest, no exceptions */
207#define FPSCR_INIT 0x00080000 181#define FPSCR_INIT 0x00080000
208 182
diff --git a/include/asm-sh/processor_64.h b/include/asm-sh/processor_64.h
index f54648229231..99c22b14a85b 100644
--- a/include/asm-sh/processor_64.h
+++ b/include/asm-sh/processor_64.h
@@ -102,8 +102,6 @@ extern struct sh_cpuinfo cpu_data[];
102 * Single step bit 102 * Single step bit
103 * 103 *
104 */ 104 */
105#define SR_FD 0x00008000
106
107#if defined(CONFIG_SH64_SR_WATCH) 105#if defined(CONFIG_SH64_SR_WATCH)
108#define SR_MMU 0x84000000 106#define SR_MMU 0x84000000
109#else 107#else
@@ -243,16 +241,6 @@ static inline void enable_fpu(void)
243 : "r" (~SR_FD)); 241 : "r" (~SR_FD));
244} 242}
245 243
246static inline void release_fpu(struct pt_regs *regs)
247{
248 regs->sr |= SR_FD;
249}
250
251static inline void grab_fpu(struct pt_regs *regs)
252{
253 regs->sr &= ~SR_FD;
254}
255
256/* Round to nearest, no exceptions on inexact, overflow, underflow, 244/* Round to nearest, no exceptions on inexact, overflow, underflow,
257 zero-divide, invalid. Configure option for whether to flush denorms to 245 zero-divide, invalid. Configure option for whether to flush denorms to
258 zero, or except if a denorm is encountered. */ 246 zero, or except if a denorm is encountered. */
@@ -263,13 +251,9 @@ static inline void grab_fpu(struct pt_regs *regs)
263#endif 251#endif
264 252
265#ifdef CONFIG_SH_FPU 253#ifdef CONFIG_SH_FPU
266/* Save the current FP regs */
267void fpsave(struct sh_fpu_hard_struct *fpregs);
268
269/* Initialise the FP state of a task */ 254/* Initialise the FP state of a task */
270void fpinit(struct sh_fpu_hard_struct *fpregs); 255void fpinit(struct sh_fpu_hard_struct *fpregs);
271#else 256#else
272#define fpsave(fpregs) do { } while (0)
273#define fpinit(fpregs) do { } while (0) 257#define fpinit(fpregs) do { } while (0)
274#endif 258#endif
275 259