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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // A helper test driver for testing Kernel Performance Logger.
23 #ifndef D_PERFLOGGER_LDD_H__
24 #define D_PERFLOGGER_LDD_H__
26 #include <kernel/kernel.h>
27 #include <kernel/kern_priv.h>
29 #include "t_perflogger_drv.h"
31 //-- current LDD version
32 const TInt KMajorVersionNumber=1;
33 const TInt KMinorVersionNumber=0;
34 const TInt KBuildVersionNumber=1;
36 //-----------------------------------------------------------------------------------
40 EWrongRequest, ///< wrong request number from the user side
41 EReqAlreadyPending ///< user asynchronous reques is already pending
44 //-----------------------------------------------------------------------------------
47 Helper class that provides events generation in ISR, DFC or IDFC context
56 void Construct(DThread* apUserThreadContext, TDfcQue* apDfcQ, NKern::TContext aLogContext);
57 void Start(const TTestLogCtrl* apLogControl, TRequestStatus* apRqStat);
59 void CompleteRequest(TInt aCompletionCode=KErrNone);
63 static void LogTimerCallback(TAny* apSelf);
64 static void LogDFC(TAny* apSelf);
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.
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)
78 //-----------------------------------------------------------------------------------
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
85 This is a singleton class, no more than 1 channel allowed
87 class DKPLoggerTestHelperLDD : public DLogicalChannelBase
91 static DKPLoggerTestHelperLDD* CreateInstance();
92 ~DKPLoggerTestHelperLDD();
95 virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
96 virtual TInt Request(TInt aFunction, TAny* a1, TAny* a2);
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);
103 DKPLoggerTestHelperLDD();
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
113 DLogTicker iIsrLogTicker; ///< generates events in ISR context.
114 DLogTicker iDfcLogTicker; ///< generates events in DFC context.
115 DLogTicker iIDfcLogTicker; ///< generates events in IDFC context.
117 static DKPLoggerTestHelperLDD* pSelf; ///< static pointer to the single instance of this class
122 //-----------------------------------------------------------------------------------
126 Logger test helper LDD factory class.
128 class DKPLoggerTestHelperLDDFactory : public DLogicalDevice
132 static DKPLoggerTestHelperLDDFactory* CreateInstance();
133 ~DKPLoggerTestHelperLDDFactory();
135 // from DLogicalDevice
136 virtual TInt Install();
137 virtual void GetCaps(TDes8& aDes) const;
138 virtual TInt Create(DLogicalChannelBase*& aChannel);
142 DKPLoggerTestHelperLDDFactory();
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 //-----------------------------------------------------------------------------------
151 //-- define this macro if you wish a debug trace from this driver.
152 //#define ENABLE_DEBUG_TRACE
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);}
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)
168 //-----------------------------------------------------------------------------------
172 #endif //D_PERFLOGGER_LDD_H__