Commit | Line | Data |
---|---|---|
cf13f0ea HC |
1 | /* |
2 | * arch/s390/kernel/machine_kexec.c | |
3 | * | |
c6b5b847 | 4 | * Copyright IBM Corp. 2005,2006 |
cf13f0ea | 5 | * |
c6b5b847 HC |
6 | * Author(s): Rolf Adelsberger, |
7 | * Heiko Carstens <heiko.carstens@de.ibm.com> | |
cf13f0ea HC |
8 | */ |
9 | ||
cf13f0ea HC |
10 | #include <linux/device.h> |
11 | #include <linux/mm.h> | |
12 | #include <linux/kexec.h> | |
13 | #include <linux/delay.h> | |
2b67fc46 | 14 | #include <linux/reboot.h> |
6966727d | 15 | #include <linux/ftrace.h> |
a386fba2 HC |
16 | #include <asm/cio.h> |
17 | #include <asm/setup.h> | |
cf13f0ea HC |
18 | #include <asm/pgtable.h> |
19 | #include <asm/pgalloc.h> | |
20 | #include <asm/system.h> | |
a386fba2 | 21 | #include <asm/smp.h> |
15e9b586 | 22 | #include <asm/reset.h> |
9c9c1761 | 23 | #include <asm/ipl.h> |
cf13f0ea | 24 | |
c6b5b847 | 25 | typedef void (*relocate_kernel_t)(kimage_entry_t *, unsigned long); |
cf13f0ea | 26 | |
2efe55a9 TK |
27 | extern const unsigned char relocate_kernel[]; |
28 | extern const unsigned long long relocate_kernel_len; | |
cf13f0ea | 29 | |
c6b5b847 | 30 | int machine_kexec_prepare(struct kimage *image) |
cf13f0ea | 31 | { |
c6b5b847 | 32 | void *reboot_code_buffer; |
cf13f0ea | 33 | |
9c9c1761 HC |
34 | /* Can't replace kernel image since it is read-only. */ |
35 | if (ipl_flags & IPL_NSS_VALID) | |
36 | return -ENOSYS; | |
37 | ||
cf13f0ea HC |
38 | /* We don't support anything but the default image type for now. */ |
39 | if (image->type != KEXEC_TYPE_DEFAULT) | |
40 | return -EINVAL; | |
41 | ||
42 | /* Get the destination where the assembler code should be copied to.*/ | |
c6b5b847 | 43 | reboot_code_buffer = (void *) page_to_phys(image->control_code_page); |
cf13f0ea HC |
44 | |
45 | /* Then copy it */ | |
c6b5b847 | 46 | memcpy(reboot_code_buffer, relocate_kernel, relocate_kernel_len); |
cf13f0ea HC |
47 | return 0; |
48 | } | |
49 | ||
c6b5b847 | 50 | void machine_kexec_cleanup(struct kimage *image) |
cf13f0ea HC |
51 | { |
52 | } | |
53 | ||
c6b5b847 | 54 | void machine_shutdown(void) |
cf13f0ea | 55 | { |
cf13f0ea HC |
56 | } |
57 | ||
2c2df118 | 58 | static void __machine_kexec(void *data) |
cf13f0ea | 59 | { |
cf13f0ea | 60 | relocate_kernel_t data_mover; |
2c2df118 | 61 | struct kimage *image = data; |
cf13f0ea | 62 | |
29b08d2b | 63 | pfault_fini(); |
15e9b586 HC |
64 | s390_reset_system(); |
65 | ||
c6b5b847 | 66 | data_mover = (relocate_kernel_t) page_to_phys(image->control_code_page); |
cf13f0ea HC |
67 | |
68 | /* Call the moving routine */ | |
c6b5b847 HC |
69 | (*data_mover)(&image->head, image->start); |
70 | for (;;); | |
cf13f0ea | 71 | } |
2c2df118 HC |
72 | |
73 | void machine_kexec(struct kimage *image) | |
74 | { | |
6966727d | 75 | tracer_disable(); |
2c2df118 HC |
76 | smp_send_stop(); |
77 | smp_switch_to_ipl_cpu(__machine_kexec, image); | |
78 | } |