os/kernelhwsrv/kerneltest/e32test/debug/d_perflogger_ldd.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/debug/d_perflogger_ldd.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,176 @@
     1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// A helper test driver for testing Kernel Performance Logger.
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +/**
    1.22 + @file
    1.23 + @internalAll
    1.24 +*/
    1.25 +
    1.26 +#ifndef D_PERFLOGGER_LDD_H__
    1.27 +#define D_PERFLOGGER_LDD_H__
    1.28 +
    1.29 +#include <kernel/kernel.h>
    1.30 +#include <kernel/kern_priv.h>
    1.31 +
    1.32 +#include "t_perflogger_drv.h"
    1.33 +
    1.34 +//-- current LDD version
    1.35 +const TInt KMajorVersionNumber=1;
    1.36 +const TInt KMinorVersionNumber=0;
    1.37 +const TInt KBuildVersionNumber=1;
    1.38 +
    1.39 +//-----------------------------------------------------------------------------------
    1.40 +/** panic codes */
    1.41 +enum TPanic
    1.42 +	{
    1.43 +    EWrongRequest,      ///< wrong request number from the user side
    1.44 +		EReqAlreadyPending  ///< user asynchronous reques is already pending
    1.45 +	};
    1.46 +
    1.47 +//-----------------------------------------------------------------------------------
    1.48 +
    1.49 +/**
    1.50 +	Helper class that provides events generation in ISR, DFC or IDFC context
    1.51 +*/
    1.52 +class DLogTicker
    1.53 +	{
    1.54 +	public:
    1.55 +		
    1.56 +		DLogTicker();
    1.57 +		~DLogTicker();
    1.58 +		
    1.59 +		void Construct(DThread* apUserThreadContext, TDfcQue* apDfcQ, NKern::TContext aLogContext);
    1.60 +		void Start(const TTestLogCtrl* apLogControl, TRequestStatus* apRqStat);
    1.61 +		void Cancel(void);
    1.62 +		void CompleteRequest(TInt aCompletionCode=KErrNone);
    1.63 +		
    1.64 +	private:
    1.65 +		
    1.66 +		static void LogTimerCallback(TAny* apSelf);
    1.67 +		static void LogDFC(TAny* apSelf);
    1.68 +		
    1.69 +	protected:
    1.70 +		
    1.71 +		NTimer          iTimer;        ///< timer for generating events
    1.72 +		TTestLogCtrl    iLogControl;   ///< log control structure 
    1.73 +		TClientRequest *iRequest;      ///< encapsulates the client's request status that will be completed when the logging has finished
    1.74 +		TDfc           *iLogDFC;       ///< DFC for logging.
    1.75 +		
    1.76 +		DThread*        iUserThreadContext;///< thread context where the ipRqStat will be completed in
    1.77 +		NKern::TContext iLogContext;   ///< specifies the desirable context the logging function shall be called from (Kern thread, ISD, IDFC)
    1.78 +		
    1.79 +	};
    1.80 +
    1.81 +//-----------------------------------------------------------------------------------
    1.82 +
    1.83 +/**
    1.84 +	Logger test helper LDD class.
    1.85 +	Performs some actions from kernel side on behalf of the user test application.
    1.86 +	Used for testing kernel performance logger
    1.87 +
    1.88 +	This is a singleton class, no more than 1 channel allowed
    1.89 +*/
    1.90 +class DKPLoggerTestHelperLDD : public DLogicalChannelBase
    1.91 +	{
    1.92 +	public:
    1.93 +		
    1.94 +		static DKPLoggerTestHelperLDD* CreateInstance();
    1.95 +		~DKPLoggerTestHelperLDD();
    1.96 +		
    1.97 +	protected:
    1.98 +		virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
    1.99 +		virtual TInt Request(TInt aFunction, TAny* a1, TAny* a2);
   1.100 +		
   1.101 +		void DoCancel(TUint aReqNumber);
   1.102 +		TInt DoRequest(TInt aReqNumber, TRequestStatus* apRqStat, TAny* apArg1, TAny* apArg2);
   1.103 +		TInt DoControl(TInt aFunction,TAny* apArg1,TAny* apArg2);   
   1.104 +		
   1.105 +	private:
   1.106 +		DKPLoggerTestHelperLDD();
   1.107 +		
   1.108 +	private:
   1.109 +		TDynamicDfcQue*        iDfcQ;					///< pointer to the Kern::DfcQue0
   1.110 +		TTestLogCtrl    iLogControlUserThread;	///< log parameters for testting in User-thread context mode.
   1.111 +		DThread*        iClientThread;			///< pointer to the client thread for requests completion
   1.112 +
   1.113 +	public:   
   1.114 +		
   1.115 +		
   1.116 +		DLogTicker      iIsrLogTicker;  ///< generates events in ISR context.
   1.117 +		DLogTicker      iDfcLogTicker;  ///< generates events in DFC context.
   1.118 +		DLogTicker      iIDfcLogTicker; ///< generates events in IDFC context.
   1.119 +
   1.120 +		static DKPLoggerTestHelperLDD* pSelf;	///< static pointer to the single instance of this class
   1.121 +
   1.122 +	};
   1.123 +
   1.124 +
   1.125 +//-----------------------------------------------------------------------------------
   1.126 +
   1.127 +
   1.128 +/**
   1.129 +	Logger test helper LDD factory class.
   1.130 +*/
   1.131 +class DKPLoggerTestHelperLDDFactory : public DLogicalDevice
   1.132 +	{
   1.133 +	public:
   1.134 +		
   1.135 +		static  DKPLoggerTestHelperLDDFactory* CreateInstance();
   1.136 +		~DKPLoggerTestHelperLDDFactory();
   1.137 +		
   1.138 +		// from DLogicalDevice
   1.139 +		virtual TInt Install();
   1.140 +		virtual void GetCaps(TDes8& aDes) const;
   1.141 +		virtual TInt Create(DLogicalChannelBase*& aChannel);
   1.142 +		
   1.143 +	private:
   1.144 +		
   1.145 +		DKPLoggerTestHelperLDDFactory();
   1.146 +	};
   1.147 +
   1.148 +
   1.149 +//-----------------------------------------------------------------------------------
   1.150 +//-- debug print macros. Debug print in this component is absolutely not important and exists only 
   1.151 +//-- for debugging purposes. So that, devising a mask for __KTRACE_OPT isn't necessary.
   1.152 +//-----------------------------------------------------------------------------------
   1.153 +
   1.154 +//-- define this macro if you wish a debug trace from this driver.
   1.155 +//#define ENABLE_DEBUG_TRACE
   1.156 +
   1.157 +#if defined(ENABLE_DEBUG_TRACE) && (defined(_DEBUG) || defined(_DEBUG_RELEASE))
   1.158 +#define __PRINT(t)          { Kern::Printf(t);}
   1.159 +#define __PRINT1(t,a)       { Kern::Printf(t,a);}
   1.160 +#define __PRINT2(t,a,b)     { Kern::Printf(t,a,b);}
   1.161 +#define __PRINT3(t,a,b,c)   { Kern::Printf(t,a,b,c);}
   1.162 +#define __PRINT4(t,a,b,c,d) { Kern::Printf(t,a,b,c,d);}
   1.163 +#else
   1.164 +#define __PRINT(t)
   1.165 +#define __PRINT1(t,a)
   1.166 +#define __PRINT2(t,a,b)
   1.167 +#define __PRINT3(t,a,b,c)
   1.168 +#define __PRINT4(t,a,b,c,d)
   1.169 +#endif
   1.170 +
   1.171 +//-----------------------------------------------------------------------------------
   1.172 +
   1.173 +
   1.174 +
   1.175 +#endif  //D_PERFLOGGER_LDD_H__
   1.176 +
   1.177 +
   1.178 +
   1.179 +