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