blob: fcec51da1d3771abe84944ca1138853417df6bec [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
16static void kill_idlers(int me)
17{
18#ifdef CONFIG_MODE_TT
19 struct task_struct *p;
20 int i;
21
22 for(i = 0; i < sizeof(idle_threads)/sizeof(idle_threads[0]); i++){
23 p = idle_threads[i];
24 if((p != NULL) && (p->thread.mode.tt.extern_pid != me))
25 os_kill_process(p->thread.mode.tt.extern_pid, 0);
26 }
27#endif
28}
29#endif
30
31static void kill_off_processes(void)
32{
33 CHOOSE_MODE(kill_off_processes_tt(), kill_off_processes_skas());
34#ifdef CONFIG_SMP
35 kill_idlers(os_getpid());
36#endif
37}
38
39void uml_cleanup(void)
40{
Jeff Dike026549d2005-06-25 14:55:23 -070041 kmalloc_ok = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 do_uml_exitcalls();
Jeff Dike026549d2005-06-25 14:55:23 -070043 kill_off_processes();
Linus Torvalds1da177e2005-04-16 15:20:36 -070044}
45
46void machine_restart(char * __unused)
47{
Jeff Dike026549d2005-06-25 14:55:23 -070048 uml_cleanup();
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 CHOOSE_MODE(reboot_tt(), reboot_skas());
50}
51
52EXPORT_SYMBOL(machine_restart);
53
54void machine_power_off(void)
55{
Jeff Dike026549d2005-06-25 14:55:23 -070056 uml_cleanup();
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 CHOOSE_MODE(halt_tt(), halt_skas());
58}
59
60EXPORT_SYMBOL(machine_power_off);
61
62void machine_halt(void)
63{
64 machine_power_off();
65}
66
67EXPORT_SYMBOL(machine_halt);
68
69/*
70 * Overrides for Emacs so that we follow Linus's tabbing style.
71 * Emacs will notice this stuff at the end of the file and automatically
72 * adjust the settings for this buffer only. This must remain at the end
73 * of the file.
74 * ---------------------------------------------------------------------------
75 * Local variables:
76 * c-file-style: "linux"
77 * End:
78 */