blob: 3c77dd36994cec6b71544a345a670d56353017d5 [file] [log] [blame]
Heiko Carstenscf13f0e2005-06-25 14:58:11 -07001/*
2 * arch/s390/kernel/machine_kexec.c
3 *
Heiko Carstensc6b5b842006-12-04 15:40:33 +01004 * Copyright IBM Corp. 2005,2006
Heiko Carstenscf13f0e2005-06-25 14:58:11 -07005 *
Heiko Carstensc6b5b842006-12-04 15:40:33 +01006 * Author(s): Rolf Adelsberger,
7 * Heiko Carstens <heiko.carstens@de.ibm.com>
Heiko Carstenscf13f0e2005-06-25 14:58:11 -07008 */
9
Heiko Carstenscf13f0e2005-06-25 14:58:11 -070010#include <linux/device.h>
11#include <linux/mm.h>
12#include <linux/kexec.h>
13#include <linux/delay.h>
Heiko Carstens2b67fc42007-02-05 21:16:47 +010014#include <linux/reboot.h>
Heiko Carstensa386fba2006-02-11 17:56:01 -080015#include <asm/cio.h>
16#include <asm/setup.h>
Heiko Carstenscf13f0e2005-06-25 14:58:11 -070017#include <asm/pgtable.h>
18#include <asm/pgalloc.h>
19#include <asm/system.h>
Heiko Carstensa386fba2006-02-11 17:56:01 -080020#include <asm/smp.h>
Heiko Carstens15e9b582006-12-04 15:40:26 +010021#include <asm/reset.h>
Heiko Carstens9c9c1762007-03-05 23:35:45 +010022#include <asm/ipl.h>
Heiko Carstenscf13f0e2005-06-25 14:58:11 -070023
Heiko Carstensc6b5b842006-12-04 15:40:33 +010024typedef void (*relocate_kernel_t)(kimage_entry_t *, unsigned long);
Heiko Carstenscf13f0e2005-06-25 14:58:11 -070025
Tobias Klauser2efe55a2006-06-26 18:57:34 +020026extern const unsigned char relocate_kernel[];
27extern const unsigned long long relocate_kernel_len;
Heiko Carstenscf13f0e2005-06-25 14:58:11 -070028
Heiko Carstensc6b5b842006-12-04 15:40:33 +010029int machine_kexec_prepare(struct kimage *image)
Heiko Carstenscf13f0e2005-06-25 14:58:11 -070030{
Heiko Carstensc6b5b842006-12-04 15:40:33 +010031 void *reboot_code_buffer;
Heiko Carstenscf13f0e2005-06-25 14:58:11 -070032
Heiko Carstens9c9c1762007-03-05 23:35:45 +010033 /* Can't replace kernel image since it is read-only. */
34 if (ipl_flags & IPL_NSS_VALID)
35 return -ENOSYS;
36
Heiko Carstenscf13f0e2005-06-25 14:58:11 -070037 /* We don't support anything but the default image type for now. */
38 if (image->type != KEXEC_TYPE_DEFAULT)
39 return -EINVAL;
40
41 /* Get the destination where the assembler code should be copied to.*/
Heiko Carstensc6b5b842006-12-04 15:40:33 +010042 reboot_code_buffer = (void *) page_to_phys(image->control_code_page);
Heiko Carstenscf13f0e2005-06-25 14:58:11 -070043
44 /* Then copy it */
Heiko Carstensc6b5b842006-12-04 15:40:33 +010045 memcpy(reboot_code_buffer, relocate_kernel, relocate_kernel_len);
Heiko Carstenscf13f0e2005-06-25 14:58:11 -070046 return 0;
47}
48
Heiko Carstensc6b5b842006-12-04 15:40:33 +010049void machine_kexec_cleanup(struct kimage *image)
Heiko Carstenscf13f0e2005-06-25 14:58:11 -070050{
51}
52
Heiko Carstensc6b5b842006-12-04 15:40:33 +010053void machine_shutdown(void)
Heiko Carstenscf13f0e2005-06-25 14:58:11 -070054{
55 printk(KERN_INFO "kexec: machine_shutdown called\n");
56}
57
Heiko Carstensc6b5b842006-12-04 15:40:33 +010058void machine_kexec(struct kimage *image)
Heiko Carstenscf13f0e2005-06-25 14:58:11 -070059{
Heiko Carstenscf13f0e2005-06-25 14:58:11 -070060 relocate_kernel_t data_mover;
61
Heiko Carstensc6b5b842006-12-04 15:40:33 +010062 smp_send_stop();
Heiko Carstens29b08d22006-12-04 15:40:40 +010063 pfault_fini();
Heiko Carstens15e9b582006-12-04 15:40:26 +010064 s390_reset_system();
65
Heiko Carstensc6b5b842006-12-04 15:40:33 +010066 data_mover = (relocate_kernel_t) page_to_phys(image->control_code_page);
Heiko Carstenscf13f0e2005-06-25 14:58:11 -070067
68 /* Call the moving routine */
Heiko Carstensc6b5b842006-12-04 15:40:33 +010069 (*data_mover)(&image->head, image->start);
70 for (;;);
Heiko Carstenscf13f0e2005-06-25 14:58:11 -070071}