xref: /illumos-gate/usr/src/uts/common/sys/fm/util.h (revision 80ab886d233f514d54c2a6bdeb9fdfd951bd6881)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 
23 /*
24  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
25  * Use is subject to license terms.
26  */
27 
28 #ifndef	_SYS_FM_UTIL_H
29 #define	_SYS_FM_UTIL_H
30 
31 #pragma ident	"%Z%%M%	%I%	%E% SMI"
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 #include <sys/nvpair.h>
38 #include <sys/errorq.h>
39 
40 /*
41  * Shared user/kernel definitions for class length, error channel name,
42  * and kernel event publisher string.
43  */
44 #define	FM_MAX_CLASS 100
45 #define	FM_ERROR_CHAN	"com.sun:fm:error"
46 #define	FM_PUB		"fm"
47 
48 /*
49  * ereport dump device transport support
50  *
51  * Ereports are written out to the dump device at a proscribed offset from the
52  * end, similar to in-transit log messages.  The ereports are represented as a
53  * erpt_dump_t header followed by ed_size bytes of packed native nvlist data.
54  *
55  * NOTE: All of these constants and the header must be defined so they have the
56  * same representation for *both* 32-bit and 64-bit producers and consumers.
57  */
58 #define	ERPT_MAGIC	0xf00d4eddU
59 #define	ERPT_MAX_ERRS	32
60 #define	ERPT_DATA_SZ	(3 * 1024)
61 #define	ERPT_EVCH_MAX	256
62 #define	ERPT_HIWAT	64
63 
64 typedef struct erpt_dump {
65 	uint32_t ed_magic;	/* ERPT_MAGIC or zero to indicate end */
66 	uint32_t ed_chksum;	/* checksum32() of packed nvlist data */
67 	uint32_t ed_size;	/* ereport (nvl) fixed buf size */
68 	uint32_t ed_pad;	/* reserved for future use */
69 	hrtime_t ed_hrt_nsec;	/* hrtime of this ereport */
70 	hrtime_t ed_hrt_base;	/* hrtime sample corresponding to ed_tod_base */
71 	struct {
72 		uint64_t sec;	/* seconds since gettimeofday() Epoch */
73 		uint64_t nsec;	/* nanoseconds past ed_tod_base.sec */
74 	} ed_tod_base;
75 } erpt_dump_t;
76 
77 #ifdef _KERNEL
78 #include <sys/systm.h>
79 
80 #define	FM_STK_DEPTH	20	/* maximum stack depth */
81 #define	FM_SYM_SZ	64	/* maximum symbol size */
82 #define	FM_ERR_PIL	2	/* PIL for ereport_errorq drain processing */
83 
84 #define	FM_EREPORT_PAYLOAD_NAME_STACK		"stack"
85 
86 extern errorq_t *ereport_errorq;
87 extern void *ereport_dumpbuf;
88 extern size_t ereport_dumplen;
89 
90 extern void fm_init(void);
91 extern void fm_nvprint(nvlist_t *);
92 extern void fm_panic(const char *, ...);
93 extern void fm_banner(void);
94 
95 extern void fm_ereport_dump(void);
96 extern void fm_ereport_post(nvlist_t *, int);
97 
98 extern void fm_payload_stack_add(nvlist_t *, const pc_t *, int);
99 
100 #endif  /* _KERNEL */
101 
102 #ifdef	__cplusplus
103 }
104 #endif
105 
106 #endif /* _SYS_FM_UTIL_H */
107