machine_kexec.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Code to handle transition of Linux booting another kernel.
  3. *
  4. * Copyright (C) 2002-2003 Eric Biederman <ebiederm@xmission.com>
  5. * GameCube/ppc32 port Copyright (C) 2004 Albert Herranz
  6. * Copyright (C) 2005 IBM Corporation.
  7. *
  8. * This source code is licensed under the GNU General Public License,
  9. * Version 2. See the file COPYING for more details.
  10. */
  11. #include <linux/kexec.h>
  12. #include <linux/reboot.h>
  13. #include <linux/threads.h>
  14. #include <asm/machdep.h>
  15. void machine_crash_shutdown(struct pt_regs *regs)
  16. {
  17. if (ppc_md.machine_crash_shutdown)
  18. ppc_md.machine_crash_shutdown(regs);
  19. }
  20. /*
  21. * Do what every setup is needed on image and the
  22. * reboot code buffer to allow us to avoid allocations
  23. * later.
  24. */
  25. int machine_kexec_prepare(struct kimage *image)
  26. {
  27. if (ppc_md.machine_kexec_prepare)
  28. return ppc_md.machine_kexec_prepare(image);
  29. /*
  30. * Fail if platform doesn't provide its own machine_kexec_prepare
  31. * implementation.
  32. */
  33. return -ENOSYS;
  34. }
  35. void machine_kexec_cleanup(struct kimage *image)
  36. {
  37. if (ppc_md.machine_kexec_cleanup)
  38. ppc_md.machine_kexec_cleanup(image);
  39. }
  40. /*
  41. * Do not allocate memory (or fail in any way) in machine_kexec().
  42. * We are past the point of no return, committed to rebooting now.
  43. */
  44. NORET_TYPE void machine_kexec(struct kimage *image)
  45. {
  46. if (ppc_md.machine_kexec)
  47. ppc_md.machine_kexec(image);
  48. else {
  49. /*
  50. * Fall back to normal restart if platform doesn't provide
  51. * its own kexec function, and user insist to kexec...
  52. */
  53. machine_restart(NULL);
  54. }
  55. for(;;);
  56. }