xref: /linux/arch/loongarch/include/asm/kexec.h (revision 4a03b2ac)
1*4a03b2acSYouling Tang /* SPDX-License-Identifier: GPL-2.0 */
2*4a03b2acSYouling Tang /*
3*4a03b2acSYouling Tang  * kexec.h for kexec
4*4a03b2acSYouling Tang  *
5*4a03b2acSYouling Tang  * Copyright (C) 2022 Loongson Technology Corporation Limited
6*4a03b2acSYouling Tang  */
7*4a03b2acSYouling Tang 
8*4a03b2acSYouling Tang #ifndef _ASM_KEXEC_H
9*4a03b2acSYouling Tang #define _ASM_KEXEC_H
10*4a03b2acSYouling Tang 
11*4a03b2acSYouling Tang #include <asm/stacktrace.h>
12*4a03b2acSYouling Tang #include <asm/page.h>
13*4a03b2acSYouling Tang 
14*4a03b2acSYouling Tang /* Maximum physical address we can use pages from */
15*4a03b2acSYouling Tang #define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
16*4a03b2acSYouling Tang /* Maximum address we can reach in physical address mode */
17*4a03b2acSYouling Tang #define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
18*4a03b2acSYouling Tang  /* Maximum address we can use for the control code buffer */
19*4a03b2acSYouling Tang #define KEXEC_CONTROL_MEMORY_LIMIT (-1UL)
20*4a03b2acSYouling Tang 
21*4a03b2acSYouling Tang /* Reserve a page for the control code buffer */
22*4a03b2acSYouling Tang #define KEXEC_CONTROL_PAGE_SIZE PAGE_SIZE
23*4a03b2acSYouling Tang 
24*4a03b2acSYouling Tang /* The native architecture */
25*4a03b2acSYouling Tang #define KEXEC_ARCH KEXEC_ARCH_LOONGARCH
26*4a03b2acSYouling Tang 
crash_setup_regs(struct pt_regs * newregs,struct pt_regs * oldregs)27*4a03b2acSYouling Tang static inline void crash_setup_regs(struct pt_regs *newregs,
28*4a03b2acSYouling Tang 				    struct pt_regs *oldregs)
29*4a03b2acSYouling Tang {
30*4a03b2acSYouling Tang 	if (oldregs)
31*4a03b2acSYouling Tang 		memcpy(newregs, oldregs, sizeof(*newregs));
32*4a03b2acSYouling Tang 	else
33*4a03b2acSYouling Tang 		prepare_frametrace(newregs);
34*4a03b2acSYouling Tang }
35*4a03b2acSYouling Tang 
36*4a03b2acSYouling Tang #define ARCH_HAS_KIMAGE_ARCH
37*4a03b2acSYouling Tang 
38*4a03b2acSYouling Tang struct kimage_arch {
39*4a03b2acSYouling Tang 	unsigned long efi_boot;
40*4a03b2acSYouling Tang 	unsigned long cmdline_ptr;
41*4a03b2acSYouling Tang 	unsigned long systable_ptr;
42*4a03b2acSYouling Tang };
43*4a03b2acSYouling Tang 
44*4a03b2acSYouling Tang typedef void (*do_kexec_t)(unsigned long efi_boot,
45*4a03b2acSYouling Tang 			   unsigned long cmdline_ptr,
46*4a03b2acSYouling Tang 			   unsigned long systable_ptr,
47*4a03b2acSYouling Tang 			   unsigned long start_addr,
48*4a03b2acSYouling Tang 			   unsigned long first_ind_entry);
49*4a03b2acSYouling Tang 
50*4a03b2acSYouling Tang struct kimage;
51*4a03b2acSYouling Tang extern const unsigned char relocate_new_kernel[];
52*4a03b2acSYouling Tang extern const size_t relocate_new_kernel_size;
53*4a03b2acSYouling Tang extern void kexec_reboot(void);
54*4a03b2acSYouling Tang 
55*4a03b2acSYouling Tang #ifdef CONFIG_SMP
56*4a03b2acSYouling Tang extern atomic_t kexec_ready_to_reboot;
57*4a03b2acSYouling Tang extern const unsigned char kexec_smp_wait[];
58*4a03b2acSYouling Tang #endif
59*4a03b2acSYouling Tang 
60*4a03b2acSYouling Tang #endif /* !_ASM_KEXEC_H */
61