4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
29 #pragma ident "%Z%%M% %I% %E% SMI"
32 #include <sys/types.h>
33 #include <sys/thread.h>
34 #include <sys/cpuvar.h>
42 #define PANICSTKSIZE 16384
44 #define PANICSTKSIZE 8192
47 #define PANICBUFSIZE 8192
48 #define PANICBUFVERS 1
50 #define PANICNVNAMELEN 16
55 * The kernel records the formatted panic message and an optional array of
56 * name/value pairs into panicbuf[], a fixed-size buffer which is saved in
57 * the crash dump and, on some platforms, is persistent across reboots.
58 * The initial part of the buffer is a struct of type panic_data_t, which
59 * includes a version number for identifying the format of subsequent data.
61 * The pd_msgoff word identifies the byte offset into panicbuf[] at which the
62 * null-terminated panic message is located. This is followed by an optional
63 * variable-sized array of panic_nv_t items, which are used to record CPU
64 * register values. The number of items in pd_nvdata is computed as follows:
66 * (pd_msgoff - (sizeof (panic_data_t) - sizeof (panic_nv_t))) /
67 * sizeof (panic_nv_t);
69 * In addition to panicbuf, debuggers can access the panic_* variables shown
70 * below to determine more information about the initiator of the panic.
75 typedef struct panic_nv
{
76 char pnv_name
[PANICNVNAMELEN
]; /* String name */
77 uint64_t pnv_value
; /* Value */
80 typedef struct panic_data
{
81 uint32_t pd_version
; /* Version number of panic_data_t */
82 uint32_t pd_msgoff
; /* Message byte offset in panicbuf */
83 panic_nv_t pd_nvdata
[1]; /* Array of named data */
89 * Kernel macros for adding information to pd_nvdata[]. PANICNVGET() returns
90 * a panic_nv_t pointer (pnv) after the end of the existing data, PANICNVADD()
91 * modifies the current item and increments pnv, and PANICNVSET() rewrites
92 * pd_msgoff to indicate the end of pd_nvdata[].
94 #define PANICNVGET(pdp) \
95 ((pdp)->pd_nvdata + (((pdp)->pd_msgoff - \
96 (sizeof (panic_data_t) - sizeof (panic_nv_t))) / sizeof (panic_nv_t)))
98 #define PANICNVADD(pnv, n, v) \
100 (void) strncpy((pnv)->pnv_name, (n), PANICNVNAMELEN); \
101 (pnv)->pnv_value = (uint64_t)(v); (pnv)++; \
104 #define PANICNVSET(pdp, pnv) \
105 (pdp)->pd_msgoff = (uint32_t)((char *)(pnv) - (char *)(pdp));
108 * Kernel panic data; preserved in crash dump for debuggers.
110 #pragma align 8(panicbuf)
111 extern char panicbuf
[PANICBUFSIZE
];
112 extern kthread_t
*panic_thread
;
113 extern cpu_t panic_cpu
;
114 extern hrtime_t panic_hrtime
;
115 extern timespec_t panic_hrestime
;
118 * Forward declarations for types:
120 struct panic_trap_info
;
124 * Miscellaneous state variables defined in or used by the panic code:
126 extern char *panic_bootstr
;
127 extern int panic_bootfcn
;
128 extern int panic_forced
;
129 extern int halt_on_panic
;
130 extern int nopanicdebug
;
131 extern int do_polled_io
;
134 extern int panic_quiesce
;
135 extern int panic_sync
;
136 extern int panic_dump
;
137 extern int64_t panic_lbolt64
;
138 extern label_t panic_regs
;
139 extern struct regs
*panic_reg
;
142 * Panic functions called from the common panic code which must be
143 * implemented by architecture or platform-specific code:
145 extern void panic_saveregs(panic_data_t
*, struct regs
*);
146 extern void panic_savetrap(panic_data_t
*, struct panic_trap_info
*);
147 extern void panic_showtrap(struct panic_trap_info
*);
148 extern void panic_stopcpus(cpu_t
*, kthread_t
*, int);
149 extern void panic_enter_hw(int);
150 extern void panic_quiesce_hw(panic_data_t
*);
151 extern void panic_dump_hw(int);
152 extern int panic_trigger(int *);
161 #endif /* _SYS_PANIC_H */