2 * Copyright 2003 PathScale, Inc.
4 * Licensed under the GPL
7 #define __FRAME_OFFSETS
8 #include <asm/ptrace.h>
9 #include <linux/sched.h>
10 #include <linux/errno.h>
12 #include <asm/uaccess.h>
20 #define SC_SS(r) (not_ss)
21 #define SC_DS(r) (not_ds)
22 #define SC_ES(r) (not_es)
24 /* determines which flags the user has access to. */
25 /* 1 = access 0 = no access */
26 #define FLAG_MASK 0x44dd5UL
28 int putreg(struct task_struct *child, int regno, unsigned long value)
33 /* Some code in the 64bit emulation may not be 64bit clean.
34 Don't take any chances. */
35 if (test_tsk_thread_flag(child, TIF_IA32))
45 if (value && (value & 3) != 3)
52 if (!((value >> 48) == 0 || (value >> 48) == 0xffff))
58 tmp = PT_REGS_EFLAGS(&child->thread.regs) & ~FLAG_MASK;
63 PT_REGS_SET(&child->thread.regs, regno, value);
67 int poke_user(struct task_struct *child, long addr, long data)
69 if ((addr & 3) || addr < 0)
72 if (addr < MAX_REG_OFFSET)
73 return putreg(child, addr, data);
75 #if 0 /* Need x86_64 debugregs handling */
76 else if((addr >= offsetof(struct user, u_debugreg[0])) &&
77 (addr <= offsetof(struct user, u_debugreg[7]))){
78 addr -= offsetof(struct user, u_debugreg[0]);
80 if((addr == 4) || (addr == 5)) return -EIO;
81 child->thread.arch.debugregs[addr] = data;
88 unsigned long getreg(struct task_struct *child, int regno)
90 unsigned long retval = ~0UL;
101 retval &= PT_REG(&child->thread.regs, regno);
103 if (test_tsk_thread_flag(child, TIF_IA32))
104 retval &= 0xffffffff;
110 int peek_user(struct task_struct *child, long addr, long data)
112 /* read the word at location addr in the USER area. */
115 if ((addr & 3) || addr < 0)
118 tmp = 0; /* Default return condition */
119 if(addr < MAX_REG_OFFSET){
120 tmp = getreg(child, addr);
122 #if 0 /* Need x86_64 debugregs handling */
123 else if((addr >= offsetof(struct user, u_debugreg[0])) &&
124 (addr <= offsetof(struct user, u_debugreg[7]))){
125 addr -= offsetof(struct user, u_debugreg[0]);
127 tmp = child->thread.arch.debugregs[addr];
130 return put_user(tmp, (unsigned long *) data);
133 void arch_switch(void)
136 printk("arch_switch\n");
140 /* XXX Mostly copied from sys-i386 */
141 int is_syscall(unsigned long addr)
143 unsigned short instr;
146 n = copy_from_user(&instr, (void __user *) addr, sizeof(instr));
148 /* access_process_vm() grants access to vsyscall and stub,
149 * while copy_from_user doesn't. Maybe access_process_vm is
150 * slow, but that doesn't matter, since it will be called only
151 * in case of singlestepping, if copy_from_user failed.
153 n = access_process_vm(current, addr, &instr, sizeof(instr), 0);
154 if(n != sizeof(instr)) {
155 printk("is_syscall : failed to read instruction from "
161 return(instr == 0x050f);
164 int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu )
170 int get_fpregs(unsigned long buf, struct task_struct *child)
176 int set_fpregs(unsigned long buf, struct task_struct *child)
182 int get_fpxregs(unsigned long buf, struct task_struct *tsk)
184 panic("get_fpxregs");
188 int set_fpxregs(unsigned long buf, struct task_struct *tsk)
190 panic("set_fxpregs");
195 * Overrides for Emacs so that we follow Linus's tabbing style.
196 * Emacs will notice this stuff at the end of the file and automatically
197 * adjust the settings for this buffer only. This must remain at the end
199 * ---------------------------------------------------------------------------
201 * c-file-style: "linux"