|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // A helper test driver for testing Kernel Performance Logger implementation. |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 */ |
|
21 |
|
22 |
|
23 #include "d_perflogger_ldd.h" |
|
24 #include <kernperflogger.h> |
|
25 |
|
26 //----------------------------------------------------------------------------------- |
|
27 |
|
28 |
|
29 DKPLoggerTestHelperLDD* DKPLoggerTestHelperLDD::pSelf = NULL; //-- static pointer to the single instance of the logical channel class |
|
30 |
|
31 //----------------------------------------------------------------------------------- |
|
32 |
|
33 DLogTicker::DLogTicker() : iTimer(LogTimerCallback,this) //-- initialize log events generator |
|
34 { |
|
35 iLogDFC = NULL; |
|
36 iRequest = NULL; |
|
37 iUserThreadContext = NULL; |
|
38 } |
|
39 |
|
40 DLogTicker::~DLogTicker() |
|
41 { |
|
42 Cancel(); //-- cancel user request, DFC, timers etc. |
|
43 Kern::DestroyClientRequest(iRequest); |
|
44 delete iLogDFC; |
|
45 } |
|
46 |
|
47 //----------------------------------------------------------------------------------- |
|
48 |
|
49 /** |
|
50 Construct ticker object. Creates appropriate TDfc object for dealing with IDFC or DFC |
|
51 |
|
52 @param apUserThreadContext pointer to the user thread context where the request will be completed in |
|
53 @param apDfcQ pointer to the DFC queue this object will be using. |
|
54 @param aLogContext specfies the context (ISR, DFC or IDFC) the logging will be made from. Can be NKern::EIDFC, NKern::EThread, NKern::EInterrupt |
|
55 */ |
|
56 void DLogTicker::Construct(DThread* aUserThreadContext, TDfcQue* aDfcQ, NKern::TContext aLogContext) |
|
57 { |
|
58 __NK_ASSERT_DEBUG(aUserThreadContext && aDfcQ); |
|
59 |
|
60 iLogContext = aLogContext; |
|
61 if(aLogContext == NKern::EIDFC) |
|
62 {//-- we will deal with IDFC, create appropriate DFC object |
|
63 iLogDFC = new TDfc(LogDFC, this); |
|
64 } |
|
65 else |
|
66 { |
|
67 if(aLogContext == NKern::EThread || aLogContext == NKern::EInterrupt) |
|
68 {//-- we will deal with DFC or ISR |
|
69 iLogDFC = new TDfc(LogDFC, this, aDfcQ, 0); |
|
70 } |
|
71 else |
|
72 {//-- wrong value |
|
73 __PRINT("#KPLogTest:DLogTicker::Construct() wrong context request !"); |
|
74 __NK_ASSERT_DEBUG(0); |
|
75 } |
|
76 } |
|
77 |
|
78 __NK_ASSERT_ALWAYS(iLogDFC); |
|
79 |
|
80 TInt r = Kern::CreateClientRequest(iRequest); |
|
81 __NK_ASSERT_ALWAYS(r == KErrNone); |
|
82 |
|
83 iUserThreadContext = aUserThreadContext; //-- store user thread context co complete requests correctly |
|
84 // iLogDFC->SetDfcQ(aDfcQ); //-- attach to the given DFC queue. !!!!DON'T DO THIS FOR IDFC!!!!! |
|
85 } |
|
86 |
|
87 //----------------------------------------------------------------------------------- |
|
88 |
|
89 /** |
|
90 Start the state machine by scheduling a DFC (or IDFC) |
|
91 |
|
92 @param apLogControl log parameters structure |
|
93 @param apRqStat pointer to the user request staus object that will be completed when all loggings done. |
|
94 */ |
|
95 void DLogTicker::Start(const TTestLogCtrl* aLogControl, TRequestStatus* aRqStat) |
|
96 { |
|
97 __NK_ASSERT_DEBUG(aLogControl && aRqStat && iLogDFC); |
|
98 kumemget32(&iLogControl, aLogControl, sizeof(TTestLogCtrl)); //-- copy control structure from the user side |
|
99 |
|
100 __NK_ASSERT_DEBUG(iLogControl.iLogsNum>=0); |
|
101 __PRINT1("#KPLogTest:DLogTicker::Start() for %d loggings",iLogControl.iLogsNum); |
|
102 |
|
103 if (iRequest->SetStatus(aRqStat) != KErrNone) |
|
104 {//-- current request is pending, panic client thread |
|
105 __PRINT("#KPLogTest:DLogTicker::Start() request is already pending !"); |
|
106 Kern::PanicCurrentThread(KPLoggerHelperTestDrv, EReqAlreadyPending); |
|
107 } |
|
108 |
|
109 if(iLogContext == NKern::EIDFC) |
|
110 {//-- DLogTicker::LogDFC() will be called as IDFC |
|
111 NKern::Lock(); |
|
112 iLogDFC->Add(); //-- start |
|
113 NKern::Unlock(); |
|
114 } |
|
115 else |
|
116 {//-- DLogTicker::LogDFC() will be called as DFC |
|
117 iLogDFC->Enque(); //-- start |
|
118 } |
|
119 |
|
120 } |
|
121 |
|
122 //----------------------------------------------------------------------------------- |
|
123 |
|
124 /** |
|
125 Complete the user request when all logging done. |
|
126 This can be called from 2 concurrent places - DFC & NTimer callback, either of them can complete the request |
|
127 |
|
128 @param aCompletionCode request completion code |
|
129 */ |
|
130 void DLogTicker::CompleteRequest(TInt aCompletionCode/*=KErrNone*/) |
|
131 { |
|
132 Kern::QueueRequestComplete(iUserThreadContext, iRequest, aCompletionCode); |
|
133 } |
|
134 |
|
135 //----------------------------------------------------------------------------------- |
|
136 |
|
137 /** |
|
138 Cancel everything |
|
139 */ |
|
140 void DLogTicker::Cancel(void) |
|
141 { |
|
142 CompleteRequest(KErrCancel); //-- cancel user request |
|
143 iLogControl.iLogsNum = 0; // Prevent DFC from restarting the timer |
|
144 iTimer.Cancel(); //-- cancel Timer |
|
145 iLogDFC->Cancel(); //-- cancel DFC |
|
146 } |
|
147 |
|
148 //----------------------------------------------------------------------------------- |
|
149 |
|
150 /** |
|
151 Ticker timer callback. Can be called in ISR or DFC context. |
|
152 If called in ISR context, makes logging, and schedules a DFC to complete the request if needed. |
|
153 If called in DFC context, makes logging for DFC (not for IDFC) mode and completes the request if needed. |
|
154 |
|
155 @param apSelf pointer to the DLogTicker object |
|
156 */ |
|
157 void DLogTicker::LogTimerCallback(TAny* aSelf) |
|
158 { |
|
159 DLogTicker *pSelf = (DLogTicker*)aSelf; |
|
160 __NK_ASSERT_DEBUG(pSelf); |
|
161 |
|
162 TTestLogCtrl& logClontrol = pSelf->iLogControl; |
|
163 __NK_ASSERT_DEBUG(logClontrol.iLogsNum >=0); |
|
164 |
|
165 TInt context = NKern::CurrentContext(); |
|
166 if(context == NKern::EInterrupt) |
|
167 {//-- This callback is from ISR |
|
168 |
|
169 //-- make logging from ISR context, category field is ignored, it will be FastTrace::EKernPerfLog |
|
170 PERF_LOG(logClontrol.iSubCategory, logClontrol.iUserData, logClontrol.iUserData2); |
|
171 |
|
172 //-- kick DFC, it will probaly complete the request. |
|
173 pSelf->iLogDFC->Add(); |
|
174 } |
|
175 else |
|
176 {//-- this is a DFC callback, but the DFC object could also have been ceated as IDFC |
|
177 //-- complete user request here if necessarily. |
|
178 if(pSelf->iLogDFC->IsIDFC()) |
|
179 {//-- the logging will be made in IDFC function. |
|
180 if(pSelf->iLogControl.iLogsNum == 0) |
|
181 {//-- all done, complete the request here, because we can't do in in IDFC |
|
182 pSelf->CompleteRequest(); |
|
183 } |
|
184 else |
|
185 {//-- this callback came from IDFC object, kick IDFC in a special way. |
|
186 NKern::Lock(); |
|
187 pSelf->iLogDFC->Add(); |
|
188 NKern::Unlock(); |
|
189 } |
|
190 } |
|
191 else |
|
192 {//-- this callback came from IDFC object, make logging from DFC context |
|
193 //-- category field is ignored, it will be FastTrace::EKernPerfLog |
|
194 PERF_LOG(logClontrol.iSubCategory, logClontrol.iUserData, logClontrol.iUserData2); |
|
195 |
|
196 pSelf->iLogDFC->Enque(); //-- kick DFC |
|
197 } |
|
198 |
|
199 } |
|
200 |
|
201 } |
|
202 |
|
203 //----------------------------------------------------------------------------------- |
|
204 |
|
205 /** |
|
206 Ticker DFC or IDFC function. Kicks the timer; |
|
207 If is called as IDFC, makes logging in this context and schedules a timer callback in DFC context to complete the request. |
|
208 If is called as DFC, schedules timer callback in DFC or ISR context. |
|
209 |
|
210 @param apSelf pointer to the DLogTicker object |
|
211 */ |
|
212 void DLogTicker::LogDFC(TAny* aSelf) |
|
213 { |
|
214 DLogTicker *pSelf = (DLogTicker*)aSelf; |
|
215 __NK_ASSERT_DEBUG(pSelf); |
|
216 |
|
217 TInt context = NKern::CurrentContext(); |
|
218 (void)context; //-- avoid warning in release mode |
|
219 |
|
220 if(pSelf->iLogControl.iLogsNum <= 0) |
|
221 {//-- complete user request, all done. The request can also be completed in LogTimerCallback() |
|
222 //-- in case if this is a IDFC and callback is a DFC |
|
223 pSelf->CompleteRequest(); |
|
224 } |
|
225 else |
|
226 { |
|
227 TTestLogCtrl& logClontrol = pSelf->iLogControl; |
|
228 logClontrol.iLogsNum--; //-- decrease remaining number of loggings |
|
229 |
|
230 if(pSelf->iLogDFC->IsIDFC()) |
|
231 {//-- we are in IDFC context, make logging from here, timer callback won't be IDFC |
|
232 __NK_ASSERT_DEBUG(context == NKern::EIDFC); |
|
233 |
|
234 //-- category field is ignored, it will be FastTrace::EKernPerfLog |
|
235 PERF_LOG(logClontrol.iSubCategory, logClontrol.iUserData, logClontrol.iUserData2); |
|
236 |
|
237 //-- kick the timer to have a callback in a specified time in DFC context |
|
238 //-- timer's DFC will complete the request if necessarily. |
|
239 pSelf->iTimer.OneShot(logClontrol.iLogPeriodTick, ETrue); |
|
240 } |
|
241 else |
|
242 {//-- we are in DFC context, kick the timer to have a callback in a specified time in ISR or DFC context |
|
243 pSelf->iTimer.OneShot(logClontrol.iLogPeriodTick, !(pSelf->iLogContext == NKern::EInterrupt)); |
|
244 } |
|
245 } |
|
246 } |
|
247 |
|
248 |
|
249 //----------------------------------------------------------------------------------- |
|
250 |
|
251 |
|
252 //################################################################################### |
|
253 //# DKPLoggerTestHelperLDD class implementation |
|
254 //################################################################################### |
|
255 |
|
256 DKPLoggerTestHelperLDD::DKPLoggerTestHelperLDD() |
|
257 |
|
258 { |
|
259 //-- store the pointer to the current thread for request completion from ISR->DFC |
|
260 iClientThread = &Kern::CurrentThread(); |
|
261 |
|
262 __NK_ASSERT_DEBUG(iClientThread); |
|
263 |
|
264 //-- Open client's user thread, incrementing ref. counter |
|
265 TInt nRes = iClientThread->Open(); |
|
266 __NK_ASSERT_DEBUG(nRes == KErrNone); |
|
267 (void)nRes;//-- avoid warning in release mode |
|
268 |
|
269 |
|
270 //-- initialize DFC machinery |
|
271 iDfcQ = Kern::DfcQue0(); //-- attach to the low priority DFC queue |
|
272 |
|
273 iIsrLogTicker.Construct (iClientThread, iDfcQ, NKern::EInterrupt);//-- construct ISR log ticker |
|
274 iDfcLogTicker.Construct (iClientThread, iDfcQ, NKern::EThread); //-- construct DFC log ticker |
|
275 iIDfcLogTicker.Construct(iClientThread, iDfcQ, NKern::EIDFC); //-- construct IDFC log ticker |
|
276 } |
|
277 |
|
278 //----------------------------------------------------------------------------------- |
|
279 |
|
280 DKPLoggerTestHelperLDD::~DKPLoggerTestHelperLDD() |
|
281 { |
|
282 __PRINT("#KPLogTest:~DKPLoggerTestHelperLDD()"); |
|
283 |
|
284 iClientThread->Close(NULL); |
|
285 |
|
286 pSelf = NULL; //-- clear the pointer to this class instance |
|
287 } |
|
288 |
|
289 //----------------------------------------------------------------------------------- |
|
290 |
|
291 /** |
|
292 static factory function for the LDD. |
|
293 |
|
294 @return pointer to the created (or existing) instance of the class |
|
295 */ |
|
296 DKPLoggerTestHelperLDD* DKPLoggerTestHelperLDD::CreateInstance() |
|
297 { |
|
298 __PRINT("#KPLogTest:DKPLoggerTestHelperLDD::CreateInstance()"); |
|
299 |
|
300 //-- create LDD channel instance |
|
301 if(pSelf) |
|
302 {//-- this is a singleton, can't have more than one instance |
|
303 __PRINT("#DKPLoggerTestHelperLDD::CreateInstance(): Attempt to create a second instance of a singleton!"); |
|
304 return pSelf; |
|
305 } |
|
306 |
|
307 pSelf = new DKPLoggerTestHelperLDD; |
|
308 |
|
309 if(!pSelf) |
|
310 {//-- OOM |
|
311 __PRINT("#KPLogTest:DKPLoggerTestHelperLDD::CreateInstance(): Unable to create class instance !"); |
|
312 } |
|
313 |
|
314 return pSelf; |
|
315 } |
|
316 |
|
317 //----------------------------------------------------------------------------------- |
|
318 |
|
319 /** |
|
320 LDD second stage constructor |
|
321 */ |
|
322 TInt DKPLoggerTestHelperLDD::DoCreate(TInt /*aUnit*/, const TDesC8* /*anInfo*/, const TVersion& aVer) |
|
323 { |
|
324 //-- check if the version aVer is supported |
|
325 if (!Kern::QueryVersionSupported(TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber),aVer)) |
|
326 return KErrNotSupported; |
|
327 |
|
328 return KErrNone; |
|
329 } |
|
330 |
|
331 //----------------------------------------------------------------------------------- |
|
332 |
|
333 /** |
|
334 Requests processing function. |
|
335 @return request processing error code. |
|
336 */ |
|
337 TInt DKPLoggerTestHelperLDD::Request(TInt aFunction, TAny* a1, TAny* a2) |
|
338 { |
|
339 TInt nRes = KErrNone; |
|
340 |
|
341 if (aFunction == KMaxTInt) |
|
342 {//-- this is DoCancel() |
|
343 |
|
344 TUint reqMask = (TUint)a1; |
|
345 DoCancel(reqMask); |
|
346 return KErrNone; |
|
347 } |
|
348 |
|
349 if(aFunction < 0) |
|
350 {//-- This is DoRequest() |
|
351 |
|
352 //-- extract request parameters |
|
353 TRequestStatus* pRqStat=(TRequestStatus*)a1; |
|
354 |
|
355 TAny* params[2]; |
|
356 kumemget32(params, a2, sizeof(params)); |
|
357 |
|
358 nRes = DoRequest(~aFunction, pRqStat, params[0], params[1]); |
|
359 } |
|
360 else |
|
361 {//-- This is DoControl() |
|
362 nRes = DoControl(aFunction, a1, a2); |
|
363 } |
|
364 |
|
365 |
|
366 return nRes; |
|
367 } |
|
368 |
|
369 //----------------------------------------------------------------------------------- |
|
370 |
|
371 /** |
|
372 Cancel outstanding request(s) |
|
373 @param aReqNumber request number to cancel |
|
374 */ |
|
375 void DKPLoggerTestHelperLDD::DoCancel(TUint aReqNumber) |
|
376 { |
|
377 |
|
378 switch (aReqNumber) |
|
379 { |
|
380 //-- cancel logging from ISR. |
|
381 case RKPLoggerTestHelper::EDoLogFromISR: |
|
382 iIsrLogTicker.Cancel(); |
|
383 break; |
|
384 |
|
385 //-- cancel logging from IDFC. |
|
386 case RKPLoggerTestHelper::EDoLogFromIDFC: |
|
387 iIDfcLogTicker.Cancel(); |
|
388 break; |
|
389 |
|
390 //-- cancel logging from DFC. |
|
391 case RKPLoggerTestHelper::EDoLogFromDFC: |
|
392 iDfcLogTicker.Cancel(); |
|
393 break; |
|
394 |
|
395 default: |
|
396 __PRINT1("#KPLogTest:DKPLoggerTestHelperLDD::DoCancel Cancelling a wrong request number:%d!", aReqMask); |
|
397 Kern::PanicCurrentThread(KPLoggerHelperTestDrv, EWrongRequest); |
|
398 break; |
|
399 |
|
400 } |
|
401 } |
|
402 |
|
403 //----------------------------------------------------------------------------------- |
|
404 |
|
405 /** |
|
406 Asynchronous request processing. |
|
407 |
|
408 @param aFunction request function number, see RKPLoggerTestHelper::TControl |
|
409 |
|
410 @param apRqStat pointer to the user's request status object. |
|
411 @param apArg1 pointer to the 1st parameter in RKPLoggerTestHelper::DoRequest |
|
412 @param apArg2 pointer to the 2nd parameter in RKPLoggerTestHelper::DoRequest |
|
413 |
|
414 @return request scheduling result, system-wide error code. |
|
415 |
|
416 */ |
|
417 TInt DKPLoggerTestHelperLDD::DoRequest(TInt aReqNumber, TRequestStatus* aRqStat, TAny* aArg1, TAny* /*apArg2*/) |
|
418 { |
|
419 switch (aReqNumber) |
|
420 { |
|
421 //-- make logging from ISR. |
|
422 case RKPLoggerTestHelper::EDoLogFromISR: |
|
423 { |
|
424 __PRINT("#KPLogTest: making loggings from ISR context"); |
|
425 iIsrLogTicker.Start((const TTestLogCtrl*)aArg1, aRqStat); |
|
426 } |
|
427 break; |
|
428 |
|
429 //-- make logging from IDFC. |
|
430 case RKPLoggerTestHelper::EDoLogFromIDFC: |
|
431 { |
|
432 __PRINT("#KPLogTest: making loggings from IDFC context"); |
|
433 iIDfcLogTicker.Start((const TTestLogCtrl*)aArg1, aRqStat); |
|
434 } |
|
435 break; |
|
436 |
|
437 //-- make logging from DFC. |
|
438 case RKPLoggerTestHelper::EDoLogFromDFC: |
|
439 { |
|
440 __PRINT("#KPLogTest: making loggings from DFC context"); |
|
441 iDfcLogTicker.Start((const TTestLogCtrl*)aArg1, aRqStat); |
|
442 } |
|
443 break; |
|
444 |
|
445 |
|
446 default: |
|
447 __PRINT1("#KPLogTest:DKPLoggerTestHelperLDD::DoRequest() Wrong request number:%d!", aReqNumber); |
|
448 Kern::PanicCurrentThread(KPLoggerHelperTestDrv, EWrongRequest); |
|
449 break; |
|
450 } |
|
451 |
|
452 return KErrNone; |
|
453 } |
|
454 |
|
455 //----------------------------------------------------------------------------------- |
|
456 |
|
457 /** |
|
458 Synchronous requests processing. |
|
459 |
|
460 @param aFunction request function number, see RKernPerfLogger::TControl |
|
461 @param apArg1 pointer to the 1st parameter in RKernPerfLogger::DoControl |
|
462 @param apArg2 pointer to the 2n parameter in RKernPerfLogger::DoControl |
|
463 |
|
464 @return request processing result |
|
465 */ |
|
466 TInt DKPLoggerTestHelperLDD::DoControl(TInt aFunction, TAny* aArg1, TAny* /*apArg2*/) |
|
467 { |
|
468 |
|
469 switch (aFunction) |
|
470 { |
|
471 //-- make test logging from the user thread |
|
472 case RKPLoggerTestHelper::EDoLogFromUserThread: |
|
473 { |
|
474 kumemget32(&iLogControlUserThread, aArg1, sizeof(iLogControlUserThread)); //-- copy control structure from the user side |
|
475 __PRINT1("#KPLogTest: making %d loggings from a user-thread context", iLogControlUserThread.iLogsNum); |
|
476 __NK_ASSERT_DEBUG(iLogControlUserThread.iLogsNum >=0 ); |
|
477 |
|
478 //-- This context is actually, a user thread. Make logging from here |
|
479 for(TInt i=0; i<iLogControlUserThread.iLogsNum; ++i) |
|
480 { |
|
481 //-- category field is ignored, it will be FastTrace::EKernPerfLog |
|
482 PERF_LOG(iLogControlUserThread.iSubCategory, iLogControlUserThread.iUserData, iLogControlUserThread.iUserData2); |
|
483 |
|
484 NKern::Sleep(iLogControlUserThread.iLogPeriodTick); |
|
485 } |
|
486 } |
|
487 break; |
|
488 |
|
489 //-- unit test for different PERF_LOG macros |
|
490 case RKPLoggerTestHelper::EDoTestMacros: |
|
491 { |
|
492 kumemget32(&iLogControlUserThread, aArg1, sizeof(iLogControlUserThread)); //-- copy control structure from the user side |
|
493 __PRINT1("#KPLogTest: making %d loggings from a user-thread context, testing different macros", iLogControlUserThread.iLogsNum); |
|
494 __NK_ASSERT_DEBUG(iLogControlUserThread.iLogsNum >=0 ); |
|
495 |
|
496 for(TInt i=0; i<iLogControlUserThread.iLogsNum; ++i) |
|
497 { |
|
498 PERF_LOG0(iLogControlUserThread.iSubCategory); |
|
499 PERF_LOG1(iLogControlUserThread.iSubCategory, iLogControlUserThread.iUserData); |
|
500 PERF_LOG (iLogControlUserThread.iSubCategory, iLogControlUserThread.iUserData, iLogControlUserThread.iUserData2); |
|
501 |
|
502 NKern::Sleep(iLogControlUserThread.iLogPeriodTick); |
|
503 } |
|
504 |
|
505 |
|
506 } |
|
507 break; |
|
508 |
|
509 default: |
|
510 __PRINT1("#KPLogTest:DKPLoggerTestHelperLDD::DoControl() Wrong function number:%d!", aFunction); |
|
511 Kern::PanicCurrentThread(KPLoggerHelperTestDrv, EWrongRequest); |
|
512 break; |
|
513 |
|
514 }; |
|
515 |
|
516 |
|
517 return KErrNone; |
|
518 } |
|
519 |
|
520 |
|
521 |
|
522 //################################################################################### |
|
523 //# LDD factory, DKPLoggerTestHelperLDDFactory class implementation |
|
524 //################################################################################### |
|
525 |
|
526 DKPLoggerTestHelperLDDFactory::DKPLoggerTestHelperLDDFactory() |
|
527 { |
|
528 iUnitsMask = 0x00; //-- don't support units |
|
529 iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber); |
|
530 } |
|
531 |
|
532 DKPLoggerTestHelperLDDFactory::~DKPLoggerTestHelperLDDFactory() |
|
533 { |
|
534 __PRINT("#KPLogTest:~DKPLoggerTestHelperLDDFactory()"); |
|
535 } |
|
536 |
|
537 //----------------------------------------------------------------------------------- |
|
538 |
|
539 /** |
|
540 static factory function for the LDD factory. |
|
541 |
|
542 @return pointer to the created instance of the class |
|
543 */ |
|
544 DKPLoggerTestHelperLDDFactory* DKPLoggerTestHelperLDDFactory::CreateInstance() |
|
545 { |
|
546 __PRINT("#KPLogTest:DKPLoggerTestHelperLDDFactory::CreateInstance()"); |
|
547 |
|
548 //-- create LDD factory |
|
549 DKPLoggerTestHelperLDDFactory* pSelf = new DKPLoggerTestHelperLDDFactory; |
|
550 |
|
551 if(!pSelf) |
|
552 {//-- OOM |
|
553 __PRINT("#KPLogTest:DKPLoggerTestHelperLDDFactory::CreateInstance(): Unable to create class instance !"); |
|
554 } |
|
555 |
|
556 return pSelf; |
|
557 } |
|
558 |
|
559 //----------------------------------------------------------------------------------- |
|
560 |
|
561 /** |
|
562 */ |
|
563 TInt DKPLoggerTestHelperLDDFactory::Install() |
|
564 { |
|
565 return SetName(&KPLoggerHelperTestDrv); // Set our name and return error code |
|
566 } |
|
567 |
|
568 //----------------------------------------------------------------------------------- |
|
569 |
|
570 /** |
|
571 */ |
|
572 void DKPLoggerTestHelperLDDFactory::GetCaps(TDes8& /*aDes*/) const |
|
573 {//-- not supported |
|
574 } |
|
575 |
|
576 //----------------------------------------------------------------------------------- |
|
577 |
|
578 /** |
|
579 LDD factory function. Creates LDD object. |
|
580 @param aChannel A pointer to an LDD channel object which will be initialised on return. |
|
581 @return KErrNone if object successfully allocated, KErrNoMemory if not. |
|
582 @return KErrAlreadyExists if the client tries to creae more than 1 instance of the channel |
|
583 |
|
584 */ |
|
585 TInt DKPLoggerTestHelperLDDFactory::Create(DLogicalChannelBase*& aChannel) |
|
586 { |
|
587 |
|
588 if(DKPLoggerTestHelperLDD::pSelf) |
|
589 {//-- channel is a singleton, can't have more than one instance |
|
590 __PRINT("#DKPLoggerTestHelperLDDFactory::Create: Attmpt to create another instance of the LDD!"); |
|
591 return KErrAlreadyExists; |
|
592 } |
|
593 |
|
594 aChannel = DKPLoggerTestHelperLDD::CreateInstance(); |
|
595 if(!aChannel) |
|
596 return KErrNoMemory; |
|
597 |
|
598 return KErrNone; |
|
599 } |
|
600 |
|
601 |
|
602 //----------------------------------------------------------------------------------- |
|
603 |
|
604 /** |
|
605 "Standard LDD" entrypoint. |
|
606 Is called on CreateLogicalDevice() if the user calls LoadLogicalDevice(). Creates LDD factory. |
|
607 |
|
608 @return pointer to the LDD factory object. |
|
609 */ |
|
610 DECLARE_STANDARD_LDD() |
|
611 { |
|
612 DKPLoggerTestHelperLDDFactory* pLDDFactory = DKPLoggerTestHelperLDDFactory::CreateInstance(); |
|
613 return pLDDFactory; |
|
614 } |
|
615 |
|
616 |
|
617 |
|
618 |
|
619 |
|
620 |
|
621 |
|
622 |
|
623 |
|
624 |
|
625 |
|
626 |
|
627 |
|
628 |
|
629 |
|
630 |
|
631 |
|
632 |
|
633 |
|
634 |
|
635 |
|
636 |
|
637 |
|
638 |
|
639 |
|
640 |
|
641 |
|
642 |
|
643 |