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