10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 55084Sjohnlev * Common Development and Distribution License (the "License"). 65084Sjohnlev * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*12967Sgavin.maltby@oracle.com * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 230Sstevel@tonic-gate */ 240Sstevel@tonic-gate 250Sstevel@tonic-gate #ifndef _SYS_PANIC_H 260Sstevel@tonic-gate #define _SYS_PANIC_H 270Sstevel@tonic-gate 280Sstevel@tonic-gate #if !defined(_ASM) 290Sstevel@tonic-gate #include <sys/types.h> 300Sstevel@tonic-gate #include <sys/thread.h> 310Sstevel@tonic-gate #include <sys/cpuvar.h> 320Sstevel@tonic-gate #endif /* !_ASM */ 330Sstevel@tonic-gate 340Sstevel@tonic-gate #ifdef __cplusplus 350Sstevel@tonic-gate extern "C" { 360Sstevel@tonic-gate #endif 370Sstevel@tonic-gate 380Sstevel@tonic-gate #ifdef _LP64 390Sstevel@tonic-gate #define PANICSTKSIZE 16384 400Sstevel@tonic-gate #else 410Sstevel@tonic-gate #define PANICSTKSIZE 8192 420Sstevel@tonic-gate #endif 430Sstevel@tonic-gate 440Sstevel@tonic-gate #define PANICBUFSIZE 8192 45*12967Sgavin.maltby@oracle.com #define PANICBUFVERS 2 460Sstevel@tonic-gate 470Sstevel@tonic-gate #define PANICNVNAMELEN 16 480Sstevel@tonic-gate 49*12967Sgavin.maltby@oracle.com #define STACK_BUF_SIZE 2048 50*12967Sgavin.maltby@oracle.com #define SUMMARY_MAGIC 0xdead0d8a 51*12967Sgavin.maltby@oracle.com 520Sstevel@tonic-gate /* 530Sstevel@tonic-gate * Panicbuf Format: 540Sstevel@tonic-gate * 550Sstevel@tonic-gate * The kernel records the formatted panic message and an optional array of 560Sstevel@tonic-gate * name/value pairs into panicbuf[], a fixed-size buffer which is saved in 570Sstevel@tonic-gate * the crash dump and, on some platforms, is persistent across reboots. 580Sstevel@tonic-gate * The initial part of the buffer is a struct of type panic_data_t, which 590Sstevel@tonic-gate * includes a version number for identifying the format of subsequent data. 600Sstevel@tonic-gate * 610Sstevel@tonic-gate * The pd_msgoff word identifies the byte offset into panicbuf[] at which the 620Sstevel@tonic-gate * null-terminated panic message is located. This is followed by an optional 630Sstevel@tonic-gate * variable-sized array of panic_nv_t items, which are used to record CPU 640Sstevel@tonic-gate * register values. The number of items in pd_nvdata is computed as follows: 650Sstevel@tonic-gate * 660Sstevel@tonic-gate * (pd_msgoff - (sizeof (panic_data_t) - sizeof (panic_nv_t))) / 670Sstevel@tonic-gate * sizeof (panic_nv_t); 680Sstevel@tonic-gate * 690Sstevel@tonic-gate * In addition to panicbuf, debuggers can access the panic_* variables shown 700Sstevel@tonic-gate * below to determine more information about the initiator of the panic. 710Sstevel@tonic-gate */ 720Sstevel@tonic-gate 730Sstevel@tonic-gate #if !defined(_ASM) 740Sstevel@tonic-gate 750Sstevel@tonic-gate typedef struct panic_nv { 760Sstevel@tonic-gate char pnv_name[PANICNVNAMELEN]; /* String name */ 770Sstevel@tonic-gate uint64_t pnv_value; /* Value */ 780Sstevel@tonic-gate } panic_nv_t; 790Sstevel@tonic-gate 800Sstevel@tonic-gate typedef struct panic_data { 810Sstevel@tonic-gate uint32_t pd_version; /* Version number of panic_data_t */ 820Sstevel@tonic-gate uint32_t pd_msgoff; /* Message byte offset in panicbuf */ 83*12967Sgavin.maltby@oracle.com char pd_uuid[36 + 1]; /* image uuid */ 840Sstevel@tonic-gate panic_nv_t pd_nvdata[1]; /* Array of named data */ 850Sstevel@tonic-gate } panic_data_t; 860Sstevel@tonic-gate 87*12967Sgavin.maltby@oracle.com typedef struct summary_dump { 88*12967Sgavin.maltby@oracle.com uint32_t sd_magic; /* magic number */ 89*12967Sgavin.maltby@oracle.com uint32_t sd_ssum; /* checsksum32(stack buffer) */ 90*12967Sgavin.maltby@oracle.com /* 91*12967Sgavin.maltby@oracle.com * stack buffer and other summary data follow here -- see 92*12967Sgavin.maltby@oracle.com * dump_summary() 93*12967Sgavin.maltby@oracle.com */ 94*12967Sgavin.maltby@oracle.com } summary_dump_t; 95*12967Sgavin.maltby@oracle.com 960Sstevel@tonic-gate #if defined(_KERNEL) 970Sstevel@tonic-gate 980Sstevel@tonic-gate /* 990Sstevel@tonic-gate * Kernel macros for adding information to pd_nvdata[]. PANICNVGET() returns 1000Sstevel@tonic-gate * a panic_nv_t pointer (pnv) after the end of the existing data, PANICNVADD() 1010Sstevel@tonic-gate * modifies the current item and increments pnv, and PANICNVSET() rewrites 1020Sstevel@tonic-gate * pd_msgoff to indicate the end of pd_nvdata[]. 1030Sstevel@tonic-gate */ 1040Sstevel@tonic-gate #define PANICNVGET(pdp) \ 1050Sstevel@tonic-gate ((pdp)->pd_nvdata + (((pdp)->pd_msgoff - \ 1060Sstevel@tonic-gate (sizeof (panic_data_t) - sizeof (panic_nv_t))) / sizeof (panic_nv_t))) 1070Sstevel@tonic-gate 1080Sstevel@tonic-gate #define PANICNVADD(pnv, n, v) \ 1090Sstevel@tonic-gate { \ 1100Sstevel@tonic-gate (void) strncpy((pnv)->pnv_name, (n), PANICNVNAMELEN); \ 1110Sstevel@tonic-gate (pnv)->pnv_value = (uint64_t)(v); (pnv)++; \ 1120Sstevel@tonic-gate } 1130Sstevel@tonic-gate 1140Sstevel@tonic-gate #define PANICNVSET(pdp, pnv) \ 1150Sstevel@tonic-gate (pdp)->pd_msgoff = (uint32_t)((char *)(pnv) - (char *)(pdp)); 1160Sstevel@tonic-gate 1170Sstevel@tonic-gate /* 1180Sstevel@tonic-gate * Kernel panic data; preserved in crash dump for debuggers. 1190Sstevel@tonic-gate */ 1200Sstevel@tonic-gate #pragma align 8(panicbuf) 1210Sstevel@tonic-gate extern char panicbuf[PANICBUFSIZE]; 1220Sstevel@tonic-gate extern kthread_t *panic_thread; 1230Sstevel@tonic-gate extern cpu_t panic_cpu; 1240Sstevel@tonic-gate extern hrtime_t panic_hrtime; 1250Sstevel@tonic-gate extern timespec_t panic_hrestime; 1260Sstevel@tonic-gate 1270Sstevel@tonic-gate /* 1285084Sjohnlev * Forward declarations for types: 1295084Sjohnlev */ 1305084Sjohnlev struct panic_trap_info; 1315084Sjohnlev struct regs; 1325084Sjohnlev 1335084Sjohnlev /* 1340Sstevel@tonic-gate * Miscellaneous state variables defined in or used by the panic code: 1350Sstevel@tonic-gate */ 1360Sstevel@tonic-gate extern char *panic_bootstr; 1370Sstevel@tonic-gate extern int panic_bootfcn; 1380Sstevel@tonic-gate extern int panic_forced; 1390Sstevel@tonic-gate extern int halt_on_panic; 1400Sstevel@tonic-gate extern int nopanicdebug; 1410Sstevel@tonic-gate extern int do_polled_io; 1420Sstevel@tonic-gate extern int obpdebug; 1430Sstevel@tonic-gate extern int in_sync; 1440Sstevel@tonic-gate extern int panic_quiesce; 1450Sstevel@tonic-gate extern int panic_sync; 1460Sstevel@tonic-gate extern int panic_dump; 1475084Sjohnlev extern int64_t panic_lbolt64; 1485084Sjohnlev extern label_t panic_regs; 1495084Sjohnlev extern struct regs *panic_reg; 1500Sstevel@tonic-gate 1510Sstevel@tonic-gate /* 1520Sstevel@tonic-gate * Panic functions called from the common panic code which must be 1530Sstevel@tonic-gate * implemented by architecture or platform-specific code: 1540Sstevel@tonic-gate */ 1550Sstevel@tonic-gate extern void panic_saveregs(panic_data_t *, struct regs *); 1565084Sjohnlev extern void panic_savetrap(panic_data_t *, struct panic_trap_info *); 1575084Sjohnlev extern void panic_showtrap(struct panic_trap_info *); 1580Sstevel@tonic-gate extern void panic_stopcpus(cpu_t *, kthread_t *, int); 1590Sstevel@tonic-gate extern void panic_enter_hw(int); 1600Sstevel@tonic-gate extern void panic_quiesce_hw(panic_data_t *); 1610Sstevel@tonic-gate extern void panic_dump_hw(int); 1620Sstevel@tonic-gate extern int panic_trigger(int *); 1630Sstevel@tonic-gate 1640Sstevel@tonic-gate #endif /* _KERNEL */ 1650Sstevel@tonic-gate #endif /* !_ASM */ 1660Sstevel@tonic-gate 1670Sstevel@tonic-gate #ifdef __cplusplus 1680Sstevel@tonic-gate } 1690Sstevel@tonic-gate #endif 1700Sstevel@tonic-gate 1710Sstevel@tonic-gate #endif /* _SYS_PANIC_H */ 172