Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 1 | #ifndef LINUX_CRASH_CORE_H |
| 2 | #define LINUX_CRASH_CORE_H |
| 3 | |
| 4 | #include <linux/linkage.h> |
| 5 | #include <linux/elfcore.h> |
| 6 | #include <linux/elf.h> |
| 7 | |
| 8 | #define CRASH_CORE_NOTE_NAME "CORE" |
| 9 | #define CRASH_CORE_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4) |
| 10 | #define CRASH_CORE_NOTE_NAME_BYTES ALIGN(sizeof(CRASH_CORE_NOTE_NAME), 4) |
| 11 | #define CRASH_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4) |
| 12 | |
Michael Holzheu | cd0ae1d | 2017-06-21 19:23:18 +0200 | [diff] [blame] | 13 | /* |
| 14 | * The per-cpu notes area is a list of notes terminated by a "NULL" |
| 15 | * note header. For kdump, the code in vmcore.c runs in the context |
| 16 | * of the second kernel to combine them into one note. |
| 17 | */ |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 18 | #define CRASH_CORE_NOTE_BYTES ((CRASH_CORE_NOTE_HEAD_BYTES * 2) + \ |
| 19 | CRASH_CORE_NOTE_NAME_BYTES + \ |
| 20 | CRASH_CORE_NOTE_DESC_BYTES) |
| 21 | |
Xunlei Pang | 203e9e4 | 2017-07-12 14:33:14 -0700 | [diff] [blame^] | 22 | #define VMCOREINFO_BYTES PAGE_SIZE |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 23 | #define VMCOREINFO_NOTE_NAME "VMCOREINFO" |
| 24 | #define VMCOREINFO_NOTE_NAME_BYTES ALIGN(sizeof(VMCOREINFO_NOTE_NAME), 4) |
| 25 | #define VMCOREINFO_NOTE_SIZE ((CRASH_CORE_NOTE_HEAD_BYTES * 2) + \ |
| 26 | VMCOREINFO_NOTE_NAME_BYTES + \ |
| 27 | VMCOREINFO_BYTES) |
| 28 | |
| 29 | typedef u32 note_buf_t[CRASH_CORE_NOTE_BYTES/4]; |
| 30 | |
| 31 | void crash_save_vmcoreinfo(void); |
| 32 | void arch_crash_save_vmcoreinfo(void); |
| 33 | __printf(1, 2) |
| 34 | void vmcoreinfo_append_str(const char *fmt, ...); |
| 35 | phys_addr_t paddr_vmcoreinfo_note(void); |
| 36 | |
| 37 | #define VMCOREINFO_OSRELEASE(value) \ |
| 38 | vmcoreinfo_append_str("OSRELEASE=%s\n", value) |
| 39 | #define VMCOREINFO_PAGESIZE(value) \ |
| 40 | vmcoreinfo_append_str("PAGESIZE=%ld\n", value) |
| 41 | #define VMCOREINFO_SYMBOL(name) \ |
| 42 | vmcoreinfo_append_str("SYMBOL(%s)=%lx\n", #name, (unsigned long)&name) |
| 43 | #define VMCOREINFO_SIZE(name) \ |
| 44 | vmcoreinfo_append_str("SIZE(%s)=%lu\n", #name, \ |
| 45 | (unsigned long)sizeof(name)) |
| 46 | #define VMCOREINFO_STRUCT_SIZE(name) \ |
| 47 | vmcoreinfo_append_str("SIZE(%s)=%lu\n", #name, \ |
| 48 | (unsigned long)sizeof(struct name)) |
| 49 | #define VMCOREINFO_OFFSET(name, field) \ |
| 50 | vmcoreinfo_append_str("OFFSET(%s.%s)=%lu\n", #name, #field, \ |
| 51 | (unsigned long)offsetof(struct name, field)) |
| 52 | #define VMCOREINFO_LENGTH(name, value) \ |
| 53 | vmcoreinfo_append_str("LENGTH(%s)=%lu\n", #name, (unsigned long)value) |
| 54 | #define VMCOREINFO_NUMBER(name) \ |
| 55 | vmcoreinfo_append_str("NUMBER(%s)=%ld\n", #name, (long)name) |
| 56 | #define VMCOREINFO_CONFIG(name) \ |
| 57 | vmcoreinfo_append_str("CONFIG_%s=y\n", #name) |
| 58 | |
Xunlei Pang | 203e9e4 | 2017-07-12 14:33:14 -0700 | [diff] [blame^] | 59 | extern u32 *vmcoreinfo_note; |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 60 | extern size_t vmcoreinfo_size; |
| 61 | extern size_t vmcoreinfo_max_size; |
| 62 | |
Hari Bathini | 51dbd92 | 2017-05-08 15:56:21 -0700 | [diff] [blame] | 63 | Elf_Word *append_elf_note(Elf_Word *buf, char *name, unsigned int type, |
| 64 | void *data, size_t data_len); |
| 65 | void final_note(Elf_Word *buf); |
| 66 | |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 67 | int __init parse_crashkernel(char *cmdline, unsigned long long system_ram, |
| 68 | unsigned long long *crash_size, unsigned long long *crash_base); |
| 69 | int parse_crashkernel_high(char *cmdline, unsigned long long system_ram, |
| 70 | unsigned long long *crash_size, unsigned long long *crash_base); |
| 71 | int parse_crashkernel_low(char *cmdline, unsigned long long system_ram, |
| 72 | unsigned long long *crash_size, unsigned long long *crash_base); |
| 73 | |
| 74 | #endif /* LINUX_CRASH_CORE_H */ |