ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / ppc / kernel / idle.c
1 /*
2  * Idle daemon for PowerPC.  Idle daemon will handle any action
3  * that needs to be taken when the system becomes idle.
4  *
5  * Written by Cort Dougan (cort@cs.nmt.edu).  Subsequently hacked
6  * on by Tom Rini, Armin Kuster, Paul Mackerras and others.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version
11  * 2 of the License, or (at your option) any later version.
12  */
13 #include <linux/config.h>
14 #include <linux/errno.h>
15 #include <linux/sched.h>
16 #include <linux/kernel.h>
17 #include <linux/mm.h>
18 #include <linux/smp.h>
19 #include <linux/smp_lock.h>
20 #include <linux/stddef.h>
21 #include <linux/unistd.h>
22 #include <linux/ptrace.h>
23 #include <linux/slab.h>
24
25 #include <asm/pgtable.h>
26 #include <asm/uaccess.h>
27 #include <asm/system.h>
28 #include <asm/io.h>
29 #include <asm/mmu.h>
30 #include <asm/cache.h>
31 #include <asm/cputable.h>
32 #include <asm/machdep.h>
33
34 void default_idle(void)
35 {
36         void (*powersave)(void);
37
38         powersave = ppc_md.power_save;
39
40         if (!need_resched()) {
41                 if (powersave != NULL)
42                         powersave();
43 #ifdef CONFIG_SMP
44                 else {
45                         set_thread_flag(TIF_POLLING_NRFLAG);
46                         while (!need_resched())
47                                 barrier();
48                         clear_thread_flag(TIF_POLLING_NRFLAG);
49                 }
50 #endif
51         }
52         if (need_resched())
53                 schedule();
54 }
55
56 /*
57  * The body of the idle task.
58  */
59 int cpu_idle(void)
60 {
61         for (;;)
62                 if (ppc_md.idle != NULL)
63                         ppc_md.idle();
64                 else
65                         default_idle();
66         return 0;
67 }