fadump: Initialize elfcore header and add PT_LOAD program headers.
[deliverable/linux.git] / arch / powerpc / include / asm / fadump.h
CommitLineData
eb39c880
MS
1/*
2 * Firmware Assisted dump header file.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 * Copyright 2011 IBM Corporation
19 * Author: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
20 */
21
22#ifndef __PPC64_FA_DUMP_H__
23#define __PPC64_FA_DUMP_H__
24
25#ifdef CONFIG_FA_DUMP
26
27/*
28 * The RMA region will be saved for later dumping when kernel crashes.
29 * RMA is Real Mode Area, the first block of logical memory address owned
30 * by logical partition, containing the storage that may be accessed with
31 * translate off.
32 */
33#define RMA_START 0x0
34#define RMA_END (ppc64_rma_size)
35
36/*
37 * On some Power systems where RMO is 128MB, it still requires minimum of
38 * 256MB for kernel to boot successfully. When kdump infrastructure is
39 * configured to save vmcore over network, we run into OOM issue while
40 * loading modules related to network setup. Hence we need aditional 64M
41 * of memory to avoid OOM issue.
42 */
43#define MIN_BOOT_MEM (((RMA_END < (0x1UL << 28)) ? (0x1UL << 28) : RMA_END) \
44 + (0x1UL << 26))
45
2df173d9
MS
46#define memblock_num_regions(memblock_type) (memblock.memblock_type.cnt)
47
48#ifndef ELF_CORE_EFLAGS
49#define ELF_CORE_EFLAGS 0
50#endif
51
eb39c880
MS
52/* Firmware provided dump sections */
53#define FADUMP_CPU_STATE_DATA 0x0001
54#define FADUMP_HPTE_REGION 0x0002
55#define FADUMP_REAL_MODE_REGION 0x0011
56
3ccc00a7
MS
57/* Dump request flag */
58#define FADUMP_REQUEST_FLAG 0x00000001
59
60/* FAD commands */
61#define FADUMP_REGISTER 1
62#define FADUMP_UNREGISTER 2
63#define FADUMP_INVALIDATE 3
64
2df173d9
MS
65/* Dump status flag */
66#define FADUMP_ERROR_FLAG 0x2000
67
3ccc00a7
MS
68/* Kernel Dump section info */
69struct fadump_section {
70 u32 request_flag;
71 u16 source_data_type;
72 u16 error_flags;
73 u64 source_address;
74 u64 source_len;
75 u64 bytes_dumped;
76 u64 destination_address;
77};
78
79/* ibm,configure-kernel-dump header. */
80struct fadump_section_header {
81 u32 dump_format_version;
82 u16 dump_num_sections;
83 u16 dump_status_flag;
84 u32 offset_first_dump_section;
85
86 /* Fields for disk dump option. */
87 u32 dd_block_size;
88 u64 dd_block_offset;
89 u64 dd_num_blocks;
90 u32 dd_offset_disk_path;
91
92 /* Maximum time allowed to prevent an automatic dump-reboot. */
93 u32 max_time_auto;
94};
95
96/*
97 * Firmware Assisted dump memory structure. This structure is required for
98 * registering future kernel dump with power firmware through rtas call.
99 *
100 * No disk dump option. Hence disk dump path string section is not included.
101 */
102struct fadump_mem_struct {
103 struct fadump_section_header header;
104
105 /* Kernel dump sections */
106 struct fadump_section cpu_state_data;
107 struct fadump_section hpte_region;
108 struct fadump_section rmr_region;
109};
110
111/* Firmware-assisted dump configuration details. */
eb39c880
MS
112struct fw_dump {
113 unsigned long cpu_state_data_size;
114 unsigned long hpte_region_size;
115 unsigned long boot_memory_size;
116 unsigned long reserve_dump_area_start;
117 unsigned long reserve_dump_area_size;
118 /* cmd line option during boot */
119 unsigned long reserve_bootvar;
120
2df173d9 121 unsigned long fadumphdr_addr;
eb39c880
MS
122 int ibm_configure_kernel_dump;
123
124 unsigned long fadump_enabled:1;
125 unsigned long fadump_supported:1;
126 unsigned long dump_active:1;
3ccc00a7 127 unsigned long dump_registered:1;
eb39c880
MS
128};
129
2df173d9
MS
130/*
131 * Copy the ascii values for first 8 characters from a string into u64
132 * variable at their respective indexes.
133 * e.g.
134 * The string "FADMPINF" will be converted into 0x4641444d50494e46
135 */
136static inline u64 str_to_u64(const char *str)
137{
138 u64 val = 0;
139 int i;
140
141 for (i = 0; i < sizeof(val); i++)
142 val = (*str) ? (val << 8) | *str++ : val << 8;
143 return val;
144}
145#define STR_TO_HEX(x) str_to_u64(x)
146
147#define FADUMP_CRASH_INFO_MAGIC STR_TO_HEX("FADMPINF")
148
149/* fadump crash info structure */
150struct fadump_crash_info_header {
151 u64 magic_number;
152 u64 elfcorehdr_addr;
153};
154
155/* Crash memory ranges */
156#define INIT_CRASHMEM_RANGES (INIT_MEMBLOCK_REGIONS + 2)
157
158struct fad_crash_memory_ranges {
159 unsigned long long base;
160 unsigned long long size;
161};
162
eb39c880
MS
163extern int early_init_dt_scan_fw_dump(unsigned long node,
164 const char *uname, int depth, void *data);
165extern int fadump_reserve_mem(void);
3ccc00a7
MS
166extern int setup_fadump(void);
167extern int is_fadump_active(void);
168#else /* CONFIG_FA_DUMP */
169static inline int is_fadump_active(void) { return 0; }
eb39c880
MS
170#endif
171#endif
This page took 0.0514 seconds and 5 git commands to generate.