crash: split crash dumping code out from kexec_core.c
[linux-2.6-block.git] / include / linux / crash_core.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
692f66f2
HB
2#ifndef LINUX_CRASH_CORE_H
3#define LINUX_CRASH_CORE_H
4
5#include <linux/linkage.h>
6#include <linux/elfcore.h>
7#include <linux/elf.h>
8
02aff848
BH
9struct kimage;
10
11#ifdef CONFIG_CRASH_DUMP
12
13int crash_shrink_memory(unsigned long new_size);
14ssize_t crash_get_memory_size(void);
15
16#ifndef arch_kexec_protect_crashkres
17/*
18 * Protection mechanism for crashkernel reserved memory after
19 * the kdump kernel is loaded.
20 *
21 * Provide an empty default implementation here -- architecture
22 * code may override this
23 */
24static inline void arch_kexec_protect_crashkres(void) { }
25#endif
26
27#ifndef arch_kexec_unprotect_crashkres
28static inline void arch_kexec_unprotect_crashkres(void) { }
29#endif
30
31
32
33#ifndef arch_crash_handle_hotplug_event
34static inline void arch_crash_handle_hotplug_event(struct kimage *image) { }
35#endif
36
37int crash_check_update_elfcorehdr(void);
38
39#ifndef crash_hotplug_cpu_support
40static inline int crash_hotplug_cpu_support(void) { return 0; }
41#endif
42
43#ifndef crash_hotplug_memory_support
44static inline int crash_hotplug_memory_support(void) { return 0; }
45#endif
46
47#ifndef crash_get_elfcorehdr_size
48static inline unsigned int crash_get_elfcorehdr_size(void) { return 0; }
49#endif
50
6f991cc3
ED
51/* Alignment required for elf header segment */
52#define ELF_CORE_HEADER_ALIGN 4096
53
54struct crash_mem {
55 unsigned int max_nr_ranges;
56 unsigned int nr_ranges;
15fcedd4 57 struct range ranges[] __counted_by(max_nr_ranges);
6f991cc3
ED
58};
59
60extern int crash_exclude_mem_range(struct crash_mem *mem,
61 unsigned long long mstart,
62 unsigned long long mend);
63extern int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map,
64 void **addr, unsigned long *sz);
65
66struct kimage;
67struct kexec_segment;
68
24726275
ED
69#define KEXEC_CRASH_HP_NONE 0
70#define KEXEC_CRASH_HP_ADD_CPU 1
71#define KEXEC_CRASH_HP_REMOVE_CPU 2
72#define KEXEC_CRASH_HP_ADD_MEMORY 3
73#define KEXEC_CRASH_HP_REMOVE_MEMORY 4
74#define KEXEC_CRASH_HP_INVALID_CPU -1U
75
02aff848
BH
76extern void __crash_kexec(struct pt_regs *regs);
77extern void crash_kexec(struct pt_regs *regs);
78int kexec_should_crash(struct task_struct *p);
79int kexec_crash_loaded(void);
80void crash_save_cpu(struct pt_regs *regs, int cpu);
81extern int kimage_crash_copy_vmcoreinfo(struct kimage *image);
82
83#else /* !CONFIG_CRASH_DUMP*/
84struct pt_regs;
85struct task_struct;
86struct kimage;
87static inline void __crash_kexec(struct pt_regs *regs) { }
88static inline void crash_kexec(struct pt_regs *regs) { }
89static inline int kexec_should_crash(struct task_struct *p) { return 0; }
90static inline int kexec_crash_loaded(void) { return 0; }
91static inline void crash_save_cpu(struct pt_regs *regs, int cpu) {};
92static inline int kimage_crash_copy_vmcoreinfo(struct kimage *image) { return 0; };
93#endif /* CONFIG_CRASH_DUMP*/
94
692f66f2 95#endif /* LINUX_CRASH_CORE_H */