reboot.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. kmalloc_ok = 0;
  37. do_uml_exitcalls();
  38. kill_off_processes();
  39. }
  40. void machine_restart(char * __unused)
  41. {
  42. uml_cleanup();
  43. CHOOSE_MODE(reboot_tt(), reboot_skas());
  44. }
  45. void machine_power_off(void)
  46. {
  47. uml_cleanup();
  48. CHOOSE_MODE(halt_tt(), halt_skas());
  49. }
  50. void machine_halt(void)
  51. {
  52. machine_power_off();
  53. }
  54. /*
  55. * Overrides for Emacs so that we follow Linus's tabbing style.
  56. * Emacs will notice this stuff at the end of the file and automatically
  57. * adjust the settings for this buffer only. This must remain at the end
  58. * of the file.
  59. * ---------------------------------------------------------------------------
  60. * Local variables:
  61. * c-file-style: "linux"
  62. * End:
  63. */