1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_PANIC_H 28*7c478bd9Sstevel@tonic-gate #define _SYS_PANIC_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #if !defined(_ASM) 33*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 34*7c478bd9Sstevel@tonic-gate #include <sys/thread.h> 35*7c478bd9Sstevel@tonic-gate #include <sys/cpuvar.h> 36*7c478bd9Sstevel@tonic-gate #endif /* !_ASM */ 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 39*7c478bd9Sstevel@tonic-gate extern "C" { 40*7c478bd9Sstevel@tonic-gate #endif 41*7c478bd9Sstevel@tonic-gate 42*7c478bd9Sstevel@tonic-gate #ifdef _LP64 43*7c478bd9Sstevel@tonic-gate #define PANICSTKSIZE 16384 44*7c478bd9Sstevel@tonic-gate #else 45*7c478bd9Sstevel@tonic-gate #define PANICSTKSIZE 8192 46*7c478bd9Sstevel@tonic-gate #endif 47*7c478bd9Sstevel@tonic-gate 48*7c478bd9Sstevel@tonic-gate #define PANICBUFSIZE 8192 49*7c478bd9Sstevel@tonic-gate #define PANICBUFVERS 1 50*7c478bd9Sstevel@tonic-gate 51*7c478bd9Sstevel@tonic-gate #define PANICNVNAMELEN 16 52*7c478bd9Sstevel@tonic-gate 53*7c478bd9Sstevel@tonic-gate /* 54*7c478bd9Sstevel@tonic-gate * Panicbuf Format: 55*7c478bd9Sstevel@tonic-gate * 56*7c478bd9Sstevel@tonic-gate * The kernel records the formatted panic message and an optional array of 57*7c478bd9Sstevel@tonic-gate * name/value pairs into panicbuf[], a fixed-size buffer which is saved in 58*7c478bd9Sstevel@tonic-gate * the crash dump and, on some platforms, is persistent across reboots. 59*7c478bd9Sstevel@tonic-gate * The initial part of the buffer is a struct of type panic_data_t, which 60*7c478bd9Sstevel@tonic-gate * includes a version number for identifying the format of subsequent data. 61*7c478bd9Sstevel@tonic-gate * 62*7c478bd9Sstevel@tonic-gate * The pd_msgoff word identifies the byte offset into panicbuf[] at which the 63*7c478bd9Sstevel@tonic-gate * null-terminated panic message is located. This is followed by an optional 64*7c478bd9Sstevel@tonic-gate * variable-sized array of panic_nv_t items, which are used to record CPU 65*7c478bd9Sstevel@tonic-gate * register values. The number of items in pd_nvdata is computed as follows: 66*7c478bd9Sstevel@tonic-gate * 67*7c478bd9Sstevel@tonic-gate * (pd_msgoff - (sizeof (panic_data_t) - sizeof (panic_nv_t))) / 68*7c478bd9Sstevel@tonic-gate * sizeof (panic_nv_t); 69*7c478bd9Sstevel@tonic-gate * 70*7c478bd9Sstevel@tonic-gate * In addition to panicbuf, debuggers can access the panic_* variables shown 71*7c478bd9Sstevel@tonic-gate * below to determine more information about the initiator of the panic. 72*7c478bd9Sstevel@tonic-gate */ 73*7c478bd9Sstevel@tonic-gate 74*7c478bd9Sstevel@tonic-gate #if !defined(_ASM) 75*7c478bd9Sstevel@tonic-gate 76*7c478bd9Sstevel@tonic-gate typedef struct panic_nv { 77*7c478bd9Sstevel@tonic-gate char pnv_name[PANICNVNAMELEN]; /* String name */ 78*7c478bd9Sstevel@tonic-gate uint64_t pnv_value; /* Value */ 79*7c478bd9Sstevel@tonic-gate } panic_nv_t; 80*7c478bd9Sstevel@tonic-gate 81*7c478bd9Sstevel@tonic-gate typedef struct panic_data { 82*7c478bd9Sstevel@tonic-gate uint32_t pd_version; /* Version number of panic_data_t */ 83*7c478bd9Sstevel@tonic-gate uint32_t pd_msgoff; /* Message byte offset in panicbuf */ 84*7c478bd9Sstevel@tonic-gate panic_nv_t pd_nvdata[1]; /* Array of named data */ 85*7c478bd9Sstevel@tonic-gate } panic_data_t; 86*7c478bd9Sstevel@tonic-gate 87*7c478bd9Sstevel@tonic-gate #if defined(_KERNEL) 88*7c478bd9Sstevel@tonic-gate 89*7c478bd9Sstevel@tonic-gate /* 90*7c478bd9Sstevel@tonic-gate * Kernel macros for adding information to pd_nvdata[]. PANICNVGET() returns 91*7c478bd9Sstevel@tonic-gate * a panic_nv_t pointer (pnv) after the end of the existing data, PANICNVADD() 92*7c478bd9Sstevel@tonic-gate * modifies the current item and increments pnv, and PANICNVSET() rewrites 93*7c478bd9Sstevel@tonic-gate * pd_msgoff to indicate the end of pd_nvdata[]. 94*7c478bd9Sstevel@tonic-gate */ 95*7c478bd9Sstevel@tonic-gate #define PANICNVGET(pdp) \ 96*7c478bd9Sstevel@tonic-gate ((pdp)->pd_nvdata + (((pdp)->pd_msgoff - \ 97*7c478bd9Sstevel@tonic-gate (sizeof (panic_data_t) - sizeof (panic_nv_t))) / sizeof (panic_nv_t))) 98*7c478bd9Sstevel@tonic-gate 99*7c478bd9Sstevel@tonic-gate #define PANICNVADD(pnv, n, v) \ 100*7c478bd9Sstevel@tonic-gate { \ 101*7c478bd9Sstevel@tonic-gate (void) strncpy((pnv)->pnv_name, (n), PANICNVNAMELEN); \ 102*7c478bd9Sstevel@tonic-gate (pnv)->pnv_value = (uint64_t)(v); (pnv)++; \ 103*7c478bd9Sstevel@tonic-gate } 104*7c478bd9Sstevel@tonic-gate 105*7c478bd9Sstevel@tonic-gate #define PANICNVSET(pdp, pnv) \ 106*7c478bd9Sstevel@tonic-gate (pdp)->pd_msgoff = (uint32_t)((char *)(pnv) - (char *)(pdp)); 107*7c478bd9Sstevel@tonic-gate 108*7c478bd9Sstevel@tonic-gate /* 109*7c478bd9Sstevel@tonic-gate * Kernel panic data; preserved in crash dump for debuggers. 110*7c478bd9Sstevel@tonic-gate */ 111*7c478bd9Sstevel@tonic-gate #pragma align 8(panicbuf) 112*7c478bd9Sstevel@tonic-gate extern char panicbuf[PANICBUFSIZE]; 113*7c478bd9Sstevel@tonic-gate extern kthread_t *panic_thread; 114*7c478bd9Sstevel@tonic-gate extern cpu_t panic_cpu; 115*7c478bd9Sstevel@tonic-gate extern hrtime_t panic_hrtime; 116*7c478bd9Sstevel@tonic-gate extern timespec_t panic_hrestime; 117*7c478bd9Sstevel@tonic-gate 118*7c478bd9Sstevel@tonic-gate /* 119*7c478bd9Sstevel@tonic-gate * Miscellaneous state variables defined in or used by the panic code: 120*7c478bd9Sstevel@tonic-gate */ 121*7c478bd9Sstevel@tonic-gate extern char *panic_bootstr; 122*7c478bd9Sstevel@tonic-gate extern int panic_bootfcn; 123*7c478bd9Sstevel@tonic-gate extern int panic_forced; 124*7c478bd9Sstevel@tonic-gate extern int halt_on_panic; 125*7c478bd9Sstevel@tonic-gate extern int nopanicdebug; 126*7c478bd9Sstevel@tonic-gate extern int do_polled_io; 127*7c478bd9Sstevel@tonic-gate extern int obpdebug; 128*7c478bd9Sstevel@tonic-gate extern int in_sync; 129*7c478bd9Sstevel@tonic-gate extern int panic_quiesce; 130*7c478bd9Sstevel@tonic-gate extern int panic_sync; 131*7c478bd9Sstevel@tonic-gate extern int panic_dump; 132*7c478bd9Sstevel@tonic-gate 133*7c478bd9Sstevel@tonic-gate /* 134*7c478bd9Sstevel@tonic-gate * Forward declarations for types: 135*7c478bd9Sstevel@tonic-gate */ 136*7c478bd9Sstevel@tonic-gate struct trap_info; 137*7c478bd9Sstevel@tonic-gate struct regs; 138*7c478bd9Sstevel@tonic-gate 139*7c478bd9Sstevel@tonic-gate /* 140*7c478bd9Sstevel@tonic-gate * Panic functions called from the common panic code which must be 141*7c478bd9Sstevel@tonic-gate * implemented by architecture or platform-specific code: 142*7c478bd9Sstevel@tonic-gate */ 143*7c478bd9Sstevel@tonic-gate extern void panic_saveregs(panic_data_t *, struct regs *); 144*7c478bd9Sstevel@tonic-gate extern void panic_savetrap(panic_data_t *, struct trap_info *); 145*7c478bd9Sstevel@tonic-gate extern void panic_showtrap(struct trap_info *); 146*7c478bd9Sstevel@tonic-gate extern void panic_stopcpus(cpu_t *, kthread_t *, int); 147*7c478bd9Sstevel@tonic-gate extern void panic_enter_hw(int); 148*7c478bd9Sstevel@tonic-gate extern void panic_quiesce_hw(panic_data_t *); 149*7c478bd9Sstevel@tonic-gate extern void panic_dump_hw(int); 150*7c478bd9Sstevel@tonic-gate extern int panic_trigger(int *); 151*7c478bd9Sstevel@tonic-gate 152*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 153*7c478bd9Sstevel@tonic-gate #endif /* !_ASM */ 154*7c478bd9Sstevel@tonic-gate 155*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 156*7c478bd9Sstevel@tonic-gate } 157*7c478bd9Sstevel@tonic-gate #endif 158*7c478bd9Sstevel@tonic-gate 159*7c478bd9Sstevel@tonic-gate #endif /* _SYS_PANIC_H */ 160