1*4c37757eSNguyen Trung Khanh /* 2*4c37757eSNguyen Trung Khanh * This file contains debug-related definitions for kernel driver 3*4c37757eSNguyen Trung Khanh * 4*4c37757eSNguyen Trung Khanh * Copyright (c) 2008-2017 Red Hat, Inc. 5*4c37757eSNguyen Trung Khanh * 6*4c37757eSNguyen Trung Khanh * Redistribution and use in source and binary forms, with or without 7*4c37757eSNguyen Trung Khanh * modification, are permitted provided that the following conditions 8*4c37757eSNguyen Trung Khanh * are met : 9*4c37757eSNguyen Trung Khanh * 1. Redistributions of source code must retain the above copyright 10*4c37757eSNguyen Trung Khanh * notice, this list of conditions and the following disclaimer. 11*4c37757eSNguyen Trung Khanh * 2. Redistributions in binary form must reproduce the above copyright 12*4c37757eSNguyen Trung Khanh * notice, this list of conditions and the following disclaimer in the 13*4c37757eSNguyen Trung Khanh * documentation and / or other materials provided with the distribution. 14*4c37757eSNguyen Trung Khanh * 3. Neither the names of the copyright holders nor the names of their contributors 15*4c37757eSNguyen Trung Khanh * may be used to endorse or promote products derived from this software 16*4c37757eSNguyen Trung Khanh * without specific prior written permission. 17*4c37757eSNguyen Trung Khanh * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 18*4c37757eSNguyen Trung Khanh * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19*4c37757eSNguyen Trung Khanh * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20*4c37757eSNguyen Trung Khanh * ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE 21*4c37757eSNguyen Trung Khanh * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22*4c37757eSNguyen Trung Khanh * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23*4c37757eSNguyen Trung Khanh * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24*4c37757eSNguyen Trung Khanh * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25*4c37757eSNguyen Trung Khanh * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26*4c37757eSNguyen Trung Khanh * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27*4c37757eSNguyen Trung Khanh * SUCH DAMAGE. 28*4c37757eSNguyen Trung Khanh */ 29*4c37757eSNguyen Trung Khanh 30*4c37757eSNguyen Trung Khanh /********************************************************************** 31*4c37757eSNguyen Trung Khanh WARNING: this file is incompatible with Logo requirements 32*4c37757eSNguyen Trung Khanh TODO: Optional WPP technique 33*4c37757eSNguyen Trung Khanh **********************************************************************/ 34*4c37757eSNguyen Trung Khanh 35*4c37757eSNguyen Trung Khanh #ifndef _K_DEBUG_PRINT_H 36*4c37757eSNguyen Trung Khanh #define _K_DEBUG_PRINT_H 37*4c37757eSNguyen Trung Khanh 38*4c37757eSNguyen Trung Khanh extern int nDebugLevel; 39*4c37757eSNguyen Trung Khanh extern int bDebugPrint; 40*4c37757eSNguyen Trung Khanh 41*4c37757eSNguyen Trung Khanh 42*4c37757eSNguyen Trung Khanh typedef void (*DEBUGPRINTFUNC)(const char *fmt, ...); 43*4c37757eSNguyen Trung Khanh extern DEBUGPRINTFUNC pDebugPrint; 44*4c37757eSNguyen Trung Khanh 45*4c37757eSNguyen Trung Khanh void _LogOutEntry(int level, const char *s); 46*4c37757eSNguyen Trung Khanh void _LogOutExitValue(int level, const char *s, ULONG value); 47*4c37757eSNguyen Trung Khanh void _LogOutString(int level, const char *s); 48*4c37757eSNguyen Trung Khanh 49*4c37757eSNguyen Trung Khanh #define DEBUG_ENTRY(level) _LogOutEntry(level, __FUNCTION__) 50*4c37757eSNguyen Trung Khanh #define DEBUG_EXIT_STATUS(level, status) _LogOutExitValue(level, __FUNCTION__, status) 51*4c37757eSNguyen Trung Khanh #define DPrintFunctionName(Level) _LogOutString(Level, __FUNCTION__) 52*4c37757eSNguyen Trung Khanh 53*4c37757eSNguyen Trung Khanh 54*4c37757eSNguyen Trung Khanh #ifndef WPP_EVENT_TRACING 55*4c37757eSNguyen Trung Khanh 56*4c37757eSNguyen Trung Khanh #define WPP_INIT_TRACING(a,b) 57*4c37757eSNguyen Trung Khanh #define WPP_CLEANUP(a) 58*4c37757eSNguyen Trung Khanh 59*4c37757eSNguyen Trung Khanh #define MAX_DEBUG_LEVEL 1 60*4c37757eSNguyen Trung Khanh 61*4c37757eSNguyen Trung Khanh #define DPrintf(Level, Fmt) { if ( (Level) > MAX_DEBUG_LEVEL || (Level) > nDebugLevel || !bDebugPrint ) {} else { pDebugPrint Fmt; } } 62*4c37757eSNguyen Trung Khanh 63*4c37757eSNguyen Trung Khanh #define DPrintfBypass(Level, Fmt) DPrintf(Level, Fmt) 64*4c37757eSNguyen Trung Khanh 65*4c37757eSNguyen Trung Khanh #else 66*4c37757eSNguyen Trung Khanh 67*4c37757eSNguyen Trung Khanh //#define WPP_USE_BYPASS 68*4c37757eSNguyen Trung Khanh 69*4c37757eSNguyen Trung Khanh 70*4c37757eSNguyen Trung Khanh #define DPrintfAnyway(Level, Fmt) \ 71*4c37757eSNguyen Trung Khanh { \ 72*4c37757eSNguyen Trung Khanh if (bDebugPrint && (Level) <= nDebugLevel) \ 73*4c37757eSNguyen Trung Khanh { \ 74*4c37757eSNguyen Trung Khanh pDebugPrint Fmt; \ 75*4c37757eSNguyen Trung Khanh } \ 76*4c37757eSNguyen Trung Khanh } 77*4c37757eSNguyen Trung Khanh 78*4c37757eSNguyen Trung Khanh //{05F77115-E57E-49bf-90DF-C0E6B6478E5F} 79*4c37757eSNguyen Trung Khanh #define WPP_CONTROL_GUIDS \ 80*4c37757eSNguyen Trung Khanh WPP_DEFINE_CONTROL_GUID(NetKVM, (05F77115,E57E,49bf,90DF,C0E6B6478E5F), \ 81*4c37757eSNguyen Trung Khanh WPP_DEFINE_BIT(TRACE_DEBUG)\ 82*4c37757eSNguyen Trung Khanh ) 83*4c37757eSNguyen Trung Khanh 84*4c37757eSNguyen Trung Khanh 85*4c37757eSNguyen Trung Khanh #define WPP_LEVEL_ENABLED(LEVEL) \ 86*4c37757eSNguyen Trung Khanh (nDebugLevel >= (LEVEL)) 87*4c37757eSNguyen Trung Khanh 88*4c37757eSNguyen Trung Khanh #define WPP_LEVEL_LOGGER(LEVEL) (WPP_CONTROL(WPP_BIT_ ## TRACE_DEBUG).Logger), 89*4c37757eSNguyen Trung Khanh 90*4c37757eSNguyen Trung Khanh 91*4c37757eSNguyen Trung Khanh #if WPP_USE_BYPASS 92*4c37757eSNguyen Trung Khanh #define DPrintfBypass(Level, Fmt) DPrintfAnyway(Level, Fmt) 93*4c37757eSNguyen Trung Khanh #else 94*4c37757eSNguyen Trung Khanh #define DPrintfBypass(Level, Fmt) 95*4c37757eSNguyen Trung Khanh #endif 96*4c37757eSNguyen Trung Khanh 97*4c37757eSNguyen Trung Khanh #define WPP_PRIVATE_ENABLE_CALLBACK WppEnableCallback 98*4c37757eSNguyen Trung Khanh 99*4c37757eSNguyen Trung Khanh extern VOID WppEnableCallback( 100*4c37757eSNguyen Trung Khanh __in LPCGUID Guid, 101*4c37757eSNguyen Trung Khanh __in __int64 Logger, 102*4c37757eSNguyen Trung Khanh __in BOOLEAN Enable, 103*4c37757eSNguyen Trung Khanh __in ULONG Flags, 104*4c37757eSNguyen Trung Khanh __in UCHAR Level); 105*4c37757eSNguyen Trung Khanh 106*4c37757eSNguyen Trung Khanh 107*4c37757eSNguyen Trung Khanh #endif 108*4c37757eSNguyen Trung Khanh #endif 109