xref: /linux/include/linux/crash_reserve.h (revision e991acf1bce7a428794514cbbe216973c9c0a3c8)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef LINUX_CRASH_RESERVE_H
3 #define LINUX_CRASH_RESERVE_H
4 
5 #include <linux/linkage.h>
6 #include <linux/elfcore.h>
7 #include <linux/elf.h>
8 #ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION
9 #include <asm/crash_reserve.h>
10 #endif
11 
12 /* Location of a reserved region to hold the crash kernel.
13  */
14 extern struct resource crashk_res;
15 extern struct resource crashk_low_res;
16 extern struct range crashk_cma_ranges[];
17 #if defined(CONFIG_CMA) && defined(CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION)
18 #define CRASHKERNEL_CMA
19 #define CRASHKERNEL_CMA_RANGES_MAX 4
20 extern int crashk_cma_cnt;
21 #else
22 #define crashk_cma_cnt 0
23 #define CRASHKERNEL_CMA_RANGES_MAX 0
24 #endif
25 
26 
27 int __init parse_crashkernel(char *cmdline, unsigned long long system_ram,
28 		unsigned long long *crash_size, unsigned long long *crash_base,
29 		unsigned long long *low_size, unsigned long long *cma_size,
30 		bool *high);
31 
32 void __init reserve_crashkernel_cma(unsigned long long cma_size);
33 
34 #ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION
35 #ifndef DEFAULT_CRASH_KERNEL_LOW_SIZE
36 #define DEFAULT_CRASH_KERNEL_LOW_SIZE	(128UL << 20)
37 #endif
38 #ifndef CRASH_ALIGN
39 #define CRASH_ALIGN			SZ_2M
40 #endif
41 #ifndef CRASH_ADDR_LOW_MAX
42 #define CRASH_ADDR_LOW_MAX		SZ_4G
43 #endif
44 #ifndef CRASH_ADDR_HIGH_MAX
45 #define CRASH_ADDR_HIGH_MAX		memblock_end_of_DRAM()
46 #endif
47 
48 void __init reserve_crashkernel_generic(unsigned long long crash_size,
49 					unsigned long long crash_base,
50 					unsigned long long crash_low_size,
51 					bool high);
52 #else
reserve_crashkernel_generic(unsigned long long crash_size,unsigned long long crash_base,unsigned long long crash_low_size,bool high)53 static inline void __init reserve_crashkernel_generic(
54 		unsigned long long crash_size,
55 		unsigned long long crash_base,
56 		unsigned long long crash_low_size,
57 		bool high)
58 {}
59 #endif
60 #endif /* LINUX_CRASH_RESERVE_H */
61