X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=arch%2Fsh%2Fkernel%2Fprocess.c;h=22dc9c21201da2b3fa212aa0dac8ee0a574a8774;hb=9464c7cf61b9433057924c36e6e02f303a00e768;hp=c9a43c8df32fb461cb3281238064283bbc2f676e;hpb=ec9397bab20a628530ce3051167d3d0fcc2c1af7;p=linux-2.6.git diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c index c9a43c8df..22dc9c212 100644 --- a/arch/sh/kernel/process.c +++ b/arch/sh/kernel/process.c @@ -15,21 +15,17 @@ #include #include #include -#include #include +#include +#include #include -#include #include +#include #include #include #include #include -#if defined(CONFIG_SH_HS7751RVOIP) -#include -#elif defined(CONFIG_SH_RTS7751R2D) -#include -#endif static int hlt_counter=0; @@ -37,6 +33,11 @@ int ubc_usercnt = 0; #define HARD_IDLE_TIMEOUT (HZ / 3) +void (*pm_idle)(void); + +void (*pm_power_off)(void); +EXPORT_SYMBOL(pm_power_off); + void disable_hlt(void) { hlt_counter++; @@ -52,66 +53,62 @@ void enable_hlt(void) EXPORT_SYMBOL(enable_hlt); void default_idle(void) +{ + if (!hlt_counter) + cpu_sleep(); + else + cpu_relax(); +} + +void cpu_idle(void) { /* endless idle loop with no priority at all */ while (1) { - if (hlt_counter) { - while (1) - if (need_resched()) - break; - } else { - while (!need_resched()) - cpu_sleep(); - } + void (*idle)(void) = pm_idle; + + if (!idle) + idle = default_idle; + + while (!need_resched()) + idle(); + preempt_enable_no_resched(); schedule(); + preempt_disable(); } } -void cpu_idle(void *unused) -{ - default_idle(); -} - void machine_restart(char * __unused) { + +#ifdef CONFIG_KEXEC + struct kimage *image; + image = xchg(&kexec_image, 0); + if (image) { + machine_shutdown(); + machine_kexec(image); + } +#endif + /* SR.BL=1 and invoke address error to let CPU reset (manual reset) */ asm volatile("ldc %0, sr\n\t" "mov.l @%1, %0" : : "r" (0x10000000), "r" (0x80000001)); } -EXPORT_SYMBOL(machine_restart); - void machine_halt(void) { -#if defined(CONFIG_SH_HS7751RVOIP) - unsigned short value; + local_irq_disable(); - value = ctrl_inw(PA_OUTPORTR); - ctrl_outw((value & 0xffdf), PA_OUTPORTR); -#elif defined(CONFIG_SH_RTS7751R2D) - ctrl_outw(0x0001, PA_POWOFF); -#endif while (1) cpu_sleep(); } -EXPORT_SYMBOL(machine_halt); - void machine_power_off(void) { -#if defined(CONFIG_SH_HS7751RVOIP) - unsigned short value; - - value = ctrl_inw(PA_OUTPORTR); - ctrl_outw((value & 0xffdf), PA_OUTPORTR); -#elif defined(CONFIG_SH_RTS7751R2D) - ctrl_outw(0x0001, PA_POWOFF); -#endif + if (pm_power_off) + pm_power_off(); } -EXPORT_SYMBOL(machine_power_off); - void show_regs(struct pt_regs * regs) { printk("\n"); @@ -199,16 +196,11 @@ void exit_thread(void) void flush_thread(void) { -#if defined(CONFIG_CPU_SH4) +#if defined(CONFIG_SH_FPU) 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 */ - clear_fpu(tsk, regs); - tsk->used_math = 0; + clear_fpu(tsk, task_pt_regs(tsk)); + clear_used_math(); #endif } @@ -222,10 +214,10 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu) { int fpvalid = 0; -#if defined(CONFIG_CPU_SH4) +#if defined(CONFIG_SH_FPU) struct task_struct *tsk = current; - fpvalid = tsk->used_math; + fpvalid = !!tsk_used_math(tsk); if (fpvalid) { unlazy_fpu(tsk, regs); memcpy(fpu, &tsk->thread.fpu.hard, sizeof(*fpu)); @@ -242,13 +234,7 @@ int dump_task_regs(struct task_struct *tsk, elf_gregset_t *regs) { struct pt_regs ptregs; - ptregs = *(struct pt_regs *) - ((unsigned long)tsk->thread_info + THREAD_SIZE - - sizeof(struct pt_regs) -#ifdef CONFIG_SH_DSP - - sizeof(struct pt_dspregs) -#endif - - sizeof(unsigned long)); + ptregs = *task_pt_regs(tsk); elf_core_copy_regs(regs, &ptregs); return 1; @@ -259,14 +245,10 @@ dump_task_fpu (struct task_struct *tsk, elf_fpregset_t *fpu) { int fpvalid = 0; -#if defined(CONFIG_CPU_SH4) - fpvalid = tsk->used_math; +#if defined(CONFIG_SH_FPU) + fpvalid = !!tsk_used_math(tsk); if (fpvalid) { - struct pt_regs *regs = (struct pt_regs *) - ((unsigned long)tsk->thread_info - + THREAD_SIZE - sizeof(struct pt_regs) - - sizeof(unsigned long)); - unlazy_fpu(tsk, regs); + unlazy_fpu(tsk, task_pt_regs(tsk)); memcpy(fpu, &tsk->thread.fpu.hard, sizeof(*fpu)); } #endif @@ -281,32 +263,26 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp, struct task_struct *p, struct pt_regs *regs) { struct pt_regs *childregs; -#if defined(CONFIG_CPU_SH4) +#if defined(CONFIG_SH_FPU) struct task_struct *tsk = current; unlazy_fpu(tsk, regs); p->thread.fpu = tsk->thread.fpu; - p->used_math = tsk->used_math; + copy_to_stopped_child_used_math(p); #endif - childregs = ((struct pt_regs *) - (THREAD_SIZE + (unsigned long) p->thread_info) -#ifdef CONFIG_SH_DSP - - sizeof(struct pt_dspregs) -#endif - - sizeof(unsigned long)) - 1; + childregs = task_pt_regs(p); *childregs = *regs; if (user_mode(regs)) { childregs->regs[15] = usp; } else { - childregs->regs[15] = (unsigned long)p->thread_info + THREAD_SIZE; + childregs->regs[15] = (unsigned long)task_stack_page(p) + THREAD_SIZE; } if (clone_flags & CLONE_SETTLS) { childregs->gbr = childregs->regs[0]; } childregs->regs[0] = 0; /* Set return value for child */ - p->set_child_tid = p->clear_child_tid = NULL; p->thread.sp = (unsigned long) childregs; p->thread.pc = (unsigned long) ret_from_fork; @@ -316,26 +292,6 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp, return 0; } -/* - * fill in the user structure for a core dump.. - */ -void dump_thread(struct pt_regs * regs, struct user * dump) -{ - dump->magic = CMAGIC; - dump->start_code = current->mm->start_code; - dump->start_data = current->mm->start_data; - dump->start_stack = regs->regs[15] & ~(PAGE_SIZE - 1); - dump->u_tsize = (current->mm->end_code - dump->start_code) >> PAGE_SHIFT; - dump->u_dsize = (current->mm->brk + (PAGE_SIZE-1) - dump->start_data) >> PAGE_SHIFT; - dump->u_ssize = (current->mm->start_stack - dump->start_stack + - PAGE_SIZE - 1) >> PAGE_SHIFT; - /* Debug registers will come here. */ - - dump->regs = *regs; - - dump->u_fpvalid = dump_fpu(regs, &dump->fpu); -} - /* Tracing by user break controller. */ static void ubc_set_tracing(int asid, unsigned long pc) @@ -363,12 +319,8 @@ ubc_set_tracing(int asid, unsigned long pc) */ struct task_struct *__switch_to(struct task_struct *prev, struct task_struct *next) { -#if defined(CONFIG_CPU_SH4) - struct pt_regs *regs = (struct pt_regs *) - ((unsigned long)prev->thread_info - + THREAD_SIZE - sizeof(struct pt_regs) - - sizeof(unsigned long)); - unlazy_fpu(prev, regs); +#if defined(CONFIG_SH_FPU) + unlazy_fpu(prev, task_pt_regs(prev)); #endif #ifdef CONFIG_PREEMPT @@ -377,13 +329,7 @@ struct task_struct *__switch_to(struct task_struct *prev, struct task_struct *ne struct pt_regs *regs; local_irq_save(flags); - regs = (struct pt_regs *) - ((unsigned long)prev->thread_info - + THREAD_SIZE - sizeof(struct pt_regs) -#ifdef CONFIG_SH_DSP - - sizeof(struct pt_dspregs) -#endif - - sizeof(unsigned long)); + regs = task_pt_regs(prev); if (user_mode(regs) && regs->regs[15] >= 0xc0000000) { int offset = (int)regs->regs[15]; @@ -403,7 +349,7 @@ struct task_struct *__switch_to(struct task_struct *prev, struct task_struct *ne */ asm volatile("ldc %0, r7_bank" : /* no output */ - : "r" (next->thread_info)); + : "r" (task_thread_info(next))); #ifdef CONFIG_MMU /* If no tasks are using the UBC, we're done */ @@ -481,8 +427,11 @@ asmlinkage int sys_execve(char *ufilename, char **uargv, (char __user * __user *)uargv, (char __user * __user *)uenvp, ®s); - if (error == 0) + if (error == 0) { + task_lock(current); current->ptrace &= ~PT_DTRACE; + task_unlock(current); + } putname(filename); out: return error;