|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // e32test\secure\d_ldd.cpp |
|
15 // LDD for testing kernel platsec APIs |
|
16 // |
|
17 // |
|
18 |
|
19 /* Hack to make sure we get the true value of iKernelConfigFlags */ |
|
20 #include "u32std.h" |
|
21 #undef __PLATSEC_FORCED_FLAGS__ |
|
22 #define __PLATSEC_FORCED_FLAGS__ 0 |
|
23 /* End hack */ |
|
24 |
|
25 #include <kernel/kern_priv.h> |
|
26 |
|
27 #include "d_sldd.h" |
|
28 |
|
29 _LIT(KLddName,"D_SLDD"); |
|
30 |
|
31 const TInt KMajorVersionNumber=0; |
|
32 const TInt KMinorVersionNumber=1; |
|
33 const TInt KBuildVersionNumber=1; |
|
34 |
|
35 TInt AFunction() |
|
36 { |
|
37 return KErrNone; |
|
38 } |
|
39 |
|
40 TInt data=0x100; |
|
41 TAny* dataptr=(TAny*)&AFunction; |
|
42 TInt TheBss; |
|
43 |
|
44 |
|
45 TUint32 KernelTestData[16] = { 0x32345678, 0x12345678 }; |
|
46 |
|
47 class DTest; |
|
48 |
|
49 class DTestFactory : public DLogicalDevice |
|
50 // |
|
51 // Test LDD factory |
|
52 // |
|
53 { |
|
54 public: |
|
55 DTestFactory(); |
|
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 |
|
59 }; |
|
60 |
|
61 class DTest : public DLogicalChannelBase |
|
62 // |
|
63 // Test logical channel |
|
64 // |
|
65 { |
|
66 public: |
|
67 virtual ~DTest(); |
|
68 protected: |
|
69 virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer); |
|
70 virtual TInt Request(TInt aFunction, TAny* a1, TAny* a2); |
|
71 }; |
|
72 |
|
73 DECLARE_STANDARD_LDD() |
|
74 { |
|
75 return new DTestFactory; |
|
76 } |
|
77 |
|
78 DTestFactory::DTestFactory() |
|
79 // |
|
80 // Constructor |
|
81 // |
|
82 { |
|
83 iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber); |
|
84 //iParseMask=0;//No units, no info, no PDD |
|
85 //iUnitsMask=0;//Only one thing |
|
86 } |
|
87 |
|
88 TInt DTestFactory::Create(DLogicalChannelBase*& aChannel) |
|
89 // |
|
90 // Create a new DTest on this logical device |
|
91 // |
|
92 { |
|
93 aChannel=new DTest; |
|
94 return aChannel?KErrNone:KErrNoMemory; |
|
95 } |
|
96 |
|
97 TInt DTestFactory::Install() |
|
98 // |
|
99 // Install the LDD - overriding pure virtual |
|
100 // |
|
101 { |
|
102 return SetName(&KLddName); |
|
103 } |
|
104 |
|
105 void DTestFactory::GetCaps(TDes8& /*aDes*/) const |
|
106 // |
|
107 // Get capabilities - overriding pure virtual |
|
108 // |
|
109 { |
|
110 // deliberately do nothing here for testing purpose |
|
111 } |
|
112 |
|
113 TInt DTest::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& aVer) |
|
114 // |
|
115 // Create channel |
|
116 // |
|
117 { |
|
118 |
|
119 if (!Kern::QueryVersionSupported(TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber),aVer)) |
|
120 return KErrNotSupported; |
|
121 return KErrNone; |
|
122 } |
|
123 |
|
124 DTest::~DTest() |
|
125 // |
|
126 // Destructor |
|
127 // |
|
128 { |
|
129 } |
|
130 |
|
131 TInt DTest::Request(TInt aFunction, TAny* a1, TAny* a2) |
|
132 { |
|
133 TInt r = KErrNone; |
|
134 switch (aFunction) |
|
135 { |
|
136 case RLddTest::EControlTest1: |
|
137 r = RLddTest::ETest1Value; |
|
138 break; |
|
139 |
|
140 case RLddTest::EGetIds: |
|
141 { |
|
142 RLddTest::TIds ids; |
|
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)); |
|
151 break; |
|
152 } |
|
153 |
|
154 case RLddTest::EGetKernelConfigFlags: |
|
155 { |
|
156 TSuperPage& superPage = Kern::SuperPage(); |
|
157 r = superPage.KernelConfigFlags(); |
|
158 break; |
|
159 } |
|
160 |
|
161 case RLddTest::ESetKernelConfigFlags: |
|
162 { |
|
163 TSuperPage& superPage = Kern::SuperPage(); |
|
164 superPage.SetKernelConfigFlags((TUint32)a1); |
|
165 break; |
|
166 } |
|
167 |
|
168 case RLddTest::ESetDisabledCapabilities0: |
|
169 { |
|
170 TSuperPage& superPage = Kern::SuperPage(); |
|
171 memcpy(superPage.iDisabledCapabilities, &a1, sizeof(TUint32)); |
|
172 break; |
|
173 } |
|
174 |
|
175 case RLddTest::EKernelTestData: |
|
176 { |
|
177 TUint32* ptr = KernelTestData; |
|
178 TUint32 data = *ptr; |
|
179 kumemput32(a1,&ptr,sizeof(ptr)); |
|
180 kumemput32(a2,&data,sizeof(data)); |
|
181 } |
|
182 break; |
|
183 |
|
184 case RLddTest::EGetSecureInfos: |
|
185 { |
|
186 TSecurityInfo infoThread(&Kern::CurrentThread()); |
|
187 TSecurityInfo infoProcess(&Kern::CurrentProcess()); |
|
188 kumemput32(a1,&infoThread,sizeof(infoThread)); |
|
189 kumemput32(a2,&infoProcess,sizeof(infoProcess)); |
|
190 } |
|
191 break; |
|
192 |
|
193 default: |
|
194 r = KErrNotSupported; |
|
195 break; |
|
196 } |
|
197 return r; |
|
198 } |