Skip to content

Commit c91b4a0

Browse files
committed
openrisc: Add floating point regset
Define REGSET_FPU to allow reading and writing the FPCSR fpu state register. This will be used primarily by debuggers like GDB. Signed-off-by: Stafford Horne <shorne@gmail.com>
1 parent 2726765 commit c91b4a0

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

arch/openrisc/kernel/ptrace.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,40 @@ static int genregs_set(struct task_struct *target,
8484
return ret;
8585
}
8686

87+
/*
88+
* As OpenRISC shares GPRs and floating point registers we don't need to export
89+
* the floating point registers again. So here we only export the fpcsr special
90+
* purpose register.
91+
*/
92+
static int fpregs_get(struct task_struct *target,
93+
const struct user_regset *regset,
94+
struct membuf to)
95+
{
96+
const struct pt_regs *regs = task_pt_regs(target);
97+
98+
return membuf_store(&to, regs->fpcsr);
99+
}
100+
101+
static int fpregs_set(struct task_struct *target,
102+
const struct user_regset *regset,
103+
unsigned int pos, unsigned int count,
104+
const void *kbuf, const void __user *ubuf)
105+
{
106+
struct pt_regs *regs = task_pt_regs(target);
107+
int ret;
108+
109+
/* FPCSR */
110+
ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
111+
&regs->fpcsr, 0, 4);
112+
return ret;
113+
}
114+
87115
/*
88116
* Define the register sets available on OpenRISC under Linux
89117
*/
90118
enum or1k_regset {
91119
REGSET_GENERAL,
120+
REGSET_FPU,
92121
};
93122

94123
static const struct user_regset or1k_regsets[] = {
@@ -100,6 +129,14 @@ static const struct user_regset or1k_regsets[] = {
100129
.regset_get = genregs_get,
101130
.set = genregs_set,
102131
},
132+
[REGSET_FPU] = {
133+
.core_note_type = NT_PRFPREG,
134+
.n = sizeof(struct __or1k_fpu_state) / sizeof(long),
135+
.size = sizeof(long),
136+
.align = sizeof(long),
137+
.regset_get = fpregs_get,
138+
.set = fpregs_set,
139+
},
103140
};
104141

105142
static const struct user_regset_view user_or1k_native_view = {

0 commit comments

Comments
 (0)