0
|
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\device\d_ldd.cpp
|
|
15 |
// LDD for testing LDD static data
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
#include <kernel/kernel.h>
|
|
20 |
#include "d_ldd.h"
|
|
21 |
#include "d_ldd2.h"
|
|
22 |
|
|
23 |
const TInt KMajorVersionNumber=0;
|
|
24 |
const TInt KMinorVersionNumber=1;
|
|
25 |
const TInt KBuildVersionNumber=1;
|
|
26 |
|
|
27 |
TInt AFunction()
|
|
28 |
{
|
|
29 |
return KErrNone;
|
|
30 |
}
|
|
31 |
|
|
32 |
TInt data=0x100;
|
|
33 |
TAny* dataptr=(TAny*)&AFunction;
|
|
34 |
TInt TheBss;
|
|
35 |
|
|
36 |
class TGlobal
|
|
37 |
{
|
|
38 |
public:
|
|
39 |
TGlobal();
|
|
40 |
~TGlobal();
|
|
41 |
void Update(TUint32 a);
|
|
42 |
TInt Verify();
|
|
43 |
public:
|
|
44 |
TUint32 iInt;
|
|
45 |
TAny* iPtr;
|
|
46 |
};
|
|
47 |
|
|
48 |
TGlobal Global;
|
|
49 |
|
|
50 |
TGlobal::TGlobal()
|
|
51 |
{
|
|
52 |
__KTRACE_OPT(KDEVICE,Kern::Printf("TGlobal::TGlobal()"));
|
|
53 |
iPtr = Kern::Alloc(65536);
|
|
54 |
Update(487);
|
|
55 |
}
|
|
56 |
|
|
57 |
TGlobal::~TGlobal()
|
|
58 |
{
|
|
59 |
__KTRACE_OPT(KDEVICE,Kern::Printf("TGlobal::~TGlobal()"));
|
|
60 |
Kern::Free(iPtr);
|
|
61 |
}
|
|
62 |
|
|
63 |
void TGlobal::Update(TUint32 a)
|
|
64 |
{
|
|
65 |
iInt = a;
|
|
66 |
if (iPtr)
|
|
67 |
{
|
|
68 |
TUint32* p = (TUint32*)iPtr;
|
|
69 |
TUint32* pE = p + 65536/4;
|
|
70 |
while (p<pE)
|
|
71 |
{
|
|
72 |
a = (a*69069u)+41;
|
|
73 |
*p++ = a;
|
|
74 |
}
|
|
75 |
}
|
|
76 |
}
|
|
77 |
|
|
78 |
TInt TGlobal::Verify()
|
|
79 |
{
|
|
80 |
TUint32 x = iInt;
|
|
81 |
if (iPtr)
|
|
82 |
{
|
|
83 |
TUint32* p = (TUint32*)iPtr;
|
|
84 |
TUint32* pE = p + 65536/4;
|
|
85 |
while (p<pE)
|
|
86 |
{
|
|
87 |
x = (x*69069u)+41;
|
|
88 |
if (*p++ != x)
|
|
89 |
return KErrGeneral;
|
|
90 |
}
|
|
91 |
return KErrNone;
|
|
92 |
}
|
|
93 |
return KErrNoMemory;
|
|
94 |
}
|
|
95 |
|
|
96 |
class DTest;
|
|
97 |
|
|
98 |
class DTestFactory : public DLogicalDevice
|
|
99 |
//
|
|
100 |
// Test LDD factory
|
|
101 |
//
|
|
102 |
{
|
|
103 |
public:
|
|
104 |
DTestFactory();
|
|
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
|
|
108 |
};
|
|
109 |
|
|
110 |
class DTest : public DLogicalChannelBase
|
|
111 |
//
|
|
112 |
// Test logical channel
|
|
113 |
//
|
|
114 |
{
|
|
115 |
public:
|
|
116 |
virtual ~DTest();
|
|
117 |
protected:
|
|
118 |
virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
|
|
119 |
virtual TInt Request(TInt aFunction, TAny* a1, TAny* a2);
|
|
120 |
};
|
|
121 |
|
|
122 |
class DKInstallTestFactory : public DLogicalDevice
|
|
123 |
//
|
|
124 |
// Extra test device which will be installed from kernel side using
|
|
125 |
// Kern::InstallLogicalDevice
|
|
126 |
//
|
|
127 |
{
|
|
128 |
public:
|
|
129 |
DKInstallTestFactory();
|
|
130 |
virtual TInt Install();
|
|
131 |
virtual void GetCaps(TDes8& aDes) const;
|
|
132 |
virtual TInt Create(DLogicalChannelBase*& aChannel);
|
|
133 |
};
|
|
134 |
|
|
135 |
class DKInstallTest : public DLogicalChannelBase
|
|
136 |
//
|
|
137 |
// Extra test logical channel
|
|
138 |
//
|
|
139 |
{
|
|
140 |
public:
|
|
141 |
virtual ~DKInstallTest();
|
|
142 |
protected:
|
|
143 |
virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
|
|
144 |
virtual TInt Request(TInt aFunction, TAny* a1, TAny* a2);
|
|
145 |
};
|
|
146 |
|
|
147 |
DECLARE_STANDARD_LDD()
|
|
148 |
{
|
|
149 |
return Global.iPtr ? new DTestFactory : NULL;
|
|
150 |
}
|
|
151 |
|
|
152 |
DTestFactory::DTestFactory()
|
|
153 |
//
|
|
154 |
// Constructor
|
|
155 |
//
|
|
156 |
{
|
|
157 |
iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);
|
|
158 |
//iParseMask=0;//No units, no info, no PDD
|
|
159 |
//iUnitsMask=0;//Only one thing
|
|
160 |
}
|
|
161 |
|
|
162 |
TInt DTestFactory::Create(DLogicalChannelBase*& aChannel)
|
|
163 |
//
|
|
164 |
// Create a new DTest on this logical device
|
|
165 |
//
|
|
166 |
{
|
|
167 |
aChannel=new DTest;
|
|
168 |
return aChannel?KErrNone:KErrNoMemory;
|
|
169 |
}
|
|
170 |
|
|
171 |
TInt DTestFactory::Install()
|
|
172 |
//
|
|
173 |
// Install the LDD - overriding pure virtual
|
|
174 |
//
|
|
175 |
{
|
|
176 |
return SetName(&KLddName);
|
|
177 |
}
|
|
178 |
|
|
179 |
void DTestFactory::GetCaps(TDes8& aDes) const
|
|
180 |
//
|
|
181 |
// Get capabilities - overriding pure virtual
|
|
182 |
//
|
|
183 |
{
|
|
184 |
TCapsTestV01 b;
|
|
185 |
b.iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);
|
|
186 |
Kern::InfoCopy(aDes,(TUint8*)&b,sizeof(b));
|
|
187 |
}
|
|
188 |
|
|
189 |
TInt DTest::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& aVer)
|
|
190 |
//
|
|
191 |
// Create channel
|
|
192 |
//
|
|
193 |
{
|
|
194 |
|
|
195 |
if (!Kern::QueryVersionSupported(TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber),aVer))
|
|
196 |
return KErrNotSupported;
|
|
197 |
return KErrNone;
|
|
198 |
}
|
|
199 |
|
|
200 |
DTest::~DTest()
|
|
201 |
//
|
|
202 |
// Destructor
|
|
203 |
//
|
|
204 |
{
|
|
205 |
}
|
|
206 |
|
|
207 |
TInt DTest::Request(TInt aFunction, TAny* a1, TAny* a2)
|
|
208 |
{
|
|
209 |
(void)a1;
|
|
210 |
(void)a2;
|
|
211 |
TInt r=KErrNone;
|
|
212 |
switch (aFunction)
|
|
213 |
{
|
|
214 |
case RLddTest::EControlTest1:
|
|
215 |
r=(TInt)dataptr;
|
|
216 |
break;
|
|
217 |
case RLddTest::EControlTest2:
|
|
218 |
r=data++;
|
|
219 |
break;
|
|
220 |
case RLddTest::EControlTest3:
|
|
221 |
r=data--;
|
|
222 |
break;
|
|
223 |
case RLddTest::EControlTest4:
|
|
224 |
r=data;
|
|
225 |
break;
|
|
226 |
case RLddTest::EControlTest5:
|
|
227 |
r=TheBss;
|
|
228 |
break;
|
|
229 |
case RLddTest::EControlTest6:
|
|
230 |
TheBss=(TInt)a1;
|
|
231 |
break;
|
|
232 |
case RLddTest::EControlTest7:
|
|
233 |
r = (TInt)Global.iInt;
|
|
234 |
break;
|
|
235 |
case RLddTest::EControlTest8:
|
|
236 |
Global.Update((TUint32)a1);
|
|
237 |
break;
|
|
238 |
case RLddTest::EControlTest9:
|
|
239 |
r = Global.Verify();
|
|
240 |
break;
|
|
241 |
case RLddTest::EControlLinkedTest1:
|
|
242 |
r=LinkedTest1();
|
|
243 |
break;
|
|
244 |
case RLddTest::EControlLinkedTest2:
|
|
245 |
r=LinkedTest2();
|
|
246 |
break;
|
|
247 |
case RLddTest::EControlLinkedTest3:
|
|
248 |
r=LinkedTest3();
|
|
249 |
break;
|
|
250 |
case RLddTest::EControlLinkedTest4:
|
|
251 |
r=LinkedTest4();
|
|
252 |
break;
|
|
253 |
case RLddTest::EControlLinkedTest5:
|
|
254 |
r=LinkedTest5();
|
|
255 |
break;
|
|
256 |
case RLddTest::EControlLinkedTest6:
|
|
257 |
r=LinkedTest6((TInt)a1);
|
|
258 |
break;
|
|
259 |
case RLddTest::EControlLinkedTest7:
|
|
260 |
r = LinkedTest7();
|
|
261 |
break;
|
|
262 |
case RLddTest::EControlLinkedTest8:
|
|
263 |
LinkedTest8((TUint32)a1);
|
|
264 |
break;
|
|
265 |
case RLddTest::EControlLinkedTest9:
|
|
266 |
r = LinkedTest9();
|
|
267 |
break;
|
|
268 |
case RLddTest::EControlTestKInstall:
|
|
269 |
{
|
|
270 |
r = KErrNoMemory;
|
|
271 |
NKern::ThreadEnterCS();
|
|
272 |
DLogicalDevice* device = new DKInstallTestFactory;
|
|
273 |
if (device!=NULL)
|
|
274 |
r = Kern::InstallLogicalDevice(device);
|
|
275 |
NKern::ThreadLeaveCS();
|
|
276 |
}
|
|
277 |
break;
|
|
278 |
default:
|
|
279 |
r=KErrNotSupported;
|
|
280 |
break;
|
|
281 |
}
|
|
282 |
return r;
|
|
283 |
}
|
|
284 |
|
|
285 |
DKInstallTestFactory::DKInstallTestFactory()
|
|
286 |
//
|
|
287 |
// Constructor
|
|
288 |
//
|
|
289 |
{
|
|
290 |
iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);
|
|
291 |
//iParseMask=0;//No units, no info, no PDD
|
|
292 |
//iUnitsMask=0;//Only one thing
|
|
293 |
}
|
|
294 |
|
|
295 |
TInt DKInstallTestFactory::Create(DLogicalChannelBase*& aChannel)
|
|
296 |
//
|
|
297 |
// Create a new DKInstallTest on this logical device
|
|
298 |
//
|
|
299 |
{
|
|
300 |
aChannel=new DKInstallTest;
|
|
301 |
return aChannel?KErrNone:KErrNoMemory;
|
|
302 |
}
|
|
303 |
|
|
304 |
TInt DKInstallTestFactory::Install()
|
|
305 |
//
|
|
306 |
// Install the LDD - overriding pure virtual
|
|
307 |
//
|
|
308 |
{
|
|
309 |
return SetName(&KKInstallLddName);
|
|
310 |
}
|
|
311 |
|
|
312 |
void DKInstallTestFactory::GetCaps(TDes8& aDes) const
|
|
313 |
//
|
|
314 |
// Get capabilities - overriding pure virtual
|
|
315 |
//
|
|
316 |
{
|
|
317 |
TCapsTestV01 b;
|
|
318 |
b.iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);
|
|
319 |
Kern::InfoCopy(aDes,(TUint8*)&b,sizeof(b));
|
|
320 |
}
|
|
321 |
|
|
322 |
TInt DKInstallTest::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& aVer)
|
|
323 |
//
|
|
324 |
// Create channel
|
|
325 |
//
|
|
326 |
{
|
|
327 |
|
|
328 |
if (!Kern::QueryVersionSupported(TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber),aVer))
|
|
329 |
return KErrNotSupported;
|
|
330 |
return KErrNone;
|
|
331 |
}
|
|
332 |
|
|
333 |
DKInstallTest::~DKInstallTest()
|
|
334 |
//
|
|
335 |
// Destructor
|
|
336 |
//
|
|
337 |
{
|
|
338 |
}
|
|
339 |
|
|
340 |
TInt DKInstallTest::Request(TInt aFunction, TAny* a1, TAny* a2)
|
|
341 |
{
|
|
342 |
(void)aFunction;
|
|
343 |
(void)a1;
|
|
344 |
(void)a2;
|
|
345 |
return KErrNotSupported;
|
|
346 |
}
|
|
347 |
|