machine_kexec.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * arch/s390/kernel/machine_kexec.c
  3. *
  4. * Copyright IBM Corp. 2005,2006
  5. *
  6. * Author(s): Rolf Adelsberger,
  7. * Heiko Carstens <heiko.carstens@de.ibm.com>
  8. */
  9. #include <linux/device.h>
  10. #include <linux/mm.h>
  11. #include <linux/kexec.h>
  12. #include <linux/delay.h>
  13. #include <linux/reboot.h>
  14. #include <asm/cio.h>
  15. #include <asm/setup.h>
  16. #include <asm/pgtable.h>
  17. #include <asm/pgalloc.h>
  18. #include <asm/system.h>
  19. #include <asm/smp.h>
  20. #include <asm/reset.h>
  21. typedef void (*relocate_kernel_t)(kimage_entry_t *, unsigned long);
  22. extern const unsigned char relocate_kernel[];
  23. extern const unsigned long long relocate_kernel_len;
  24. int machine_kexec_prepare(struct kimage *image)
  25. {
  26. void *reboot_code_buffer;
  27. /* We don't support anything but the default image type for now. */
  28. if (image->type != KEXEC_TYPE_DEFAULT)
  29. return -EINVAL;
  30. /* Get the destination where the assembler code should be copied to.*/
  31. reboot_code_buffer = (void *) page_to_phys(image->control_code_page);
  32. /* Then copy it */
  33. memcpy(reboot_code_buffer, relocate_kernel, relocate_kernel_len);
  34. return 0;
  35. }
  36. void machine_kexec_cleanup(struct kimage *image)
  37. {
  38. }
  39. void machine_shutdown(void)
  40. {
  41. printk(KERN_INFO "kexec: machine_shutdown called\n");
  42. }
  43. void machine_kexec(struct kimage *image)
  44. {
  45. relocate_kernel_t data_mover;
  46. smp_send_stop();
  47. pfault_fini();
  48. s390_reset_system();
  49. data_mover = (relocate_kernel_t) page_to_phys(image->control_code_page);
  50. /* Call the moving routine */
  51. (*data_mover)(&image->head, image->start);
  52. for (;;);
  53. }