reboot.c 1.5 KB

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