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 /* Maximum number of memory regions kernel supports */
13 #define FADUMP_MAX_MEM_REGS 128
15 #ifndef CONFIG_PRESERVE_FA_DUMP
17 /* The upper limit percentage for user specified boot memory size (25%) */
18 #define MAX_BOOT_MEM_RATIO 4
20 #define memblock_num_regions(memblock_type) (memblock.memblock_type.cnt)
23 #define FADUMP_REGISTER 1
24 #define FADUMP_UNREGISTER 2
25 #define FADUMP_INVALIDATE 3
28 * Copy the ascii values for first 8 characters from a string into u64
29 * variable at their respective indexes.
31 * The string "FADMPINF" will be converted into 0x4641444d50494e46
33 static inline u64 fadump_str_to_u64(const char *str)
38 for (i = 0; i < sizeof(val); i++)
39 val = (*str) ? (val << 8) | *str++ : val << 8;
43 #define FADUMP_CPU_UNKNOWN (~((u32)0))
45 #define FADUMP_CRASH_INFO_MAGIC fadump_str_to_u64("FADMPINF")
47 /* fadump crash info structure */
48 struct fadump_crash_info_header {
53 struct cpumask cpu_mask;
56 struct fadump_memory_range {
61 /* fadump memory ranges info */
62 #define RNG_NAME_SZ 16
63 struct fadump_mrange_info {
64 char name[RNG_NAME_SZ];
65 struct fadump_memory_range *mem_ranges;
72 /* Platform specific callback functions */
75 /* Firmware-assisted dump configuration details. */
77 unsigned long reserve_dump_area_start;
78 unsigned long reserve_dump_area_size;
79 /* cmd line option during boot */
80 unsigned long reserve_bootvar;
82 unsigned long cpu_state_data_size;
83 u64 cpu_state_dest_vaddr;
84 u32 cpu_state_data_version;
85 u32 cpu_state_entry_size;
87 unsigned long hpte_region_size;
89 unsigned long boot_memory_size;
90 u64 boot_mem_dest_addr;
91 u64 boot_mem_addr[FADUMP_MAX_MEM_REGS];
92 u64 boot_mem_sz[FADUMP_MAX_MEM_REGS];
94 u64 boot_mem_regs_cnt;
96 unsigned long fadumphdr_addr;
97 unsigned long cpu_notes_buf_vaddr;
98 unsigned long cpu_notes_buf_size;
101 * Maximum size supported by firmware to copy from source to
102 * destination address per entry.
107 int ibm_configure_kernel_dump;
109 unsigned long fadump_enabled:1;
110 unsigned long fadump_supported:1;
111 unsigned long dump_active:1;
112 unsigned long dump_registered:1;
113 unsigned long nocma:1;
115 struct fadump_ops *ops;
119 u64 (*fadump_init_mem_struct)(struct fw_dump *fadump_conf);
120 u64 (*fadump_get_metadata_size)(void);
121 int (*fadump_setup_metadata)(struct fw_dump *fadump_conf);
122 u64 (*fadump_get_bootmem_min)(void);
123 int (*fadump_register)(struct fw_dump *fadump_conf);
124 int (*fadump_unregister)(struct fw_dump *fadump_conf);
125 int (*fadump_invalidate)(struct fw_dump *fadump_conf);
126 void (*fadump_cleanup)(struct fw_dump *fadump_conf);
127 int (*fadump_process)(struct fw_dump *fadump_conf);
128 void (*fadump_region_show)(struct fw_dump *fadump_conf,
130 void (*fadump_trigger)(struct fadump_crash_info_header *fdh,
134 /* Helper functions */
135 s32 __init fadump_setup_cpu_notes_buf(u32 num_cpus);
136 void fadump_free_cpu_notes_buf(void);
137 u32 *__init fadump_regs_to_elf_notes(u32 *buf, struct pt_regs *regs);
138 void __init fadump_update_elfcore_header(char *bufp);
139 bool is_fadump_boot_mem_contiguous(void);
140 bool is_fadump_reserved_mem_contiguous(void);
142 #else /* !CONFIG_PRESERVE_FA_DUMP */
144 /* Firmware-assisted dump configuration details. */
150 #endif /* CONFIG_PRESERVE_FA_DUMP */
152 #ifdef CONFIG_PPC_PSERIES
153 extern void rtas_fadump_dt_scan(struct fw_dump *fadump_conf, u64 node);
156 rtas_fadump_dt_scan(struct fw_dump *fadump_conf, u64 node) { }
159 #ifdef CONFIG_PPC_POWERNV
160 extern void opal_fadump_dt_scan(struct fw_dump *fadump_conf, u64 node);
163 opal_fadump_dt_scan(struct fw_dump *fadump_conf, u64 node) { }
166 #endif /* _ASM_POWERPC_FADUMP_INTERNAL_H */