11ae08745Sheppo /* 21ae08745Sheppo * CDDL HEADER START 31ae08745Sheppo * 41ae08745Sheppo * The contents of this file are subject to the terms of the 51ae08745Sheppo * Common Development and Distribution License (the "License"). 61ae08745Sheppo * You may not use this file except in compliance with the License. 71ae08745Sheppo * 81ae08745Sheppo * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 91ae08745Sheppo * or http://www.opensolaris.org/os/licensing. 101ae08745Sheppo * See the License for the specific language governing permissions 111ae08745Sheppo * and limitations under the License. 121ae08745Sheppo * 131ae08745Sheppo * When distributing Covered Code, include this CDDL HEADER in each 141ae08745Sheppo * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 151ae08745Sheppo * If applicable, add the following below this CDDL HEADER, with the 161ae08745Sheppo * fields enclosed by brackets "[]" replaced with your own identifying 171ae08745Sheppo * information: Portions Copyright [yyyy] [name of copyright owner] 181ae08745Sheppo * 191ae08745Sheppo * CDDL HEADER END 201ae08745Sheppo */ 211ae08745Sheppo 221ae08745Sheppo /* 23*79afa7fbSSean McEnroe * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 241ae08745Sheppo * Use is subject to license terms. 251ae08745Sheppo */ 261ae08745Sheppo 271ae08745Sheppo #ifndef _DR_UTIL_H 281ae08745Sheppo #define _DR_UTIL_H 291ae08745Sheppo 301ae08745Sheppo /* 311ae08745Sheppo * sun4v Common DR Header 321ae08745Sheppo */ 331ae08745Sheppo 341ae08745Sheppo #include <sys/ksynch.h> 351ae08745Sheppo #include <sys/cmn_err.h> 361ae08745Sheppo #include <sys/note.h> 371ae08745Sheppo 381ae08745Sheppo #ifdef __cplusplus 391ae08745Sheppo extern "C" { 401ae08745Sheppo #endif 411ae08745Sheppo 421ae08745Sheppo /* 431ae08745Sheppo * Debugging support 441ae08745Sheppo */ 451ae08745Sheppo #ifdef DEBUG 461ae08745Sheppo 471ae08745Sheppo extern uint_t dr_debug; 481ae08745Sheppo 491ae08745Sheppo #define DR_DBG_FLAG_CTL 0x01 501ae08745Sheppo #define DR_DBG_FLAG_CPU 0x02 511ae08745Sheppo #define DR_DBG_FLAG_MEM 0x04 521ae08745Sheppo #define DR_DBG_FLAG_IO 0x08 531ae08745Sheppo #define DR_DBG_FLAG_TRANS 0x10 5499c7e855SJames Marks - Sun Microsystems #define DR_DBG_FLAG_KMEM 0x20 551ae08745Sheppo 561ae08745Sheppo #define DR_DBG_ALL if (dr_debug) printf 571ae08745Sheppo #define DR_DBG_CTL if (dr_debug & DR_DBG_FLAG_CTL) printf 581ae08745Sheppo #define DR_DBG_CPU if (dr_debug & DR_DBG_FLAG_CPU) printf 591ae08745Sheppo #define DR_DBG_MEM if (dr_debug & DR_DBG_FLAG_MEM) printf 601ae08745Sheppo #define DR_DBG_IO if (dr_debug & DR_DBG_FLAG_IO) printf 611ae08745Sheppo #define DR_DBG_TRANS if (dr_debug & DR_DBG_FLAG_TRANS) printf 6299c7e855SJames Marks - Sun Microsystems #define DR_DBG_KMEM if (dr_debug & DR_DBG_FLAG_KMEM) printf 631ae08745Sheppo 641ae08745Sheppo #define DR_DBG_DUMP_MSG(buf, len) dr_dbg_dump_msg(buf, len) 651ae08745Sheppo 661ae08745Sheppo extern void dr_dbg_dump_msg(void *buf, size_t len); 671ae08745Sheppo 681ae08745Sheppo #else /* DEBUG */ 691ae08745Sheppo 701ae08745Sheppo #define DR_DBG_ALL _NOTE(CONSTCOND) if (0) printf 711ae08745Sheppo #define DR_DBG_CTL DR_DBG_ALL 721ae08745Sheppo #define DR_DBG_CPU DR_DBG_ALL 731ae08745Sheppo #define DR_DBG_MEM DR_DBG_ALL 741ae08745Sheppo #define DR_DBG_IO DR_DBG_ALL 751ae08745Sheppo #define DR_DBG_TRANS DR_DBG_ALL 7699c7e855SJames Marks - Sun Microsystems #define DR_DBG_KMEM DR_DBG_ALL 771ae08745Sheppo 781ae08745Sheppo #define DR_DBG_DUMP_MSG(buf, len) 791ae08745Sheppo 801ae08745Sheppo #endif /* DEBUG */ 811ae08745Sheppo 821ae08745Sheppo typedef enum { 831ae08745Sheppo DR_TYPE_INVAL, 841ae08745Sheppo DR_TYPE_CPU, 851ae08745Sheppo DR_TYPE_MEM, 868fea755aSjm22469 DR_TYPE_VIO 871ae08745Sheppo } dr_type_t; 881ae08745Sheppo 891ae08745Sheppo /* 901ae08745Sheppo * Macro to convert a dr_type_t into a string. These strings are 911ae08745Sheppo * used to generate DR events and should only be modified using 921ae08745Sheppo * extreme caution. 931ae08745Sheppo */ 941ae08745Sheppo #define DR_TYPE2STR(t) ((t) == DR_TYPE_INVAL ? "invalid" : \ 951ae08745Sheppo (t) == DR_TYPE_CPU ? OBP_CPU : \ 961ae08745Sheppo (t) == DR_TYPE_MEM ? "memory" : \ 971ae08745Sheppo (t) == DR_TYPE_VIO ? "vio" : \ 981ae08745Sheppo "unknown") 991ae08745Sheppo 1001ae08745Sheppo extern boolean_t dr_is_disabled(dr_type_t type); 1011ae08745Sheppo extern void dr_generate_event(dr_type_t type, int se_hint); 102*79afa7fbSSean McEnroe extern struct memlist *dr_memlist_dup(struct memlist *mlist); 103*79afa7fbSSean McEnroe extern void dr_memlist_delete(struct memlist *mlist); 1041ae08745Sheppo 1051ae08745Sheppo #ifdef __cplusplus 1061ae08745Sheppo } 1071ae08745Sheppo #endif 1081ae08745Sheppo 1091ae08745Sheppo #endif /* _DR_UTIL_H */ 110