sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // A helper test driver for testing Kernel Performance Logger. sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalAll sl@0: */ sl@0: sl@0: #ifndef D_PERFLOGGER_LDD_H__ sl@0: #define D_PERFLOGGER_LDD_H__ sl@0: sl@0: #include sl@0: #include sl@0: sl@0: #include "t_perflogger_drv.h" sl@0: sl@0: //-- current LDD version sl@0: const TInt KMajorVersionNumber=1; sl@0: const TInt KMinorVersionNumber=0; sl@0: const TInt KBuildVersionNumber=1; sl@0: sl@0: //----------------------------------------------------------------------------------- sl@0: /** panic codes */ sl@0: enum TPanic sl@0: { sl@0: EWrongRequest, ///< wrong request number from the user side sl@0: EReqAlreadyPending ///< user asynchronous reques is already pending sl@0: }; sl@0: sl@0: //----------------------------------------------------------------------------------- sl@0: sl@0: /** sl@0: Helper class that provides events generation in ISR, DFC or IDFC context sl@0: */ sl@0: class DLogTicker sl@0: { sl@0: public: sl@0: sl@0: DLogTicker(); sl@0: ~DLogTicker(); sl@0: sl@0: void Construct(DThread* apUserThreadContext, TDfcQue* apDfcQ, NKern::TContext aLogContext); sl@0: void Start(const TTestLogCtrl* apLogControl, TRequestStatus* apRqStat); sl@0: void Cancel(void); sl@0: void CompleteRequest(TInt aCompletionCode=KErrNone); sl@0: sl@0: private: sl@0: sl@0: static void LogTimerCallback(TAny* apSelf); sl@0: static void LogDFC(TAny* apSelf); sl@0: sl@0: protected: sl@0: sl@0: NTimer iTimer; ///< timer for generating events sl@0: TTestLogCtrl iLogControl; ///< log control structure sl@0: TClientRequest *iRequest; ///< encapsulates the client's request status that will be completed when the logging has finished sl@0: TDfc *iLogDFC; ///< DFC for logging. sl@0: sl@0: DThread* iUserThreadContext;///< thread context where the ipRqStat will be completed in sl@0: NKern::TContext iLogContext; ///< specifies the desirable context the logging function shall be called from (Kern thread, ISD, IDFC) sl@0: sl@0: }; sl@0: sl@0: //----------------------------------------------------------------------------------- sl@0: sl@0: /** sl@0: Logger test helper LDD class. sl@0: Performs some actions from kernel side on behalf of the user test application. sl@0: Used for testing kernel performance logger sl@0: sl@0: This is a singleton class, no more than 1 channel allowed sl@0: */ sl@0: class DKPLoggerTestHelperLDD : public DLogicalChannelBase sl@0: { sl@0: public: sl@0: sl@0: static DKPLoggerTestHelperLDD* CreateInstance(); sl@0: ~DKPLoggerTestHelperLDD(); sl@0: sl@0: protected: sl@0: virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer); sl@0: virtual TInt Request(TInt aFunction, TAny* a1, TAny* a2); sl@0: sl@0: void DoCancel(TUint aReqNumber); sl@0: TInt DoRequest(TInt aReqNumber, TRequestStatus* apRqStat, TAny* apArg1, TAny* apArg2); sl@0: TInt DoControl(TInt aFunction,TAny* apArg1,TAny* apArg2); sl@0: sl@0: private: sl@0: DKPLoggerTestHelperLDD(); sl@0: sl@0: private: sl@0: TDynamicDfcQue* iDfcQ; ///< pointer to the Kern::DfcQue0 sl@0: TTestLogCtrl iLogControlUserThread; ///< log parameters for testting in User-thread context mode. sl@0: DThread* iClientThread; ///< pointer to the client thread for requests completion sl@0: sl@0: public: sl@0: sl@0: sl@0: DLogTicker iIsrLogTicker; ///< generates events in ISR context. sl@0: DLogTicker iDfcLogTicker; ///< generates events in DFC context. sl@0: DLogTicker iIDfcLogTicker; ///< generates events in IDFC context. sl@0: sl@0: static DKPLoggerTestHelperLDD* pSelf; ///< static pointer to the single instance of this class sl@0: sl@0: }; sl@0: sl@0: sl@0: //----------------------------------------------------------------------------------- sl@0: sl@0: sl@0: /** sl@0: Logger test helper LDD factory class. sl@0: */ sl@0: class DKPLoggerTestHelperLDDFactory : public DLogicalDevice sl@0: { sl@0: public: sl@0: sl@0: static DKPLoggerTestHelperLDDFactory* CreateInstance(); sl@0: ~DKPLoggerTestHelperLDDFactory(); sl@0: sl@0: // from DLogicalDevice sl@0: virtual TInt Install(); sl@0: virtual void GetCaps(TDes8& aDes) const; sl@0: virtual TInt Create(DLogicalChannelBase*& aChannel); sl@0: sl@0: private: sl@0: sl@0: DKPLoggerTestHelperLDDFactory(); sl@0: }; sl@0: sl@0: sl@0: //----------------------------------------------------------------------------------- sl@0: //-- debug print macros. Debug print in this component is absolutely not important and exists only sl@0: //-- for debugging purposes. So that, devising a mask for __KTRACE_OPT isn't necessary. sl@0: //----------------------------------------------------------------------------------- sl@0: sl@0: //-- define this macro if you wish a debug trace from this driver. sl@0: //#define ENABLE_DEBUG_TRACE sl@0: sl@0: #if defined(ENABLE_DEBUG_TRACE) && (defined(_DEBUG) || defined(_DEBUG_RELEASE)) sl@0: #define __PRINT(t) { Kern::Printf(t);} sl@0: #define __PRINT1(t,a) { Kern::Printf(t,a);} sl@0: #define __PRINT2(t,a,b) { Kern::Printf(t,a,b);} sl@0: #define __PRINT3(t,a,b,c) { Kern::Printf(t,a,b,c);} sl@0: #define __PRINT4(t,a,b,c,d) { Kern::Printf(t,a,b,c,d);} sl@0: #else sl@0: #define __PRINT(t) sl@0: #define __PRINT1(t,a) sl@0: #define __PRINT2(t,a,b) sl@0: #define __PRINT3(t,a,b,c) sl@0: #define __PRINT4(t,a,b,c,d) sl@0: #endif sl@0: sl@0: //----------------------------------------------------------------------------------- sl@0: sl@0: sl@0: sl@0: #endif //D_PERFLOGGER_LDD_H__ sl@0: sl@0: sl@0: sl@0: