ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / um / kernel / reboot.c
1 /* 
2  * Copyright (C) 2000, 2002 Jeff Dike (jdike@karaya.com)
3  * Licensed under the GPL
4  */
5
6 #include "linux/module.h"
7 #include "linux/sched.h"
8 #include "user_util.h"
9 #include "kern_util.h"
10 #include "kern.h"
11 #include "os.h"
12 #include "mode.h"
13 #include "choose-mode.h"
14
15 #ifdef CONFIG_SMP
16 static void kill_idlers(int me)
17 {
18         struct task_struct *p;
19         int i;
20
21         for(i = 0; i < sizeof(idle_threads)/sizeof(idle_threads[0]); i++){
22                 p = idle_threads[i];
23                 if((p != NULL) && (p->thread.mode.tt.extern_pid != me))
24                         os_kill_process(p->thread.mode.tt.extern_pid, 0);
25         }
26 }
27 #endif
28
29 static void kill_off_processes(void)
30 {
31         CHOOSE_MODE(kill_off_processes_tt(), kill_off_processes_skas());
32 #ifdef CONFIG_SMP
33         kill_idlers(os_getpid());
34 #endif
35 }
36
37 void uml_cleanup(void)
38 {
39         kill_off_processes();
40         do_uml_exitcalls();
41 }
42
43 void machine_restart(char * __unused)
44 {
45         do_uml_exitcalls();
46         kill_off_processes();
47         CHOOSE_MODE(reboot_tt(), reboot_skas());
48 }
49
50 EXPORT_SYMBOL(machine_restart);
51
52 void machine_power_off(void)
53 {
54         do_uml_exitcalls();
55         kill_off_processes();
56         CHOOSE_MODE(halt_tt(), halt_skas());
57 }
58
59 EXPORT_SYMBOL(machine_power_off);
60
61 void machine_halt(void)
62 {
63         machine_power_off();
64 }
65
66 EXPORT_SYMBOL(machine_halt);
67
68 /*
69  * Overrides for Emacs so that we follow Linus's tabbing style.
70  * Emacs will notice this stuff at the end of the file and automatically
71  * adjust the settings for this buffer only.  This must remain at the end
72  * of the file.
73  * ---------------------------------------------------------------------------
74  * Local variables:
75  * c-file-style: "linux"
76  * End:
77  */