include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / arch / avr32 / kernel / process.c
index 4e4181e..2d76515 100644 (file)
@@ -9,18 +9,22 @@
 #include <linux/module.h>
 #include <linux/kallsyms.h>
 #include <linux/fs.h>
+#include <linux/pm.h>
 #include <linux/ptrace.h>
+#include <linux/slab.h>
 #include <linux/reboot.h>
+#include <linux/tick.h>
 #include <linux/uaccess.h>
 #include <linux/unistd.h>
 
 #include <asm/sysreg.h>
 #include <asm/ocd.h>
+#include <asm/syscalls.h>
 
-void (*pm_power_off)(void) = NULL;
-EXPORT_SYMBOL(pm_power_off);
+#include <mach/pm.h>
 
-extern void cpu_idle_sleep(void);
+void (*pm_power_off)(void);
+EXPORT_SYMBOL(pm_power_off);
 
 /*
  * This file handles the architecture-dependent parts of process handling..
@@ -30,8 +34,10 @@ void cpu_idle(void)
 {
        /* endless idle loop with no priority at all */
        while (1) {
+               tick_nohz_stop_sched_tick(1);
                while (!need_resched())
                        cpu_idle_sleep();
+               tick_nohz_restart_sched_tick();
                preempt_enable_no_resched();
                schedule();
                preempt_disable();
@@ -51,12 +57,14 @@ void machine_halt(void)
 
 void machine_power_off(void)
 {
+       if (pm_power_off)
+               pm_power_off();
 }
 
 void machine_restart(char *cmd)
 {
-       __mtdr(DBGREG_DC, DC_DBE);
-       __mtdr(DBGREG_DC, DC_RES);
+       ocd_write(DC, (1 << OCD_DC_DBE_BIT));
+       ocd_write(DC, (1 << OCD_DC_RES_BIT));
        while (1) ;
 }
 
@@ -103,7 +111,7 @@ EXPORT_SYMBOL(kernel_thread);
  */
 void exit_thread(void)
 {
-       /* nothing to do */
+       ocd_disable(current);
 }
 
 void flush_thread(void)
@@ -287,10 +295,11 @@ void show_regs_log_lvl(struct pt_regs *regs, const char *log_lvl)
               regs->sr & SR_N ? 'N' : 'n',
               regs->sr & SR_Z ? 'Z' : 'z',
               regs->sr & SR_C ? 'C' : 'c');
-       printk("%sMode bits: %c%c%c%c%c%c%c%c%c\n", log_lvl,
+       printk("%sMode bits: %c%c%c%c%c%c%c%c%c%c\n", log_lvl,
               regs->sr & SR_H ? 'H' : 'h',
-              regs->sr & SR_R ? 'R' : 'r',
               regs->sr & SR_J ? 'J' : 'j',
+              regs->sr & SR_DM ? 'M' : 'm',
+              regs->sr & SR_D ? 'D' : 'd',
               regs->sr & SR_EM ? 'E' : 'e',
               regs->sr & SR_I3M ? '3' : '.',
               regs->sr & SR_I2M ? '2' : '.',
@@ -324,19 +333,19 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
 
 asmlinkage void ret_from_fork(void);
 
-int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
+int copy_thread(unsigned long clone_flags, unsigned long usp,
                unsigned long unused,
                struct task_struct *p, struct pt_regs *regs)
 {
        struct pt_regs *childregs;
 
-       childregs = ((struct pt_regs *)(THREAD_SIZE + (unsigned long)p->thread_info)) - 1;
+       childregs = ((struct pt_regs *)(THREAD_SIZE + (unsigned long)task_stack_page(p))) - 1;
        *childregs = *regs;
 
        if (user_mode(regs))
                childregs->sp = usp;
        else
-               childregs->sp = (unsigned long)p->thread_info + THREAD_SIZE;
+               childregs->sp = (unsigned long)task_stack_page(p) + THREAD_SIZE;
 
        childregs->r12 = 0; /* Set return value for child */
 
@@ -344,6 +353,10 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
        p->thread.cpu_context.ksp = (unsigned long)childregs;
        p->thread.cpu_context.pc = (unsigned long)ret_from_fork;
 
+       clear_tsk_thread_flag(p, TIF_DEBUG);
+       if ((clone_flags & CLONE_PTRACE) && test_thread_flag(TIF_DEBUG))
+               ocd_enable(p);
+
        return 0;
 }
 
@@ -382,8 +395,6 @@ asmlinkage int sys_execve(char __user *ufilename, char __user *__user *uargv,
                goto out;
 
        error = do_execve(filename, uargv, uenvp, regs);
-       if (error == 0)
-               current->ptrace &= ~PT_DTRACE;
        putname(filename);
 
 out:
@@ -403,7 +414,7 @@ unsigned long get_wchan(struct task_struct *p)
        if (!p || p == current || p->state == TASK_RUNNING)
                return 0;
 
-       stack_page = (unsigned long)p->thread_info;
+       stack_page = (unsigned long)task_stack_page(p);
        BUG_ON(!stack_page);
 
        /*