reboot.c 937 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 "skas.h"
  12. void (*pm_power_off)(void);
  13. static void kill_off_processes(void)
  14. {
  15. if(proc_mm)
  16. /*
  17. * FIXME: need to loop over userspace_pids
  18. */
  19. os_kill_ptraced_process(userspace_pid[0], 1);
  20. else {
  21. struct task_struct *p;
  22. int pid, me;
  23. me = os_getpid();
  24. for_each_process(p){
  25. if(p->mm == NULL)
  26. continue;
  27. pid = p->mm->context.skas.id.u.pid;
  28. os_kill_ptraced_process(pid, 1);
  29. }
  30. }
  31. }
  32. void uml_cleanup(void)
  33. {
  34. kmalloc_ok = 0;
  35. do_uml_exitcalls();
  36. kill_off_processes();
  37. }
  38. void machine_restart(char * __unused)
  39. {
  40. uml_cleanup();
  41. reboot_skas();
  42. }
  43. void machine_power_off(void)
  44. {
  45. uml_cleanup();
  46. halt_skas();
  47. }
  48. void machine_halt(void)
  49. {
  50. machine_power_off();
  51. }