1*1709Smlf /* 2*1709Smlf * CDDL HEADER START 3*1709Smlf * 4*1709Smlf * The contents of this file are subject to the terms of the 5*1709Smlf * Common Development and Distribution License (the "License"). 6*1709Smlf * You may not use this file except in compliance with the License. 7*1709Smlf * 8*1709Smlf * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*1709Smlf * or http://www.opensolaris.org/os/licensing. 10*1709Smlf * See the License for the specific language governing permissions 11*1709Smlf * and limitations under the License. 12*1709Smlf * 13*1709Smlf * When distributing Covered Code, include this CDDL HEADER in each 14*1709Smlf * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*1709Smlf * If applicable, add the following below this CDDL HEADER, with the 16*1709Smlf * fields enclosed by brackets "[]" replaced with your own identifying 17*1709Smlf * information: Portions Copyright [yyyy] [name of copyright owner] 18*1709Smlf * 19*1709Smlf * CDDL HEADER END 20*1709Smlf */ 21*1709Smlf 22*1709Smlf /* 23*1709Smlf * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*1709Smlf * Use is subject to license terms. 25*1709Smlf */ 26*1709Smlf 27*1709Smlf #ifndef _GHD_DEBUG_H 28*1709Smlf #define _GHD_DEBUG_H 29*1709Smlf 30*1709Smlf #pragma ident "%Z%%M% %I% %E% SMI" 31*1709Smlf 32*1709Smlf #ifdef __cplusplus 33*1709Smlf extern "C" { 34*1709Smlf #endif 35*1709Smlf 36*1709Smlf #include <sys/varargs.h> 37*1709Smlf 38*1709Smlf /*PRINTFLIKE1*/ 39*1709Smlf extern void ghd_err(const char *fmt, ...) __PRINTFLIKE(1); 40*1709Smlf extern ulong_t ghd_debug_flags; 41*1709Smlf 42*1709Smlf #define GDBG_FLAG_ERROR 0x0001 43*1709Smlf #define GDBG_FLAG_INTR 0x0002 44*1709Smlf #define GDBG_FLAG_PEND_INTR 0x0004 45*1709Smlf #define GDBG_FLAG_START 0x0008 46*1709Smlf #define GDBG_FLAG_WARN 0x0010 47*1709Smlf #define GDBG_FLAG_DMA 0x0020 48*1709Smlf #define GDBG_FLAG_PKT 0x0040 49*1709Smlf #define GDBG_FLAG_INIT 0x0080 50*1709Smlf #define GDBG_FLAG_WAITQ 0x0100 51*1709Smlf 52*1709Smlf /* 53*1709Smlf * Use prom_printf() or vcmn_err() 54*1709Smlf */ 55*1709Smlf #ifdef GHD_DEBUG_PROM_PRINTF 56*1709Smlf #define GDBG_PRF(fmt) prom_printf fmt 57*1709Smlf #include <sys/promif.h> 58*1709Smlf #else 59*1709Smlf #define GDBG_PRF(fmt) ghd_err fmt 60*1709Smlf #endif 61*1709Smlf 62*1709Smlf #if defined(GHD_DEBUG) || defined(__lint) 63*1709Smlf 64*1709Smlf #define GDBG_FLAG_CHK(flag, fmt) if (ghd_debug_flags & (flag)) GDBG_PRF(fmt) 65*1709Smlf 66*1709Smlf #else /* GHD_DEBUG || __lint */ 67*1709Smlf 68*1709Smlf #define GDBG_FLAG_CHK(flag, fmt) 69*1709Smlf 70*1709Smlf #endif /* GHD_DEBUG || __lint */ 71*1709Smlf 72*1709Smlf /* 73*1709Smlf * Always print "real" error messages on non-debugging kernels 74*1709Smlf */ 75*1709Smlf 76*1709Smlf #if defined(GHD_DEBUG) || defined(__lint) 77*1709Smlf #define GDBG_ERROR(fmt) GDBG_FLAG_CHK(GDBG_FLAG_ERROR, fmt) 78*1709Smlf #else 79*1709Smlf #define GDBG_ERROR(fmt) ghd_err fmt 80*1709Smlf #endif 81*1709Smlf 82*1709Smlf /* 83*1709Smlf * Debugging printf macros 84*1709Smlf */ 85*1709Smlf 86*1709Smlf #define GDBG_INTR(fmt) GDBG_FLAG_CHK(GDBG_FLAG_INTR, fmt) 87*1709Smlf #define GDBG_PEND_INTR(fmt) GDBG_FLAG_CHK(GDBG_FLAG_PEND_INTR, fmt) 88*1709Smlf #define GDBG_START(fmt) GDBG_FLAG_CHK(GDBG_FLAG_START, fmt) 89*1709Smlf #define GDBG_WARN(fmt) GDBG_FLAG_CHK(GDBG_FLAG_WARN, fmt) 90*1709Smlf #define GDBG_DMA(fmt) GDBG_FLAG_CHK(GDBG_FLAG_DMA, fmt) 91*1709Smlf #define GDBG_PKT(fmt) GDBG_FLAG_CHK(GDBG_FLAG_PKT, fmt) 92*1709Smlf #define GDBG_INIT(fmt) GDBG_FLAG_CHK(GDBG_FLAG_INIT, fmt) 93*1709Smlf #define GDBG_WAITQ(fmt) GDBG_FLAG_CHK(GDBG_FLAG_WAITQ, fmt) 94*1709Smlf 95*1709Smlf #ifdef __cplusplus 96*1709Smlf } 97*1709Smlf #endif 98*1709Smlf 99*1709Smlf #endif /* _GHD_DEBUG_H */ 100