1 // SPDX-License-Identifier: GPL-2.0-or-later
2 
3 #include <linux/regset.h>
4 
5 #include <asm/switch_to.h>
6 
7 #include "ptrace-decl.h"
8 
9 int ptrace_get_fpr(struct task_struct *child, int index, unsigned long *data)
10 {
11 	unsigned int fpidx = index - PT_FPR0;
12 
13 	if (index > PT_FPSCR)
14 		return -EIO;
15 
16 	flush_fp_to_thread(child);
17 	if (fpidx < (PT_FPSCR - PT_FPR0))
18 		memcpy(data, &child->thread.TS_FPR(fpidx), sizeof(long));
19 	else
20 		*data = child->thread.fp_state.fpscr;
21 
22 	return 0;
23 }
24 
25 int ptrace_put_fpr(struct task_struct *child, int index, unsigned long data)
26 {
27 	unsigned int fpidx = index - PT_FPR0;
28 
29 	if (index > PT_FPSCR)
30 		return -EIO;
31 
32 	flush_fp_to_thread(child);
33 	if (fpidx < (PT_FPSCR - PT_FPR0))
34 		memcpy(&child->thread.TS_FPR(fpidx), &data, sizeof(long));
35 	else
36 		child->thread.fp_state.fpscr = data;
37 
38 	return 0;
39 }
40 
41