xref: /titanic_50/usr/src/uts/sun4v/sys/dr_util.h (revision e4b86885570d77af552e9cf94f142f4d744fb8c8)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _DR_UTIL_H
28 #define	_DR_UTIL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * sun4v Common DR Header
34  */
35 
36 #include <sys/ksynch.h>
37 #include <sys/cmn_err.h>
38 #include <sys/note.h>
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 /*
45  * Debugging support
46  */
47 #ifdef DEBUG
48 
49 extern uint_t	dr_debug;
50 
51 #define	DR_DBG_FLAG_CTL		0x01
52 #define	DR_DBG_FLAG_CPU		0x02
53 #define	DR_DBG_FLAG_MEM		0x04
54 #define	DR_DBG_FLAG_IO		0x08
55 #define	DR_DBG_FLAG_TRANS	0x10
56 
57 #define	DR_DBG_ALL	if (dr_debug)			  printf
58 #define	DR_DBG_CTL	if (dr_debug & DR_DBG_FLAG_CTL)	  printf
59 #define	DR_DBG_CPU	if (dr_debug & DR_DBG_FLAG_CPU)	  printf
60 #define	DR_DBG_MEM	if (dr_debug & DR_DBG_FLAG_MEM)	  printf
61 #define	DR_DBG_IO	if (dr_debug & DR_DBG_FLAG_IO)	  printf
62 #define	DR_DBG_TRANS	if (dr_debug & DR_DBG_FLAG_TRANS) printf
63 
64 #define	DR_DBG_DUMP_MSG(buf, len)	dr_dbg_dump_msg(buf, len)
65 
66 extern void dr_dbg_dump_msg(void *buf, size_t len);
67 
68 #else /* DEBUG */
69 
70 #define	DR_DBG_ALL	_NOTE(CONSTCOND) if (0)	printf
71 #define	DR_DBG_CTL	DR_DBG_ALL
72 #define	DR_DBG_CPU	DR_DBG_ALL
73 #define	DR_DBG_MEM	DR_DBG_ALL
74 #define	DR_DBG_IO	DR_DBG_ALL
75 #define	DR_DBG_TRANS	DR_DBG_ALL
76 
77 #define	DR_DBG_DUMP_MSG(buf, len)
78 
79 #endif /* DEBUG */
80 
81 typedef enum {
82 	DR_TYPE_INVAL,
83 	DR_TYPE_CPU,
84 	DR_TYPE_MEM,
85 	DR_TYPE_VIO
86 } dr_type_t;
87 
88 /*
89  * Macro to convert a dr_type_t into a string. These strings are
90  * used to generate DR events and should only be modified using
91  * extreme caution.
92  */
93 #define	DR_TYPE2STR(t)	((t) == DR_TYPE_INVAL ? "invalid" :	\
94 			    (t) == DR_TYPE_CPU ? OBP_CPU : 	\
95 			    (t) == DR_TYPE_MEM ? "memory" :	\
96 			    (t) == DR_TYPE_VIO ? "vio" :	\
97 			    "unknown")
98 
99 extern boolean_t dr_is_disabled(dr_type_t type);
100 extern void dr_generate_event(dr_type_t type, int se_hint);
101 
102 #ifdef __cplusplus
103 }
104 #endif
105 
106 #endif /* _DR_UTIL_H */
107