docs/how-to-build.md: use proper markup for directory names
[unleashed/tickless.git] / include / sys / panic.h
blob995e0a1831913a65ddb6526ccff67ab1fc4e2e65
1 /*
2 * CDDL HEADER START
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]
19 * CDDL HEADER END
22 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2016 by Delphix. All rights reserved.
26 #ifndef _SYS_PANIC_H
27 #define _SYS_PANIC_H
29 #if !defined(_ASM)
30 #include <sys/types.h>
31 #include <sys/thread.h>
32 #include <sys/cpuvar.h>
33 #endif /* !_ASM */
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
39 #ifdef _LP64
40 #define PANICSTKSIZE 16384
41 #else
42 #define PANICSTKSIZE 8192
43 #endif
45 #define PANICBUFSIZE 8192
46 #define PANICBUFVERS 2
48 #define PANICNVNAMELEN 16
50 #define STACK_BUF_SIZE 2048
51 #define SUMMARY_MAGIC 0xdead0d8a
54 * Panicbuf Format:
56 * The kernel records the formatted panic message and an optional array of
57 * name/value pairs into panicbuf[], a fixed-size buffer which is saved in
58 * the crash dump and, on some platforms, is persistent across reboots.
59 * The initial part of the buffer is a struct of type panic_data_t, which
60 * includes a version number for identifying the format of subsequent data.
62 * The pd_msgoff word identifies the byte offset into panicbuf[] at which the
63 * null-terminated panic message is located. This is followed by an optional
64 * variable-sized array of panic_nv_t items, which are used to record CPU
65 * register values. The number of items in pd_nvdata is computed as follows:
67 * (pd_msgoff - (sizeof (panic_data_t) - sizeof (panic_nv_t))) /
68 * sizeof (panic_nv_t);
70 * In addition to panicbuf, debuggers can access the panic_* variables shown
71 * below to determine more information about the initiator of the panic.
74 #if !defined(_ASM)
76 typedef struct panic_nv {
77 char pnv_name[PANICNVNAMELEN]; /* String name */
78 uint64_t pnv_value; /* Value */
79 } panic_nv_t;
81 typedef struct panic_data {
82 uint32_t pd_version; /* Version number of panic_data_t */
83 uint32_t pd_msgoff; /* Message byte offset in panicbuf */
84 char pd_uuid[36 + 1]; /* image uuid */
85 panic_nv_t pd_nvdata[1]; /* Array of named data */
86 } panic_data_t;
88 typedef struct summary_dump {
89 uint32_t sd_magic; /* magic number */
90 uint32_t sd_ssum; /* checsksum32(stack buffer) */
92 * stack buffer and other summary data follow here -- see
93 * dump_summary()
95 } summary_dump_t;
97 #if defined(_KERNEL)
100 * Kernel macros for adding information to pd_nvdata[]. PANICNVGET() returns
101 * a panic_nv_t pointer (pnv) after the end of the existing data, PANICNVADD()
102 * modifies the current item and increments pnv, and PANICNVSET() rewrites
103 * pd_msgoff to indicate the end of pd_nvdata[].
105 #define PANICNVGET(pdp) \
106 ((pdp)->pd_nvdata + (((pdp)->pd_msgoff - \
107 (sizeof (panic_data_t) - sizeof (panic_nv_t))) / sizeof (panic_nv_t)))
109 #define PANICNVADD(pnv, n, v) \
111 (void) strncpy((pnv)->pnv_name, (n), PANICNVNAMELEN); \
112 (pnv)->pnv_value = (uint64_t)(v); (pnv)++; \
115 #define PANICNVSET(pdp, pnv) \
116 (pdp)->pd_msgoff = (uint32_t)((char *)(pnv) - (char *)(pdp));
119 * Kernel panic data; preserved in crash dump for debuggers.
121 #pragma align 8(panicbuf)
122 extern char panicbuf[PANICBUFSIZE];
123 extern kthread_t *panic_thread;
124 extern cpu_t panic_cpu;
125 extern hrtime_t panic_hrtime;
126 extern timespec_t panic_hrestime;
129 * Forward declarations for types:
131 struct panic_trap_info;
132 struct regs;
135 * Miscellaneous state variables defined in or used by the panic code:
137 extern char *panic_bootstr;
138 extern int panic_bootfcn;
139 extern int panic_forced;
140 extern int halt_on_panic;
141 extern int nopanicdebug;
142 extern int do_polled_io;
143 extern int obpdebug;
144 extern int in_sync;
145 extern int panic_quiesce;
146 extern int panic_dump;
147 extern int64_t panic_lbolt64;
148 extern label_t panic_regs;
149 extern struct regs *panic_reg;
152 * Panic functions called from the common panic code which must be
153 * implemented by architecture or platform-specific code:
155 extern void panic_saveregs(panic_data_t *, struct regs *);
156 extern void panic_savetrap(panic_data_t *, struct panic_trap_info *);
157 extern void panic_showtrap(struct panic_trap_info *);
158 extern void panic_stopcpus(cpu_t *, kthread_t *, int);
159 extern void panic_enter_hw(int);
160 extern void panic_quiesce_hw(panic_data_t *);
161 extern void panic_dump_hw(int);
162 extern int panic_trigger(int *);
164 #endif /* _KERNEL */
165 #endif /* !_ASM */
167 #ifdef __cplusplus
169 #endif
171 #endif /* _SYS_PANIC_H */