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>
11 #include <asm/uaccess.h>
19 #define SC_SS(r) (not_ss)
20 #define SC_DS(r) (not_ds)
21 #define SC_ES(r) (not_es)
23 /* determines which flags the user has access to. */
24 /* 1 = access 0 = no access */
25 #define FLAG_MASK 0x44dd5UL
27 int putreg(struct task_struct *child, int regno, unsigned long value)
32 /* Some code in the 64bit emulation may not be 64bit clean.
33 Don't take any chances. */
34 if (test_tsk_thread_flag(child, TIF_IA32))
44 if (value && (value & 3) != 3)
51 if (!((value >> 48) == 0 || (value >> 48) == 0xffff))
57 tmp = PT_REGS_EFLAGS(&child->thread.regs) & ~FLAG_MASK;
62 PT_REGS_SET(&child->thread.regs, regno, value);
66 int poke_user(struct task_struct *child, long addr, long data)
68 if ((addr & 3) || addr < 0)
71 if (addr < MAX_REG_OFFSET)
72 return putreg(child, addr, data);
74 #if 0 /* Need x86_64 debugregs handling */
75 else if((addr >= offsetof(struct user, u_debugreg[0])) &&
76 (addr <= offsetof(struct user, u_debugreg[7]))){
77 addr -= offsetof(struct user, u_debugreg[0]);
79 if((addr == 4) || (addr == 5)) return -EIO;
80 child->thread.arch.debugregs[addr] = data;
87 unsigned long getreg(struct task_struct *child, int regno)
89 unsigned long retval = ~0UL;
100 retval &= PT_REG(&child->thread.regs, regno);
102 if (test_tsk_thread_flag(child, TIF_IA32))
103 retval &= 0xffffffff;
109 int peek_user(struct task_struct *child, long addr, long data)
111 /* read the word at location addr in the USER area. */
114 if ((addr & 3) || addr < 0)
117 tmp = 0; /* Default return condition */
118 if(addr < MAX_REG_OFFSET){
119 tmp = getreg(child, addr);
121 #if 0 /* Need x86_64 debugregs handling */
122 else if((addr >= offsetof(struct user, u_debugreg[0])) &&
123 (addr <= offsetof(struct user, u_debugreg[7]))){
124 addr -= offsetof(struct user, u_debugreg[0]);
126 tmp = child->thread.arch.debugregs[addr];
129 return put_user(tmp, (unsigned long *) data);
132 void arch_switch(void)
135 printk("arch_switch\n");
139 int is_syscall(unsigned long addr)
144 int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu )
150 int get_fpregs(unsigned long buf, struct task_struct *child)
156 int set_fpregs(unsigned long buf, struct task_struct *child)
162 int get_fpxregs(unsigned long buf, struct task_struct *tsk)
164 panic("get_fpxregs");
168 int set_fpxregs(unsigned long buf, struct task_struct *tsk)
170 panic("set_fxpregs");
175 * Overrides for Emacs so that we follow Linus's tabbing style.
176 * Emacs will notice this stuff at the end of the file and automatically
177 * adjust the settings for this buffer only. This must remain at the end
179 * ---------------------------------------------------------------------------
181 * c-file-style: "linux"