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 2004 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27#ifndef _GHD_DEBUG_H 28#define _GHD_DEBUG_H 29 30#pragma ident "%Z%%M% %I% %E% SMI" 31 32#ifdef __cplusplus 33extern "C" { 34#endif 35 36#include <sys/varargs.h> 37 38/*PRINTFLIKE1*/ 39extern void ghd_err(const char *fmt, ...) __PRINTFLIKE(1); 40extern ulong_t ghd_debug_flags; 41 42#define GDBG_FLAG_ERROR 0x0001 43#define GDBG_FLAG_INTR 0x0002 44#define GDBG_FLAG_PEND_INTR 0x0004 45#define GDBG_FLAG_START 0x0008 46#define GDBG_FLAG_WARN 0x0010 47#define GDBG_FLAG_DMA 0x0020 48#define GDBG_FLAG_PKT 0x0040 49#define GDBG_FLAG_INIT 0x0080 50#define GDBG_FLAG_WAITQ 0x0100 51 52/* 53 * Use prom_printf() or vcmn_err() 54 */ 55#ifdef GHD_DEBUG_PROM_PRINTF 56#define GDBG_PRF(fmt) prom_printf fmt 57#include <sys/promif.h> 58#else 59#define GDBG_PRF(fmt) ghd_err fmt 60#endif 61 62#if defined(GHD_DEBUG) || defined(__lint) 63 64#define GDBG_FLAG_CHK(flag, fmt) if (ghd_debug_flags & (flag)) GDBG_PRF(fmt) 65 66#else /* GHD_DEBUG || __lint */ 67 68#define GDBG_FLAG_CHK(flag, fmt) 69 70#endif /* GHD_DEBUG || __lint */ 71 72/* 73 * Always print "real" error messages on non-debugging kernels 74 */ 75 76#if defined(GHD_DEBUG) || defined(__lint) 77#define GDBG_ERROR(fmt) GDBG_FLAG_CHK(GDBG_FLAG_ERROR, fmt) 78#else 79#define GDBG_ERROR(fmt) ghd_err fmt 80#endif 81 82/* 83 * Debugging printf macros 84 */ 85 86#define GDBG_INTR(fmt) GDBG_FLAG_CHK(GDBG_FLAG_INTR, fmt) 87#define GDBG_PEND_INTR(fmt) GDBG_FLAG_CHK(GDBG_FLAG_PEND_INTR, fmt) 88#define GDBG_START(fmt) GDBG_FLAG_CHK(GDBG_FLAG_START, fmt) 89#define GDBG_WARN(fmt) GDBG_FLAG_CHK(GDBG_FLAG_WARN, fmt) 90#define GDBG_DMA(fmt) GDBG_FLAG_CHK(GDBG_FLAG_DMA, fmt) 91#define GDBG_PKT(fmt) GDBG_FLAG_CHK(GDBG_FLAG_PKT, fmt) 92#define GDBG_INIT(fmt) GDBG_FLAG_CHK(GDBG_FLAG_INIT, fmt) 93#define GDBG_WAITQ(fmt) GDBG_FLAG_CHK(GDBG_FLAG_WAITQ, fmt) 94 95#ifdef __cplusplus 96} 97#endif 98 99#endif /* _GHD_DEBUG_H */ 100