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 /* 31 * sun4v Common DR Header 32 */ 33 34 #include <sys/ksynch.h> 35 #include <sys/cmn_err.h> 36 #include <sys/note.h> 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 /* 43 * Debugging support 44 */ 45 #ifdef DEBUG 46 47 extern uint_t dr_debug; 48 49 #define DR_DBG_FLAG_CTL 0x01 50 #define DR_DBG_FLAG_CPU 0x02 51 #define DR_DBG_FLAG_MEM 0x04 52 #define DR_DBG_FLAG_IO 0x08 53 #define DR_DBG_FLAG_TRANS 0x10 54 #define DR_DBG_FLAG_KMEM 0x20 55 56 #define DR_DBG_ALL if (dr_debug) printf 57 #define DR_DBG_CTL if (dr_debug & DR_DBG_FLAG_CTL) printf 58 #define DR_DBG_CPU if (dr_debug & DR_DBG_FLAG_CPU) printf 59 #define DR_DBG_MEM if (dr_debug & DR_DBG_FLAG_MEM) printf 60 #define DR_DBG_IO if (dr_debug & DR_DBG_FLAG_IO) printf 61 #define DR_DBG_TRANS if (dr_debug & DR_DBG_FLAG_TRANS) printf 62 #define DR_DBG_KMEM if (dr_debug & DR_DBG_FLAG_KMEM) 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 #define DR_DBG_KMEM DR_DBG_ALL 77 78 #define DR_DBG_DUMP_MSG(buf, len) 79 80 #endif /* DEBUG */ 81 82 typedef enum { 83 DR_TYPE_INVAL, 84 DR_TYPE_CPU, 85 DR_TYPE_MEM, 86 DR_TYPE_VIO 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 "unknown") 99 100 extern boolean_t dr_is_disabled(dr_type_t type); 101 extern void dr_generate_event(dr_type_t type, int se_hint); 102 103 #ifdef __cplusplus 104 } 105 #endif 106 107 #endif /* _DR_UTIL_H */ 108