machine_kexec.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. /*
  16. * Provide a dummy crash_notes definition until crash dump is implemented.
  17. * This prevents breakage of crash_notes attribute in kernel/ksysfs.c.
  18. */
  19. note_buf_t crash_notes[NR_CPUS];
  20. void machine_crash_shutdown(struct pt_regs *regs)
  21. {
  22. if (ppc_md.machine_crash_shutdown)
  23. ppc_md.machine_crash_shutdown(regs);
  24. }
  25. /*
  26. * Do what every setup is needed on image and the
  27. * reboot code buffer to allow us to avoid allocations
  28. * later.
  29. */
  30. int machine_kexec_prepare(struct kimage *image)
  31. {
  32. if (ppc_md.machine_kexec_prepare)
  33. return ppc_md.machine_kexec_prepare(image);
  34. /*
  35. * Fail if platform doesn't provide its own machine_kexec_prepare
  36. * implementation.
  37. */
  38. return -ENOSYS;
  39. }
  40. void machine_kexec_cleanup(struct kimage *image)
  41. {
  42. if (ppc_md.machine_kexec_cleanup)
  43. ppc_md.machine_kexec_cleanup(image);
  44. }
  45. /*
  46. * Do not allocate memory (or fail in any way) in machine_kexec().
  47. * We are past the point of no return, committed to rebooting now.
  48. */
  49. NORET_TYPE void machine_kexec(struct kimage *image)
  50. {
  51. if (ppc_md.machine_kexec)
  52. ppc_md.machine_kexec(image);
  53. else {
  54. /*
  55. * Fall back to normal restart if platform doesn't provide
  56. * its own kexec function, and user insist to kexec...
  57. */
  58. machine_restart(NULL);
  59. }
  60. for(;;);
  61. }