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, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _SYS_DUMPHDR_H 28 #define _SYS_DUMPHDR_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #include <sys/types.h> 33 #include <sys/param.h> 34 #include <sys/utsname.h> 35 #include <sys/log.h> 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 /* 42 * The dump header describes the contents of a crash dump. Two headers 43 * are written out: one at the beginning of the dump, and the other at 44 * the very end of the dump device. The terminal header is at a known 45 * location (end of device) so we can always find it. The initial header 46 * is redundant, but helps savecore(1M) determine whether the dump has been 47 * overwritten by swap activity. See dumpadm(1M) for dump configuration. 48 */ 49 #define DUMP_MAGIC 0xdefec8edU /* dump magic number */ 50 #define DUMP_VERSION 9 /* version of this dumphdr */ 51 #define DUMP_WORDSIZE (sizeof (long) * NBBY) /* word size (32 or 64) */ 52 #define DUMP_PANICSIZE 200 /* Max panic string copied */ 53 #define DUMP_COMPRESS_RATIO 2 /* conservative; usually 2.5+ */ 54 #define DUMP_OFFSET 65536 /* pad at start/end of dev */ 55 #define DUMP_LOGSIZE (2 * LOG_HIWAT) /* /dev/log message save area */ 56 #define DUMP_ERPTSIZE (P2ROUNDUP( \ 57 (ERPT_DATA_SZ / 2) * \ 58 (ERPT_EVCH_MAX + \ 59 ERPT_MAX_ERRS * ERPT_HIWAT), \ 60 DUMP_OFFSET)) /* ereport save area */ 61 62 typedef struct dumphdr { 63 uint32_t dump_magic; /* magic number */ 64 uint32_t dump_version; /* version number */ 65 uint32_t dump_flags; /* flags; see below */ 66 uint32_t dump_wordsize; /* 32 or 64 */ 67 offset_t dump_start; /* starting offset on dump device */ 68 offset_t dump_ksyms; /* offset of compressed symbol table */ 69 offset_t dump_pfn; /* offset of pfn table for all pages */ 70 offset_t dump_map; /* offset of page translation map */ 71 offset_t dump_data; /* offset of actual dump data */ 72 struct utsname dump_utsname; /* copy of utsname structure */ 73 char dump_platform[SYS_NMLN]; /* platform name (uname -i) */ 74 char dump_panicstring[DUMP_PANICSIZE]; /* copy of panicstr */ 75 time_t dump_crashtime; /* time of crash */ 76 long dump_pageshift; /* log2(pagesize) */ 77 long dump_pagesize; /* pagesize */ 78 long dump_hashmask; /* page translation hash mask */ 79 long dump_nvtop; /* number of vtop table entries */ 80 pgcnt_t dump_npages; /* number of data pages */ 81 size_t dump_ksyms_size; /* kernel symbol table size */ 82 size_t dump_ksyms_csize; /* compressed symbol table size */ 83 } dumphdr_t; 84 85 /* 86 * Values for dump_flags 87 */ 88 #define DF_VALID 0x00000001 /* Dump is valid (savecore clears) */ 89 #define DF_COMPLETE 0x00000002 /* All pages present as configured */ 90 #define DF_LIVE 0x00000004 /* Dump was taken on a live system */ 91 #define DF_KERNEL 0x00010000 /* Contains kernel pages only */ 92 #define DF_ALL 0x00020000 /* Contains all pages */ 93 #define DF_CURPROC 0x00040000 /* Contains kernel + cur proc pages */ 94 #define DF_CONTENT 0xffff0000 /* The set of all dump content flags */ 95 96 /* 97 * Dump translation map hash table entry. 98 */ 99 typedef struct dump_map { 100 offset_t dm_first; 101 offset_t dm_next; 102 offset_t dm_data; 103 struct as *dm_as; 104 uintptr_t dm_va; 105 } dump_map_t; 106 107 /* 108 * Dump translation map hash function. 109 */ 110 #define DUMP_HASH(dhp, as, va) \ 111 ((((uintptr_t)(as) >> 3) + ((va) >> (dhp)->dump_pageshift)) & \ 112 (dhp)->dump_hashmask) 113 114 #ifdef _KERNEL 115 116 extern kmutex_t dump_lock; 117 extern struct vnode *dumpvp; 118 extern u_offset_t dumpvp_size; 119 extern struct dumphdr *dumphdr; 120 extern int dump_conflags; 121 extern char *dumppath; 122 123 extern int dump_timeout; 124 extern int dump_timeleft; 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 138 #endif /* _KERNEL */ 139 140 #ifdef __cplusplus 141 } 142 #endif 143 144 #endif /* _SYS_DUMPHDR_H */ 145