xref: /openbmc/linux/arch/riscv/include/asm/kexec.h (revision ecfb9f40)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (C) 2019 FORTH-ICS/CARV
4  *  Nick Kossifidis <mick@ics.forth.gr>
5  */
6 
7 #ifndef _RISCV_KEXEC_H
8 #define _RISCV_KEXEC_H
9 
10 #include <asm/page.h>    /* For PAGE_SIZE */
11 
12 /* Maximum physical address we can use pages from */
13 #define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
14 
15 /* Maximum address we can reach in physical address mode */
16 #define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
17 
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 #define KEXEC_ARCH KEXEC_ARCH_RISCV
25 
26 extern void riscv_crash_save_regs(struct pt_regs *newregs);
27 
28 static inline void
29 crash_setup_regs(struct pt_regs *newregs,
30 		 struct pt_regs *oldregs)
31 {
32 	if (oldregs)
33 		memcpy(newregs, oldregs, sizeof(struct pt_regs));
34 	else
35 		riscv_crash_save_regs(newregs);
36 }
37 
38 
39 #define ARCH_HAS_KIMAGE_ARCH
40 
41 struct kimage_arch {
42 	void *fdt; /* For CONFIG_KEXEC_FILE */
43 	unsigned long fdt_addr;
44 };
45 
46 extern const unsigned char riscv_kexec_relocate[];
47 extern const unsigned int riscv_kexec_relocate_size;
48 
49 typedef void (*riscv_kexec_method)(unsigned long first_ind_entry,
50 				   unsigned long jump_addr,
51 				   unsigned long fdt_addr,
52 				   unsigned long hartid,
53 				   unsigned long va_pa_off);
54 
55 extern riscv_kexec_method riscv_kexec_norelocate;
56 
57 #ifdef CONFIG_KEXEC_FILE
58 extern const struct kexec_file_ops elf_kexec_ops;
59 
60 struct purgatory_info;
61 int arch_kexec_apply_relocations_add(struct purgatory_info *pi,
62 				     Elf_Shdr *section,
63 				     const Elf_Shdr *relsec,
64 				     const Elf_Shdr *symtab);
65 #define arch_kexec_apply_relocations_add arch_kexec_apply_relocations_add
66 
67 struct kimage;
68 int arch_kimage_file_post_load_cleanup(struct kimage *image);
69 #define arch_kimage_file_post_load_cleanup arch_kimage_file_post_load_cleanup
70 #endif
71 
72 #endif
73