reboot.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 "asm/smp.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 < ARRAY_SIZE(idle_threads); 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. }