8442 uts: startup_bios_disk() should check for BIOS
[unleashed.git] / include / sys / dumphdr.h
blob3d0cce88b479bf72fc14c9d2785d483d59e2bc8d
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2016 by Delphix. All rights reserved.
26 #ifndef _SYS_DUMPHDR_H
27 #define _SYS_DUMPHDR_H
29 #include <sys/types.h>
30 #include <sys/param.h>
31 #include <sys/utsname.h>
32 #include <sys/log.h>
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
39 * The dump header describes the contents of a crash dump. Two headers
40 * are written out: one at the beginning of the dump, and the other at
41 * the very end of the dump device. The terminal header is at a known
42 * location (end of device) so we can always find it. The initial header
43 * is redundant, but helps savecore(8) determine whether the dump has been
44 * overwritten by swap activity. See dumpadm(8) for dump configuration.
46 #define DUMP_MAGIC 0xdefec8edU /* dump magic number */
47 #define DUMP_VERSION 10 /* version of this dumphdr */
48 #define DUMP_WORDSIZE (sizeof (long) * NBBY) /* word size (32 or 64) */
49 #define DUMP_PANICSIZE 200 /* Max panic string copied */
50 #define DUMP_COMPRESS_RATIO 2 /* conservative; usually 2.5+ */
51 #define DUMP_OFFSET 65536 /* pad at start/end of dev */
52 #define DUMP_LOGSIZE (2 * LOG_HIWAT) /* /dev/log message save area */
53 #define DUMP_ERPTSIZE (P2ROUNDUP( \
54 (ERPT_DATA_SZ / 2) * \
55 (ERPT_EVCH_MAX + \
56 ERPT_MAX_ERRS * ERPT_HIWAT), \
57 DUMP_OFFSET)) /* ereport save area */
58 #define DUMP_SUMMARYSIZE (P2ROUNDUP( \
59 (STACK_BUF_SIZE + \
60 sizeof (summary_dump_t) + 1024), \
61 DUMP_OFFSET)) /* summary save area */
63 typedef struct dumphdr {
64 uint32_t dump_magic; /* magic number */
65 uint32_t dump_version; /* version number */
66 uint32_t dump_flags; /* flags; see below */
67 uint32_t dump_wordsize; /* 32 or 64 */
68 offset_t dump_start; /* starting offset on dump device */
69 offset_t dump_ksyms; /* offset of compressed symbol table */
70 offset_t dump_pfn; /* offset of pfn table for all pages */
71 offset_t dump_map; /* offset of page translation map */
72 offset_t dump_data; /* offset of actual dump data */
73 struct utsname dump_utsname; /* copy of utsname structure */
74 char dump_platform[SYS_NMLN]; /* platform name (uname -i) */
75 char dump_panicstring[DUMP_PANICSIZE]; /* copy of panicstr */
76 time_t dump_crashtime; /* time of crash */
77 long dump_pageshift; /* log2(pagesize) */
78 long dump_pagesize; /* pagesize */
79 long dump_hashmask; /* page translation hash mask */
80 long dump_nvtop; /* number of vtop table entries */
81 pgcnt_t dump_npages; /* number of data pages */
82 size_t dump_ksyms_size; /* kernel symbol table size */
83 size_t dump_ksyms_csize; /* compressed symbol table size */
84 uint32_t dump_fm_panic; /* initiated from fm subsystems */
85 char dump_uuid[36 + 1]; /* os image uuid */
86 } dumphdr_t;
89 * Values for dump_flags
91 #define DF_VALID 0x00000001 /* Dump is valid (savecore clears) */
92 #define DF_COMPLETE 0x00000002 /* All pages present as configured */
93 #define DF_LIVE 0x00000004 /* Dump was taken on a live system */
94 #define DF_COMPRESSED 0x00000008 /* Dump is compressed */
95 #define DF_KERNEL 0x00010000 /* Contains kernel pages only */
96 #define DF_ALL 0x00020000 /* Contains all pages */
97 #define DF_CURPROC 0x00040000 /* Contains kernel + cur proc pages */
98 #define DF_CONTENT 0xffff0000 /* The set of all dump content flags */
101 * Dump translation map hash table entry.
103 typedef struct dump_map {
104 offset_t dm_first;
105 offset_t dm_next;
106 offset_t dm_data;
107 struct as *dm_as;
108 uintptr_t dm_va;
109 } dump_map_t;
112 * Dump translation map hash function.
114 #define DUMP_HASH(dhp, as, va) \
115 ((((uintptr_t)(as) >> 3) + ((va) >> (dhp)->dump_pageshift)) & \
116 (dhp)->dump_hashmask)
119 * Encoding of the csize word used to provide meta information
120 * between dumpsys and savecore.
122 * tag size
123 * 1-4095 1..dump_maxcsize stream block
124 * 0 1..pagesize one lzjb page
125 * 0 0 marks end of data
127 typedef uint32_t dumpcsize_t;
129 #define DUMP_MAX_TAG (0xfffU)
130 #define DUMP_MAX_CSIZE (0xfffffU)
131 #define DUMP_SET_TAG(w, v) (((w) & DUMP_MAX_CSIZE) | ((v) << 20))
132 #define DUMP_GET_TAG(w) (((w) >> 20) & DUMP_MAX_TAG)
133 #define DUMP_SET_CSIZE(w, v) \
134 (((w) & (DUMP_MAX_TAG << 20)) | ((v) & DUMP_MAX_CSIZE))
135 #define DUMP_GET_CSIZE(w) ((w) & DUMP_MAX_CSIZE)
137 typedef struct dumpstreamhdr {
138 char stream_magic[8]; /* "StrmHdr" */
139 pgcnt_t stream_pagenum; /* starting pfn */
140 pgcnt_t stream_npages; /* uncompressed size */
141 } dumpstreamhdr_t;
143 #define DUMP_STREAM_MAGIC "StrmHdr"
145 /* The number of helpers is limited by the number of stream tags. */
146 #define DUMP_MAX_NHELPER DUMP_MAX_TAG
149 * The dump data header is placed after the dumphdr in the compressed
150 * image. It is not needed after savecore runs and the data pages have
151 * been decompressed.
153 typedef struct dumpdatahdr {
154 uint32_t dump_datahdr_magic; /* data header presence */
155 uint32_t dump_datahdr_version; /* data header version */
156 uint64_t dump_data_csize; /* compressed data size */
157 uint32_t dump_maxcsize; /* compressed data max block size */
158 uint32_t dump_maxrange; /* max number of pages per range */
159 uint16_t dump_nstreams; /* number of compression streams */
160 uint16_t dump_clevel; /* compression level (0-9) */
161 uint32_t dump_metrics; /* size of metrics data */
162 } dumpdatahdr_t;
164 #define DUMP_DATAHDR_MAGIC ('d' << 24 | 'h' << 16 | 'd' << 8 | 'r')
166 #define DUMP_DATAHDR_VERSION 1
167 #define DUMP_CLEVEL_LZJB 1 /* parallel lzjb compression */
168 #define DUMP_CLEVEL_BZIP2 2 /* parallel bzip2 level 1 */
170 #ifdef _KERNEL
172 extern kmutex_t dump_lock;
173 extern struct vnode *dumpvp;
174 extern uoff_t dumpvp_size;
175 extern struct dumphdr *dumphdr;
176 extern int dump_conflags;
177 extern char *dumppath;
179 extern int dump_timeout;
180 extern int dump_timeleft;
181 extern int dump_ioerr;
183 extern int dumpinit(struct vnode *, char *, int);
184 extern void dumpfini(void);
185 extern void dump_resize(void);
186 extern void dump_page(pfn_t);
187 extern void dump_addpage(struct as *, void *, pfn_t);
188 extern void dumpsys(void);
189 extern void dump_messages(void);
190 extern void dump_ereports(void);
191 extern void dumpvp_write(const void *, size_t);
192 extern int dumpvp_resize(void);
193 extern int dump_plat_addr(void);
194 extern void dump_plat_pfn(void);
195 extern int dump_plat_data(void *);
196 extern int dump_set_uuid(const char *);
197 extern const char *dump_get_uuid(void);
200 * Define a CPU count threshold that determines when to employ
201 * bzip2. This value is defined per-platform.
203 extern uint_t dump_plat_mincpu_default;
205 #define DUMP_PLAT_SUN4U_MINCPU 0
206 #define DUMP_PLAT_SUN4U_OPL_MINCPU 0
207 #define DUMP_PLAT_SUN4V_MINCPU 0
208 #define DUMP_PLAT_X86_64_MINCPU 0
209 #define DUMP_PLAT_X86_32_MINCPU 0
212 * Override the per-platform default by setting this variable with
213 * /etc/system. The value 0 disables parallelism, and the old format
214 * dump is produced.
216 extern uint_t dump_plat_mincpu;
218 #endif /* _KERNEL */
220 #ifdef __cplusplus
222 #endif
224 #endif /* _SYS_DUMPHDR_H */