17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5843e1988Sjohnlev * Common Development and Distribution License (the "License"). 6843e1988Sjohnlev * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*f6e214c7SGavin Maltby * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 237c478bd9Sstevel@tonic-gate */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate #ifndef _SYS_PANIC_H 267c478bd9Sstevel@tonic-gate #define _SYS_PANIC_H 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate #if !defined(_ASM) 297c478bd9Sstevel@tonic-gate #include <sys/types.h> 307c478bd9Sstevel@tonic-gate #include <sys/thread.h> 317c478bd9Sstevel@tonic-gate #include <sys/cpuvar.h> 327c478bd9Sstevel@tonic-gate #endif /* !_ASM */ 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #ifdef __cplusplus 357c478bd9Sstevel@tonic-gate extern "C" { 367c478bd9Sstevel@tonic-gate #endif 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #ifdef _LP64 397c478bd9Sstevel@tonic-gate #define PANICSTKSIZE 16384 407c478bd9Sstevel@tonic-gate #else 417c478bd9Sstevel@tonic-gate #define PANICSTKSIZE 8192 427c478bd9Sstevel@tonic-gate #endif 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate #define PANICBUFSIZE 8192 45*f6e214c7SGavin Maltby #define PANICBUFVERS 2 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate #define PANICNVNAMELEN 16 487c478bd9Sstevel@tonic-gate 49*f6e214c7SGavin Maltby #define STACK_BUF_SIZE 2048 50*f6e214c7SGavin Maltby #define SUMMARY_MAGIC 0xdead0d8a 51*f6e214c7SGavin Maltby 527c478bd9Sstevel@tonic-gate /* 537c478bd9Sstevel@tonic-gate * Panicbuf Format: 547c478bd9Sstevel@tonic-gate * 557c478bd9Sstevel@tonic-gate * The kernel records the formatted panic message and an optional array of 567c478bd9Sstevel@tonic-gate * name/value pairs into panicbuf[], a fixed-size buffer which is saved in 577c478bd9Sstevel@tonic-gate * the crash dump and, on some platforms, is persistent across reboots. 587c478bd9Sstevel@tonic-gate * The initial part of the buffer is a struct of type panic_data_t, which 597c478bd9Sstevel@tonic-gate * includes a version number for identifying the format of subsequent data. 607c478bd9Sstevel@tonic-gate * 617c478bd9Sstevel@tonic-gate * The pd_msgoff word identifies the byte offset into panicbuf[] at which the 627c478bd9Sstevel@tonic-gate * null-terminated panic message is located. This is followed by an optional 637c478bd9Sstevel@tonic-gate * variable-sized array of panic_nv_t items, which are used to record CPU 647c478bd9Sstevel@tonic-gate * register values. The number of items in pd_nvdata is computed as follows: 657c478bd9Sstevel@tonic-gate * 667c478bd9Sstevel@tonic-gate * (pd_msgoff - (sizeof (panic_data_t) - sizeof (panic_nv_t))) / 677c478bd9Sstevel@tonic-gate * sizeof (panic_nv_t); 687c478bd9Sstevel@tonic-gate * 697c478bd9Sstevel@tonic-gate * In addition to panicbuf, debuggers can access the panic_* variables shown 707c478bd9Sstevel@tonic-gate * below to determine more information about the initiator of the panic. 717c478bd9Sstevel@tonic-gate */ 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate #if !defined(_ASM) 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate typedef struct panic_nv { 767c478bd9Sstevel@tonic-gate char pnv_name[PANICNVNAMELEN]; /* String name */ 777c478bd9Sstevel@tonic-gate uint64_t pnv_value; /* Value */ 787c478bd9Sstevel@tonic-gate } panic_nv_t; 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate typedef struct panic_data { 817c478bd9Sstevel@tonic-gate uint32_t pd_version; /* Version number of panic_data_t */ 827c478bd9Sstevel@tonic-gate uint32_t pd_msgoff; /* Message byte offset in panicbuf */ 83*f6e214c7SGavin Maltby char pd_uuid[36 + 1]; /* image uuid */ 847c478bd9Sstevel@tonic-gate panic_nv_t pd_nvdata[1]; /* Array of named data */ 857c478bd9Sstevel@tonic-gate } panic_data_t; 867c478bd9Sstevel@tonic-gate 87*f6e214c7SGavin Maltby typedef struct summary_dump { 88*f6e214c7SGavin Maltby uint32_t sd_magic; /* magic number */ 89*f6e214c7SGavin Maltby uint32_t sd_ssum; /* checsksum32(stack buffer) */ 90*f6e214c7SGavin Maltby /* 91*f6e214c7SGavin Maltby * stack buffer and other summary data follow here -- see 92*f6e214c7SGavin Maltby * dump_summary() 93*f6e214c7SGavin Maltby */ 94*f6e214c7SGavin Maltby } summary_dump_t; 95*f6e214c7SGavin Maltby 967c478bd9Sstevel@tonic-gate #if defined(_KERNEL) 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate /* 997c478bd9Sstevel@tonic-gate * Kernel macros for adding information to pd_nvdata[]. PANICNVGET() returns 1007c478bd9Sstevel@tonic-gate * a panic_nv_t pointer (pnv) after the end of the existing data, PANICNVADD() 1017c478bd9Sstevel@tonic-gate * modifies the current item and increments pnv, and PANICNVSET() rewrites 1027c478bd9Sstevel@tonic-gate * pd_msgoff to indicate the end of pd_nvdata[]. 1037c478bd9Sstevel@tonic-gate */ 1047c478bd9Sstevel@tonic-gate #define PANICNVGET(pdp) \ 1057c478bd9Sstevel@tonic-gate ((pdp)->pd_nvdata + (((pdp)->pd_msgoff - \ 1067c478bd9Sstevel@tonic-gate (sizeof (panic_data_t) - sizeof (panic_nv_t))) / sizeof (panic_nv_t))) 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate #define PANICNVADD(pnv, n, v) \ 1097c478bd9Sstevel@tonic-gate { \ 1107c478bd9Sstevel@tonic-gate (void) strncpy((pnv)->pnv_name, (n), PANICNVNAMELEN); \ 1117c478bd9Sstevel@tonic-gate (pnv)->pnv_value = (uint64_t)(v); (pnv)++; \ 1127c478bd9Sstevel@tonic-gate } 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate #define PANICNVSET(pdp, pnv) \ 1157c478bd9Sstevel@tonic-gate (pdp)->pd_msgoff = (uint32_t)((char *)(pnv) - (char *)(pdp)); 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate /* 1187c478bd9Sstevel@tonic-gate * Kernel panic data; preserved in crash dump for debuggers. 1197c478bd9Sstevel@tonic-gate */ 1207c478bd9Sstevel@tonic-gate #pragma align 8(panicbuf) 1217c478bd9Sstevel@tonic-gate extern char panicbuf[PANICBUFSIZE]; 1227c478bd9Sstevel@tonic-gate extern kthread_t *panic_thread; 1237c478bd9Sstevel@tonic-gate extern cpu_t panic_cpu; 1247c478bd9Sstevel@tonic-gate extern hrtime_t panic_hrtime; 1257c478bd9Sstevel@tonic-gate extern timespec_t panic_hrestime; 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate /* 128843e1988Sjohnlev * Forward declarations for types: 129843e1988Sjohnlev */ 130843e1988Sjohnlev struct panic_trap_info; 131843e1988Sjohnlev struct regs; 132843e1988Sjohnlev 133843e1988Sjohnlev /* 1347c478bd9Sstevel@tonic-gate * Miscellaneous state variables defined in or used by the panic code: 1357c478bd9Sstevel@tonic-gate */ 1367c478bd9Sstevel@tonic-gate extern char *panic_bootstr; 1377c478bd9Sstevel@tonic-gate extern int panic_bootfcn; 1387c478bd9Sstevel@tonic-gate extern int panic_forced; 1397c478bd9Sstevel@tonic-gate extern int halt_on_panic; 1407c478bd9Sstevel@tonic-gate extern int nopanicdebug; 1417c478bd9Sstevel@tonic-gate extern int do_polled_io; 1427c478bd9Sstevel@tonic-gate extern int obpdebug; 1437c478bd9Sstevel@tonic-gate extern int in_sync; 1447c478bd9Sstevel@tonic-gate extern int panic_quiesce; 1457c478bd9Sstevel@tonic-gate extern int panic_sync; 1467c478bd9Sstevel@tonic-gate extern int panic_dump; 147843e1988Sjohnlev extern int64_t panic_lbolt64; 148843e1988Sjohnlev extern label_t panic_regs; 149843e1988Sjohnlev extern struct regs *panic_reg; 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate /* 1527c478bd9Sstevel@tonic-gate * Panic functions called from the common panic code which must be 1537c478bd9Sstevel@tonic-gate * implemented by architecture or platform-specific code: 1547c478bd9Sstevel@tonic-gate */ 1557c478bd9Sstevel@tonic-gate extern void panic_saveregs(panic_data_t *, struct regs *); 156843e1988Sjohnlev extern void panic_savetrap(panic_data_t *, struct panic_trap_info *); 157843e1988Sjohnlev extern void panic_showtrap(struct panic_trap_info *); 1587c478bd9Sstevel@tonic-gate extern void panic_stopcpus(cpu_t *, kthread_t *, int); 1597c478bd9Sstevel@tonic-gate extern void panic_enter_hw(int); 1607c478bd9Sstevel@tonic-gate extern void panic_quiesce_hw(panic_data_t *); 1617c478bd9Sstevel@tonic-gate extern void panic_dump_hw(int); 1627c478bd9Sstevel@tonic-gate extern int panic_trigger(int *); 1637c478bd9Sstevel@tonic-gate 1647c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1657c478bd9Sstevel@tonic-gate #endif /* !_ASM */ 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1687c478bd9Sstevel@tonic-gate } 1697c478bd9Sstevel@tonic-gate #endif 1707c478bd9Sstevel@tonic-gate 1717c478bd9Sstevel@tonic-gate #endif /* _SYS_PANIC_H */ 172