Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Eric W. Biederman | 5e38291 | 2006-01-08 01:03:46 -0800 | [diff] [blame^] | 15 | void (*pm_power_off)(void); |
| 16 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #ifdef CONFIG_SMP |
| 18 | static void kill_idlers(int me) |
| 19 | { |
| 20 | #ifdef CONFIG_MODE_TT |
| 21 | struct task_struct *p; |
| 22 | int i; |
| 23 | |
| 24 | for(i = 0; i < sizeof(idle_threads)/sizeof(idle_threads[0]); i++){ |
| 25 | p = idle_threads[i]; |
| 26 | if((p != NULL) && (p->thread.mode.tt.extern_pid != me)) |
| 27 | os_kill_process(p->thread.mode.tt.extern_pid, 0); |
| 28 | } |
| 29 | #endif |
| 30 | } |
| 31 | #endif |
| 32 | |
| 33 | static void kill_off_processes(void) |
| 34 | { |
| 35 | CHOOSE_MODE(kill_off_processes_tt(), kill_off_processes_skas()); |
| 36 | #ifdef CONFIG_SMP |
| 37 | kill_idlers(os_getpid()); |
| 38 | #endif |
| 39 | } |
| 40 | |
| 41 | void uml_cleanup(void) |
| 42 | { |
Jeff Dike | 026549d | 2005-06-25 14:55:23 -0700 | [diff] [blame] | 43 | kmalloc_ok = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | do_uml_exitcalls(); |
Jeff Dike | 026549d | 2005-06-25 14:55:23 -0700 | [diff] [blame] | 45 | kill_off_processes(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | void machine_restart(char * __unused) |
| 49 | { |
Jeff Dike | 026549d | 2005-06-25 14:55:23 -0700 | [diff] [blame] | 50 | uml_cleanup(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | CHOOSE_MODE(reboot_tt(), reboot_skas()); |
| 52 | } |
| 53 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | void machine_power_off(void) |
| 55 | { |
Jeff Dike | 026549d | 2005-06-25 14:55:23 -0700 | [diff] [blame] | 56 | uml_cleanup(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | CHOOSE_MODE(halt_tt(), halt_skas()); |
| 58 | } |
| 59 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | void machine_halt(void) |
| 61 | { |
| 62 | machine_power_off(); |
| 63 | } |
| 64 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | /* |
| 66 | * Overrides for Emacs so that we follow Linus's tabbing style. |
| 67 | * Emacs will notice this stuff at the end of the file and automatically |
| 68 | * adjust the settings for this buffer only. This must remain at the end |
| 69 | * of the file. |
| 70 | * --------------------------------------------------------------------------- |
| 71 | * Local variables: |
| 72 | * c-file-style: "linux" |
| 73 | * End: |
| 74 | */ |