| 1 |
// SPDX-License-Identifier: GPL-2.0 |
| 2 |
/* |
| 3 |
* machine_kexec.c - handle transition of Linux booting another kernel |
| 4 |
*/ |
| 5 |
#include <linux/compiler.h> |
| 6 |
#include <linux/kexec.h> |
| 7 |
#include <linux/mm.h> |
| 8 |
#include <linux/delay.h> |
| 9 |
#include <linux/reboot.h> |
| 10 |
|
| 11 |
#include <asm/cacheflush.h> |
| 12 |
#include <asm/page.h> |
| 13 |
#include <asm/setup.h> |
| 14 |
|
| 15 |
extern const unsigned char relocate_new_kernel[]; |
| 16 |
extern const size_t relocate_new_kernel_size; |
| 17 |
|
| 18 |
int machine_kexec_prepare(struct kimage *kimage) |
| 19 |
{ |
| 20 |
return 0; |
| 21 |
} |
| 22 |
|
| 23 |
void machine_kexec_cleanup(struct kimage *kimage) |
| 24 |
{ |
| 25 |
} |
| 26 |
|
| 27 |
void machine_shutdown(void) |
| 28 |
{ |
| 29 |
} |
| 30 |
|
| 31 |
void machine_crash_shutdown(struct pt_regs *regs) |
| 32 |
{ |
| 33 |
} |
| 34 |
|
| 35 |
typedef void (*relocate_kernel_t)(unsigned long ptr, |
| 36 |
unsigned long start, |
| 37 |
unsigned long cpu_mmu_flags) __noreturn; |
| 38 |
|
| 39 |
void machine_kexec(struct kimage *image) |
| 40 |
{ |
| 41 |
void *reboot_code_buffer; |
| 42 |
unsigned long cpu_mmu_flags; |
| 43 |
|
| 44 |
reboot_code_buffer = page_address(image->control_code_page); |
| 45 |
|
| 46 |
memcpy(reboot_code_buffer, relocate_new_kernel, |
| 47 |
relocate_new_kernel_size); |
| 48 |
|
| 49 |
/* |
| 50 |
* we do not want to be bothered. |
| 51 |
*/ |
| 52 |
local_irq_disable(); |
| 53 |
|
| 54 |
pr_info("Will call new kernel at 0x%08lx. Bye...\n", image->start); |
| 55 |
__flush_cache_all(); |
| 56 |
cpu_mmu_flags = m68k_cputype | m68k_mmutype << 8; |
| 57 |
((relocate_kernel_t) reboot_code_buffer)(image->head & PAGE_MASK, |
| 58 |
image->start, |
| 59 |
cpu_mmu_flags); |
| 60 |
} |