reboot.c 1.5 KB

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