blob: 3ef73bf2e781a79dbd039c623fc20c3dd3f289d5 [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"
Paolo 'Blaisorblade' Giarrusso72e55252006-02-01 03:06:29 -08008#include "asm/smp.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#include "user_util.h"
10#include "kern_util.h"
11#include "kern.h"
12#include "os.h"
13#include "mode.h"
14#include "choose-mode.h"
15
Eric W. Biederman5e382912006-01-08 01:03:46 -080016void (*pm_power_off)(void);
17
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#ifdef CONFIG_SMP
19static void kill_idlers(int me)
20{
21#ifdef CONFIG_MODE_TT
22 struct task_struct *p;
23 int i;
24
25 for(i = 0; i < sizeof(idle_threads)/sizeof(idle_threads[0]); i++){
26 p = idle_threads[i];
27 if((p != NULL) && (p->thread.mode.tt.extern_pid != me))
28 os_kill_process(p->thread.mode.tt.extern_pid, 0);
29 }
30#endif
31}
32#endif
33
34static void kill_off_processes(void)
35{
36 CHOOSE_MODE(kill_off_processes_tt(), kill_off_processes_skas());
37#ifdef CONFIG_SMP
38 kill_idlers(os_getpid());
39#endif
40}
41
42void uml_cleanup(void)
43{
Jeff Dike026549d2005-06-25 14:55:23 -070044 kmalloc_ok = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 do_uml_exitcalls();
Jeff Dike026549d2005-06-25 14:55:23 -070046 kill_off_processes();
Linus Torvalds1da177e2005-04-16 15:20:36 -070047}
48
49void machine_restart(char * __unused)
50{
Jeff Dike026549d2005-06-25 14:55:23 -070051 uml_cleanup();
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 CHOOSE_MODE(reboot_tt(), reboot_skas());
53}
54
Linus Torvalds1da177e2005-04-16 15:20:36 -070055void machine_power_off(void)
56{
Jeff Dike026549d2005-06-25 14:55:23 -070057 uml_cleanup();
Linus Torvalds1da177e2005-04-16 15:20:36 -070058 CHOOSE_MODE(halt_tt(), halt_skas());
59}
60
Linus Torvalds1da177e2005-04-16 15:20:36 -070061void machine_halt(void)
62{
63 machine_power_off();
64}
65
Linus Torvalds1da177e2005-04-16 15:20:36 -070066/*
67 * Overrides for Emacs so that we follow Linus's tabbing style.
68 * Emacs will notice this stuff at the end of the file and automatically
69 * adjust the settings for this buffer only. This must remain at the end
70 * of the file.
71 * ---------------------------------------------------------------------------
72 * Local variables:
73 * c-file-style: "linux"
74 * End:
75 */