xref: /onnv-gate/usr/src/uts/sun4v/sys/dr_util.h (revision 12037:88afeddf1b92)
11991Sheppo /*
21991Sheppo  * CDDL HEADER START
31991Sheppo  *
41991Sheppo  * The contents of this file are subject to the terms of the
51991Sheppo  * Common Development and Distribution License (the "License").
61991Sheppo  * You may not use this file except in compliance with the License.
71991Sheppo  *
81991Sheppo  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
91991Sheppo  * or http://www.opensolaris.org/os/licensing.
101991Sheppo  * See the License for the specific language governing permissions
111991Sheppo  * and limitations under the License.
121991Sheppo  *
131991Sheppo  * When distributing Covered Code, include this CDDL HEADER in each
141991Sheppo  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
151991Sheppo  * If applicable, add the following below this CDDL HEADER, with the
161991Sheppo  * fields enclosed by brackets "[]" replaced with your own identifying
171991Sheppo  * information: Portions Copyright [yyyy] [name of copyright owner]
181991Sheppo  *
191991Sheppo  * CDDL HEADER END
201991Sheppo  */
211991Sheppo 
221991Sheppo /*
23*12037SSean.McEnroe@Sun.COM  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
241991Sheppo  * Use is subject to license terms.
251991Sheppo  */
261991Sheppo 
271991Sheppo #ifndef _DR_UTIL_H
281991Sheppo #define	_DR_UTIL_H
291991Sheppo 
301991Sheppo /*
311991Sheppo  * sun4v Common DR Header
321991Sheppo  */
331991Sheppo 
341991Sheppo #include <sys/ksynch.h>
351991Sheppo #include <sys/cmn_err.h>
361991Sheppo #include <sys/note.h>
371991Sheppo 
381991Sheppo #ifdef __cplusplus
391991Sheppo extern "C" {
401991Sheppo #endif
411991Sheppo 
421991Sheppo /*
431991Sheppo  * Debugging support
441991Sheppo  */
451991Sheppo #ifdef DEBUG
461991Sheppo 
471991Sheppo extern uint_t	dr_debug;
481991Sheppo 
491991Sheppo #define	DR_DBG_FLAG_CTL		0x01
501991Sheppo #define	DR_DBG_FLAG_CPU		0x02
511991Sheppo #define	DR_DBG_FLAG_MEM		0x04
521991Sheppo #define	DR_DBG_FLAG_IO		0x08
531991Sheppo #define	DR_DBG_FLAG_TRANS	0x10
547899SJames.Marks@Sun.COM #define	DR_DBG_FLAG_KMEM	0x20
551991Sheppo 
561991Sheppo #define	DR_DBG_ALL	if (dr_debug)			  printf
571991Sheppo #define	DR_DBG_CTL	if (dr_debug & DR_DBG_FLAG_CTL)	  printf
581991Sheppo #define	DR_DBG_CPU	if (dr_debug & DR_DBG_FLAG_CPU)	  printf
591991Sheppo #define	DR_DBG_MEM	if (dr_debug & DR_DBG_FLAG_MEM)	  printf
601991Sheppo #define	DR_DBG_IO	if (dr_debug & DR_DBG_FLAG_IO)	  printf
611991Sheppo #define	DR_DBG_TRANS	if (dr_debug & DR_DBG_FLAG_TRANS) printf
627899SJames.Marks@Sun.COM #define	DR_DBG_KMEM	if (dr_debug & DR_DBG_FLAG_KMEM)  printf
631991Sheppo 
641991Sheppo #define	DR_DBG_DUMP_MSG(buf, len)	dr_dbg_dump_msg(buf, len)
651991Sheppo 
661991Sheppo extern void dr_dbg_dump_msg(void *buf, size_t len);
671991Sheppo 
681991Sheppo #else /* DEBUG */
691991Sheppo 
701991Sheppo #define	DR_DBG_ALL	_NOTE(CONSTCOND) if (0)	printf
711991Sheppo #define	DR_DBG_CTL	DR_DBG_ALL
721991Sheppo #define	DR_DBG_CPU	DR_DBG_ALL
731991Sheppo #define	DR_DBG_MEM	DR_DBG_ALL
741991Sheppo #define	DR_DBG_IO	DR_DBG_ALL
751991Sheppo #define	DR_DBG_TRANS	DR_DBG_ALL
767899SJames.Marks@Sun.COM #define	DR_DBG_KMEM	DR_DBG_ALL
771991Sheppo 
781991Sheppo #define	DR_DBG_DUMP_MSG(buf, len)
791991Sheppo 
801991Sheppo #endif /* DEBUG */
811991Sheppo 
821991Sheppo typedef enum {
831991Sheppo 	DR_TYPE_INVAL,
841991Sheppo 	DR_TYPE_CPU,
851991Sheppo 	DR_TYPE_MEM,
866441Sjm22469 	DR_TYPE_VIO
871991Sheppo } dr_type_t;
881991Sheppo 
891991Sheppo /*
901991Sheppo  * Macro to convert a dr_type_t into a string. These strings are
911991Sheppo  * used to generate DR events and should only be modified using
921991Sheppo  * extreme caution.
931991Sheppo  */
941991Sheppo #define	DR_TYPE2STR(t)	((t) == DR_TYPE_INVAL ? "invalid" :	\
951991Sheppo 			    (t) == DR_TYPE_CPU ? OBP_CPU : 	\
961991Sheppo 			    (t) == DR_TYPE_MEM ? "memory" :	\
971991Sheppo 			    (t) == DR_TYPE_VIO ? "vio" :	\
981991Sheppo 			    "unknown")
991991Sheppo 
1001991Sheppo extern boolean_t dr_is_disabled(dr_type_t type);
1011991Sheppo extern void dr_generate_event(dr_type_t type, int se_hint);
102*12037SSean.McEnroe@Sun.COM extern struct memlist *dr_memlist_dup(struct memlist *mlist);
103*12037SSean.McEnroe@Sun.COM extern void dr_memlist_delete(struct memlist *mlist);
1041991Sheppo 
1051991Sheppo #ifdef __cplusplus
1061991Sheppo }
1071991Sheppo #endif
1081991Sheppo 
1091991Sheppo #endif /* _DR_UTIL_H */
110