d1997ca76e5cbd182a6ce606b609516cfcdbbcc6
[deliverable/linux.git] / arch / um / os-Linux / sys-i386 / registers.c
1 /*
2 * Copyright (C) 2004 PathScale, Inc
3 * Copyright (C) 2004 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
4 * Licensed under the GPL
5 */
6
7 #include <errno.h>
8 #include "kern_constants.h"
9 #include "longjmp.h"
10 #include "user.h"
11 #include "sysdep/ptrace_user.h"
12
13 int save_fp_registers(int pid, unsigned long *fp_regs)
14 {
15 if (ptrace(PTRACE_GETFPREGS, pid, 0, fp_regs) < 0)
16 return -errno;
17 return 0;
18 }
19
20 int restore_fp_registers(int pid, unsigned long *fp_regs)
21 {
22 if (ptrace(PTRACE_SETFPREGS, pid, 0, fp_regs) < 0)
23 return -errno;
24 return 0;
25 }
26
27 int save_fpx_registers(int pid, unsigned long *fp_regs)
28 {
29 if (ptrace(PTRACE_GETFPXREGS, pid, 0, fp_regs) < 0)
30 return -errno;
31 return 0;
32 }
33
34 int restore_fpx_registers(int pid, unsigned long *fp_regs)
35 {
36 if (ptrace(PTRACE_SETFPXREGS, pid, 0, fp_regs) < 0)
37 return -errno;
38 return 0;
39 }
40
41 unsigned long get_thread_reg(int reg, jmp_buf *buf)
42 {
43 switch (reg) {
44 case EIP:
45 return buf[0]->__eip;
46 case UESP:
47 return buf[0]->__esp;
48 case EBP:
49 return buf[0]->__ebp;
50 default:
51 printk(UM_KERN_ERR "get_thread_regs - unknown register %d\n",
52 reg);
53 return 0;
54 }
55 }
56
57 int have_fpx_regs = 1;
58
59 void arch_init_registers(int pid)
60 {
61 unsigned long fpx_regs[HOST_XFP_SIZE];
62 int err;
63
64 err = ptrace(PTRACE_GETFPXREGS, pid, 0, fpx_regs);
65 if(!err)
66 return;
67
68 if(errno != EIO)
69 panic("check_ptrace : PTRACE_GETFPXREGS failed, errno = %d",
70 errno);
71
72 have_fpx_regs = 0;
73 }
This page took 0.031059 seconds and 4 git commands to generate.