xref: /openbmc/linux/arch/riscv/include/asm/kexec.h (revision 61cb9ac6)
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 	unsigned long fdt_addr;
43 };
44 
45 extern const unsigned char riscv_kexec_relocate[];
46 extern const unsigned int riscv_kexec_relocate_size;
47 
48 typedef void (*riscv_kexec_method)(unsigned long first_ind_entry,
49 				   unsigned long jump_addr,
50 				   unsigned long fdt_addr,
51 				   unsigned long hartid,
52 				   unsigned long va_pa_off);
53 
54 extern riscv_kexec_method riscv_kexec_norelocate;
55 
56 #endif
57