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