2 * Copyright (C) 2004 PathScale, Inc
3 * Copyright (C) 2004 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
4 * Licensed under the GPL
8 #include <sys/ptrace.h>
13 #include <sysdep/ptrace_user.h>
15 int save_fp_registers(int pid
, unsigned long *fp_regs
)
17 if (ptrace(PTRACE_GETFPREGS
, pid
, 0, fp_regs
) < 0)
22 int restore_fp_registers(int pid
, unsigned long *fp_regs
)
24 if (ptrace(PTRACE_SETFPREGS
, pid
, 0, fp_regs
) < 0)
30 int have_fpx_regs
= 1;
31 int save_fpx_registers(int pid
, unsigned long *fp_regs
)
33 if (ptrace(PTRACE_GETFPXREGS
, pid
, 0, fp_regs
) < 0)
38 int restore_fpx_registers(int pid
, unsigned long *fp_regs
)
40 if (ptrace(PTRACE_SETFPXREGS
, pid
, 0, fp_regs
) < 0)
45 int get_fp_registers(int pid
, unsigned long *regs
)
48 return save_fpx_registers(pid
, regs
);
50 return save_fp_registers(pid
, regs
);
53 int put_fp_registers(int pid
, unsigned long *regs
)
56 return restore_fpx_registers(pid
, regs
);
58 return restore_fp_registers(pid
, regs
);
61 void arch_init_registers(int pid
)
63 struct user_fpxregs_struct fpx_regs
;
66 err
= ptrace(PTRACE_GETFPXREGS
, pid
, 0, &fpx_regs
);
71 panic("check_ptrace : PTRACE_GETFPXREGS failed, errno = %d",
78 int get_fp_registers(int pid
, unsigned long *regs
)
80 return save_fp_registers(pid
, regs
);
83 int put_fp_registers(int pid
, unsigned long *regs
)
85 return restore_fp_registers(pid
, regs
);
90 unsigned long get_thread_reg(int reg
, jmp_buf *buf
)
102 return buf
[0]->__rip
;
104 return buf
[0]->__rsp
;
106 return buf
[0]->__rbp
;
109 printk(UM_KERN_ERR
"get_thread_regs - unknown register %d\n",