]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - arch/um/os-Linux/sys-x86_64/registers.c
Linux-2.6.12-rc2
[mirror_ubuntu-artful-kernel.git] / arch / um / os-Linux / sys-x86_64 / registers.c
1 /*
2 * Copyright (C) 2004 PathScale, Inc
3 * Licensed under the GPL
4 */
5
6 #include <errno.h>
7 #include <string.h>
8 #include "ptrace_user.h"
9 #include "uml-config.h"
10 #include "skas_ptregs.h"
11 #include "registers.h"
12 #include "user.h"
13
14 /* These are set once at boot time and not changed thereafter */
15
16 static unsigned long exec_regs[HOST_FRAME_SIZE];
17 static unsigned long exec_fp_regs[HOST_FP_SIZE];
18
19 void init_thread_registers(union uml_pt_regs *to)
20 {
21 memcpy(to->skas.regs, exec_regs, sizeof(to->skas.regs));
22 memcpy(to->skas.fp, exec_fp_regs, sizeof(to->skas.fp));
23 }
24
25 static int move_registers(int pid, int int_op, int fp_op,
26 union uml_pt_regs *regs)
27 {
28 if(ptrace(int_op, pid, 0, regs->skas.regs) < 0)
29 return(-errno);
30
31 if(ptrace(fp_op, pid, 0, regs->skas.fp) < 0)
32 return(-errno);
33
34 return(0);
35 }
36
37 void save_registers(int pid, union uml_pt_regs *regs)
38 {
39 int err;
40
41 err = move_registers(pid, PTRACE_GETREGS, PTRACE_GETFPREGS, regs);
42 if(err)
43 panic("save_registers - saving registers failed, errno = %d\n",
44 -err);
45 }
46
47 void restore_registers(int pid, union uml_pt_regs *regs)
48 {
49 int err;
50
51 err = move_registers(pid, PTRACE_SETREGS, PTRACE_SETFPREGS, regs);
52 if(err)
53 panic("restore_registers - saving registers failed, "
54 "errno = %d\n", -err);
55 }
56
57 void init_registers(int pid)
58 {
59 int err;
60
61 err = ptrace(PTRACE_GETREGS, pid, 0, exec_regs);
62 if(err)
63 panic("check_ptrace : PTRACE_GETREGS failed, errno = %d",
64 err);
65
66 err = ptrace(PTRACE_GETFPREGS, pid, 0, exec_fp_regs);
67 if(err)
68 panic("check_ptrace : PTRACE_GETFPREGS failed, errno = %d",
69 err);
70 }
71
72 /*
73 * Overrides for Emacs so that we follow Linus's tabbing style.
74 * Emacs will notice this stuff at the end of the file and automatically
75 * adjust the settings for this buffer only. This must remain at the end
76 * of the file.
77 * ---------------------------------------------------------------------------
78 * Local variables:
79 * c-file-style: "linux"
80 * End:
81 */