xref: /titanic_41/usr/src/uts/sun4v/sys/dr_util.h (revision 60405de4d8688d96dd05157c28db3ade5c9bc234)
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 2006 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_DIO
87 } dr_type_t;
88 
89 /*
90  * Macro to convert a dr_type_t into a string. These strings are
91  * used to generate DR events and should only be modified using
92  * extreme caution.
93  */
94 #define	DR_TYPE2STR(t)	((t) == DR_TYPE_INVAL ? "invalid" :	\
95 			    (t) == DR_TYPE_CPU ? OBP_CPU : 	\
96 			    (t) == DR_TYPE_MEM ? "memory" :	\
97 			    (t) == DR_TYPE_VIO ? "vio" :	\
98 			    (t) == DR_TYPE_DIO ? "dio" :	\
99 			    "unknown")
100 
101 extern boolean_t dr_is_disabled(dr_type_t type);
102 extern void dr_generate_event(dr_type_t type, int se_hint);
103 
104 #ifdef __cplusplus
105 }
106 #endif
107 
108 #endif /* _DR_UTIL_H */
109