Update contrib.
1 // Copyright (c) 1998-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 // e32test\device\d_ldd.cpp
15 // LDD for testing LDD static data
19 #include <kernel/kernel.h>
23 const TInt KMajorVersionNumber=0;
24 const TInt KMinorVersionNumber=1;
25 const TInt KBuildVersionNumber=1;
33 TAny* dataptr=(TAny*)&AFunction;
41 void Update(TUint32 a);
52 __KTRACE_OPT(KDEVICE,Kern::Printf("TGlobal::TGlobal()"));
53 iPtr = Kern::Alloc(65536);
59 __KTRACE_OPT(KDEVICE,Kern::Printf("TGlobal::~TGlobal()"));
63 void TGlobal::Update(TUint32 a)
68 TUint32* p = (TUint32*)iPtr;
69 TUint32* pE = p + 65536/4;
78 TInt TGlobal::Verify()
83 TUint32* p = (TUint32*)iPtr;
84 TUint32* pE = p + 65536/4;
98 class DTestFactory : public DLogicalDevice
105 virtual TInt Install(); //overriding pure virtual
106 virtual void GetCaps(TDes8& aDes) const; //overriding pure virtual
107 virtual TInt Create(DLogicalChannelBase*& aChannel); //overriding pure virtual
110 class DTest : public DLogicalChannelBase
112 // Test logical channel
118 virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
119 virtual TInt Request(TInt aFunction, TAny* a1, TAny* a2);
122 class DKInstallTestFactory : public DLogicalDevice
124 // Extra test device which will be installed from kernel side using
125 // Kern::InstallLogicalDevice
129 DKInstallTestFactory();
130 virtual TInt Install();
131 virtual void GetCaps(TDes8& aDes) const;
132 virtual TInt Create(DLogicalChannelBase*& aChannel);
135 class DKInstallTest : public DLogicalChannelBase
137 // Extra test logical channel
141 virtual ~DKInstallTest();
143 virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
144 virtual TInt Request(TInt aFunction, TAny* a1, TAny* a2);
147 DECLARE_STANDARD_LDD()
149 return Global.iPtr ? new DTestFactory : NULL;
152 DTestFactory::DTestFactory()
157 iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);
158 //iParseMask=0;//No units, no info, no PDD
159 //iUnitsMask=0;//Only one thing
162 TInt DTestFactory::Create(DLogicalChannelBase*& aChannel)
164 // Create a new DTest on this logical device
168 return aChannel?KErrNone:KErrNoMemory;
171 TInt DTestFactory::Install()
173 // Install the LDD - overriding pure virtual
176 return SetName(&KLddName);
179 void DTestFactory::GetCaps(TDes8& aDes) const
181 // Get capabilities - overriding pure virtual
185 b.iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);
186 Kern::InfoCopy(aDes,(TUint8*)&b,sizeof(b));
189 TInt DTest::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& aVer)
195 if (!Kern::QueryVersionSupported(TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber),aVer))
196 return KErrNotSupported;
207 TInt DTest::Request(TInt aFunction, TAny* a1, TAny* a2)
214 case RLddTest::EControlTest1:
217 case RLddTest::EControlTest2:
220 case RLddTest::EControlTest3:
223 case RLddTest::EControlTest4:
226 case RLddTest::EControlTest5:
229 case RLddTest::EControlTest6:
232 case RLddTest::EControlTest7:
233 r = (TInt)Global.iInt;
235 case RLddTest::EControlTest8:
236 Global.Update((TUint32)a1);
238 case RLddTest::EControlTest9:
241 case RLddTest::EControlLinkedTest1:
244 case RLddTest::EControlLinkedTest2:
247 case RLddTest::EControlLinkedTest3:
250 case RLddTest::EControlLinkedTest4:
253 case RLddTest::EControlLinkedTest5:
256 case RLddTest::EControlLinkedTest6:
257 r=LinkedTest6((TInt)a1);
259 case RLddTest::EControlLinkedTest7:
262 case RLddTest::EControlLinkedTest8:
263 LinkedTest8((TUint32)a1);
265 case RLddTest::EControlLinkedTest9:
268 case RLddTest::EControlTestKInstall:
271 NKern::ThreadEnterCS();
272 DLogicalDevice* device = new DKInstallTestFactory;
274 r = Kern::InstallLogicalDevice(device);
275 NKern::ThreadLeaveCS();
285 DKInstallTestFactory::DKInstallTestFactory()
290 iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);
291 //iParseMask=0;//No units, no info, no PDD
292 //iUnitsMask=0;//Only one thing
295 TInt DKInstallTestFactory::Create(DLogicalChannelBase*& aChannel)
297 // Create a new DKInstallTest on this logical device
300 aChannel=new DKInstallTest;
301 return aChannel?KErrNone:KErrNoMemory;
304 TInt DKInstallTestFactory::Install()
306 // Install the LDD - overriding pure virtual
309 return SetName(&KKInstallLddName);
312 void DKInstallTestFactory::GetCaps(TDes8& aDes) const
314 // Get capabilities - overriding pure virtual
318 b.iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);
319 Kern::InfoCopy(aDes,(TUint8*)&b,sizeof(b));
322 TInt DKInstallTest::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& aVer)
328 if (!Kern::QueryVersionSupported(TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber),aVer))
329 return KErrNotSupported;
333 DKInstallTest::~DKInstallTest()
340 TInt DKInstallTest::Request(TInt aFunction, TAny* a1, TAny* a2)
345 return KErrNotSupported;