reboot.c 897 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  3. * Licensed under the GPL
  4. */
  5. #include <linux/sched.h>
  6. #include <linux/spinlock.h>
  7. #include <linux/slab.h>
  8. #include <linux/oom.h>
  9. #include <kern_util.h>
  10. #include <os.h>
  11. #include <skas.h>
  12. void (*pm_power_off)(void);
  13. static void kill_off_processes(void)
  14. {
  15. struct task_struct *p;
  16. int pid;
  17. read_lock(&tasklist_lock);
  18. for_each_process(p) {
  19. struct task_struct *t;
  20. t = find_lock_task_mm(p);
  21. if (!t)
  22. continue;
  23. pid = t->mm->context.id.u.pid;
  24. task_unlock(t);
  25. os_kill_ptraced_process(pid, 1);
  26. }
  27. read_unlock(&tasklist_lock);
  28. }
  29. void uml_cleanup(void)
  30. {
  31. kmalloc_ok = 0;
  32. do_uml_exitcalls();
  33. kill_off_processes();
  34. }
  35. void machine_restart(char * __unused)
  36. {
  37. uml_cleanup();
  38. reboot_skas();
  39. }
  40. void machine_power_off(void)
  41. {
  42. uml_cleanup();
  43. halt_skas();
  44. }
  45. void machine_halt(void)
  46. {
  47. machine_power_off();
  48. }