0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _ASM_POWERPC_FADUMP_INTERNAL_H
0010 #define _ASM_POWERPC_FADUMP_INTERNAL_H
0011
0012
0013 #define FADUMP_MAX_MEM_REGS 128
0014
0015 #ifndef CONFIG_PRESERVE_FA_DUMP
0016
0017
0018 #define MAX_BOOT_MEM_RATIO 4
0019
0020 #define memblock_num_regions(memblock_type) (memblock.memblock_type.cnt)
0021
0022
0023 #define FADUMP_REGISTER 1
0024 #define FADUMP_UNREGISTER 2
0025 #define FADUMP_INVALIDATE 3
0026
0027
0028
0029
0030
0031
0032
0033 static inline u64 fadump_str_to_u64(const char *str)
0034 {
0035 u64 val = 0;
0036 int i;
0037
0038 for (i = 0; i < sizeof(val); i++)
0039 val = (*str) ? (val << 8) | *str++ : val << 8;
0040 return val;
0041 }
0042
0043 #define FADUMP_CPU_UNKNOWN (~((u32)0))
0044
0045 #define FADUMP_CRASH_INFO_MAGIC fadump_str_to_u64("FADMPINF")
0046
0047
0048 struct fadump_crash_info_header {
0049 u64 magic_number;
0050 u64 elfcorehdr_addr;
0051 u32 crashing_cpu;
0052 struct pt_regs regs;
0053 struct cpumask cpu_mask;
0054 };
0055
0056 struct fadump_memory_range {
0057 u64 base;
0058 u64 size;
0059 };
0060
0061
0062 #define RNG_NAME_SZ 16
0063 struct fadump_mrange_info {
0064 char name[RNG_NAME_SZ];
0065 struct fadump_memory_range *mem_ranges;
0066 u32 mem_ranges_sz;
0067 u32 mem_range_cnt;
0068 u32 max_mem_ranges;
0069 bool is_static;
0070 };
0071
0072
0073 struct fadump_ops;
0074
0075
0076 struct fw_dump {
0077 unsigned long reserve_dump_area_start;
0078 unsigned long reserve_dump_area_size;
0079
0080 unsigned long reserve_bootvar;
0081
0082 unsigned long cpu_state_data_size;
0083 u64 cpu_state_dest_vaddr;
0084 u32 cpu_state_data_version;
0085 u32 cpu_state_entry_size;
0086
0087 unsigned long hpte_region_size;
0088
0089 unsigned long boot_memory_size;
0090 u64 boot_mem_dest_addr;
0091 u64 boot_mem_addr[FADUMP_MAX_MEM_REGS];
0092 u64 boot_mem_sz[FADUMP_MAX_MEM_REGS];
0093 u64 boot_mem_top;
0094 u64 boot_mem_regs_cnt;
0095
0096 unsigned long fadumphdr_addr;
0097 unsigned long cpu_notes_buf_vaddr;
0098 unsigned long cpu_notes_buf_size;
0099
0100
0101
0102
0103
0104 u64 max_copy_size;
0105 u64 kernel_metadata;
0106
0107 int ibm_configure_kernel_dump;
0108
0109 unsigned long fadump_enabled:1;
0110 unsigned long fadump_supported:1;
0111 unsigned long dump_active:1;
0112 unsigned long dump_registered:1;
0113 unsigned long nocma:1;
0114
0115 struct fadump_ops *ops;
0116 };
0117
0118 struct fadump_ops {
0119 u64 (*fadump_init_mem_struct)(struct fw_dump *fadump_conf);
0120 u64 (*fadump_get_metadata_size)(void);
0121 int (*fadump_setup_metadata)(struct fw_dump *fadump_conf);
0122 u64 (*fadump_get_bootmem_min)(void);
0123 int (*fadump_register)(struct fw_dump *fadump_conf);
0124 int (*fadump_unregister)(struct fw_dump *fadump_conf);
0125 int (*fadump_invalidate)(struct fw_dump *fadump_conf);
0126 void (*fadump_cleanup)(struct fw_dump *fadump_conf);
0127 int (*fadump_process)(struct fw_dump *fadump_conf);
0128 void (*fadump_region_show)(struct fw_dump *fadump_conf,
0129 struct seq_file *m);
0130 void (*fadump_trigger)(struct fadump_crash_info_header *fdh,
0131 const char *msg);
0132 };
0133
0134
0135 s32 __init fadump_setup_cpu_notes_buf(u32 num_cpus);
0136 void fadump_free_cpu_notes_buf(void);
0137 u32 *__init fadump_regs_to_elf_notes(u32 *buf, struct pt_regs *regs);
0138 void __init fadump_update_elfcore_header(char *bufp);
0139 bool is_fadump_boot_mem_contiguous(void);
0140 bool is_fadump_reserved_mem_contiguous(void);
0141
0142 #else
0143
0144
0145 struct fw_dump {
0146 u64 boot_mem_top;
0147 u64 dump_active;
0148 };
0149
0150 #endif
0151
0152 #ifdef CONFIG_PPC_PSERIES
0153 extern void rtas_fadump_dt_scan(struct fw_dump *fadump_conf, u64 node);
0154 #else
0155 static inline void
0156 rtas_fadump_dt_scan(struct fw_dump *fadump_conf, u64 node) { }
0157 #endif
0158
0159 #ifdef CONFIG_PPC_POWERNV
0160 extern void opal_fadump_dt_scan(struct fw_dump *fadump_conf, u64 node);
0161 #else
0162 static inline void
0163 opal_fadump_dt_scan(struct fw_dump *fadump_conf, u64 node) { }
0164 #endif
0165
0166 #endif