xref: /titanic_50/usr/src/cmd/fm/fmd/common/fmd_subr.h (revision 015a6ef6781cc3ceba8ad3bfbae98449b6002a1f)
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 2005 Sun Microsystems, Inc.  All rights reserved.
25  * Use is subject to license terms.
26  */
27 
28 #ifndef	_FMD_SUBR_H
29 #define	_FMD_SUBR_H
30 
31 #pragma ident	"%Z%%M%	%I%	%E% SMI"
32 
33 #include <pthread.h>
34 #include <stdarg.h>
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 extern int fmd_rw_read_held(pthread_rwlock_t *);
41 extern int fmd_rw_write_held(pthread_rwlock_t *);
42 extern int fmd_mutex_held(pthread_mutex_t *);
43 
44 #define	RW_READ_HELD(x)		fmd_rw_read_held(x)
45 #define	RW_WRITE_HELD(x)	fmd_rw_write_held(x)
46 #define	RW_LOCK_HELD(x)		(RW_READ_HELD(x) || RW_WRITE_HELD(x))
47 #define	MUTEX_HELD(x)		fmd_mutex_held(x)
48 
49 #ifdef DEBUG
50 extern int fmd_assert(const char *, const char *, int);
51 #define	ASSERT(x)	((void)((x) || fmd_assert(#x, __FILE__, __LINE__)))
52 #else
53 #define	ASSERT(x)
54 #endif
55 
56 extern void fmd_vpanic(const char *, va_list);
57 extern void fmd_panic(const char *, ...);
58 
59 extern void fmd_verror(int, const char *, va_list);
60 extern void fmd_error(int, const char *, ...);
61 
62 #define	FMD_DBG_HELP	0x0001	/* display list of debugging modes and exit */
63 #define	FMD_DBG_ERR	0x0002	/* enable error handling debug messages */
64 #define	FMD_DBG_MOD	0x0004	/* enable module subsystem debug messages */
65 #define	FMD_DBG_DISP	0x0008	/* enable dispq subsystem debug messages */
66 #define	FMD_DBG_XPRT	0x0010	/* enable transport subsystem debug messages */
67 #define	FMD_DBG_EVT	0x0020	/* enable event subsystem debug messages */
68 #define	FMD_DBG_LOG	0x0040	/* enable log subsystem debug messages */
69 #define	FMD_DBG_TMR	0x0080	/* enable timer subsystem debug messages */
70 #define	FMD_DBG_FMRI	0x0100	/* enable fmri subsystem debug messages */
71 #define	FMD_DBG_ASRU	0x0200	/* enable asru subsystem debug messages */
72 #define	FMD_DBG_CASE	0x0400	/* enable case subsystem debug messages */
73 #define	FMD_DBG_CKPT	0x0800	/* enable checkpoint debug messages */
74 #define	FMD_DBG_RPC	0x1000	/* enable rpc service debug messages */
75 #define	FMD_DBG_TRACE	0x2000	/* display matching TRACE() calls */
76 #define	FMD_DBG_ALL	0x1ffe	/* enable all modes except for HELP, TRACE */
77 
78 extern void fmd_vdprintf(int, const char *, va_list);
79 extern void fmd_dprintf(int, const char *, ...);
80 
81 extern void fmd_trace_cpp(void *, const char *, int);
82 extern void *fmd_trace(uint_t, const char *, ...);
83 
84 #ifdef DEBUG
85 #define	TRACE(args)	{ fmd_trace_cpp(fmd_trace args, __FILE__, __LINE__); }
86 #else
87 #define	TRACE(args)
88 #endif
89 
90 extern const char *fmd_ea_strerror(int);
91 extern uint64_t fmd_ena(void);
92 extern uint32_t fmd_ntz32(uint32_t);
93 
94 #ifdef	__cplusplus
95 }
96 #endif
97 
98 #endif	/* _FMD_SUBR_H */
99