reboot.c 1.6 KB

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