os/kernelhwsrv/kerneltest/e32test/debug/d_perflogger_ldd.cpp
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.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,661 @@
     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 implementation.
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +/**
    1.22 + @file
    1.23 +*/
    1.24 +
    1.25 +
    1.26 +#include "d_perflogger_ldd.h"
    1.27 +#include <kernperflogger.h>
    1.28 +
    1.29 +_LIT(KDFCThreadName,"D_PL_DFC_THREAD");
    1.30 +const TInt KDFCThreadPriority=27;
    1.31 +
    1.32 +//-----------------------------------------------------------------------------------
    1.33 +
    1.34 +
    1.35 +DKPLoggerTestHelperLDD* DKPLoggerTestHelperLDD::pSelf = NULL;	//-- static pointer to the single instance of the logical channel class
    1.36 +
    1.37 +//-----------------------------------------------------------------------------------
    1.38 +
    1.39 +DLogTicker::DLogTicker() : iTimer(LogTimerCallback,this)  //-- initialize log events generator
    1.40 +	{
    1.41 +    iLogDFC = NULL;
    1.42 +    iRequest = NULL;
    1.43 +    iUserThreadContext = NULL;
    1.44 +	}
    1.45 +
    1.46 +DLogTicker::~DLogTicker()
    1.47 +	{
    1.48 +    Cancel(); //-- cancel user request, DFC, timers etc.
    1.49 +	Kern::DestroyClientRequest(iRequest);
    1.50 +    delete  iLogDFC;
    1.51 +	}
    1.52 +
    1.53 +//-----------------------------------------------------------------------------------
    1.54 +
    1.55 +/**
    1.56 +	Construct ticker object. Creates appropriate TDfc object for dealing with IDFC or DFC
    1.57 +
    1.58 +	@param  apUserThreadContext pointer to the user thread context where the request will be completed in
    1.59 +	@param  apDfcQ              pointer to the DFC queue this object will be using.
    1.60 +	@param  aLogContext         specfies the context (ISR, DFC or IDFC) the logging will be made from. Can be NKern::EIDFC, NKern::EThread, NKern::EInterrupt
    1.61 +*/
    1.62 +void DLogTicker::Construct(DThread* aUserThreadContext, TDfcQue* aDfcQ, NKern::TContext aLogContext)
    1.63 +	{
    1.64 +    __NK_ASSERT_DEBUG(aUserThreadContext && aDfcQ);
    1.65 +	
    1.66 +    iLogContext = aLogContext;
    1.67 +    if(aLogContext == NKern::EIDFC)
    1.68 +		{//-- we will deal with IDFC, create appropriate DFC object
    1.69 +        iLogDFC = new TDfc(LogDFC, this);
    1.70 +		}
    1.71 +    else
    1.72 +		{
    1.73 +		if(aLogContext == NKern::EThread || aLogContext == NKern::EInterrupt)
    1.74 +			{//-- we will deal with DFC or ISR
    1.75 +			iLogDFC = new TDfc(LogDFC, this, aDfcQ, 0);
    1.76 +			}
    1.77 +		else
    1.78 +			{//-- wrong value
    1.79 +			__PRINT("#KPLogTest:DLogTicker::Construct() wrong context request !");
    1.80 +			__NK_ASSERT_DEBUG(0);
    1.81 +			}
    1.82 +		}
    1.83 +		
    1.84 +	__NK_ASSERT_ALWAYS(iLogDFC);
    1.85 +
    1.86 +	TInt r = Kern::CreateClientRequest(iRequest);
    1.87 +	__NK_ASSERT_ALWAYS(r == KErrNone);
    1.88 +		
    1.89 +	iUserThreadContext = aUserThreadContext; //-- store user thread context co complete requests correctly
    1.90 +//	iLogDFC->SetDfcQ(aDfcQ); //-- attach to the given DFC queue. !!!!DON'T DO THIS FOR IDFC!!!!!
    1.91 +	}
    1.92 +
    1.93 +//-----------------------------------------------------------------------------------
    1.94 +
    1.95 +/**
    1.96 +	Start the state machine by scheduling a DFC (or IDFC)
    1.97 +
    1.98 +	@param  apLogControl    log parameters structure
    1.99 +	@param  apRqStat        pointer to the user request staus object that will be completed when all loggings done.
   1.100 +*/
   1.101 +void DLogTicker::Start(const TTestLogCtrl* aLogControl, TRequestStatus* aRqStat)
   1.102 +	{
   1.103 +    __NK_ASSERT_DEBUG(aLogControl && aRqStat && iLogDFC);
   1.104 +    kumemget32(&iLogControl, aLogControl, sizeof(TTestLogCtrl)); //-- copy control structure from the user side
   1.105 +	
   1.106 +	__NK_ASSERT_DEBUG(iLogControl.iLogsNum>=0);
   1.107 +	__PRINT1("#KPLogTest:DLogTicker::Start() for %d loggings",iLogControl.iLogsNum);
   1.108 +
   1.109 +	if (iRequest->SetStatus(aRqStat) != KErrNone)
   1.110 +		{//-- current request is pending, panic client thread
   1.111 +        __PRINT("#KPLogTest:DLogTicker::Start() request is already pending !");
   1.112 +        Kern::PanicCurrentThread(KPLoggerHelperTestDrv, EReqAlreadyPending);
   1.113 +		}
   1.114 +	
   1.115 +    if(iLogContext == NKern::EIDFC)
   1.116 +		{//-- DLogTicker::LogDFC() will be called as IDFC 
   1.117 +        NKern::Lock();   
   1.118 +        iLogDFC->Add();  //-- start
   1.119 +        NKern::Unlock();
   1.120 +		}
   1.121 +    else
   1.122 +		{//-- DLogTicker::LogDFC() will be called as DFC 
   1.123 +        iLogDFC->Enque(); //-- start
   1.124 +		}
   1.125 +	
   1.126 +	}
   1.127 +
   1.128 +//-----------------------------------------------------------------------------------
   1.129 +
   1.130 +/**
   1.131 +	Complete the user request when all logging done.
   1.132 +	This can be called from 2 concurrent places - DFC & NTimer callback, either of them can complete the request
   1.133 +
   1.134 +	@param aCompletionCode request completion code
   1.135 +*/
   1.136 +void DLogTicker::CompleteRequest(TInt aCompletionCode/*=KErrNone*/)
   1.137 +	{
   1.138 +	Kern::QueueRequestComplete(iUserThreadContext, iRequest, aCompletionCode);
   1.139 +	}
   1.140 +
   1.141 +//-----------------------------------------------------------------------------------
   1.142 +
   1.143 +/**
   1.144 +	Cancel everything
   1.145 +*/
   1.146 +void DLogTicker::Cancel(void)
   1.147 +	{
   1.148 +    CompleteRequest(KErrCancel); //-- cancel user request
   1.149 +	iLogControl.iLogsNum = 0;	 // Prevent DFC from restarting the timer
   1.150 +	iTimer.Cancel();    //-- cancel Timer
   1.151 +	iLogDFC->Cancel(); //-- cancel DFC
   1.152 +	}
   1.153 +
   1.154 +//-----------------------------------------------------------------------------------
   1.155 +
   1.156 +/**
   1.157 +	Ticker timer callback. Can be called in ISR or DFC context.
   1.158 +	If called in ISR context, makes logging, and schedules a DFC to complete the request if needed.
   1.159 +	If called in DFC context, makes logging for DFC (not for IDFC) mode and completes the request if needed.
   1.160 +
   1.161 +	@param  apSelf pointer to the DLogTicker object
   1.162 +*/
   1.163 +void DLogTicker::LogTimerCallback(TAny* aSelf)
   1.164 +	{
   1.165 +    DLogTicker *pSelf = (DLogTicker*)aSelf;
   1.166 +    __NK_ASSERT_DEBUG(pSelf);
   1.167 +    
   1.168 +    TTestLogCtrl& logClontrol = pSelf->iLogControl;
   1.169 +    __NK_ASSERT_DEBUG(logClontrol.iLogsNum >=0);
   1.170 +	
   1.171 +    TInt context = NKern::CurrentContext();
   1.172 +    if(context == NKern::EInterrupt)
   1.173 +		{//-- This callback is from ISR
   1.174 +        
   1.175 +        //-- make logging from ISR context, category field is ignored, it will be FastTrace::EKernPerfLog
   1.176 +        PERF_LOG(logClontrol.iSubCategory, logClontrol.iUserData, logClontrol.iUserData2);
   1.177 +		
   1.178 +        //-- kick DFC, it will probaly complete the request. 
   1.179 +        pSelf->iLogDFC->Add();  
   1.180 +		}
   1.181 +    else
   1.182 +		{//-- this is a DFC callback, but the DFC object could also have been ceated as IDFC
   1.183 +		//-- complete user request here if necessarily.
   1.184 +        if(pSelf->iLogDFC->IsIDFC())
   1.185 +			{//-- the logging will be made in IDFC function.
   1.186 +            if(pSelf->iLogControl.iLogsNum == 0)
   1.187 +				{//-- all done, complete the request here, because we can't do in in IDFC
   1.188 +                pSelf->CompleteRequest();
   1.189 +				}
   1.190 +            else
   1.191 +				{//-- this callback came from IDFC object, kick IDFC in a special way.
   1.192 +                NKern::Lock();
   1.193 +                pSelf->iLogDFC->Add(); 
   1.194 +                NKern::Unlock();
   1.195 +				}
   1.196 +			}
   1.197 +        else
   1.198 +			{//-- this callback came from IDFC object, make logging from DFC context
   1.199 +            //-- category field is ignored, it will be FastTrace::EKernPerfLog
   1.200 +            PERF_LOG(logClontrol.iSubCategory, logClontrol.iUserData, logClontrol.iUserData2);    
   1.201 +			
   1.202 +            pSelf->iLogDFC->Enque(); //-- kick DFC 
   1.203 +			}
   1.204 +        
   1.205 +		}
   1.206 +	
   1.207 +	}
   1.208 +
   1.209 +//-----------------------------------------------------------------------------------
   1.210 +
   1.211 +/**
   1.212 +	Ticker DFC or IDFC function. Kicks the timer; 
   1.213 +	If is called as IDFC, makes logging in this context and schedules a timer callback in DFC context to complete the request.
   1.214 +	If is called as DFC, schedules timer callback in DFC or ISR context. 
   1.215 +
   1.216 +	@param  apSelf pointer to the DLogTicker object
   1.217 +*/
   1.218 +void DLogTicker::LogDFC(TAny* aSelf)
   1.219 +	{
   1.220 +    DLogTicker *pSelf = (DLogTicker*)aSelf;
   1.221 +    __NK_ASSERT_DEBUG(pSelf);
   1.222 +	
   1.223 +    TInt context = NKern::CurrentContext();
   1.224 +    (void)context; //-- avoid warning in release mode
   1.225 +	
   1.226 +    if(pSelf->iLogControl.iLogsNum <= 0)
   1.227 +		{//-- complete user request, all done. The request can also be completed in LogTimerCallback()
   1.228 +		//-- in case if this is a IDFC and callback is a DFC
   1.229 +        pSelf->CompleteRequest();    
   1.230 +		}
   1.231 +    else
   1.232 +		{
   1.233 +        TTestLogCtrl& logClontrol = pSelf->iLogControl;
   1.234 +        logClontrol.iLogsNum--; //-- decrease remaining number of loggings
   1.235 +		
   1.236 +        if(pSelf->iLogDFC->IsIDFC())
   1.237 +			{//-- we are in IDFC context, make logging from here, timer callback won't be IDFC
   1.238 +            __NK_ASSERT_DEBUG(context == NKern::EIDFC);
   1.239 +			
   1.240 +            //-- category field is ignored, it will be FastTrace::EKernPerfLog
   1.241 +            PERF_LOG(logClontrol.iSubCategory, logClontrol.iUserData, logClontrol.iUserData2);
   1.242 +			
   1.243 +            //-- kick the timer to have a callback in a specified time in DFC context
   1.244 +            //-- timer's DFC will complete the request if necessarily.
   1.245 +            pSelf->iTimer.OneShot(logClontrol.iLogPeriodTick, ETrue); 
   1.246 +			}
   1.247 +        else
   1.248 +			{//-- we are in DFC context, kick the timer to have a callback in a specified time in ISR or DFC context
   1.249 +            pSelf->iTimer.OneShot(logClontrol.iLogPeriodTick, !(pSelf->iLogContext == NKern::EInterrupt));
   1.250 +			}
   1.251 +		}
   1.252 +	}
   1.253 +
   1.254 +
   1.255 +//-----------------------------------------------------------------------------------
   1.256 +
   1.257 +
   1.258 +//###################################################################################
   1.259 +//#            DKPLoggerTestHelperLDD   class implementation
   1.260 +//###################################################################################
   1.261 +
   1.262 +DKPLoggerTestHelperLDD::DKPLoggerTestHelperLDD()
   1.263 +
   1.264 +	{
   1.265 +    //-- store the pointer to the current thread for request completion from ISR->DFC
   1.266 +    iClientThread = &Kern::CurrentThread();
   1.267 +	
   1.268 +    __NK_ASSERT_DEBUG(iClientThread);
   1.269 +	
   1.270 +	//-- Open client's user thread, incrementing ref. counter 
   1.271 +	TInt nRes = iClientThread->Open();
   1.272 +	__NK_ASSERT_DEBUG(nRes == KErrNone);
   1.273 +	(void)nRes;//-- avoid warning in release mode
   1.274 +
   1.275 +
   1.276 +    //-- initialize DFC machinery
   1.277 +    //iDfcQ = Kern::DfcQue0();   //-- attach to the low priority DFC queue
   1.278 +	if (!iDfcQ)
   1.279 + 		{
   1.280 + 		TInt r = Kern::DynamicDfcQCreate(iDfcQ, KDFCThreadPriority, KDFCThreadName);
   1.281 +		if (r!= KErrNone)
   1.282 +			{
   1.283 +			return;
   1.284 +			}
   1.285 +
   1.286 +#ifdef CPU_AFFINITY_ANY
   1.287 +		NKern::ThreadSetCpuAffinity((NThread*)(iDfcQ->iThread), KCpuAffinityAny);			
   1.288 +#endif
   1.289 + 		}	
   1.290 +    
   1.291 +    iIsrLogTicker.Construct (iClientThread, iDfcQ, NKern::EInterrupt);//-- construct ISR log ticker
   1.292 +    iDfcLogTicker.Construct (iClientThread, iDfcQ, NKern::EThread);   //-- construct DFC log ticker
   1.293 +    iIDfcLogTicker.Construct(iClientThread, iDfcQ, NKern::EIDFC);     //-- construct IDFC log ticker
   1.294 +	}
   1.295 +
   1.296 +//-----------------------------------------------------------------------------------
   1.297 +
   1.298 +DKPLoggerTestHelperLDD::~DKPLoggerTestHelperLDD()
   1.299 +	{
   1.300 +    __PRINT("#KPLogTest:~DKPLoggerTestHelperLDD()");
   1.301 +	
   1.302 +	iClientThread->Close(NULL);
   1.303 +
   1.304 +	if (iDfcQ)
   1.305 +		iDfcQ->Destroy();
   1.306 +		
   1.307 +	pSelf = NULL;  //-- clear the pointer to this class instance
   1.308 +	}
   1.309 +
   1.310 +//-----------------------------------------------------------------------------------
   1.311 +
   1.312 +/**
   1.313 +	static factory function for the LDD.
   1.314 +
   1.315 +	@return pointer to the created (or existing) instance of the class
   1.316 +*/
   1.317 +DKPLoggerTestHelperLDD* DKPLoggerTestHelperLDD::CreateInstance()
   1.318 +	{
   1.319 +    __PRINT("#KPLogTest:DKPLoggerTestHelperLDD::CreateInstance()");
   1.320 +    
   1.321 +    //-- create LDD channel instance
   1.322 +    if(pSelf)
   1.323 +	    {//-- this is a singleton, can't have more than one instance
   1.324 +        __PRINT("#DKPLoggerTestHelperLDD::CreateInstance(): Attempt to create a second instance of a singleton!");
   1.325 +        return pSelf;
   1.326 +		}
   1.327 +
   1.328 +	pSelf = new DKPLoggerTestHelperLDD;
   1.329 +	
   1.330 +    if(!pSelf)
   1.331 +		{//-- OOM 
   1.332 +        __PRINT("#KPLogTest:DKPLoggerTestHelperLDD::CreateInstance(): Unable to create class instance !");
   1.333 +		}
   1.334 +	
   1.335 +    return pSelf;
   1.336 +	}
   1.337 +
   1.338 +//-----------------------------------------------------------------------------------
   1.339 +
   1.340 +/**
   1.341 +	LDD second stage constructor
   1.342 +*/
   1.343 +TInt DKPLoggerTestHelperLDD::DoCreate(TInt /*aUnit*/, const TDesC8* /*anInfo*/, const TVersion& aVer)
   1.344 +	{
   1.345 +	//-- check if the version aVer is supported
   1.346 +    if (!Kern::QueryVersionSupported(TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber),aVer))
   1.347 +		return KErrNotSupported;
   1.348 +	
   1.349 +    return KErrNone;
   1.350 +	}
   1.351 +
   1.352 +//-----------------------------------------------------------------------------------
   1.353 +
   1.354 +/**
   1.355 +	Requests processing function.
   1.356 +	@return     request processing error code.
   1.357 +*/
   1.358 +TInt DKPLoggerTestHelperLDD::Request(TInt aFunction, TAny* a1, TAny* a2)
   1.359 +	{
   1.360 +    TInt nRes = KErrNone;
   1.361 +	
   1.362 +	if (aFunction == KMaxTInt)
   1.363 +		{//-- this is DoCancel()
   1.364 +		
   1.365 +        TUint reqMask = (TUint)a1;
   1.366 +        DoCancel(reqMask);
   1.367 +		return KErrNone;
   1.368 +		}
   1.369 +	
   1.370 +    if(aFunction < 0)
   1.371 +		{//-- This is DoRequest()
   1.372 +        
   1.373 +        //-- extract request parameters
   1.374 +        TRequestStatus* pRqStat=(TRequestStatus*)a1;
   1.375 +        
   1.376 +        TAny* params[2];
   1.377 +        kumemget32(params, a2, sizeof(params));
   1.378 +        
   1.379 +        nRes = DoRequest(~aFunction, pRqStat, params[0], params[1]); 
   1.380 +		}
   1.381 +    else
   1.382 +		{//-- This is DoControl()
   1.383 +        nRes = DoControl(aFunction, a1, a2);
   1.384 +		}
   1.385 +	
   1.386 +	
   1.387 +    return nRes;
   1.388 +	}
   1.389 +
   1.390 +//-----------------------------------------------------------------------------------
   1.391 +
   1.392 +/**
   1.393 +	Cancel outstanding request(s)
   1.394 +	@param  aReqNumber	request number to cancel
   1.395 +*/
   1.396 +void DKPLoggerTestHelperLDD::DoCancel(TUint aReqNumber)
   1.397 +	{
   1.398 +	
   1.399 +    switch (aReqNumber)
   1.400 +		{
   1.401 +		//-- cancel logging from ISR.
   1.402 +		case RKPLoggerTestHelper::EDoLogFromISR:  
   1.403 +			iIsrLogTicker.Cancel();
   1.404 +			break;
   1.405 +			
   1.406 +			//-- cancel logging from IDFC.
   1.407 +		case RKPLoggerTestHelper::EDoLogFromIDFC: 
   1.408 +			iIDfcLogTicker.Cancel();
   1.409 +			break;
   1.410 +			
   1.411 +			//-- cancel logging from DFC.
   1.412 +		case RKPLoggerTestHelper::EDoLogFromDFC:  
   1.413 +			iDfcLogTicker.Cancel();
   1.414 +			break;
   1.415 +			
   1.416 +		default:
   1.417 +			__PRINT1("#KPLogTest:DKPLoggerTestHelperLDD::DoCancel Cancelling a wrong request number:%d!", aReqMask);
   1.418 +			Kern::PanicCurrentThread(KPLoggerHelperTestDrv, EWrongRequest);
   1.419 +			break;
   1.420 +			
   1.421 +		}
   1.422 +	}
   1.423 +
   1.424 +//-----------------------------------------------------------------------------------
   1.425 +
   1.426 +/**
   1.427 +	Asynchronous request processing. 
   1.428 +
   1.429 +	@param aFunction    request function number, see RKPLoggerTestHelper::TControl
   1.430 +  
   1.431 +    @param apRqStat     pointer to the user's request status object.
   1.432 +    @param apArg1       pointer to the 1st parameter in RKPLoggerTestHelper::DoRequest
   1.433 +    @param apArg2       pointer to the 2nd parameter in RKPLoggerTestHelper::DoRequest
   1.434 +	
   1.435 +	@return request scheduling result, system-wide error code.
   1.436 +	  
   1.437 +*/
   1.438 +TInt DKPLoggerTestHelperLDD::DoRequest(TInt aReqNumber, TRequestStatus* aRqStat, TAny* aArg1, TAny* /*apArg2*/)
   1.439 +	{
   1.440 +    switch (aReqNumber)
   1.441 +		{
   1.442 +		//-- make logging from ISR.
   1.443 +		case RKPLoggerTestHelper::EDoLogFromISR:  
   1.444 +			{   
   1.445 +			__PRINT("#KPLogTest: making loggings from ISR context");
   1.446 +			iIsrLogTicker.Start((const TTestLogCtrl*)aArg1, aRqStat);
   1.447 +			}
   1.448 +			break;
   1.449 +			
   1.450 +			//-- make logging from IDFC.
   1.451 +		case RKPLoggerTestHelper::EDoLogFromIDFC: 
   1.452 +			{   
   1.453 +			__PRINT("#KPLogTest: making loggings from IDFC context");			
   1.454 +			iIDfcLogTicker.Start((const TTestLogCtrl*)aArg1, aRqStat);
   1.455 +			}			
   1.456 +			break;
   1.457 +			
   1.458 +			//-- make logging from DFC.
   1.459 +		case RKPLoggerTestHelper::EDoLogFromDFC:  
   1.460 +			{   
   1.461 +			__PRINT("#KPLogTest: making loggings from DFC context");			
   1.462 +			iDfcLogTicker.Start((const TTestLogCtrl*)aArg1, aRqStat);
   1.463 +			}
   1.464 +			break;
   1.465 +			
   1.466 +			
   1.467 +		default:
   1.468 +			__PRINT1("#KPLogTest:DKPLoggerTestHelperLDD::DoRequest() Wrong request number:%d!", aReqNumber);
   1.469 +			Kern::PanicCurrentThread(KPLoggerHelperTestDrv, EWrongRequest);
   1.470 +			break;
   1.471 +		}
   1.472 +    
   1.473 +    return KErrNone;
   1.474 +	}
   1.475 +
   1.476 +//-----------------------------------------------------------------------------------
   1.477 +
   1.478 +/**
   1.479 +	Synchronous requests processing. 
   1.480 +
   1.481 +	@param aFunction    request function number, see RKernPerfLogger::TControl
   1.482 +	@param apArg1       pointer to the 1st parameter in RKernPerfLogger::DoControl
   1.483 +	@param apArg2       pointer to the 2n parameter in RKernPerfLogger::DoControl 
   1.484 +  
   1.485 +    @return request processing result
   1.486 +*/
   1.487 +TInt DKPLoggerTestHelperLDD::DoControl(TInt aFunction, TAny* aArg1, TAny* /*apArg2*/)
   1.488 +	{
   1.489 +	
   1.490 +    switch (aFunction)
   1.491 +		{
   1.492 +        //-- make test logging from the user thread
   1.493 +        case RKPLoggerTestHelper::EDoLogFromUserThread:
   1.494 +			{    
   1.495 +            kumemget32(&iLogControlUserThread, aArg1, sizeof(iLogControlUserThread)); //-- copy control structure from the user side
   1.496 +            __PRINT1("#KPLogTest: making %d loggings from a user-thread context", iLogControlUserThread.iLogsNum);
   1.497 +            __NK_ASSERT_DEBUG(iLogControlUserThread.iLogsNum >=0 );
   1.498 +			
   1.499 +            //-- This context is actually, a user thread. Make logging from here
   1.500 +            for(TInt i=0; i<iLogControlUserThread.iLogsNum; ++i)
   1.501 +				{
   1.502 +                //-- category field is ignored, it will be FastTrace::EKernPerfLog
   1.503 +                PERF_LOG(iLogControlUserThread.iSubCategory, iLogControlUserThread.iUserData, iLogControlUserThread.iUserData2);
   1.504 +                
   1.505 +                NKern::Sleep(iLogControlUserThread.iLogPeriodTick);
   1.506 +				}
   1.507 +			}
   1.508 +			break;
   1.509 +			
   1.510 +		//-- unit test for different PERF_LOG macros
   1.511 +        case RKPLoggerTestHelper::EDoTestMacros:
   1.512 +			{
   1.513 +            kumemget32(&iLogControlUserThread, aArg1, sizeof(iLogControlUserThread)); //-- copy control structure from the user side
   1.514 +            __PRINT1("#KPLogTest: making %d loggings from a user-thread context, testing different macros", iLogControlUserThread.iLogsNum);
   1.515 +            __NK_ASSERT_DEBUG(iLogControlUserThread.iLogsNum >=0 );
   1.516 +			
   1.517 +            for(TInt i=0; i<iLogControlUserThread.iLogsNum; ++i)
   1.518 +				{
   1.519 +                PERF_LOG0(iLogControlUserThread.iSubCategory);
   1.520 +                PERF_LOG1(iLogControlUserThread.iSubCategory, iLogControlUserThread.iUserData);
   1.521 +                PERF_LOG (iLogControlUserThread.iSubCategory, iLogControlUserThread.iUserData, iLogControlUserThread.iUserData2);
   1.522 +                
   1.523 +                NKern::Sleep(iLogControlUserThread.iLogPeriodTick);
   1.524 +				}
   1.525 +			
   1.526 +			
   1.527 +			}
   1.528 +			break;
   1.529 +			
   1.530 +        default:
   1.531 +			__PRINT1("#KPLogTest:DKPLoggerTestHelperLDD::DoControl() Wrong function number:%d!", aFunction);
   1.532 +			Kern::PanicCurrentThread(KPLoggerHelperTestDrv, EWrongRequest);
   1.533 +			break;
   1.534 +			
   1.535 +		};
   1.536 +	
   1.537 +	
   1.538 +    return KErrNone;
   1.539 +	}
   1.540 +
   1.541 +
   1.542 +
   1.543 +//###################################################################################
   1.544 +//#            LDD factory, DKPLoggerTestHelperLDDFactory class implementation 
   1.545 +//###################################################################################
   1.546 +
   1.547 +DKPLoggerTestHelperLDDFactory::DKPLoggerTestHelperLDDFactory()
   1.548 +	{
   1.549 +    iUnitsMask = 0x00; //-- don't support units
   1.550 +    iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);	
   1.551 +	}
   1.552 +
   1.553 +DKPLoggerTestHelperLDDFactory::~DKPLoggerTestHelperLDDFactory()
   1.554 +	{
   1.555 +    __PRINT("#KPLogTest:~DKPLoggerTestHelperLDDFactory()");
   1.556 +	}
   1.557 +
   1.558 +//-----------------------------------------------------------------------------------
   1.559 +
   1.560 +/**
   1.561 +	static factory function for the LDD factory.
   1.562 +
   1.563 +	@return pointer to the created instance of the class
   1.564 +*/
   1.565 +DKPLoggerTestHelperLDDFactory* DKPLoggerTestHelperLDDFactory::CreateInstance()
   1.566 +	{
   1.567 +    __PRINT("#KPLogTest:DKPLoggerTestHelperLDDFactory::CreateInstance()");
   1.568 +    
   1.569 +    //-- create LDD factory
   1.570 +    DKPLoggerTestHelperLDDFactory* pSelf = new DKPLoggerTestHelperLDDFactory;
   1.571 +	
   1.572 +    if(!pSelf)
   1.573 +		{//-- OOM 
   1.574 +        __PRINT("#KPLogTest:DKPLoggerTestHelperLDDFactory::CreateInstance(): Unable to create class instance !");
   1.575 +		}
   1.576 +	
   1.577 +    return pSelf;
   1.578 +	}
   1.579 +
   1.580 +//-----------------------------------------------------------------------------------
   1.581 +
   1.582 +/**
   1.583 +*/
   1.584 +TInt DKPLoggerTestHelperLDDFactory::Install()
   1.585 +	{
   1.586 +    return SetName(&KPLoggerHelperTestDrv); // Set our name and return error code
   1.587 +	}
   1.588 +
   1.589 +//-----------------------------------------------------------------------------------
   1.590 +
   1.591 +/**
   1.592 +*/
   1.593 +void DKPLoggerTestHelperLDDFactory::GetCaps(TDes8& /*aDes*/) const
   1.594 +	{//-- not supported
   1.595 +	}
   1.596 +
   1.597 +//-----------------------------------------------------------------------------------
   1.598 +
   1.599 +/**
   1.600 +	LDD factory function. Creates LDD object.
   1.601 +	@param  aChannel    A pointer to an LDD channel object which will be initialised on return.
   1.602 +	@return KErrNone    if object successfully allocated, KErrNoMemory if not.
   1.603 +	@return KErrAlreadyExists	if the client tries to creae more than 1 instance of the channel
   1.604 +
   1.605 +*/
   1.606 +TInt DKPLoggerTestHelperLDDFactory::Create(DLogicalChannelBase*& aChannel)
   1.607 +	{
   1.608 +
   1.609 +	if(DKPLoggerTestHelperLDD::pSelf)
   1.610 +		{//-- channel is a singleton, can't have more than one instance
   1.611 +        __PRINT("#DKPLoggerTestHelperLDDFactory::Create: Attmpt to create another instance of the LDD!");
   1.612 +        return KErrAlreadyExists;
   1.613 +		}
   1.614 +    
   1.615 +	aChannel = DKPLoggerTestHelperLDD::CreateInstance();
   1.616 +    if(!aChannel)
   1.617 +        return KErrNoMemory;  
   1.618 +	
   1.619 +    return KErrNone;
   1.620 +	}
   1.621 +
   1.622 +
   1.623 +//-----------------------------------------------------------------------------------
   1.624 +
   1.625 +/**
   1.626 +	"Standard LDD" entrypoint.
   1.627 +	Is called on CreateLogicalDevice() if the user calls LoadLogicalDevice(). Creates LDD factory.
   1.628 +
   1.629 +	@return pointer to the LDD factory object.
   1.630 +*/
   1.631 +DECLARE_STANDARD_LDD()
   1.632 +	{
   1.633 +    DKPLoggerTestHelperLDDFactory* pLDDFactory = DKPLoggerTestHelperLDDFactory::CreateInstance();
   1.634 +    return  pLDDFactory;
   1.635 +	}
   1.636 +
   1.637 +
   1.638 +
   1.639 +
   1.640 +
   1.641 +
   1.642 +
   1.643 +
   1.644 +
   1.645 +
   1.646 +
   1.647 +
   1.648 +
   1.649 +
   1.650 +
   1.651 +
   1.652 +
   1.653 +
   1.654 +
   1.655 +
   1.656 +
   1.657 +
   1.658 +
   1.659 +
   1.660 +
   1.661 +
   1.662 +
   1.663 +
   1.664 +