1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Firmware-Assisted Dump internal code.
5 * Copyright 2011, Mahesh Salgaonkar, IBM Corporation.
6 * Copyright 2019, Hari Bathini, IBM Corporation.
9 #ifndef _ASM_POWERPC_FADUMP_INTERNAL_H
10 #define _ASM_POWERPC_FADUMP_INTERNAL_H
12 #ifndef CONFIG_PRESERVE_FA_DUMP
14 * The RMA region will be saved for later dumping when kernel crashes.
15 * RMA is Real Mode Area, the first block of logical memory address owned
16 * by logical partition, containing the storage that may be accessed with
20 #define RMA_END (ppc64_rma_size)
22 /* The upper limit percentage for user specified boot memory size (25%) */
23 #define MAX_BOOT_MEM_RATIO 4
25 #define memblock_num_regions(memblock_type) (memblock.memblock_type.cnt)
27 /* Alignment per CMA requirement. */
28 #define FADUMP_CMA_ALIGNMENT (PAGE_SIZE << \
29 max_t(unsigned long, MAX_ORDER - 1, \
33 #define FADUMP_REGISTER 1
34 #define FADUMP_UNREGISTER 2
35 #define FADUMP_INVALIDATE 3
38 * Copy the ascii values for first 8 characters from a string into u64
39 * variable at their respective indexes.
41 * The string "FADMPINF" will be converted into 0x4641444d50494e46
43 static inline u64 fadump_str_to_u64(const char *str)
48 for (i = 0; i < sizeof(val); i++)
49 val = (*str) ? (val << 8) | *str++ : val << 8;
53 #define FADUMP_CPU_UNKNOWN (~((u32)0))
55 #define FADUMP_CRASH_INFO_MAGIC fadump_str_to_u64("FADMPINF")
57 /* fadump crash info structure */
58 struct fadump_crash_info_header {
63 struct cpumask online_mask;
66 struct fadump_memory_range {
71 /* fadump memory ranges info */
72 struct fadump_mrange_info {
74 struct fadump_memory_range *mem_ranges;
80 /* Platform specific callback functions */
83 /* Firmware-assisted dump configuration details. */
85 unsigned long reserve_dump_area_start;
86 unsigned long reserve_dump_area_size;
87 /* cmd line option during boot */
88 unsigned long reserve_bootvar;
90 unsigned long cpu_state_data_size;
91 u64 cpu_state_dest_vaddr;
92 u32 cpu_state_data_version;
93 u32 cpu_state_entry_size;
95 unsigned long hpte_region_size;
97 unsigned long boot_memory_size;
98 u64 boot_mem_dest_addr;
100 unsigned long fadumphdr_addr;
101 unsigned long cpu_notes_buf_vaddr;
102 unsigned long cpu_notes_buf_size;
106 int ibm_configure_kernel_dump;
108 unsigned long fadump_enabled:1;
109 unsigned long fadump_supported:1;
110 unsigned long dump_active:1;
111 unsigned long dump_registered:1;
112 unsigned long nocma:1;
114 struct fadump_ops *ops;
118 u64 (*fadump_init_mem_struct)(struct fw_dump *fadump_conf);
119 u64 (*fadump_get_metadata_size)(void);
120 int (*fadump_setup_metadata)(struct fw_dump *fadump_conf);
121 u64 (*fadump_get_bootmem_min)(void);
122 int (*fadump_register)(struct fw_dump *fadump_conf);
123 int (*fadump_unregister)(struct fw_dump *fadump_conf);
124 int (*fadump_invalidate)(struct fw_dump *fadump_conf);
125 void (*fadump_cleanup)(struct fw_dump *fadump_conf);
126 int (*fadump_process)(struct fw_dump *fadump_conf);
127 void (*fadump_region_show)(struct fw_dump *fadump_conf,
129 void (*fadump_trigger)(struct fadump_crash_info_header *fdh,
133 /* Helper functions */
134 s32 fadump_setup_cpu_notes_buf(u32 num_cpus);
135 void fadump_free_cpu_notes_buf(void);
136 u32 *fadump_regs_to_elf_notes(u32 *buf, struct pt_regs *regs);
137 void fadump_update_elfcore_header(char *bufp);
138 bool is_fadump_boot_mem_contiguous(void);
139 bool is_fadump_reserved_mem_contiguous(void);
141 #else /* !CONFIG_PRESERVE_FA_DUMP */
143 /* Firmware-assisted dump configuration details. */
149 #endif /* CONFIG_PRESERVE_FA_DUMP */
151 #ifdef CONFIG_PPC_PSERIES
152 extern void rtas_fadump_dt_scan(struct fw_dump *fadump_conf, u64 node);
155 rtas_fadump_dt_scan(struct fw_dump *fadump_conf, u64 node) { }
158 #ifdef CONFIG_PPC_POWERNV
159 extern void opal_fadump_dt_scan(struct fw_dump *fadump_conf, u64 node);
162 opal_fadump_dt_scan(struct fw_dump *fadump_conf, u64 node) { }
165 #endif /* _ASM_POWERPC_FADUMP_INTERNAL_H */