Linux 2.6.39-rc2
[pohmelfs.git] / arch / um / os-Linux / sys-x86_64 / registers.c
blob594d97ad02b3408b8b351a3b4263f82cb88461ad
1 /*
2 * Copyright (C) 2006 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL
4 */
6 #include <errno.h>
7 #include <sys/ptrace.h>
8 #define __FRAME_OFFSETS
9 #include <asm/ptrace.h>
10 #include "kern_constants.h"
11 #include "longjmp.h"
12 #include "user.h"
14 int save_fp_registers(int pid, unsigned long *fp_regs)
16 if (ptrace(PTRACE_GETFPREGS, pid, 0, fp_regs) < 0)
17 return -errno;
18 return 0;
21 int restore_fp_registers(int pid, unsigned long *fp_regs)
23 if (ptrace(PTRACE_SETFPREGS, pid, 0, fp_regs) < 0)
24 return -errno;
25 return 0;
28 unsigned long get_thread_reg(int reg, jmp_buf *buf)
30 switch (reg) {
31 case RIP:
32 return buf[0]->__rip;
33 case RSP:
34 return buf[0]->__rsp;
35 case RBP:
36 return buf[0]->__rbp;
37 default:
38 printk(UM_KERN_ERR "get_thread_regs - unknown register %d\n",
39 reg);
40 return 0;
44 int get_fp_registers(int pid, unsigned long *regs)
46 return save_fp_registers(pid, regs);
49 int put_fp_registers(int pid, unsigned long *regs)
51 return restore_fp_registers(pid, regs);