diff options
author | Michael Neuling <mikey@neuling.org> | 2008-06-26 03:07:48 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2008-06-30 21:28:43 -0400 |
commit | 9c75a31c3525a127f70b919856e32be3d8b03755 (patch) | |
tree | 3beee76d3dd4a55af868b5edfbef80c911819fed /arch/powerpc/kernel | |
parent | 9e7511861c4f8d35852a3721c5bcd92661cb4c9f (diff) |
powerpc: Add macros to access floating point registers in thread_struct.
We are going to change where the floating point registers are stored
in the thread_struct, so in preparation add some macros to access the
floating point registers. Update all code to use these new macros.
Signed-off-by: Michael Neuling <mikey@neuling.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/kernel')
-rw-r--r-- | arch/powerpc/kernel/align.c | 6 | ||||
-rw-r--r-- | arch/powerpc/kernel/process.c | 2 | ||||
-rw-r--r-- | arch/powerpc/kernel/ptrace.c | 10 | ||||
-rw-r--r-- | arch/powerpc/kernel/ptrace32.c | 14 | ||||
-rw-r--r-- | arch/powerpc/kernel/softemu8xx.c | 4 |
5 files changed, 23 insertions, 13 deletions
diff --git a/arch/powerpc/kernel/align.c b/arch/powerpc/kernel/align.c index e06f75daeba3..c95954c81454 100644 --- a/arch/powerpc/kernel/align.c +++ b/arch/powerpc/kernel/align.c | |||
@@ -366,7 +366,7 @@ static int emulate_multiple(struct pt_regs *regs, unsigned char __user *addr, | |||
366 | static int emulate_fp_pair(struct pt_regs *regs, unsigned char __user *addr, | 366 | static int emulate_fp_pair(struct pt_regs *regs, unsigned char __user *addr, |
367 | unsigned int reg, unsigned int flags) | 367 | unsigned int reg, unsigned int flags) |
368 | { | 368 | { |
369 | char *ptr = (char *) ¤t->thread.fpr[reg]; | 369 | char *ptr = (char *) ¤t->thread.TS_FPR(reg); |
370 | int i, ret; | 370 | int i, ret; |
371 | 371 | ||
372 | if (!(flags & F)) | 372 | if (!(flags & F)) |
@@ -784,7 +784,7 @@ int fix_alignment(struct pt_regs *regs) | |||
784 | return -EFAULT; | 784 | return -EFAULT; |
785 | } | 785 | } |
786 | } else if (flags & F) { | 786 | } else if (flags & F) { |
787 | data.dd = current->thread.fpr[reg]; | 787 | data.dd = current->thread.TS_FPR(reg); |
788 | if (flags & S) { | 788 | if (flags & S) { |
789 | /* Single-precision FP store requires conversion... */ | 789 | /* Single-precision FP store requires conversion... */ |
790 | #ifdef CONFIG_PPC_FPU | 790 | #ifdef CONFIG_PPC_FPU |
@@ -862,7 +862,7 @@ int fix_alignment(struct pt_regs *regs) | |||
862 | if (unlikely(ret)) | 862 | if (unlikely(ret)) |
863 | return -EFAULT; | 863 | return -EFAULT; |
864 | } else if (flags & F) | 864 | } else if (flags & F) |
865 | current->thread.fpr[reg] = data.dd; | 865 | current->thread.TS_FPR(reg) = data.dd; |
866 | else | 866 | else |
867 | regs->gpr[reg] = data.ll; | 867 | regs->gpr[reg] = data.ll; |
868 | 868 | ||
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index 7de41c3948ec..582df70439cb 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c | |||
@@ -110,7 +110,7 @@ int dump_task_fpu(struct task_struct *tsk, elf_fpregset_t *fpregs) | |||
110 | return 0; | 110 | return 0; |
111 | flush_fp_to_thread(current); | 111 | flush_fp_to_thread(current); |
112 | 112 | ||
113 | memcpy(fpregs, &tsk->thread.fpr[0], sizeof(*fpregs)); | 113 | memcpy(fpregs, &tsk->thread.TS_FPR(0), sizeof(*fpregs)); |
114 | 114 | ||
115 | return 1; | 115 | return 1; |
116 | } | 116 | } |
diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c index 2a9fe97e4521..59ff08704e94 100644 --- a/arch/powerpc/kernel/ptrace.c +++ b/arch/powerpc/kernel/ptrace.c | |||
@@ -218,7 +218,7 @@ static int fpr_get(struct task_struct *target, const struct user_regset *regset, | |||
218 | flush_fp_to_thread(target); | 218 | flush_fp_to_thread(target); |
219 | 219 | ||
220 | BUILD_BUG_ON(offsetof(struct thread_struct, fpscr) != | 220 | BUILD_BUG_ON(offsetof(struct thread_struct, fpscr) != |
221 | offsetof(struct thread_struct, fpr[32])); | 221 | offsetof(struct thread_struct, TS_FPR(32))); |
222 | 222 | ||
223 | return user_regset_copyout(&pos, &count, &kbuf, &ubuf, | 223 | return user_regset_copyout(&pos, &count, &kbuf, &ubuf, |
224 | &target->thread.fpr, 0, -1); | 224 | &target->thread.fpr, 0, -1); |
@@ -231,7 +231,7 @@ static int fpr_set(struct task_struct *target, const struct user_regset *regset, | |||
231 | flush_fp_to_thread(target); | 231 | flush_fp_to_thread(target); |
232 | 232 | ||
233 | BUILD_BUG_ON(offsetof(struct thread_struct, fpscr) != | 233 | BUILD_BUG_ON(offsetof(struct thread_struct, fpscr) != |
234 | offsetof(struct thread_struct, fpr[32])); | 234 | offsetof(struct thread_struct, TS_FPR(32))); |
235 | 235 | ||
236 | return user_regset_copyin(&pos, &count, &kbuf, &ubuf, | 236 | return user_regset_copyin(&pos, &count, &kbuf, &ubuf, |
237 | &target->thread.fpr, 0, -1); | 237 | &target->thread.fpr, 0, -1); |
@@ -728,7 +728,8 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) | |||
728 | tmp = ptrace_get_reg(child, (int) index); | 728 | tmp = ptrace_get_reg(child, (int) index); |
729 | } else { | 729 | } else { |
730 | flush_fp_to_thread(child); | 730 | flush_fp_to_thread(child); |
731 | tmp = ((unsigned long *)child->thread.fpr)[index - PT_FPR0]; | 731 | tmp = ((unsigned long *)child->thread.fpr) |
732 | [TS_FPRWIDTH * (index - PT_FPR0)]; | ||
732 | } | 733 | } |
733 | ret = put_user(tmp,(unsigned long __user *) data); | 734 | ret = put_user(tmp,(unsigned long __user *) data); |
734 | break; | 735 | break; |
@@ -755,7 +756,8 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) | |||
755 | ret = ptrace_put_reg(child, index, data); | 756 | ret = ptrace_put_reg(child, index, data); |
756 | } else { | 757 | } else { |
757 | flush_fp_to_thread(child); | 758 | flush_fp_to_thread(child); |
758 | ((unsigned long *)child->thread.fpr)[index - PT_FPR0] = data; | 759 | ((unsigned long *)child->thread.fpr) |
760 | [TS_FPRWIDTH * (index - PT_FPR0)] = data; | ||
759 | ret = 0; | 761 | ret = 0; |
760 | } | 762 | } |
761 | break; | 763 | break; |
diff --git a/arch/powerpc/kernel/ptrace32.c b/arch/powerpc/kernel/ptrace32.c index 4c1de6af4c09..67bf1a1e7e14 100644 --- a/arch/powerpc/kernel/ptrace32.c +++ b/arch/powerpc/kernel/ptrace32.c | |||
@@ -64,6 +64,11 @@ static long compat_ptrace_old(struct task_struct *child, long request, | |||
64 | return -EPERM; | 64 | return -EPERM; |
65 | } | 65 | } |
66 | 66 | ||
67 | /* Macros to workout the correct index for the FPR in the thread struct */ | ||
68 | #define FPRNUMBER(i) (((i) - PT_FPR0) >> 1) | ||
69 | #define FPRHALF(i) (((i) - PT_FPR0) & 1) | ||
70 | #define FPRINDEX(i) TS_FPRWIDTH * FPRNUMBER(i) + FPRHALF(i) | ||
71 | |||
67 | long compat_arch_ptrace(struct task_struct *child, compat_long_t request, | 72 | long compat_arch_ptrace(struct task_struct *child, compat_long_t request, |
68 | compat_ulong_t caddr, compat_ulong_t cdata) | 73 | compat_ulong_t caddr, compat_ulong_t cdata) |
69 | { | 74 | { |
@@ -122,7 +127,8 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request, | |||
122 | * to be an array of unsigned int (32 bits) - the | 127 | * to be an array of unsigned int (32 bits) - the |
123 | * index passed in is based on this assumption. | 128 | * index passed in is based on this assumption. |
124 | */ | 129 | */ |
125 | tmp = ((unsigned int *)child->thread.fpr)[index - PT_FPR0]; | 130 | tmp = ((unsigned int *)child->thread.fpr) |
131 | [FPRINDEX(index)]; | ||
126 | } | 132 | } |
127 | ret = put_user((unsigned int)tmp, (u32 __user *)data); | 133 | ret = put_user((unsigned int)tmp, (u32 __user *)data); |
128 | break; | 134 | break; |
@@ -162,7 +168,8 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request, | |||
162 | CHECK_FULL_REGS(child->thread.regs); | 168 | CHECK_FULL_REGS(child->thread.regs); |
163 | if (numReg >= PT_FPR0) { | 169 | if (numReg >= PT_FPR0) { |
164 | flush_fp_to_thread(child); | 170 | flush_fp_to_thread(child); |
165 | tmp = ((unsigned long int *)child->thread.fpr)[numReg - PT_FPR0]; | 171 | tmp = ((unsigned long int *)child->thread.fpr) |
172 | [FPRINDEX(numReg)]; | ||
166 | } else { /* register within PT_REGS struct */ | 173 | } else { /* register within PT_REGS struct */ |
167 | tmp = ptrace_get_reg(child, numReg); | 174 | tmp = ptrace_get_reg(child, numReg); |
168 | } | 175 | } |
@@ -217,7 +224,8 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request, | |||
217 | * to be an array of unsigned int (32 bits) - the | 224 | * to be an array of unsigned int (32 bits) - the |
218 | * index passed in is based on this assumption. | 225 | * index passed in is based on this assumption. |
219 | */ | 226 | */ |
220 | ((unsigned int *)child->thread.fpr)[index - PT_FPR0] = data; | 227 | ((unsigned int *)child->thread.fpr) |
228 | [FPRINDEX(index)] = data; | ||
221 | ret = 0; | 229 | ret = 0; |
222 | } | 230 | } |
223 | break; | 231 | break; |
diff --git a/arch/powerpc/kernel/softemu8xx.c b/arch/powerpc/kernel/softemu8xx.c index 67d6f6890edc..c906c4bf6835 100644 --- a/arch/powerpc/kernel/softemu8xx.c +++ b/arch/powerpc/kernel/softemu8xx.c | |||
@@ -124,7 +124,7 @@ int Soft_emulate_8xx(struct pt_regs *regs) | |||
124 | disp = instword & 0xffff; | 124 | disp = instword & 0xffff; |
125 | 125 | ||
126 | ea = (u32 *)(regs->gpr[idxreg] + disp); | 126 | ea = (u32 *)(regs->gpr[idxreg] + disp); |
127 | ip = (u32 *)¤t->thread.fpr[flreg]; | 127 | ip = (u32 *)¤t->thread.TS_FPR(flreg); |
128 | 128 | ||
129 | switch ( inst ) | 129 | switch ( inst ) |
130 | { | 130 | { |
@@ -168,7 +168,7 @@ int Soft_emulate_8xx(struct pt_regs *regs) | |||
168 | break; | 168 | break; |
169 | case FMR: | 169 | case FMR: |
170 | /* assume this is a fp move -- Cort */ | 170 | /* assume this is a fp move -- Cort */ |
171 | memcpy(ip, ¤t->thread.fpr[(instword>>11)&0x1f], | 171 | memcpy(ip, ¤t->thread.TS_FPR((instword>>11)&0x1f), |
172 | sizeof(double)); | 172 | sizeof(double)); |
173 | break; | 173 | break; |
174 | default: | 174 | default: |