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 10 #include <linux/device.h> 11 #include <linux/mm.h> 12 #include <linux/kexec.h> 13 #include <linux/delay.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 22 typedef void (*relocate_kernel_t)(kimage_entry_t *, unsigned long); 23 24 extern const unsigned char relocate_kernel[]; 25 extern const unsigned long long relocate_kernel_len; 26 27 int machine_kexec_prepare(struct kimage *image) 28 { 29 void *reboot_code_buffer; 30 31 /* We don't support anything but the default image type for now. */ 32 if (image->type != KEXEC_TYPE_DEFAULT) 33 return -EINVAL; 34 35 /* Get the destination where the assembler code should be copied to.*/ 36 reboot_code_buffer = (void *) page_to_phys(image->control_code_page); 37 38 /* Then copy it */ 39 memcpy(reboot_code_buffer, relocate_kernel, relocate_kernel_len); 40 return 0; 41 } 42 43 void machine_kexec_cleanup(struct kimage *image) 44 { 45 } 46 47 void machine_shutdown(void) 48 { 49 printk(KERN_INFO "kexec: machine_shutdown called\n"); 50 } 51 52 void machine_kexec(struct kimage *image) 53 { 54 relocate_kernel_t data_mover; 55 56 smp_send_stop(); 57 pfault_fini(); 58 s390_reset_system(); 59 60 data_mover = (relocate_kernel_t) page_to_phys(image->control_code_page); 61 62 /* Call the moving routine */ 63 (*data_mover)(&image->head, image->start); 64 for (;;); 65 } 66