Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/drzeus/mmc
[linux-2.6] / arch / um / os-Linux / sys-x86_64 / registers.c
1 /*
2  * Copyright (C) 2006 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3  * Licensed under the GPL
4  */
5
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"
13
14 int save_fp_registers(int pid, unsigned long *fp_regs)
15 {
16         if (ptrace(PTRACE_GETFPREGS, pid, 0, fp_regs) < 0)
17                 return -errno;
18         return 0;
19 }
20
21 int restore_fp_registers(int pid, unsigned long *fp_regs)
22 {
23         if (ptrace(PTRACE_SETFPREGS, pid, 0, fp_regs) < 0)
24                 return -errno;
25         return 0;
26 }
27
28 unsigned long get_thread_reg(int reg, jmp_buf *buf)
29 {
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;
41         }
42 }