machine_kexec.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 <asm/cio.h>
  14. #include <asm/setup.h>
  15. #include <asm/pgtable.h>
  16. #include <asm/pgalloc.h>
  17. #include <asm/system.h>
  18. #include <asm/smp.h>
  19. #include <asm/reset.h>
  20. typedef void (*relocate_kernel_t)(kimage_entry_t *, unsigned long);
  21. extern const unsigned char relocate_kernel[];
  22. extern const unsigned long long relocate_kernel_len;
  23. int machine_kexec_prepare(struct kimage *image)
  24. {
  25. void *reboot_code_buffer;
  26. /* We don't support anything but the default image type for now. */
  27. if (image->type != KEXEC_TYPE_DEFAULT)
  28. return -EINVAL;
  29. /* Get the destination where the assembler code should be copied to.*/
  30. reboot_code_buffer = (void *) page_to_phys(image->control_code_page);
  31. /* Then copy it */
  32. memcpy(reboot_code_buffer, relocate_kernel, relocate_kernel_len);
  33. return 0;
  34. }
  35. void machine_kexec_cleanup(struct kimage *image)
  36. {
  37. }
  38. void machine_shutdown(void)
  39. {
  40. printk(KERN_INFO "kexec: machine_shutdown called\n");
  41. }
  42. void machine_kexec(struct kimage *image)
  43. {
  44. relocate_kernel_t data_mover;
  45. smp_send_stop();
  46. pfault_fini();
  47. s390_reset_system();
  48. data_mover = (relocate_kernel_t) page_to_phys(image->control_code_page);
  49. /* Call the moving routine */
  50. (*data_mover)(&image->head, image->start);
  51. for (;;);
  52. }