1
2
3
4
5
6
7
8#include <linux/sched.h>
9#include <asm/fpu.h>
10
11#ifdef CONFIG_ISA_ARCOMPACT
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32void fpu_save_restore(struct task_struct *prev, struct task_struct *next)
33{
34 unsigned int *saveto = &prev->thread.fpu.aux_dpfp[0].l;
35 unsigned int *readfrom = &next->thread.fpu.aux_dpfp[0].l;
36
37 const unsigned int zero = 0;
38
39 __asm__ __volatile__(
40 "daddh11 %0, %2, %2\n"
41 "dexcl1 %1, %3, %4\n"
42 : "=&r" (*(saveto + 1)),
43 "=&r" (*(saveto))
44 : "r" (zero), "r" (*(readfrom + 1)), "r" (*(readfrom))
45 );
46
47 __asm__ __volatile__(
48 "daddh22 %0, %2, %2\n"
49 "dexcl2 %1, %3, %4\n"
50 : "=&r"(*(saveto + 3)),
51 "=&r"(*(saveto + 2))
52 : "r" (zero), "r" (*(readfrom + 3)), "r" (*(readfrom + 2))
53 );
54}
55
56#else
57
58void fpu_init_task(struct pt_regs *regs)
59{
60
61 write_aux_reg(ARC_REG_FPU_CTRL, 0x100);
62
63
64 write_aux_reg(ARC_REG_FPU_STATUS, 0x80000000);
65}
66
67void fpu_save_restore(struct task_struct *prev, struct task_struct *next)
68{
69 struct arc_fpu *save = &prev->thread.fpu;
70 struct arc_fpu *restore = &next->thread.fpu;
71
72 save->ctrl = read_aux_reg(ARC_REG_FPU_CTRL);
73 save->status = read_aux_reg(ARC_REG_FPU_STATUS);
74
75 write_aux_reg(ARC_REG_FPU_CTRL, restore->ctrl);
76 write_aux_reg(ARC_REG_FPU_STATUS, restore->status);
77}
78
79#endif
80