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\secure\d_ldd.cpp
15 // LDD for testing kernel platsec APIs
19 /* Hack to make sure we get the true value of iKernelConfigFlags */
21 #undef __PLATSEC_FORCED_FLAGS__
22 #define __PLATSEC_FORCED_FLAGS__ 0
25 #include <kernel/kern_priv.h>
29 _LIT(KLddName,"D_SLDD");
31 const TInt KMajorVersionNumber=0;
32 const TInt KMinorVersionNumber=1;
33 const TInt KBuildVersionNumber=1;
41 TAny* dataptr=(TAny*)&AFunction;
45 TUint32 KernelTestData[16] = { 0x32345678, 0x12345678 };
49 class DTestFactory : public DLogicalDevice
56 virtual TInt Install(); //overriding pure virtual
57 virtual void GetCaps(TDes8& aDes) const; //overriding pure virtual
58 virtual TInt Create(DLogicalChannelBase*& aChannel); //overriding pure virtual
61 class DTest : public DLogicalChannelBase
63 // Test logical channel
69 virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
70 virtual TInt Request(TInt aFunction, TAny* a1, TAny* a2);
73 DECLARE_STANDARD_LDD()
75 return new DTestFactory;
78 DTestFactory::DTestFactory()
83 iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);
84 //iParseMask=0;//No units, no info, no PDD
85 //iUnitsMask=0;//Only one thing
88 TInt DTestFactory::Create(DLogicalChannelBase*& aChannel)
90 // Create a new DTest on this logical device
94 return aChannel?KErrNone:KErrNoMemory;
97 TInt DTestFactory::Install()
99 // Install the LDD - overriding pure virtual
102 return SetName(&KLddName);
105 void DTestFactory::GetCaps(TDes8& /*aDes*/) const
107 // Get capabilities - overriding pure virtual
110 // deliberately do nothing here for testing purpose
113 TInt DTest::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& aVer)
119 if (!Kern::QueryVersionSupported(TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber),aVer))
120 return KErrNotSupported;
131 TInt DTest::Request(TInt aFunction, TAny* a1, TAny* a2)
136 case RLddTest::EControlTest1:
137 r = RLddTest::ETest1Value;
140 case RLddTest::EGetIds:
143 memclr(&ids, sizeof(ids));
144 DThread* thread = &Kern::CurrentThread();
145 ids.iThreadVID = Kern::ThreadVendorId(thread);
146 ids.iThreadSID = Kern::ThreadSecureId(thread);
147 DProcess* process = &Kern::CurrentProcess();
148 ids.iProcessVID = Kern::ProcessVendorId(process);
149 ids.iProcessSID = Kern::ProcessSecureId(process);
150 kumemput(a1, &ids, sizeof(ids));
154 case RLddTest::EGetKernelConfigFlags:
156 TSuperPage& superPage = Kern::SuperPage();
157 r = superPage.KernelConfigFlags();
161 case RLddTest::ESetKernelConfigFlags:
163 TSuperPage& superPage = Kern::SuperPage();
164 superPage.SetKernelConfigFlags((TUint32)a1);
168 case RLddTest::ESetDisabledCapabilities0:
170 TSuperPage& superPage = Kern::SuperPage();
171 memcpy(superPage.iDisabledCapabilities, &a1, sizeof(TUint32));
175 case RLddTest::EKernelTestData:
177 TUint32* ptr = KernelTestData;
179 kumemput32(a1,&ptr,sizeof(ptr));
180 kumemput32(a2,&data,sizeof(data));
184 case RLddTest::EGetSecureInfos:
186 TSecurityInfo infoThread(&Kern::CurrentThread());
187 TSecurityInfo infoProcess(&Kern::CurrentProcess());
188 kumemput32(a1,&infoThread,sizeof(infoThread));
189 kumemput32(a2,&infoProcess,sizeof(infoProcess));
194 r = KErrNotSupported;