Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[linux-2.6] / arch / um / kernel / reboot.c
1 /* 
2  * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3  * Licensed under the GPL
4  */
5
6 #include "linux/sched.h"
7 #include "os.h"
8 #include "skas.h"
9
10 void (*pm_power_off)(void);
11
12 static void kill_off_processes(void)
13 {
14         if(proc_mm)
15                 /*
16                  * FIXME: need to loop over userspace_pids
17                  */
18                 os_kill_ptraced_process(userspace_pid[0], 1);
19         else {
20                 struct task_struct *p;
21                 int pid, me;
22
23                 me = os_getpid();
24                 for_each_process(p){
25                         if(p->mm == NULL)
26                                 continue;
27
28                         pid = p->mm->context.id.u.pid;
29                         os_kill_ptraced_process(pid, 1);
30                 }
31         }
32 }
33
34 void uml_cleanup(void)
35 {
36         kmalloc_ok = 0;
37         do_uml_exitcalls();
38         kill_off_processes();
39 }
40
41 void machine_restart(char * __unused)
42 {
43         uml_cleanup();
44         reboot_skas();
45 }
46
47 void machine_power_off(void)
48 {
49         uml_cleanup();
50         halt_skas();
51 }
52
53 void machine_halt(void)
54 {
55         machine_power_off();
56 }