machine_kexec_32.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * PPC32 code to handle 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/mm.h>
  13. #include <linux/string.h>
  14. #include <asm/cacheflush.h>
  15. #include <asm/hw_irq.h>
  16. #include <asm/io.h>
  17. typedef void (*relocate_new_kernel_t)(
  18. unsigned long indirection_page,
  19. unsigned long reboot_code_buffer,
  20. unsigned long start_address) __noreturn;
  21. /*
  22. * This is a generic machine_kexec function suitable at least for
  23. * non-OpenFirmware embedded platforms.
  24. * It merely copies the image relocation code to the control page and
  25. * jumps to it.
  26. * A platform specific function may just call this one.
  27. */
  28. void default_machine_kexec(struct kimage *image)
  29. {
  30. extern const unsigned char relocate_new_kernel[];
  31. extern const unsigned int relocate_new_kernel_size;
  32. unsigned long page_list;
  33. unsigned long reboot_code_buffer, reboot_code_buffer_phys;
  34. relocate_new_kernel_t rnk;
  35. /* Interrupts aren't acceptable while we reboot */
  36. local_irq_disable();
  37. /* mask each interrupt so we are in a more sane state for the
  38. * kexec kernel */
  39. machine_kexec_mask_interrupts();
  40. page_list = image->head;
  41. /* we need both effective and real address here */
  42. reboot_code_buffer =
  43. (unsigned long)page_address(image->control_code_page);
  44. reboot_code_buffer_phys = virt_to_phys((void *)reboot_code_buffer);
  45. /* copy our kernel relocation code to the control code page */
  46. memcpy((void *)reboot_code_buffer, relocate_new_kernel,
  47. relocate_new_kernel_size);
  48. flush_icache_range(reboot_code_buffer,
  49. reboot_code_buffer + KEXEC_CONTROL_PAGE_SIZE);
  50. printk(KERN_INFO "Bye!\n");
  51. /* now call it */
  52. rnk = (relocate_new_kernel_t) reboot_code_buffer;
  53. (*rnk)(page_list, reboot_code_buffer_phys, image->start);
  54. }
  55. int default_machine_kexec_prepare(struct kimage *image)
  56. {
  57. return 0;
  58. }