blob: 8245df41b201f5c59f600f984f85124f56b67c9f [file] [log] [blame]
Al Viro37185b32012-10-08 03:27:32 +01001#include <linux/sched.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#include "asm/ptrace.h"
3
4int putreg(struct task_struct *child, unsigned long regno,
5 unsigned long value)
6{
7 child->thread.process_regs.regs[regno >> 2] = value;
8 return 0;
9}
10
Bodo Stroesser82c1c112005-05-06 21:30:46 -070011int poke_user(struct task_struct *child, long addr, long data)
12{
13 if ((addr & 3) || addr < 0)
14 return -EIO;
15
16 if (addr < MAX_REG_OFFSET)
17 return putreg(child, addr, data);
18
19 else if((addr >= offsetof(struct user, u_debugreg[0])) &&
20 (addr <= offsetof(struct user, u_debugreg[7]))){
21 addr -= offsetof(struct user, u_debugreg[0]);
22 addr = addr >> 2;
23 if((addr == 4) || (addr == 5)) return -EIO;
24 child->thread.arch.debugregs[addr] = data;
25 return 0;
26 }
27 return -EIO;
28}
29
Linus Torvalds1da177e2005-04-16 15:20:36 -070030unsigned long getreg(struct task_struct *child, unsigned long regno)
31{
32 unsigned long retval = ~0UL;
33
34 retval &= child->thread.process_regs.regs[regno >> 2];
35 return retval;
36}
37
Bodo Stroesser82c1c112005-05-06 21:30:46 -070038int peek_user(struct task_struct *child, long addr, long data)
39{
40 /* read the word at location addr in the USER area. */
41 unsigned long tmp;
42
43 if ((addr & 3) || addr < 0)
44 return -EIO;
45
46 tmp = 0; /* Default return condition */
47 if(addr < MAX_REG_OFFSET){
48 tmp = getreg(child, addr);
49 }
50 else if((addr >= offsetof(struct user, u_debugreg[0])) &&
51 (addr <= offsetof(struct user, u_debugreg[7]))){
52 addr -= offsetof(struct user, u_debugreg[0]);
53 addr = addr >> 2;
54 tmp = child->thread.arch.debugregs[addr];
55 }
56 return put_user(tmp, (unsigned long *) data);
57}
58