reboot.c 991 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  3. * Licensed under the GPL
  4. */
  5. #include <linux/sched/signal.h>
  6. #include <linux/sched/task.h>
  7. #include <linux/sched/mm.h>
  8. #include <linux/spinlock.h>
  9. #include <linux/slab.h>
  10. #include <linux/oom.h>
  11. #include <kern_util.h>
  12. #include <os.h>
  13. #include <skas.h>
  14. void (*pm_power_off)(void);
  15. EXPORT_SYMBOL(pm_power_off);
  16. static void kill_off_processes(void)
  17. {
  18. struct task_struct *p;
  19. int pid;
  20. read_lock(&tasklist_lock);
  21. for_each_process(p) {
  22. struct task_struct *t;
  23. t = find_lock_task_mm(p);
  24. if (!t)
  25. continue;
  26. pid = t->mm->context.id.u.pid;
  27. task_unlock(t);
  28. os_kill_ptraced_process(pid, 1);
  29. }
  30. read_unlock(&tasklist_lock);
  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. }