2 * Copyright (C) 2004 PathScale, Inc
3 * Licensed under the GPL
8 #include "sysdep/ptrace_user.h"
9 #include "sysdep/ptrace.h"
10 #include "uml-config.h"
11 #include "skas_ptregs.h"
12 #include "registers.h"
15 /* These are set once at boot time and not changed thereafter */
17 static unsigned long exec_regs[HOST_FRAME_SIZE];
18 static unsigned long exec_fp_regs[HOST_FP_SIZE];
19 static unsigned long exec_fpx_regs[HOST_XFP_SIZE];
20 static int have_fpx_regs = 1;
22 void init_thread_registers(union uml_pt_regs *to)
24 memcpy(to->skas.regs, exec_regs, sizeof(to->skas.regs));
25 memcpy(to->skas.fp, exec_fp_regs, sizeof(to->skas.fp));
27 memcpy(to->skas.xfp, exec_fpx_regs, sizeof(to->skas.xfp));
30 /* XXX These need to use [GS]ETFPXREGS and copy_sc_{to,from}_user_skas needs
31 * to pass in a sufficiently large buffer
33 int save_fp_registers(int pid, unsigned long *fp_regs)
35 if(ptrace(PTRACE_GETFPREGS, pid, 0, fp_regs) < 0)
40 int restore_fp_registers(int pid, unsigned long *fp_regs)
42 if(ptrace(PTRACE_SETFPREGS, pid, 0, fp_regs) < 0)
47 static int move_registers(int pid, int int_op, union uml_pt_regs *regs,
48 int fp_op, unsigned long *fp_regs)
50 if(ptrace(int_op, pid, 0, regs->skas.regs) < 0)
53 if(ptrace(fp_op, pid, 0, fp_regs) < 0)
59 void save_registers(int pid, union uml_pt_regs *regs)
61 unsigned long *fp_regs;
65 fp_op = PTRACE_GETFPXREGS;
66 fp_regs = regs->skas.xfp;
69 fp_op = PTRACE_GETFPREGS;
70 fp_regs = regs->skas.fp;
73 err = move_registers(pid, PTRACE_GETREGS, regs, fp_op, fp_regs);
75 panic("save_registers - saving registers failed, errno = %d\n",
79 void restore_registers(int pid, union uml_pt_regs *regs)
81 unsigned long *fp_regs;
85 fp_op = PTRACE_SETFPXREGS;
86 fp_regs = regs->skas.xfp;
89 fp_op = PTRACE_SETFPREGS;
90 fp_regs = regs->skas.fp;
93 err = move_registers(pid, PTRACE_SETREGS, regs, fp_op, fp_regs);
95 panic("restore_registers - saving registers failed, "
96 "errno = %d\n", -err);
99 void init_registers(int pid)
103 err = ptrace(PTRACE_GETREGS, pid, 0, exec_regs);
105 panic("check_ptrace : PTRACE_GETREGS failed, errno = %d",
108 err = ptrace(PTRACE_GETFPXREGS, pid, 0, exec_fpx_regs);
114 panic("check_ptrace : PTRACE_GETFPXREGS failed, errno = %d",
117 err = ptrace(PTRACE_GETFPREGS, pid, 0, exec_fp_regs);
119 panic("check_ptrace : PTRACE_GETFPREGS failed, errno = %d",
124 * Overrides for Emacs so that we follow Linus's tabbing style.
125 * Emacs will notice this stuff at the end of the file and automatically
126 * adjust the settings for this buffer only. This must remain at the end
128 * ---------------------------------------------------------------------------
130 * c-file-style: "linux"