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