Update contrib.
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 // LDD for testing nanokernel debug trace bits
18 //#undef __REMOVE_PLATSEC_DIAGNOSTICS__
20 #include <kernel/kern_priv.h>
22 #include "d_kern_msg.h"
25 const TInt KMajorVersionNumber=0;
26 const TInt KMinorVersionNumber=1;
27 const TInt KBuildVersionNumber=1;
29 class DKernMsgTestFactory : public DLogicalDevice
31 // Kernel msg test LDD factory
35 DKernMsgTestFactory();
36 virtual TInt Install(); //overriding pure virtual
37 virtual void GetCaps(TDes8& aDes) const; //overriding pure virtual
38 virtual TInt Create(DLogicalChannelBase*& aChannel); //overriding pure virtual
41 class DKernMsgTest : public DLogicalChannelBase
43 // Trace test LDD channel
50 virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2);
51 virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
58 static void NTimerCallBack(TAny*);
62 DECLARE_STANDARD_LDD()
65 return new DKernMsgTestFactory;
68 DKernMsgTestFactory::DKernMsgTestFactory()
74 iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);
77 TInt DKernMsgTestFactory::Create(DLogicalChannelBase*& aChannel)
79 // Create a new DNKTraceTest on this logical device
83 aChannel=new DKernMsgTest;
84 return aChannel?KErrNone:KErrNoMemory;
87 TInt DKernMsgTestFactory::Install()
89 // Install the LDD - overriding pure virtual
93 return SetName(&KLddName);
97 void DKernMsgTestFactory::GetCaps(TDes8& aDes) const
99 // Get capabilities - overriding pure virtual
103 b.iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);
104 Kern::InfoCopy(aDes,(TUint8*)&b,sizeof(b));
107 DKernMsgTest::DKernMsgTest()
108 : iNTimer(NTimerCallBack, this)
114 // Get pointer to client threads DThread object
115 iClient=&Kern::CurrentThread();
117 // Open a reference on client thread so it's control block can't dissapear until
118 // this driver has finished with it.
119 // Note, this call to Open can't fail since its the thread we are currently running in
126 DKernMsgTest::~DKernMsgTest()
129 // Close our reference on the client thread
130 Kern::SafeClose((DObject*&)iClient,NULL);
133 TInt DKernMsgTest::DoCreate(TInt /*aUnit*/, const TDesC8* /*anInfo*/, const TVersion& aVer)
140 if (!Kern::QueryVersionSupported(TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber),aVer))
141 return KErrNotSupported;
145 TInt DKernMsgTest::Request(TInt aReqNo, TAny* a1, TAny*)
147 TInt r=KErrNotSupported;
150 case RKernMsgTest::EControlKDebug:
155 TInt ret=Kern::ThreadDesRead(iClient,a1,msg,0,0);
159 *((char*)msg.Ptr() + msg.Length()) = '\0';
161 Kern::Printf("%s", msg.Ptr());
162 r = Kern::CurrentThread().iId;
166 case RKernMsgTest::EControlIsrContextTest:
168 iShotNumber = (TInt) a1;
184 void DKernMsgTest::NTimerCallBack(TAny* ptr)
186 DKernMsgTest* p = (DKernMsgTest*) ptr;
188 if (p->iCurShot++ == p->iShotNumber)
191 Kern::Printf("%d", p->iCurShot);
193 p->iNTimer.Again(10);