reboot.c 926 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. EXPORT_SYMBOL(pm_power_off);
  14. static void kill_off_processes(void)
  15. {
  16. struct task_struct *p;
  17. int pid;
  18. read_lock(&tasklist_lock);
  19. for_each_process(p) {
  20. struct task_struct *t;
  21. t = find_lock_task_mm(p);
  22. if (!t)
  23. continue;
  24. pid = t->mm->context.id.u.pid;
  25. task_unlock(t);
  26. os_kill_ptraced_process(pid, 1);
  27. }
  28. read_unlock(&tasklist_lock);
  29. }
  30. void uml_cleanup(void)
  31. {
  32. kmalloc_ok = 0;
  33. do_uml_exitcalls();
  34. kill_off_processes();
  35. }
  36. void machine_restart(char * __unused)
  37. {
  38. uml_cleanup();
  39. reboot_skas();
  40. }
  41. void machine_power_off(void)
  42. {
  43. uml_cleanup();
  44. halt_skas();
  45. }
  46. void machine_halt(void)
  47. {
  48. machine_power_off();
  49. }