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 2004 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 #include <sys/fm/util.h> 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 /* 43 * The dump header describes the contents of a crash dump. Two headers 44 * are written out: one at the beginning of the dump, and the other at 45 * the very end of the dump device. The terminal header is at a known 46 * location (end of device) so we can always find it. The initial header 47 * is redundant, but helps savecore(1M) determine whether the dump has been 48 * overwritten by swap activity. See dumpadm(1M) for dump configuration. 49 */ 50 #define DUMP_MAGIC 0xdefec8edU /* dump magic number */ 51 #define DUMP_VERSION 9 /* version of this dumphdr */ 52 #define DUMP_WORDSIZE (sizeof (long) * NBBY) /* word size (32 or 64) */ 53 #define DUMP_PANICSIZE 200 /* Max panic string copied */ 54 #define DUMP_COMPRESS_RATIO 2 /* conservative; usually 2.5+ */ 55 #define DUMP_OFFSET 65536 /* pad at start/end of dev */ 56 #define DUMP_LOGSIZE (2 * LOG_HIWAT) /* /dev/log message save area */ 57 #define DUMP_ERPTSIZE (P2ROUNDUP( \ 58 (ERPT_DATA_SZ / 2) * \ 59 (ERPT_EVCH_MAX + \ 60 ERPT_MAX_ERRS * ERPT_HIWAT), \ 61 DUMP_OFFSET)) /* ereport save area */ 62 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 } dumphdr_t; 85 86 /* 87 * Values for dump_flags 88 */ 89 #define DF_VALID 0x00000001 /* Dump is valid (savecore clears) */ 90 #define DF_COMPLETE 0x00000002 /* All pages present as configured */ 91 #define DF_LIVE 0x00000004 /* Dump was taken on a live system */ 92 #define DF_KERNEL 0x00010000 /* Contains kernel pages only */ 93 #define DF_ALL 0x00020000 /* Contains all pages */ 94 #define DF_CURPROC 0x00040000 /* Contains kernel + cur proc pages */ 95 #define DF_CONTENT 0xffff0000 /* The set of all dump content flags */ 96 97 /* 98 * Dump translation map hash table entry. 99 */ 100 typedef struct dump_map { 101 offset_t dm_first; 102 offset_t dm_next; 103 offset_t dm_data; 104 struct as *dm_as; 105 uintptr_t dm_va; 106 } dump_map_t; 107 108 /* 109 * Dump translation map hash function. 110 */ 111 #define DUMP_HASH(dhp, as, va) \ 112 ((((uintptr_t)(as) >> 3) + ((va) >> (dhp)->dump_pageshift)) & \ 113 (dhp)->dump_hashmask) 114 115 #ifdef _KERNEL 116 117 extern kmutex_t dump_lock; 118 extern struct vnode *dumpvp; 119 extern u_offset_t dumpvp_size; 120 extern struct dumphdr *dumphdr; 121 extern int dump_conflags; 122 extern char *dumppath; 123 124 extern int dump_timeout; 125 extern int dump_timeleft; 126 extern int sync_timeout; 127 extern int sync_timeleft; 128 129 extern int dumpinit(struct vnode *, char *, int); 130 extern void dumpfini(void); 131 extern void dump_resize(void); 132 extern void dump_page(pfn_t); 133 extern void dump_addpage(struct as *, void *, pfn_t); 134 extern void dumpsys(void); 135 extern void dump_messages(void); 136 extern void dump_ereports(void); 137 extern void dumpvp_write(const void *, size_t); 138 139 #endif /* _KERNEL */ 140 141 #ifdef __cplusplus 142 } 143 #endif 144 145 #endif /* _SYS_DUMPHDR_H */ 146