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