os/kernelhwsrv/kerneltest/e32test/debug/d_perflogger_ldd.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2005-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 // A helper test driver for testing Kernel Performance Logger.
    15 // 
    16 //
    17 
    18 /**
    19  @file
    20  @internalAll
    21 */
    22 
    23 #ifndef D_PERFLOGGER_LDD_H__
    24 #define D_PERFLOGGER_LDD_H__
    25 
    26 #include <kernel/kernel.h>
    27 #include <kernel/kern_priv.h>
    28 
    29 #include "t_perflogger_drv.h"
    30 
    31 //-- current LDD version
    32 const TInt KMajorVersionNumber=1;
    33 const TInt KMinorVersionNumber=0;
    34 const TInt KBuildVersionNumber=1;
    35 
    36 //-----------------------------------------------------------------------------------
    37 /** panic codes */
    38 enum TPanic
    39 	{
    40     EWrongRequest,      ///< wrong request number from the user side
    41 		EReqAlreadyPending  ///< user asynchronous reques is already pending
    42 	};
    43 
    44 //-----------------------------------------------------------------------------------
    45 
    46 /**
    47 	Helper class that provides events generation in ISR, DFC or IDFC context
    48 */
    49 class DLogTicker
    50 	{
    51 	public:
    52 		
    53 		DLogTicker();
    54 		~DLogTicker();
    55 		
    56 		void Construct(DThread* apUserThreadContext, TDfcQue* apDfcQ, NKern::TContext aLogContext);
    57 		void Start(const TTestLogCtrl* apLogControl, TRequestStatus* apRqStat);
    58 		void Cancel(void);
    59 		void CompleteRequest(TInt aCompletionCode=KErrNone);
    60 		
    61 	private:
    62 		
    63 		static void LogTimerCallback(TAny* apSelf);
    64 		static void LogDFC(TAny* apSelf);
    65 		
    66 	protected:
    67 		
    68 		NTimer          iTimer;        ///< timer for generating events
    69 		TTestLogCtrl    iLogControl;   ///< log control structure 
    70 		TClientRequest *iRequest;      ///< encapsulates the client's request status that will be completed when the logging has finished
    71 		TDfc           *iLogDFC;       ///< DFC for logging.
    72 		
    73 		DThread*        iUserThreadContext;///< thread context where the ipRqStat will be completed in
    74 		NKern::TContext iLogContext;   ///< specifies the desirable context the logging function shall be called from (Kern thread, ISD, IDFC)
    75 		
    76 	};
    77 
    78 //-----------------------------------------------------------------------------------
    79 
    80 /**
    81 	Logger test helper LDD class.
    82 	Performs some actions from kernel side on behalf of the user test application.
    83 	Used for testing kernel performance logger
    84 
    85 	This is a singleton class, no more than 1 channel allowed
    86 */
    87 class DKPLoggerTestHelperLDD : public DLogicalChannelBase
    88 	{
    89 	public:
    90 		
    91 		static DKPLoggerTestHelperLDD* CreateInstance();
    92 		~DKPLoggerTestHelperLDD();
    93 		
    94 	protected:
    95 		virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
    96 		virtual TInt Request(TInt aFunction, TAny* a1, TAny* a2);
    97 		
    98 		void DoCancel(TUint aReqNumber);
    99 		TInt DoRequest(TInt aReqNumber, TRequestStatus* apRqStat, TAny* apArg1, TAny* apArg2);
   100 		TInt DoControl(TInt aFunction,TAny* apArg1,TAny* apArg2);   
   101 		
   102 	private:
   103 		DKPLoggerTestHelperLDD();
   104 		
   105 	private:
   106 		TDynamicDfcQue*        iDfcQ;					///< pointer to the Kern::DfcQue0
   107 		TTestLogCtrl    iLogControlUserThread;	///< log parameters for testting in User-thread context mode.
   108 		DThread*        iClientThread;			///< pointer to the client thread for requests completion
   109 
   110 	public:   
   111 		
   112 		
   113 		DLogTicker      iIsrLogTicker;  ///< generates events in ISR context.
   114 		DLogTicker      iDfcLogTicker;  ///< generates events in DFC context.
   115 		DLogTicker      iIDfcLogTicker; ///< generates events in IDFC context.
   116 
   117 		static DKPLoggerTestHelperLDD* pSelf;	///< static pointer to the single instance of this class
   118 
   119 	};
   120 
   121 
   122 //-----------------------------------------------------------------------------------
   123 
   124 
   125 /**
   126 	Logger test helper LDD factory class.
   127 */
   128 class DKPLoggerTestHelperLDDFactory : public DLogicalDevice
   129 	{
   130 	public:
   131 		
   132 		static  DKPLoggerTestHelperLDDFactory* CreateInstance();
   133 		~DKPLoggerTestHelperLDDFactory();
   134 		
   135 		// from DLogicalDevice
   136 		virtual TInt Install();
   137 		virtual void GetCaps(TDes8& aDes) const;
   138 		virtual TInt Create(DLogicalChannelBase*& aChannel);
   139 		
   140 	private:
   141 		
   142 		DKPLoggerTestHelperLDDFactory();
   143 	};
   144 
   145 
   146 //-----------------------------------------------------------------------------------
   147 //-- debug print macros. Debug print in this component is absolutely not important and exists only 
   148 //-- for debugging purposes. So that, devising a mask for __KTRACE_OPT isn't necessary.
   149 //-----------------------------------------------------------------------------------
   150 
   151 //-- define this macro if you wish a debug trace from this driver.
   152 //#define ENABLE_DEBUG_TRACE
   153 
   154 #if defined(ENABLE_DEBUG_TRACE) && (defined(_DEBUG) || defined(_DEBUG_RELEASE))
   155 #define __PRINT(t)          { Kern::Printf(t);}
   156 #define __PRINT1(t,a)       { Kern::Printf(t,a);}
   157 #define __PRINT2(t,a,b)     { Kern::Printf(t,a,b);}
   158 #define __PRINT3(t,a,b,c)   { Kern::Printf(t,a,b,c);}
   159 #define __PRINT4(t,a,b,c,d) { Kern::Printf(t,a,b,c,d);}
   160 #else
   161 #define __PRINT(t)
   162 #define __PRINT1(t,a)
   163 #define __PRINT2(t,a,b)
   164 #define __PRINT3(t,a,b,c)
   165 #define __PRINT4(t,a,b,c,d)
   166 #endif
   167 
   168 //-----------------------------------------------------------------------------------
   169 
   170 
   171 
   172 #endif  //D_PERFLOGGER_LDD_H__
   173 
   174 
   175 
   176