kernel/eka/drivers/hcr/hcr_debug.h
changeset 9 96e5fb8b040d
child 11 329ab0095843
equal deleted inserted replaced
-1:000000000000 9:96e5fb8b040d
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Hardware Configuration Repository Platform Independent Layer (PIL)
       
    15 //
       
    16 
       
    17 #ifndef HCR_DEBUG_H
       
    18 #define HCR_DEBUG_H
       
    19 
       
    20 #include <e32err.h>
       
    21 #include <e32const.h>
       
    22 #include <e32def.h>
       
    23 #include <e32cmn.h>
       
    24 #include <e32des8.h>
       
    25 #include <kernel/kernel.h>
       
    26 
       
    27 //
       
    28 // MACROs for log statements in code.
       
    29 //
       
    30 
       
    31 #ifdef _DEBUG
       
    32 
       
    33 #define HCR_LOG0(_text)				__KTRACE_OPT(KHCR, Kern::Printf("=== "_text))
       
    34 #define HCR_LOG1(_text, _a1)		__KTRACE_OPT(KHCR, Kern::Printf("... "_text, (_a1)))
       
    35 
       
    36 #else
       
    37 
       
    38 #define HCR_LOG0(_text)				
       
    39 #define HCR_LOG1(_text, _a1)		
       
    40 
       
    41 #endif
       
    42 
       
    43 
       
    44 //
       
    45 // MACROs for trace statements in code.
       
    46 //
       
    47 
       
    48 #ifdef HCR_TRACE
       
    49 
       
    50 #define HCR_TRACE0(_text)								Kern::Printf((_text))
       
    51 #define HCR_TRACE1(_text, _a1)							Kern::Printf((_text), (_a1))
       
    52 #define HCR_TRACE2(_text, _a1, _a2)						Kern::Printf((_text), (_a1), (_a2))
       
    53 #define HCR_TRACE3(_text, _a1, _a2, _a3)				Kern::Printf((_text), (_a1), (_a2), (_a3))
       
    54 #define HCR_TRACE4(_text, _a1, _a2, _a3, _a4)			Kern::Printf((_text), (_a1), (_a2), (_a3), (_a4))
       
    55 #define HCR_TRACE5(_text, _a1, _a2, _a3, _a4, _a5)		Kern::Printf((_text), (_a1), (_a2), (_a3), (_a4), (_a5))
       
    56 #define HCR_TRACE6(_text, _a1, _a2, _a3, _a4, _a5, _a6)	Kern::Printf((_text), (_a1), (_a2), (_a3), (_a4), (_a5), (_a6))
       
    57 #define HCR_TRACE_RETURN(_r1)	 						return (Kern::Printf("!-- Function exit return(%d) (%s:%d)", (_r1), __FILE__, __LINE__), _r1)
       
    58 #define HCR_TRACEMSG_RETURN(_s1, _r1)	 				return (Kern::Printf("!-- "_s1" (%d)", (_r1)), _r1)
       
    59 #define HCR_FUNC(_text)     							TEntryExit _entryexit(_text)
       
    60 
       
    61 #define HCR_HEX_DUMP_ABS(_address, _length)	HexDump((_address), (_length));			//Hex dump with absolute address
       
    62 #define HCR_HEX_DUMP_REL(_address, _length)	HexDump((_address), (_length), EFalse); //Hex dump with relative (from) address
       
    63 
       
    64 
       
    65 #else
       
    66  
       
    67 #define HCR_TRACE0(_text)                               __KTRACE_OPT(KHCR, Kern::Printf((_text)))
       
    68 #define HCR_TRACE1(_text, _a1)                          __KTRACE_OPT(KHCR, Kern::Printf((_text), (_a1)))
       
    69 #define HCR_TRACE2(_text, _a1, _a2)                     __KTRACE_OPT(KHCR, Kern::Printf((_text), (_a1), (_a2)))
       
    70 #define HCR_TRACE3(_text, _a1, _a2, _a3)                __KTRACE_OPT(KHCR, Kern::Printf((_text), (_a1), (_a2), (_a3)))
       
    71 #define HCR_TRACE4(_text, _a1, _a2, _a3, _a4)           __KTRACE_OPT(KHCR, Kern::Printf((_text), (_a1), (_a2), (_a3), (_a4)))
       
    72 #define HCR_TRACE5(_text, _a1, _a2, _a3, _a4, _a5)      __KTRACE_OPT(KHCR, Kern::Printf((_text), (_a1), (_a2), (_a3), (_a4), (_a5)))
       
    73 #define HCR_TRACE6(_text, _a1, _a2, _a3, _a4, _a5, _a6) __KTRACE_OPT(KHCR, Kern::Printf((_text), (_a1), (_a2), (_a3), (_a4), (_a5), (_a6)))
       
    74 #define HCR_TRACE_RETURN(_r1)                           { __KTRACE_OPT(KHCR, Kern::Printf("!-- Function exit return(%d) (%s:%d)", (_r1), __FILE__, __LINE__)); return (_r1);}
       
    75 #define HCR_TRACEMSG_RETURN(_s1, _r1)                   { __KTRACE_OPT(KHCR, Kern::Printf("!-- "_s1" (%d)", (_r1))); return (_r1);}
       
    76 #define HCR_FUNC(_text)
       
    77 
       
    78 #define HCR_HEX_DUMP_ABS(_address, _length)
       
    79 #define HCR_HEX_DUMP_REL(_address, _length)
       
    80 
       
    81 #endif
       
    82 
       
    83 
       
    84 class TEntryExit
       
    85 {
       
    86 public:
       
    87     inline TEntryExit(const char *aFn);
       
    88     inline ~TEntryExit();
       
    89 
       
    90 public:
       
    91     const char* iName;
       
    92 };
       
    93 
       
    94 TEntryExit::TEntryExit(const char* aFn)
       
    95  : iName(aFn)
       
    96     {
       
    97     HCR_TRACE1("--> %s " , iName);
       
    98     };
       
    99 
       
   100 TEntryExit::~TEntryExit()
       
   101     {
       
   102     HCR_TRACE1("<-- %s " , iName);
       
   103     };
       
   104     
       
   105 
       
   106 void HexDump(TUint8* aStartAddress, TUint32 aLength, TBool aAbsolute = ETrue);
       
   107 
       
   108 
       
   109 #endif // HCR_DEBUG_H
       
   110