xref: /titanic_50/usr/src/uts/common/sys/dumphdr.h (revision 3fbbb872ea33adea240e8fd8c692f6d3131cc69b)
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_DUMPHDR_H
27 #define	_SYS_DUMPHDR_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/types.h>
32 #include <sys/param.h>
33 #include <sys/utsname.h>
34 #include <sys/log.h>
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 /*
41  * The dump header describes the contents of a crash dump.  Two headers
42  * are written out: one at the beginning of the dump, and the other at
43  * the very end of the dump device.  The terminal header is at a known
44  * location (end of device) so we can always find it.  The initial header
45  * is redundant, but helps savecore(1M) determine whether the dump has been
46  * overwritten by swap activity.  See dumpadm(1M) for dump configuration.
47  */
48 #define	DUMP_MAGIC	0xdefec8edU		/* dump magic number */
49 #define	DUMP_VERSION	9			/* version of this dumphdr */
50 #define	DUMP_WORDSIZE	(sizeof (long) * NBBY)	/* word size (32 or 64) */
51 #define	DUMP_PANICSIZE	200			/* Max panic string copied */
52 #define	DUMP_COMPRESS_RATIO	2		/* conservative; usually 2.5+ */
53 #define	DUMP_OFFSET	65536			/* pad at start/end of dev */
54 #define	DUMP_LOGSIZE	(2 * LOG_HIWAT)		/* /dev/log message save area */
55 #define	DUMP_ERPTSIZE   (P2ROUNDUP(	\
56 	(ERPT_DATA_SZ / 2) *		\
57 	(ERPT_EVCH_MAX +		\
58 	ERPT_MAX_ERRS * ERPT_HIWAT),	\
59 	DUMP_OFFSET))				/* ereport save area */
60 
61 typedef struct dumphdr {
62 	uint32_t dump_magic;		/* magic number */
63 	uint32_t dump_version;		/* version number */
64 	uint32_t dump_flags;		/* flags; see below */
65 	uint32_t dump_wordsize;		/* 32 or 64 */
66 	offset_t dump_start;		/* starting offset on dump device */
67 	offset_t dump_ksyms;		/* offset of compressed symbol table */
68 	offset_t dump_pfn;		/* offset of pfn table for all pages */
69 	offset_t dump_map;		/* offset of page translation map */
70 	offset_t dump_data;		/* offset of actual dump data */
71 	struct utsname dump_utsname;	/* copy of utsname structure */
72 	char	dump_platform[SYS_NMLN]; /* platform name (uname -i) */
73 	char	dump_panicstring[DUMP_PANICSIZE]; /* copy of panicstr */
74 	time_t	dump_crashtime;		/* time of crash */
75 	long	dump_pageshift;		/* log2(pagesize) */
76 	long	dump_pagesize;		/* pagesize */
77 	long	dump_hashmask;		/* page translation hash mask */
78 	long	dump_nvtop;		/* number of vtop table entries */
79 	pgcnt_t	dump_npages;		/* number of data pages */
80 	size_t	dump_ksyms_size;	/* kernel symbol table size */
81 	size_t	dump_ksyms_csize;	/* compressed symbol table size */
82 } dumphdr_t;
83 
84 /*
85  * Values for dump_flags
86  */
87 #define	DF_VALID	0x00000001	/* Dump is valid (savecore clears) */
88 #define	DF_COMPLETE	0x00000002	/* All pages present as configured */
89 #define	DF_LIVE		0x00000004	/* Dump was taken on a live system */
90 #define	DF_KERNEL	0x00010000	/* Contains kernel pages only */
91 #define	DF_ALL		0x00020000	/* Contains all pages */
92 #define	DF_CURPROC	0x00040000	/* Contains kernel + cur proc pages */
93 #define	DF_CONTENT	0xffff0000	/* The set of all dump content flags */
94 
95 /*
96  * Dump translation map hash table entry.
97  */
98 typedef struct dump_map {
99 	offset_t	dm_first;
100 	offset_t	dm_next;
101 	offset_t	dm_data;
102 	struct as	*dm_as;
103 	uintptr_t	dm_va;
104 } dump_map_t;
105 
106 /*
107  * Dump translation map hash function.
108  */
109 #define	DUMP_HASH(dhp, as, va)	\
110 	((((uintptr_t)(as) >> 3) + ((va) >> (dhp)->dump_pageshift)) & \
111 	(dhp)->dump_hashmask)
112 
113 #ifdef _KERNEL
114 
115 extern kmutex_t dump_lock;
116 extern struct vnode *dumpvp;
117 extern u_offset_t dumpvp_size;
118 extern struct dumphdr *dumphdr;
119 extern int dump_conflags;
120 extern char *dumppath;
121 
122 extern int dump_timeout;
123 extern int dump_timeleft;
124 extern int dump_ioerr;
125 extern int sync_timeout;
126 extern int sync_timeleft;
127 
128 extern int dumpinit(struct vnode *, char *, int);
129 extern void dumpfini(void);
130 extern void dump_resize(void);
131 extern void dump_page(pfn_t);
132 extern void dump_addpage(struct as *, void *, pfn_t);
133 extern void dumpsys(void);
134 extern void dump_messages(void);
135 extern void dump_ereports(void);
136 extern void dumpvp_write(const void *, size_t);
137 extern int dump_plat_addr(void);
138 extern void dump_plat_pfn(void);
139 extern int dump_plat_data(void *);
140 
141 #endif /* _KERNEL */
142 
143 #ifdef	__cplusplus
144 }
145 #endif
146 
147 #endif	/* _SYS_DUMPHDR_H */
148