xref: /titanic_51/usr/src/uts/common/sys/fm/util.h (revision fa9e4066f08beec538e775443c5be79dd423fcab)
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  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_FM_UTIL_H
28 #define	_SYS_FM_UTIL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #include <sys/nvpair.h>
37 #include <sys/errorq.h>
38 
39 /*
40  * Shared user/kernel definitions for class length, error channel name,
41  * and kernel event publisher string.
42  */
43 #define	FM_MAX_CLASS 100
44 #define	FM_ERROR_CHAN	"com.sun:fm:error"
45 #define	FM_PUB		"fm"
46 
47 /*
48  * ereport dump device transport support
49  *
50  * Ereports are written out to the dump device at a proscribed offset from the
51  * end, similar to in-transit log messages.  The ereports are represented as a
52  * erpt_dump_t header followed by ed_size bytes of packed native nvlist data.
53  *
54  * NOTE: All of these constants and the header must be defined so they have the
55  * same representation for *both* 32-bit and 64-bit producers and consumers.
56  */
57 #define	ERPT_MAGIC	0xf00d4eddU
58 #define	ERPT_MAX_ERRS	32
59 #define	ERPT_DATA_SZ	(3 * 1024)
60 #define	ERPT_EVCH_MAX	256
61 #define	ERPT_HIWAT	64
62 
63 typedef struct erpt_dump {
64 	uint32_t ed_magic;	/* ERPT_MAGIC or zero to indicate end */
65 	uint32_t ed_chksum;	/* checksum32() of packed nvlist data */
66 	uint32_t ed_size;	/* ereport (nvl) fixed buf size */
67 	uint32_t ed_pad;	/* reserved for future use */
68 	hrtime_t ed_hrt_nsec;	/* hrtime of this ereport */
69 	hrtime_t ed_hrt_base;	/* hrtime sample corresponding to ed_tod_base */
70 	struct {
71 		uint64_t sec;	/* seconds since gettimeofday() Epoch */
72 		uint64_t nsec;	/* nanoseconds past ed_tod_base.sec */
73 	} ed_tod_base;
74 } erpt_dump_t;
75 
76 #ifdef _KERNEL
77 
78 #define	FM_ERR_PIL	2	/* PIL for ereport_errorq drain processing */
79 
80 extern errorq_t *ereport_errorq;
81 extern void *ereport_dumpbuf;
82 extern size_t ereport_dumplen;
83 
84 extern void fm_init(void);
85 extern void fm_nvprint(nvlist_t *);
86 extern void fm_panic(const char *, ...);
87 extern void fm_banner(void);
88 
89 extern void fm_ereport_dump(void);
90 extern void fm_ereport_post(nvlist_t *, int);
91 
92 #endif  /* _KERNEL */
93 
94 #ifdef	__cplusplus
95 }
96 #endif
97 
98 #endif /* _SYS_FM_UTIL_H */
99