0001
0002
0003 #include <linux/regset.h>
0004 #include <linux/elf.h>
0005
0006 #include <asm/switch_to.h>
0007
0008 #include "ptrace-decl.h"
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 int vr_active(struct task_struct *target, const struct user_regset *regset)
0024 {
0025 flush_altivec_to_thread(target);
0026 return target->thread.used_vr ? regset->n : 0;
0027 }
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043 int vr_get(struct task_struct *target, const struct user_regset *regset,
0044 struct membuf to)
0045 {
0046 union {
0047 elf_vrreg_t reg;
0048 u32 word;
0049 } vrsave;
0050
0051 flush_altivec_to_thread(target);
0052
0053 BUILD_BUG_ON(offsetof(struct thread_vr_state, vscr) !=
0054 offsetof(struct thread_vr_state, vr[32]));
0055
0056 membuf_write(&to, &target->thread.vr_state, 33 * sizeof(vector128));
0057
0058
0059
0060 memset(&vrsave, 0, sizeof(vrsave));
0061 vrsave.word = target->thread.vrsave;
0062 return membuf_write(&to, &vrsave, sizeof(vrsave));
0063 }
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079 int vr_set(struct task_struct *target, const struct user_regset *regset,
0080 unsigned int pos, unsigned int count,
0081 const void *kbuf, const void __user *ubuf)
0082 {
0083 int ret;
0084
0085 flush_altivec_to_thread(target);
0086
0087 BUILD_BUG_ON(offsetof(struct thread_vr_state, vscr) !=
0088 offsetof(struct thread_vr_state, vr[32]));
0089
0090 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
0091 &target->thread.vr_state, 0,
0092 33 * sizeof(vector128));
0093 if (!ret && count > 0) {
0094
0095
0096
0097 int start, end;
0098 union {
0099 elf_vrreg_t reg;
0100 u32 word;
0101 } vrsave;
0102 memset(&vrsave, 0, sizeof(vrsave));
0103
0104 vrsave.word = target->thread.vrsave;
0105
0106 start = 33 * sizeof(vector128);
0107 end = start + sizeof(vrsave);
0108 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &vrsave,
0109 start, end);
0110 if (!ret)
0111 target->thread.vrsave = vrsave.word;
0112 }
0113
0114 return ret;
0115 }