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 5*5084Sjohnlev * Common Development and Distribution License (the "License"). 6*5084Sjohnlev * 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*5084Sjohnlev * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _SYS_PANIC_H 270Sstevel@tonic-gate #define _SYS_PANIC_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate #if !defined(_ASM) 320Sstevel@tonic-gate #include <sys/types.h> 330Sstevel@tonic-gate #include <sys/thread.h> 340Sstevel@tonic-gate #include <sys/cpuvar.h> 350Sstevel@tonic-gate #endif /* !_ASM */ 360Sstevel@tonic-gate 370Sstevel@tonic-gate #ifdef __cplusplus 380Sstevel@tonic-gate extern "C" { 390Sstevel@tonic-gate #endif 400Sstevel@tonic-gate 410Sstevel@tonic-gate #ifdef _LP64 420Sstevel@tonic-gate #define PANICSTKSIZE 16384 430Sstevel@tonic-gate #else 440Sstevel@tonic-gate #define PANICSTKSIZE 8192 450Sstevel@tonic-gate #endif 460Sstevel@tonic-gate 470Sstevel@tonic-gate #define PANICBUFSIZE 8192 480Sstevel@tonic-gate #define PANICBUFVERS 1 490Sstevel@tonic-gate 500Sstevel@tonic-gate #define PANICNVNAMELEN 16 510Sstevel@tonic-gate 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 */ 830Sstevel@tonic-gate panic_nv_t pd_nvdata[1]; /* Array of named data */ 840Sstevel@tonic-gate } panic_data_t; 850Sstevel@tonic-gate 860Sstevel@tonic-gate #if defined(_KERNEL) 870Sstevel@tonic-gate 880Sstevel@tonic-gate /* 890Sstevel@tonic-gate * Kernel macros for adding information to pd_nvdata[]. PANICNVGET() returns 900Sstevel@tonic-gate * a panic_nv_t pointer (pnv) after the end of the existing data, PANICNVADD() 910Sstevel@tonic-gate * modifies the current item and increments pnv, and PANICNVSET() rewrites 920Sstevel@tonic-gate * pd_msgoff to indicate the end of pd_nvdata[]. 930Sstevel@tonic-gate */ 940Sstevel@tonic-gate #define PANICNVGET(pdp) \ 950Sstevel@tonic-gate ((pdp)->pd_nvdata + (((pdp)->pd_msgoff - \ 960Sstevel@tonic-gate (sizeof (panic_data_t) - sizeof (panic_nv_t))) / sizeof (panic_nv_t))) 970Sstevel@tonic-gate 980Sstevel@tonic-gate #define PANICNVADD(pnv, n, v) \ 990Sstevel@tonic-gate { \ 1000Sstevel@tonic-gate (void) strncpy((pnv)->pnv_name, (n), PANICNVNAMELEN); \ 1010Sstevel@tonic-gate (pnv)->pnv_value = (uint64_t)(v); (pnv)++; \ 1020Sstevel@tonic-gate } 1030Sstevel@tonic-gate 1040Sstevel@tonic-gate #define PANICNVSET(pdp, pnv) \ 1050Sstevel@tonic-gate (pdp)->pd_msgoff = (uint32_t)((char *)(pnv) - (char *)(pdp)); 1060Sstevel@tonic-gate 1070Sstevel@tonic-gate /* 1080Sstevel@tonic-gate * Kernel panic data; preserved in crash dump for debuggers. 1090Sstevel@tonic-gate */ 1100Sstevel@tonic-gate #pragma align 8(panicbuf) 1110Sstevel@tonic-gate extern char panicbuf[PANICBUFSIZE]; 1120Sstevel@tonic-gate extern kthread_t *panic_thread; 1130Sstevel@tonic-gate extern cpu_t panic_cpu; 1140Sstevel@tonic-gate extern hrtime_t panic_hrtime; 1150Sstevel@tonic-gate extern timespec_t panic_hrestime; 1160Sstevel@tonic-gate 1170Sstevel@tonic-gate /* 118*5084Sjohnlev * Forward declarations for types: 119*5084Sjohnlev */ 120*5084Sjohnlev struct panic_trap_info; 121*5084Sjohnlev struct regs; 122*5084Sjohnlev 123*5084Sjohnlev /* 1240Sstevel@tonic-gate * Miscellaneous state variables defined in or used by the panic code: 1250Sstevel@tonic-gate */ 1260Sstevel@tonic-gate extern char *panic_bootstr; 1270Sstevel@tonic-gate extern int panic_bootfcn; 1280Sstevel@tonic-gate extern int panic_forced; 1290Sstevel@tonic-gate extern int halt_on_panic; 1300Sstevel@tonic-gate extern int nopanicdebug; 1310Sstevel@tonic-gate extern int do_polled_io; 1320Sstevel@tonic-gate extern int obpdebug; 1330Sstevel@tonic-gate extern int in_sync; 1340Sstevel@tonic-gate extern int panic_quiesce; 1350Sstevel@tonic-gate extern int panic_sync; 1360Sstevel@tonic-gate extern int panic_dump; 137*5084Sjohnlev extern int64_t panic_lbolt64; 138*5084Sjohnlev extern label_t panic_regs; 139*5084Sjohnlev extern struct regs *panic_reg; 1400Sstevel@tonic-gate 1410Sstevel@tonic-gate /* 1420Sstevel@tonic-gate * Panic functions called from the common panic code which must be 1430Sstevel@tonic-gate * implemented by architecture or platform-specific code: 1440Sstevel@tonic-gate */ 1450Sstevel@tonic-gate extern void panic_saveregs(panic_data_t *, struct regs *); 146*5084Sjohnlev extern void panic_savetrap(panic_data_t *, struct panic_trap_info *); 147*5084Sjohnlev extern void panic_showtrap(struct panic_trap_info *); 1480Sstevel@tonic-gate extern void panic_stopcpus(cpu_t *, kthread_t *, int); 1490Sstevel@tonic-gate extern void panic_enter_hw(int); 1500Sstevel@tonic-gate extern void panic_quiesce_hw(panic_data_t *); 1510Sstevel@tonic-gate extern void panic_dump_hw(int); 1520Sstevel@tonic-gate extern int panic_trigger(int *); 1530Sstevel@tonic-gate 1540Sstevel@tonic-gate #endif /* _KERNEL */ 1550Sstevel@tonic-gate #endif /* !_ASM */ 1560Sstevel@tonic-gate 1570Sstevel@tonic-gate #ifdef __cplusplus 1580Sstevel@tonic-gate } 1590Sstevel@tonic-gate #endif 1600Sstevel@tonic-gate 1610Sstevel@tonic-gate #endif /* _SYS_PANIC_H */ 162