Commit 3cf0f4ec authored by Al Viro's avatar Al Viro Committed by Linus Torvalds

[PATCH] sh: task_pt_regs()

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 26ecbdea
...@@ -191,13 +191,8 @@ void flush_thread(void) ...@@ -191,13 +191,8 @@ void flush_thread(void)
{ {
#if defined(CONFIG_SH_FPU) #if defined(CONFIG_SH_FPU)
struct task_struct *tsk = current; struct task_struct *tsk = current;
struct pt_regs *regs = (struct pt_regs *)
((unsigned long)tsk->thread_info
+ THREAD_SIZE - sizeof(struct pt_regs)
- sizeof(unsigned long));
/* Forget lazy FPU state */ /* Forget lazy FPU state */
clear_fpu(tsk, regs); clear_fpu(tsk, task_pt_regs(tsk));
clear_used_math(); clear_used_math();
#endif #endif
} }
...@@ -232,13 +227,7 @@ int dump_task_regs(struct task_struct *tsk, elf_gregset_t *regs) ...@@ -232,13 +227,7 @@ int dump_task_regs(struct task_struct *tsk, elf_gregset_t *regs)
{ {
struct pt_regs ptregs; struct pt_regs ptregs;
ptregs = *(struct pt_regs *) ptregs = *task_pt_regs(tsk);
((unsigned long)tsk->thread_info + THREAD_SIZE
- sizeof(struct pt_regs)
#ifdef CONFIG_SH_DSP
- sizeof(struct pt_dspregs)
#endif
- sizeof(unsigned long));
elf_core_copy_regs(regs, &ptregs); elf_core_copy_regs(regs, &ptregs);
return 1; return 1;
...@@ -252,11 +241,7 @@ dump_task_fpu (struct task_struct *tsk, elf_fpregset_t *fpu) ...@@ -252,11 +241,7 @@ dump_task_fpu (struct task_struct *tsk, elf_fpregset_t *fpu)
#if defined(CONFIG_SH_FPU) #if defined(CONFIG_SH_FPU)
fpvalid = !!tsk_used_math(tsk); fpvalid = !!tsk_used_math(tsk);
if (fpvalid) { if (fpvalid) {
struct pt_regs *regs = (struct pt_regs *) unlazy_fpu(tsk, task_pt_regs(tsk));
((unsigned long)tsk->thread_info
+ THREAD_SIZE - sizeof(struct pt_regs)
- sizeof(unsigned long));
unlazy_fpu(tsk, regs);
memcpy(fpu, &tsk->thread.fpu.hard, sizeof(*fpu)); memcpy(fpu, &tsk->thread.fpu.hard, sizeof(*fpu));
} }
#endif #endif
...@@ -279,12 +264,7 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp, ...@@ -279,12 +264,7 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
copy_to_stopped_child_used_math(p); copy_to_stopped_child_used_math(p);
#endif #endif
childregs = ((struct pt_regs *) childregs = task_pt_regs(p);
(THREAD_SIZE + (unsigned long) p->thread_info)
#ifdef CONFIG_SH_DSP
- sizeof(struct pt_dspregs)
#endif
- sizeof(unsigned long)) - 1;
*childregs = *regs; *childregs = *regs;
if (user_mode(regs)) { if (user_mode(regs)) {
...@@ -333,11 +313,7 @@ ubc_set_tracing(int asid, unsigned long pc) ...@@ -333,11 +313,7 @@ ubc_set_tracing(int asid, unsigned long pc)
struct task_struct *__switch_to(struct task_struct *prev, struct task_struct *next) struct task_struct *__switch_to(struct task_struct *prev, struct task_struct *next)
{ {
#if defined(CONFIG_SH_FPU) #if defined(CONFIG_SH_FPU)
struct pt_regs *regs = (struct pt_regs *) unlazy_fpu(prev, task_pt_regs(prev));
((unsigned long)prev->thread_info
+ THREAD_SIZE - sizeof(struct pt_regs)
- sizeof(unsigned long));
unlazy_fpu(prev, regs);
#endif #endif
#ifdef CONFIG_PREEMPT #ifdef CONFIG_PREEMPT
...@@ -346,13 +322,7 @@ struct task_struct *__switch_to(struct task_struct *prev, struct task_struct *ne ...@@ -346,13 +322,7 @@ struct task_struct *__switch_to(struct task_struct *prev, struct task_struct *ne
struct pt_regs *regs; struct pt_regs *regs;
local_irq_save(flags); local_irq_save(flags);
regs = (struct pt_regs *) regs = task_pt_regs(prev);
((unsigned long)prev->thread_info
+ THREAD_SIZE - sizeof(struct pt_regs)
#ifdef CONFIG_SH_DSP
- sizeof(struct pt_dspregs)
#endif
- sizeof(unsigned long));
if (user_mode(regs) && regs->regs[15] >= 0xc0000000) { if (user_mode(regs) && regs->regs[15] >= 0xc0000000) {
int offset = (int)regs->regs[15]; int offset = (int)regs->regs[15];
......
...@@ -41,12 +41,7 @@ static inline int get_stack_long(struct task_struct *task, int offset) ...@@ -41,12 +41,7 @@ static inline int get_stack_long(struct task_struct *task, int offset)
{ {
unsigned char *stack; unsigned char *stack;
stack = (unsigned char *) stack = (unsigned char *)task_pt_regs(task);
task->thread_info + THREAD_SIZE - sizeof(struct pt_regs)
#ifdef CONFIG_SH_DSP
- sizeof(struct pt_dspregs)
#endif
- sizeof(unsigned long);
stack += offset; stack += offset;
return (*((int *)stack)); return (*((int *)stack));
} }
...@@ -59,12 +54,7 @@ static inline int put_stack_long(struct task_struct *task, int offset, ...@@ -59,12 +54,7 @@ static inline int put_stack_long(struct task_struct *task, int offset,
{ {
unsigned char *stack; unsigned char *stack;
stack = (unsigned char *) stack = (unsigned char *)task_pt_regs(task);
task->thread_info + THREAD_SIZE - sizeof(struct pt_regs)
#ifdef CONFIG_SH_DSP
- sizeof(struct pt_dspregs)
#endif
- sizeof(unsigned long);
stack += offset; stack += offset;
*(unsigned long *) stack = data; *(unsigned long *) stack = data;
return 0; return 0;
......
...@@ -91,6 +91,16 @@ struct pt_dspregs { ...@@ -91,6 +91,16 @@ struct pt_dspregs {
#define instruction_pointer(regs) ((regs)->pc) #define instruction_pointer(regs) ((regs)->pc)
extern void show_regs(struct pt_regs *); extern void show_regs(struct pt_regs *);
#ifdef CONFIG_SH_DSP
#define task_pt_regs(task) \
((struct pt_regs *) ((unsigned long)(task)->thread_info + THREAD_SIZE \
- sizeof(struct pt_dspregs) - sizeof(unsigned long)) - 1)
#else
#define task_pt_regs(task) \
((struct pt_regs *) ((unsigned long)(task)->thread_info + THREAD_SIZE \
- sizeof(unsigned long)) - 1)
#endif
static inline unsigned long profile_pc(struct pt_regs *regs) static inline unsigned long profile_pc(struct pt_regs *regs)
{ {
unsigned long pc = instruction_pointer(regs); unsigned long pc = instruction_pointer(regs);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment