0
|
1 |
// Copyright (c) 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/hcr/d_hcrsim.cpp
|
|
15 |
//
|
|
16 |
|
|
17 |
#include "d_hcrsim.h"
|
|
18 |
#include <kernel/kernel.h>
|
|
19 |
#include <plat_priv.h>
|
|
20 |
#include "hcr_debug.h"
|
|
21 |
#include "hcr_hai.h"
|
|
22 |
#include "hcr_pil.h"
|
|
23 |
|
|
24 |
#define TEST(a) CheckPoint(a, __LINE__)
|
|
25 |
#define TEST_KERRNONE(a) CheckPointError(a, __LINE__)
|
|
26 |
|
|
27 |
TInt InitExtension();
|
|
28 |
extern TUint32 PslConfigurationFlags;
|
|
29 |
|
|
30 |
class DHcrSimTestDrvFactory : public DLogicalDevice
|
|
31 |
{
|
|
32 |
public:
|
|
33 |
DHcrSimTestDrvFactory();
|
|
34 |
~DHcrSimTestDrvFactory();
|
|
35 |
virtual TInt Install();
|
|
36 |
virtual void GetCaps(TDes8& aDes) const;
|
|
37 |
virtual TInt Create(DLogicalChannelBase*& aChannel);
|
|
38 |
public:
|
|
39 |
TDynamicDfcQue* iDfcQ;
|
|
40 |
};
|
|
41 |
|
|
42 |
class DHcrSimTestDrvChannel : public DLogicalChannel
|
|
43 |
{
|
|
44 |
public:
|
|
45 |
DHcrSimTestDrvChannel();
|
|
46 |
~DHcrSimTestDrvChannel();
|
|
47 |
// Inherited from DLogicalChannel
|
|
48 |
virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
|
|
49 |
TInt DoControl(TInt aReqNo, TAny* a1, TAny* a2);
|
|
50 |
virtual void HandleMsg(TMessageBase* aMsg);
|
|
51 |
public:
|
|
52 |
DThread* iClient;
|
|
53 |
};
|
|
54 |
|
|
55 |
void CheckPoint(TInt aCondition, TInt aLine)
|
|
56 |
{
|
|
57 |
if (!aCondition)
|
|
58 |
{
|
|
59 |
Kern::Printf("Device driver test failed (line %d)", aLine);
|
|
60 |
}
|
|
61 |
}
|
|
62 |
|
|
63 |
void CheckPointError(TInt aErrorCode, TInt aLine)
|
|
64 |
{
|
|
65 |
if (aErrorCode != KErrNone)
|
|
66 |
{
|
|
67 |
Kern::Printf("Device driver error %d (line %d)", aErrorCode, aLine);
|
|
68 |
}
|
|
69 |
}
|
|
70 |
|
|
71 |
DECLARE_EXTENSION_LDD()
|
|
72 |
{
|
|
73 |
return new DHcrSimTestDrvFactory;
|
|
74 |
}
|
|
75 |
|
|
76 |
DHcrSimTestDrvFactory::DHcrSimTestDrvFactory()
|
|
77 |
{
|
|
78 |
iParseMask = 0;
|
|
79 |
iUnitsMask = 0;
|
|
80 |
iVersion = TVersion(1,0,KE32BuildVersionNumber);
|
|
81 |
}
|
|
82 |
|
|
83 |
DHcrSimTestDrvFactory::~DHcrSimTestDrvFactory()
|
|
84 |
{
|
|
85 |
if (iDfcQ)
|
|
86 |
iDfcQ->Destroy();
|
|
87 |
}
|
|
88 |
|
|
89 |
const TInt KHcrSimTestThreadPriority = 1;
|
|
90 |
_LIT(KHcrSimTestThread,"HcrSimTestThread");
|
|
91 |
|
|
92 |
TInt DHcrSimTestDrvFactory::Install()
|
|
93 |
{
|
|
94 |
TInt r = Kern::DynamicDfcQCreate(iDfcQ, KHcrSimTestThreadPriority, KHcrSimTestThread);
|
|
95 |
if (r != KErrNone)
|
|
96 |
return r;
|
|
97 |
return(SetName(&KTestHcrSim));
|
|
98 |
}
|
|
99 |
|
|
100 |
void DHcrSimTestDrvFactory::GetCaps(TDes8& /*aDes*/) const
|
|
101 |
{
|
|
102 |
// Get capabilities - overriding pure virtual
|
|
103 |
}
|
|
104 |
|
|
105 |
TInt DHcrSimTestDrvFactory::Create(DLogicalChannelBase*& aChannel)
|
|
106 |
{
|
|
107 |
aChannel=new DHcrSimTestDrvChannel;
|
|
108 |
return aChannel?KErrNone:KErrNoMemory;
|
|
109 |
}
|
|
110 |
|
|
111 |
// ----------------------------------------------------------------------------
|
|
112 |
|
|
113 |
DHcrSimTestDrvChannel::DHcrSimTestDrvChannel()
|
|
114 |
{
|
|
115 |
iClient=&Kern::CurrentThread();
|
|
116 |
iClient->Open();
|
|
117 |
}
|
|
118 |
|
|
119 |
DHcrSimTestDrvChannel::~DHcrSimTestDrvChannel()
|
|
120 |
{
|
|
121 |
Kern::SafeClose((DObject*&)iClient, NULL);
|
|
122 |
}
|
|
123 |
|
|
124 |
TInt DHcrSimTestDrvChannel::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/)
|
|
125 |
{
|
|
126 |
SetDfcQ(((DHcrSimTestDrvFactory*)iDevice)->iDfcQ);
|
|
127 |
iMsgQ.Receive();
|
|
128 |
return KErrNone;
|
|
129 |
}
|
|
130 |
|
|
131 |
void DHcrSimTestDrvChannel::HandleMsg(TMessageBase* aMsg)
|
|
132 |
{
|
|
133 |
TInt r=KErrNone;
|
|
134 |
TThreadMessage& m=*(TThreadMessage*)aMsg;
|
|
135 |
TInt id=m.iValue;
|
|
136 |
if (id==(TInt)ECloseMsg)
|
|
137 |
{
|
|
138 |
m.Complete(KErrNone,EFalse);
|
|
139 |
return;
|
|
140 |
}
|
|
141 |
else
|
|
142 |
{
|
|
143 |
r=DoControl(id,m.Ptr0(),m.Ptr1());
|
|
144 |
}
|
|
145 |
m.Complete(r,ETrue);
|
|
146 |
}
|
|
147 |
|
|
148 |
TInt DHcrSimTestDrvChannel::DoControl(TInt aReqNo, TAny* a1, TAny* a2)
|
|
149 |
{
|
|
150 |
TInt r=KErrNotSupported;
|
|
151 |
switch (aReqNo)
|
|
152 |
{
|
|
153 |
case RHcrSimTestChannel::EHcrGetLinAddr:
|
|
154 |
{
|
|
155 |
HCR::TSettingId setting;
|
|
156 |
TLinAddr value;
|
|
157 |
Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId));
|
|
158 |
r = HCR::GetLinAddr(setting, value);
|
|
159 |
Kern::ThreadRawWrite(iClient, a2, &value, sizeof(value));
|
|
160 |
break;
|
|
161 |
}
|
|
162 |
case RHcrSimTestChannel::EHcrFindNumSettingsInCategory:
|
|
163 |
{
|
|
164 |
r = HCR::FindNumSettingsInCategory((HCR::TCategoryUid) a1);
|
|
165 |
break;
|
|
166 |
}
|
|
167 |
case RHcrSimTestChannel::EHcrFindSettingsCategory:
|
|
168 |
{
|
|
169 |
// Get list of pointers
|
|
170 |
TAny* args[6];
|
|
171 |
Kern::ThreadRawRead(iClient, a1, args, sizeof(args));
|
|
172 |
TInt aMaxNum = (TInt) args[1];
|
|
173 |
// Allocate temporary memory
|
|
174 |
TUint32 numfound;
|
|
175 |
HCR::TElementId* ids;
|
|
176 |
HCR::TSettingType* types = NULL;
|
|
177 |
TUint16* lens = NULL;
|
|
178 |
ids = (HCR::TElementId*) Kern::Alloc(aMaxNum * sizeof(HCR::TElementId));
|
|
179 |
if (ids == NULL)
|
|
180 |
{
|
|
181 |
r = KErrNoMemory;
|
|
182 |
}
|
|
183 |
else
|
|
184 |
{
|
|
185 |
if (args[4]) // aTypes
|
|
186 |
{
|
|
187 |
types = (HCR::TSettingType*) Kern::Alloc(aMaxNum * sizeof(HCR::TSettingType));
|
|
188 |
}
|
|
189 |
if (types == NULL && args[4])
|
|
190 |
{
|
|
191 |
r = KErrNoMemory;
|
|
192 |
}
|
|
193 |
else
|
|
194 |
{
|
|
195 |
if (args[5]) // aLens
|
|
196 |
{
|
|
197 |
lens = (TUint16*) Kern::Alloc(aMaxNum * sizeof(TUint16));
|
|
198 |
}
|
|
199 |
if (lens == NULL && args[5])
|
|
200 |
{
|
|
201 |
r = KErrNoMemory;
|
|
202 |
}
|
|
203 |
else
|
|
204 |
{
|
|
205 |
// Actual API call
|
|
206 |
r = HCR::FindSettings((HCR::TCategoryUid) args[0],
|
|
207 |
aMaxNum, numfound, ids, types, lens);
|
|
208 |
TEST_KERRNONE(r);
|
|
209 |
// Send values back to client
|
|
210 |
if (!r)
|
|
211 |
{
|
|
212 |
Kern::ThreadRawWrite(iClient, args[2], &numfound, sizeof(TUint32));
|
|
213 |
Kern::ThreadRawWrite(iClient, args[3], ids, aMaxNum * sizeof(HCR::TElementId));
|
|
214 |
if (args[4])
|
|
215 |
{
|
|
216 |
Kern::ThreadRawWrite(iClient, args[4], types, aMaxNum * sizeof(HCR::TSettingType));
|
|
217 |
}
|
|
218 |
if (args[5])
|
|
219 |
{
|
|
220 |
Kern::ThreadRawWrite(iClient, args[5], lens, aMaxNum * sizeof(TUint16));
|
|
221 |
}
|
|
222 |
}
|
|
223 |
if (args[5])
|
|
224 |
{
|
|
225 |
Kern::Free(lens);
|
|
226 |
}
|
|
227 |
}
|
|
228 |
if (args[4])
|
|
229 |
{
|
|
230 |
Kern::Free(types);
|
|
231 |
}
|
|
232 |
}
|
|
233 |
Kern::Free(ids);
|
|
234 |
}
|
|
235 |
break;
|
|
236 |
}
|
|
237 |
case RHcrSimTestChannel::EHcrFindSettingsPattern:
|
|
238 |
{
|
|
239 |
// Get list of pointers
|
|
240 |
TAny* args[9];
|
|
241 |
Kern::ThreadRawRead(iClient, a1, args, sizeof(args));
|
|
242 |
TInt aMaxNum = (TInt) args[1];
|
|
243 |
// Allocate temporary memory
|
|
244 |
TUint32 numfound;
|
|
245 |
HCR::TElementId* ids;
|
|
246 |
HCR::TSettingType* types = NULL;
|
|
247 |
TUint16* lens = NULL;
|
|
248 |
ids = (HCR::TElementId*) Kern::Alloc(aMaxNum * sizeof(HCR::TElementId));
|
|
249 |
if (ids == NULL)
|
|
250 |
{
|
|
251 |
r = KErrNoMemory;
|
|
252 |
}
|
|
253 |
else
|
|
254 |
{
|
|
255 |
if (args[7]) // aTypes
|
|
256 |
{
|
|
257 |
types = (HCR::TSettingType*) Kern::Alloc(aMaxNum * sizeof(HCR::TSettingType));
|
|
258 |
}
|
|
259 |
if (types == NULL && args[7])
|
|
260 |
{
|
|
261 |
r = KErrNoMemory;
|
|
262 |
}
|
|
263 |
else
|
|
264 |
{
|
|
265 |
if (args[8]) // aLens
|
|
266 |
{
|
|
267 |
lens = (TUint16*) Kern::Alloc(aMaxNum * sizeof(TUint16));
|
|
268 |
}
|
|
269 |
if (lens == NULL && args[8])
|
|
270 |
{
|
|
271 |
r = KErrNoMemory;
|
|
272 |
}
|
|
273 |
else
|
|
274 |
{
|
|
275 |
// Actual API call
|
|
276 |
r = HCR::FindSettings((HCR::TCategoryUid) args[0],
|
|
277 |
aMaxNum, (TUint32) args[2], (TUint32) args[3], (TUint32) args[4],
|
|
278 |
numfound, ids, types, lens);
|
|
279 |
TEST_KERRNONE(r);
|
|
280 |
// Send values back to client
|
|
281 |
if (!r)
|
|
282 |
{
|
|
283 |
Kern::ThreadRawWrite(iClient, args[5], &numfound, sizeof(TUint32));
|
|
284 |
Kern::ThreadRawWrite(iClient, args[6], ids, aMaxNum * sizeof(HCR::TElementId));
|
|
285 |
if (args[7])
|
|
286 |
{
|
|
287 |
Kern::ThreadRawWrite(iClient, args[7], types, aMaxNum * sizeof(HCR::TSettingType));
|
|
288 |
}
|
|
289 |
if (args[8])
|
|
290 |
{
|
|
291 |
Kern::ThreadRawWrite(iClient, args[8], lens, aMaxNum * sizeof(TUint16));
|
|
292 |
}
|
|
293 |
}
|
|
294 |
if (args[8])
|
|
295 |
{
|
|
296 |
Kern::Free(lens);
|
|
297 |
}
|
|
298 |
}
|
|
299 |
if (args[7])
|
|
300 |
{
|
|
301 |
Kern::Free(types);
|
|
302 |
}
|
|
303 |
}
|
|
304 |
Kern::Free(ids);
|
|
305 |
}
|
|
306 |
break;
|
|
307 |
}
|
|
308 |
case RHcrSimTestChannel::EHcrGetTypeAndSize:
|
|
309 |
{
|
|
310 |
// Get list of pointers
|
|
311 |
TAny* args[3];
|
|
312 |
Kern::ThreadRawRead(iClient, a1, args, sizeof(args));
|
|
313 |
HCR::TSettingId id;
|
|
314 |
Kern::ThreadRawRead(iClient, args[0], &id, sizeof(HCR::TSettingId));
|
|
315 |
HCR::TSettingType type;
|
|
316 |
TUint16 len;
|
|
317 |
TEST_KERRNONE(r = HCR::GetTypeAndSize(id, type, len));
|
|
318 |
Kern::ThreadRawWrite(iClient, args[1], &type, sizeof(HCR::TSettingType));
|
|
319 |
Kern::ThreadRawWrite(iClient, args[2], &len, sizeof(TUint16));
|
|
320 |
break;
|
|
321 |
}
|
|
322 |
case RHcrSimTestChannel::EHcrGetWordSettings:
|
|
323 |
{
|
|
324 |
// Get list of pointers
|
|
325 |
TAny* args[5];
|
|
326 |
Kern::ThreadRawRead(iClient, a1, args, sizeof(args));
|
|
327 |
TInt aNum = (TInt) args[0];
|
|
328 |
// Allocate temporary memory
|
|
329 |
HCR::SSettingId* ids;
|
|
330 |
TInt32* vals;
|
|
331 |
HCR::TSettingType* types= NULL;
|
|
332 |
TInt* errors = NULL;
|
|
333 |
ids = (HCR::SSettingId*) Kern::Alloc(aNum * sizeof(HCR::SSettingId*));
|
|
334 |
if (ids == NULL)
|
|
335 |
{
|
|
336 |
r = KErrNoMemory;
|
|
337 |
}
|
|
338 |
else
|
|
339 |
{
|
|
340 |
vals = (TInt32*) Kern::Alloc(aNum * sizeof(TInt32));
|
|
341 |
if (vals == NULL)
|
|
342 |
{
|
|
343 |
r = KErrNoMemory;
|
|
344 |
}
|
|
345 |
else
|
|
346 |
{
|
|
347 |
if (args[3]) // aTypes
|
|
348 |
{
|
|
349 |
types = (HCR::TSettingType*) Kern::Alloc(aNum * sizeof(HCR::TSettingType));
|
|
350 |
}
|
|
351 |
if (types == NULL && args[3])
|
|
352 |
{
|
|
353 |
r = KErrNoMemory;
|
|
354 |
}
|
|
355 |
else
|
|
356 |
{
|
|
357 |
if (args[4]) // aErrors
|
|
358 |
{
|
|
359 |
errors = (TInt*) Kern::Alloc(aNum * sizeof(TInt));
|
|
360 |
}
|
|
361 |
if (errors == NULL && args[4])
|
|
362 |
{
|
|
363 |
r = KErrNoMemory;
|
|
364 |
}
|
|
365 |
else
|
|
366 |
{
|
|
367 |
// Actual API call
|
|
368 |
TEST_KERRNONE(r = HCR::GetWordSettings(aNum, ids, vals, types, errors));
|
|
369 |
// Send values back to client
|
|
370 |
if (!r)
|
|
371 |
{
|
|
372 |
Kern::ThreadRawWrite(iClient, args[1], ids, aNum * sizeof(HCR::SSettingId));
|
|
373 |
Kern::ThreadRawWrite(iClient, args[2], vals, aNum * sizeof(TInt32));
|
|
374 |
if (args[3])
|
|
375 |
{
|
|
376 |
Kern::ThreadRawWrite(iClient, args[3], types, aNum * sizeof(HCR::TSettingType));
|
|
377 |
}
|
|
378 |
if (args[4])
|
|
379 |
{
|
|
380 |
Kern::ThreadRawWrite(iClient, args[4], errors, aNum * sizeof(TInt));
|
|
381 |
}
|
|
382 |
}
|
|
383 |
if (args[4])
|
|
384 |
{
|
|
385 |
Kern::Free(errors);
|
|
386 |
}
|
|
387 |
}
|
|
388 |
if (args[3])
|
|
389 |
{
|
|
390 |
Kern::Free(types);
|
|
391 |
}
|
|
392 |
}
|
|
393 |
Kern::Free(vals);
|
|
394 |
}
|
|
395 |
Kern::Free(ids);
|
|
396 |
}
|
|
397 |
break;
|
|
398 |
}
|
|
399 |
case RHcrSimTestChannel::EHcrGetInt64:
|
|
400 |
{
|
|
401 |
HCR::TSettingId setting;
|
|
402 |
TInt64 value;
|
|
403 |
Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId));
|
|
404 |
r = HCR::GetInt(setting, value);
|
|
405 |
Kern::ThreadRawWrite(iClient, a2, &value, sizeof(value));
|
|
406 |
break;
|
|
407 |
}
|
|
408 |
case RHcrSimTestChannel::EHcrGetInt32:
|
|
409 |
{
|
|
410 |
HCR::TSettingId setting;
|
|
411 |
TInt32 value;
|
|
412 |
Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId));
|
|
413 |
r = HCR::GetInt(setting, value);
|
|
414 |
Kern::ThreadRawWrite(iClient, a2, &value, sizeof(value));
|
|
415 |
break;
|
|
416 |
}
|
|
417 |
case RHcrSimTestChannel::EHcrGetInt16:
|
|
418 |
{
|
|
419 |
HCR::TSettingId setting;
|
|
420 |
TInt16 value;
|
|
421 |
Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId));
|
|
422 |
r = HCR::GetInt(setting, value);
|
|
423 |
Kern::ThreadRawWrite(iClient, a2, &value, sizeof(value));
|
|
424 |
break;
|
|
425 |
}
|
|
426 |
case RHcrSimTestChannel::EHcrGetInt8:
|
|
427 |
{
|
|
428 |
HCR::TSettingId setting;
|
|
429 |
TInt8 value;
|
|
430 |
Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId));
|
|
431 |
r = HCR::GetInt(setting, value);
|
|
432 |
Kern::ThreadRawWrite(iClient, a2, &value, sizeof(value));
|
|
433 |
break;
|
|
434 |
}
|
|
435 |
case RHcrSimTestChannel::EHcrGetBool:
|
|
436 |
{
|
|
437 |
HCR::TSettingId setting;
|
|
438 |
TBool value;
|
|
439 |
Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId));
|
|
440 |
r = HCR::GetBool(setting, value);
|
|
441 |
Kern::ThreadRawWrite(iClient, a2, &value, sizeof(value));
|
|
442 |
break;
|
|
443 |
}
|
|
444 |
case RHcrSimTestChannel::EHcrGetDataArray:
|
|
445 |
{
|
|
446 |
// Get list of pointers
|
|
447 |
TAny* args[4];
|
|
448 |
Kern::ThreadRawRead(iClient, a1, args, sizeof(args));
|
|
449 |
TUint maxlen = (TUint) args[1];
|
|
450 |
// Retrieve structures from client
|
|
451 |
HCR::TSettingId id;
|
|
452 |
Kern::ThreadRawRead(iClient, args[0], &id, sizeof(HCR::TSettingId));
|
|
453 |
// Allocate temporary memory
|
|
454 |
TUint16 len;
|
|
455 |
TUint8* value;
|
|
456 |
value = (TUint8*) Kern::Alloc(maxlen * sizeof(TUint8));
|
|
457 |
if (value == NULL)
|
|
458 |
{
|
|
459 |
r = KErrNoMemory;
|
|
460 |
}
|
|
461 |
else
|
|
462 |
{
|
|
463 |
// Actual API call
|
|
464 |
r = HCR::GetData(id, (TUint16) maxlen,
|
|
465 |
value, len);
|
|
466 |
// Send value back to client
|
|
467 |
if (!r)
|
|
468 |
{
|
|
469 |
Kern::ThreadRawWrite(iClient, args[2], value, maxlen * sizeof(TUint8));
|
|
470 |
Kern::ThreadRawWrite(iClient, args[3], &len, sizeof(TUint16));
|
|
471 |
}
|
|
472 |
Kern::Free(value);
|
|
473 |
}
|
|
474 |
break;
|
|
475 |
}
|
|
476 |
case RHcrSimTestChannel::EHcrGetDataDes:
|
|
477 |
{
|
|
478 |
HCR::TSettingId setting;
|
|
479 |
TBuf8<HCR::KMaxSettingLength> value;
|
|
480 |
Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId));
|
|
481 |
r = HCR::GetData(setting, value);
|
|
482 |
Kern::ThreadDesWrite(iClient, a2, value, 0);
|
|
483 |
break;
|
|
484 |
}
|
|
485 |
case RHcrSimTestChannel::EHcrGetUInt64:
|
|
486 |
{
|
|
487 |
HCR::TSettingId setting;
|
|
488 |
TUint64 value;
|
|
489 |
Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId));
|
|
490 |
r = HCR::GetUInt(setting, value);
|
|
491 |
Kern::ThreadRawWrite(iClient, a2, &value, sizeof(value));
|
|
492 |
break;
|
|
493 |
}
|
|
494 |
case RHcrSimTestChannel::EHcrGetUInt32:
|
|
495 |
{
|
|
496 |
HCR::TSettingId setting;
|
|
497 |
TUint32 value;
|
|
498 |
Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId));
|
|
499 |
r = HCR::GetUInt(setting, value);
|
|
500 |
Kern::ThreadRawWrite(iClient, a2, &value, sizeof(value));
|
|
501 |
break;
|
|
502 |
}
|
|
503 |
case RHcrSimTestChannel::EHcrGetUInt16:
|
|
504 |
{
|
|
505 |
HCR::TSettingId setting;
|
|
506 |
TUint16 value;
|
|
507 |
Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId));
|
|
508 |
r = HCR::GetUInt(setting, value);
|
|
509 |
Kern::ThreadRawWrite(iClient, a2, &value, sizeof(value));
|
|
510 |
break;
|
|
511 |
}
|
|
512 |
case RHcrSimTestChannel::EHcrGetUInt8:
|
|
513 |
{
|
|
514 |
HCR::TSettingId setting;
|
|
515 |
TUint8 value;
|
|
516 |
Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId));
|
|
517 |
r = HCR::GetUInt(setting, value);
|
|
518 |
Kern::ThreadRawWrite(iClient, a2, &value, sizeof(value));
|
|
519 |
break;
|
|
520 |
}
|
|
521 |
case RHcrSimTestChannel::EHcrGetArrayInt:
|
|
522 |
{
|
|
523 |
// Get list of pointers
|
|
524 |
TAny* args[4];
|
|
525 |
Kern::ThreadRawRead(iClient, a1, args, sizeof(args));
|
|
526 |
TUint maxlen = (TUint) args[1];
|
|
527 |
// Retrieve structures from client
|
|
528 |
HCR::TSettingId id;
|
|
529 |
Kern::ThreadRawRead(iClient, args[0], &id, sizeof(HCR::TSettingId));
|
|
530 |
// Allocate temporary memory
|
|
531 |
TUint16 len;
|
|
532 |
TInt32* value;
|
|
533 |
value = (TInt32*) Kern::Alloc(maxlen);
|
|
534 |
if (value == NULL)
|
|
535 |
{
|
|
536 |
r = KErrNoMemory;
|
|
537 |
}
|
|
538 |
else
|
|
539 |
{
|
|
540 |
// Actual API call
|
|
541 |
r = HCR::GetArray(id, (TUint16) maxlen,
|
|
542 |
value, len);
|
|
543 |
// Send value back to client
|
|
544 |
if (!r)
|
|
545 |
{
|
|
546 |
Kern::ThreadRawWrite(iClient, args[2], value, maxlen);
|
|
547 |
Kern::ThreadRawWrite(iClient, args[3], &len, sizeof(TUint16));
|
|
548 |
}
|
|
549 |
Kern::Free(value);
|
|
550 |
}
|
|
551 |
break;
|
|
552 |
}
|
|
553 |
case RHcrSimTestChannel::EHcrGetArrayUInt:
|
|
554 |
{
|
|
555 |
// Get list of pointers
|
|
556 |
TAny* args[4];
|
|
557 |
Kern::ThreadRawRead(iClient, a1, args, sizeof(args));
|
|
558 |
TUint maxlen = (TUint) args[1];
|
|
559 |
// Retrieve structures from client
|
|
560 |
HCR::TSettingId id;
|
|
561 |
Kern::ThreadRawRead(iClient, args[0], &id, sizeof(HCR::TSettingId));
|
|
562 |
// Allocate temporary memory
|
|
563 |
TUint16 len;
|
|
564 |
TUint32* value;
|
|
565 |
value = (TUint32*) Kern::Alloc(maxlen);
|
|
566 |
if (value == NULL)
|
|
567 |
{
|
|
568 |
r = KErrNoMemory;
|
|
569 |
}
|
|
570 |
else
|
|
571 |
{
|
|
572 |
// Actual API call
|
|
573 |
r = HCR::GetArray(id, (TUint16) maxlen,
|
|
574 |
value, len);
|
|
575 |
// Send value back to client
|
|
576 |
if (!r)
|
|
577 |
{
|
|
578 |
Kern::ThreadRawWrite(iClient, args[2], value, maxlen);
|
|
579 |
Kern::ThreadRawWrite(iClient, args[3], &len, sizeof(TUint16));
|
|
580 |
}
|
|
581 |
Kern::Free(value);
|
|
582 |
}
|
|
583 |
break;
|
|
584 |
}
|
|
585 |
case RHcrSimTestChannel::EHcrGetStringArray:
|
|
586 |
{
|
|
587 |
// Get list of pointers
|
|
588 |
TAny* args[4];
|
|
589 |
Kern::ThreadRawRead(iClient, a1, args, sizeof(args));
|
|
590 |
TUint maxlen = (TUint) args[1];
|
|
591 |
// Retrieve structures from client
|
|
592 |
HCR::TSettingId id;
|
|
593 |
Kern::ThreadRawRead(iClient, args[0], &id, sizeof(HCR::TSettingId));
|
|
594 |
// Allocate temporary memory
|
|
595 |
TUint16 len;
|
|
596 |
TText8* value;
|
|
597 |
value = (TText8*) Kern::Alloc(maxlen * sizeof(TText8));
|
|
598 |
if (value == NULL)
|
|
599 |
{
|
|
600 |
r = KErrNoMemory;
|
|
601 |
}
|
|
602 |
else
|
|
603 |
{
|
|
604 |
// Actual API call
|
|
605 |
r = HCR::GetString(id, (TUint16) maxlen,
|
|
606 |
value, len);
|
|
607 |
// Send value back to client
|
|
608 |
if (!r)
|
|
609 |
{
|
|
610 |
Kern::ThreadRawWrite(iClient, args[2], value, maxlen * sizeof(TText8));
|
|
611 |
Kern::ThreadRawWrite(iClient, args[3], &len, sizeof(TUint16));
|
|
612 |
}
|
|
613 |
Kern::Free(value);
|
|
614 |
}
|
|
615 |
break;
|
|
616 |
}
|
|
617 |
case RHcrSimTestChannel::EHcrGetStringDes:
|
|
618 |
{
|
|
619 |
HCR::TSettingId setting;
|
|
620 |
TBuf8<HCR::KMaxSettingLength> value;
|
|
621 |
Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId));
|
|
622 |
r = HCR::GetString(setting, value);
|
|
623 |
Kern::ThreadDesWrite(iClient, a2, value, 0);
|
|
624 |
break;
|
|
625 |
}
|
|
626 |
case RHcrSimTestChannel::EHcrInitExtension:
|
|
627 |
{
|
|
628 |
PslConfigurationFlags = (TInt) a1;
|
|
629 |
r = InitExtension();
|
|
630 |
break;
|
|
631 |
}
|
|
632 |
case RHcrSimTestChannel::EHcrSwitchRepository:
|
|
633 |
{
|
|
634 |
TBuf8<80> filename;
|
|
635 |
Kern::ThreadDesRead(iClient, a1, filename, 0);
|
|
636 |
TText8 filestr[81];
|
|
637 |
memcpy(filestr, filename.Ptr(), filename.Length());
|
|
638 |
filestr[filename.Length()] = 0; // Zero-terminate string
|
|
639 |
TText8* pfile = filestr;
|
|
640 |
if (filename.Length() == 0)
|
|
641 |
{
|
|
642 |
pfile = NULL;
|
|
643 |
}
|
|
644 |
if ((TUint) a2 == HCR::HCRInternal::ECoreRepos)
|
|
645 |
{
|
|
646 |
r = HCRSingleton->SwitchRepository(pfile, HCR::HCRInternal::ECoreRepos);
|
|
647 |
}
|
|
648 |
else if ((TUint) a2 == HCR::HCRInternal::EOverrideRepos)
|
|
649 |
{
|
|
650 |
r = HCRSingleton->SwitchRepository(pfile, HCR::HCRInternal::EOverrideRepos);
|
|
651 |
}
|
|
652 |
break;
|
|
653 |
}
|
|
654 |
case RHcrSimTestChannel::EHcrCheckIntegrity:
|
|
655 |
{
|
|
656 |
r = HCRSingleton->CheckIntegrity();
|
|
657 |
break;
|
|
658 |
}
|
|
659 |
}
|
|
660 |
return r;
|
|
661 |
}
|