2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2004 PathScale, Inc
|
2007-10-16 08:27:18 +00:00
|
|
|
* Copyright (C) 2004 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
|
2005-04-16 22:20:36 +00:00
|
|
|
* Licensed under the GPL
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <errno.h>
|
2007-10-16 08:27:18 +00:00
|
|
|
#include "kern_constants.h"
|
2006-09-26 06:32:59 +00:00
|
|
|
#include "longjmp.h"
|
2005-04-16 22:20:36 +00:00
|
|
|
#include "user.h"
|
2007-10-16 08:27:18 +00:00
|
|
|
#include "sysdep/ptrace_user.h"
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
int save_fp_registers(int pid, unsigned long *fp_regs)
|
|
|
|
{
|
2007-10-16 08:27:18 +00:00
|
|
|
if (ptrace(PTRACE_GETFPREGS, pid, 0, fp_regs) < 0)
|
2007-02-10 09:44:26 +00:00
|
|
|
return -errno;
|
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int restore_fp_registers(int pid, unsigned long *fp_regs)
|
|
|
|
{
|
2007-10-16 08:27:18 +00:00
|
|
|
if (ptrace(PTRACE_SETFPREGS, pid, 0, fp_regs) < 0)
|
2007-02-10 09:44:26 +00:00
|
|
|
return -errno;
|
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2007-10-16 08:27:15 +00:00
|
|
|
int save_fpx_registers(int pid, unsigned long *fp_regs)
|
|
|
|
{
|
2007-10-16 08:27:18 +00:00
|
|
|
if (ptrace(PTRACE_GETFPXREGS, pid, 0, fp_regs) < 0)
|
2007-10-16 08:27:15 +00:00
|
|
|
return -errno;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int restore_fpx_registers(int pid, unsigned long *fp_regs)
|
|
|
|
{
|
2007-10-16 08:27:18 +00:00
|
|
|
if (ptrace(PTRACE_SETFPXREGS, pid, 0, fp_regs) < 0)
|
2007-10-16 08:27:15 +00:00
|
|
|
return -errno;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-09-26 06:33:08 +00:00
|
|
|
unsigned long get_thread_reg(int reg, jmp_buf *buf)
|
2005-10-04 18:53:52 +00:00
|
|
|
{
|
2007-10-16 08:27:18 +00:00
|
|
|
switch (reg) {
|
|
|
|
case EIP:
|
|
|
|
return buf[0]->__eip;
|
|
|
|
case UESP:
|
|
|
|
return buf[0]->__esp;
|
|
|
|
case EBP:
|
|
|
|
return buf[0]->__ebp;
|
2006-09-26 06:33:08 +00:00
|
|
|
default:
|
2007-10-16 08:27:18 +00:00
|
|
|
printk(UM_KERN_ERR "get_thread_regs - unknown register %d\n",
|
|
|
|
reg);
|
2006-09-26 06:33:08 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2005-10-04 18:53:52 +00:00
|
|
|
}
|
2007-10-16 08:27:15 +00:00
|
|
|
|
|
|
|
int have_fpx_regs = 1;
|
|
|
|
|
|
|
|
void arch_init_registers(int pid)
|
|
|
|
{
|
|
|
|
unsigned long fpx_regs[HOST_XFP_SIZE];
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = ptrace(PTRACE_GETFPXREGS, pid, 0, fpx_regs);
|
|
|
|
if(!err)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if(errno != EIO)
|
|
|
|
panic("check_ptrace : PTRACE_GETFPXREGS failed, errno = %d",
|
|
|
|
errno);
|
|
|
|
|
|
|
|
have_fpx_regs = 0;
|
|
|
|
}
|