First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test/hcr/d_hcrsim.cpp
18 #include <kernel/kernel.h>
19 #include <plat_priv.h>
20 #include "hcr_debug.h"
22 #ifdef HCRTEST_USERSIDE_INTERFACE
23 #include "d_hcrsim_testdata.h"
24 #endif // HCRTEST_USERSIDE_INTERFACE
26 #define TEST(a) CheckPoint(a, __LINE__)
27 #define TEST_KERRNONE(a) CheckPointError(a, __LINE__)
29 #ifndef HCRTEST_USERSIDE_INTERFACE
31 extern TUint32 PslConfigurationFlags;
32 #endif // HCRTEST_USERSIDE_INTERFACE
34 #ifdef HCRTEST_CLIENT_THREAD
35 #define TEST_ENTERCS() NKern::ThreadEnterCS()
36 #define TEST_LEAVECS() NKern::ThreadLeaveCS()
37 #define TEST_MEMGET(s, d, l) kumemget(d, s, l)
38 #define TEST_MEMPUT(d, s, l) kumemput(d, s, l)
39 #define TEST_DESGET(s, d) Kern::KUDesGet(d, *(TDes8*) s)
40 #define TEST_DESPUT(d, s) Kern::KUDesPut(*(TDes8*) d, s)
42 #define TEST_ENTERCS()
43 #define TEST_LEAVECS()
44 #define TEST_MEMGET(s, d, l) Kern::ThreadRawRead(iClient, s, d, l)
45 #define TEST_MEMPUT(d, s, l) Kern::ThreadRawWrite(iClient, d, s, l)
46 #define TEST_DESGET(s, d) Kern::ThreadDesRead(iClient, s, d, 0)
47 #define TEST_DESPUT(d, s) Kern::ThreadDesWrite(iClient, d, s, 0)
48 #endif // HCRTEST_CLIENT_THREAD
50 // Test results for the Kernel Extension initialisation routine
51 TInt TestKernExtensionTestLine = -1;
52 TInt TestKernExtensionTestError = -1;
54 const TUint KTestBenchmarkIterations = 10000;
55 const TUint KTestGetMultipleBenchmarkIterations = 100;
57 class DHcrSimTestDrvFactory : public DLogicalDevice
60 DHcrSimTestDrvFactory();
61 ~DHcrSimTestDrvFactory();
62 virtual TInt Install();
63 virtual void GetCaps(TDes8& aDes) const;
64 virtual TInt Create(DLogicalChannelBase*& aChannel);
66 #ifndef HCRTEST_CLIENT_THREAD
67 TDynamicDfcQue* iDfcQ;
71 #ifdef HCRTEST_CLIENT_THREAD
72 class DHcrSimTestDrvChannel : public DLogicalChannelBase
74 class DHcrSimTestDrvChannel : public DLogicalChannel
78 DHcrSimTestDrvChannel();
79 ~DHcrSimTestDrvChannel();
80 // Inherited from DLogicalChannel
81 virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
82 #ifdef HCRTEST_CLIENT_THREAD
83 // Inherited from DLogicalChannelBase: process all DoControl in the user's context
84 virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2);
86 TInt DoControl(TInt aReqNo, TAny* a1, TAny* a2);
87 virtual void HandleMsg(TMessageBase* aMsg);
90 #endif // HCRTEST_CLIENT_THREAD
93 void CheckPoint(TInt aCondition, TInt aLine)
97 Kern::Printf("Device driver test failed (line %d)", aLine);
101 void CheckPointError(TInt aErrorCode, TInt aLine)
103 if (aErrorCode != KErrNone)
105 Kern::Printf("Device driver error %d (line %d)", aErrorCode, aLine);
109 void HasRepositoryInSmr(TBool& aHasSmr, TBool& aHasSmrHcr)
114 // Note: the SMR feature by which we obtain the address of the override
115 // repository is only supported in the ARM bootstrap, not X86 or WINS so
116 // this test code needs conditional compilation.
117 #if !defined(__WINS__) && !defined(__X86__)
118 const TSuperPage& superpage = Kern::SuperPage();
119 TUint32* smrib = (TUint32*) superpage.iSmrData;
120 SSmrBank* smrbank = (SSmrBank*) smrib;
121 if((smrib != NULL) && (smrib != (TUint32*)KSuperPageAddressFieldUndefined))
124 while (smrbank->iBase)
126 if (smrbank->iPayloadUID == KHCRUID_SMRPayloadUID)
128 // We have a HCR repository - assuming it is the test one...
135 #endif // !__WINS__ && !__X86__
138 #ifdef HCRTEST_USERSIDE_INTERFACE
139 #define KEXT_TESTKERRNONE(_r) \
142 if ((_s) && !TestKernExtensionTestLine) \
144 TestKernExtensionTestError = (_r); \
145 TestKernExtensionTestLine = __LINE__; \
148 #define KEXT_TEST(_r) \
150 if (!(_r) && !TestKernExtensionTestLine) \
152 TestKernExtensionTestError = 1; \
153 TestKernExtensionTestLine = __LINE__; \
160 // Get last Setting in Reference Compiled Repository
162 TSettingId setting1(0xFFFFFFFF, 0xFFFFFFFF);
163 r = GetUInt(setting1, value1);
164 KEXT_TESTKERRNONE(r);
165 KEXT_TEST(value1==0x4C415354); // 'L', 'A', 'S', 'T'
167 // Determine what test repositories the HCR has loaded
168 // Make sure we have the file repository
169 const TRomHeader& romheader = Epoc::RomHeader();
170 KEXT_TEST(romheader.iHcrFileAddress != NULL); // Assuming this is the test repository (hcr.dat)
171 // Find the nand repository
174 SSettingC* repos = NULL;
176 HasRepositoryInSmr(smr, smrrep);
179 repos = SettingsList6; // File+Nand
180 nosettings = sizeof(SettingsList6) / sizeof(SSettingC);
184 repos = SettingsList7; // File Only
185 nosettings = sizeof(SettingsList7) / sizeof(SSettingC);
189 // SMR partitions found but no HCR repository
194 // Simple word setting Get
195 for (SSettingC* setting = repos; setting < repos + nosettings; setting++)
197 // Note: these macros are irrelevant here, it is just so the two test kernel
198 // extensions do something different
199 #ifdef HCRTEST_CLIENT_THREAD
200 if (setting->iName.iType == ETypeInt32)
202 TSettingId id(setting->iName.iId.iCat, setting->iName.iId.iKey);
205 KEXT_TESTKERRNONE(r);
206 KEXT_TEST(setting->iValue.iLit.iInt32 == val);
208 #else // !HCRTEST_CLIENT_THREAD
209 if (setting->iName.iType == ETypeUInt32)
211 TSettingId id(setting->iName.iId.iCat, setting->iName.iId.iKey);
213 r = GetUInt(id, val);
214 KEXT_TESTKERRNONE(r);
215 KEXT_TEST(setting->iValue.iLit.iUInt32 == val);
217 #endif // !HCRTEST_CLIENT_THREAD
221 for (SSettingC* setting = repos; setting < repos + nosettings; setting++)
223 // Note: these macros are irrelevant here, it is just so the two test kernel
224 // extensions do something different
225 #ifdef HCRTEST_CLIENT_THREAD
226 if (setting->iName.iType == ETypeBinData)
228 TSettingId id(setting->iName.iId.iCat, setting->iName.iId.iKey);
229 TBuf8<KMaxSettingLength> val;
230 TPtrC8 aval(setting->iValue.iPtr.iData, setting->iName.iLen);
231 r = GetData(id, val);
232 KEXT_TESTKERRNONE(r);
233 KEXT_TEST(0 == val.Compare(aval));
235 #else // !HCRTEST_CLIENT_THREAD
236 if (setting->iName.iType == ETypeText8)
238 TSettingId id(setting->iName.iId.iCat, setting->iName.iId.iKey);
239 TBuf8<KMaxSettingLength> val;
240 TPtrC8 aval(setting->iValue.iPtr.iString8, setting->iName.iLen);
241 r = GetString(id, val);
242 KEXT_TESTKERRNONE(r);
243 KEXT_TEST(0 == val.Compare(aval));
245 #endif // !HCRTEST_CLIENT_THREAD
248 // Some other API calls
250 for (i = 0; i < sizeof(KTestCategories) / sizeof(TCategoryUid); i++)
252 r = FindNumSettingsInCategory(KTestCategories[i]);
257 DECLARE_EXTENSION_WITH_PRIORITY(KExtensionMaximumPriority)
259 // Set these to 0 so we know we've been here
260 TestKernExtensionTestLine = 0;
261 TestKernExtensionTestError = 0;
265 #endif // HCRTEST_USERSIDE_INTERFACE
267 DECLARE_EXTENSION_LDD()
269 return new DHcrSimTestDrvFactory;
272 DHcrSimTestDrvFactory::DHcrSimTestDrvFactory()
276 iVersion = TVersion(1,0,KE32BuildVersionNumber);
279 DHcrSimTestDrvFactory::~DHcrSimTestDrvFactory()
281 #ifndef HCRTEST_CLIENT_THREAD
287 #ifndef HCRTEST_CLIENT_THREAD
288 const TInt KHcrSimTestThreadPriority = 1;
289 _LIT(KHcrSimTestThread,"HcrSimTestThread");
292 TInt DHcrSimTestDrvFactory::Install()
295 #ifndef HCRTEST_CLIENT_THREAD
296 r = Kern::DynamicDfcQCreate(iDfcQ, KHcrSimTestThreadPriority, KHcrSimTestThread);
299 #ifdef HCRTEST_USERSIDE_INTERFACE
300 r = SetName(&KTestHcrRealOwn);
302 r = SetName(&KTestHcrSimOwn);
303 #endif // HCRTEST_USERSIDE_INTERFACE
305 #ifdef HCRTEST_USERSIDE_INTERFACE
306 r = SetName(&KTestHcrRealClient);
308 r = SetName(&KTestHcrSimClient);
309 #endif // HCRTEST_USERSIDE_INTERFACE
310 #endif // HCRTEST_CLIENT_THREAD
314 void DHcrSimTestDrvFactory::GetCaps(TDes8& /*aDes*/) const
316 // Get capabilities - overriding pure virtual
319 TInt DHcrSimTestDrvFactory::Create(DLogicalChannelBase*& aChannel)
321 aChannel=new DHcrSimTestDrvChannel;
322 return aChannel?KErrNone:KErrNoMemory;
325 // ----------------------------------------------------------------------------
327 DHcrSimTestDrvChannel::DHcrSimTestDrvChannel()
329 #ifndef HCRTEST_CLIENT_THREAD
330 iClient=&Kern::CurrentThread();
335 DHcrSimTestDrvChannel::~DHcrSimTestDrvChannel()
337 #ifndef HCRTEST_CLIENT_THREAD
338 Kern::SafeClose((DObject*&)iClient, NULL);
342 TInt DHcrSimTestDrvChannel::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/)
344 #ifndef HCRTEST_CLIENT_THREAD
345 SetDfcQ(((DHcrSimTestDrvFactory*)iDevice)->iDfcQ);
351 #ifndef HCRTEST_CLIENT_THREAD
352 void DHcrSimTestDrvChannel::HandleMsg(TMessageBase* aMsg)
355 TThreadMessage& m=*(TThreadMessage*)aMsg;
357 if (id==(TInt)ECloseMsg)
359 m.Complete(KErrNone,EFalse);
364 r=DoControl(id,m.Ptr0(),m.Ptr1());
368 #endif // HCRTEST_CLIENT_THREAD
370 #ifdef HCRTEST_CLIENT_THREAD
371 TInt DHcrSimTestDrvChannel::Request(TInt aReqNo, TAny* a1, TAny* a2)
373 TInt DHcrSimTestDrvChannel::DoControl(TInt aReqNo, TAny* a1, TAny* a2)
376 TInt r=KErrNotSupported;
379 case RHcrSimTestChannel::EHcrGetLinAddr:
383 TEST_MEMGET(a1, &setting, sizeof(TSettingId));
384 r = GetLinAddr(setting, value);
385 TEST_MEMPUT(a2, &value, sizeof(value));
388 case RHcrSimTestChannel::EHcrFindNumSettingsInCategory:
390 r = FindNumSettingsInCategory((TCategoryUid) a1);
393 case RHcrSimTestChannel::EHcrFindSettingsCategory:
395 // Get list of pointers
397 TEST_MEMGET(a1, args, sizeof(args));
398 TInt aMaxNum = (TInt) args[1];
400 TElementId* ids = NULL;
401 TSettingType* types = NULL;
402 TUint16* lens = NULL;
406 ids = (TElementId*) Kern::Alloc(_ABS(aMaxNum) * sizeof(TElementId));
410 if (args[4]) // aTypes
413 types = (TSettingType*) Kern::Alloc(_ABS(aMaxNum) * sizeof(TSettingType));
416 if (types == NULL && args[4])
422 if (args[5]) // aLens
425 lens = (TUint16*) Kern::Alloc(_ABS(aMaxNum) * sizeof(TUint16));
428 if (lens == NULL && args[5])
435 r = FindSettings((TCategoryUid) args[0],
436 aMaxNum, ids, types, lens);
438 // Send values back to client
443 TEST_MEMPUT(args[3], ids, _ABS(aMaxNum) * sizeof(TElementId));
447 TEST_MEMPUT(args[4], types, _ABS(aMaxNum) * sizeof(TSettingType));
451 TEST_MEMPUT(args[5], lens, _ABS(aMaxNum) * sizeof(TUint16));
481 case RHcrSimTestChannel::EHcrFindSettingsPattern:
483 // Get list of pointers
485 TEST_MEMGET(a1, args, sizeof(args));
486 TInt aMaxNum = (TInt) args[1];
487 // Allocate temporary memory
489 TElementId* ids = NULL;
490 TSettingType* types = NULL;
491 TUint16* lens = NULL;
496 ids = (TElementId*) Kern::Alloc(_ABS(aMaxNum) * sizeof(TElementId));
502 if (args[6]) // aTypes
505 types = (TSettingType*) Kern::Alloc(_ABS(aMaxNum) * sizeof(TSettingType));
509 if (types == NULL && args[6])
515 if (args[7]) // aLens
518 lens = (TUint16*) Kern::Alloc(_ABS(aMaxNum) * sizeof(TUint16));
521 if (lens == NULL && args[7])
529 r = FindSettings((TCategoryUid) args[0],
530 aMaxNum, (TUint32) args[2], (TUint32) args[3],
533 // Send values back to client
537 TEST_MEMPUT(args[5], ids, _ABS(aMaxNum) * sizeof(TElementId));
540 TEST_MEMPUT(args[6], types, _ABS(aMaxNum) * sizeof(TSettingType));
544 TEST_MEMPUT(args[7], lens, _ABS(aMaxNum) * sizeof(TUint16));
572 case RHcrSimTestChannel::EHcrGetTypeAndSize:
574 // Get list of pointers
576 TEST_MEMGET(a1, args, sizeof(args));
578 TEST_MEMGET(args[0], &id, sizeof(TSettingId));
581 r = GetTypeAndSize(id, type, len);
582 TEST_MEMPUT(args[1], &type, sizeof(TSettingType));
583 TEST_MEMPUT(args[2], &len, sizeof(TUint16));
586 case RHcrSimTestChannel::EHcrGetWordSettings:
588 // Get list of pointers
590 TEST_MEMGET(a1, args, sizeof(args));
591 TInt aNum = (TInt) args[0];
592 // Allocate temporary memory
594 SSettingId* inIds = (SSettingId*)args[1];
596 TSettingType* types= NULL;
602 ids = (SSettingId*) Kern::Alloc((aNum>=0?aNum:-aNum) * sizeof(SSettingId));
603 //Read data from the user side
610 TEST_MEMGET(inIds, ids, (aNum>=0?aNum:-aNum) * sizeof(SSettingId));
616 if (args[2]) //values
619 vals = (TInt32*) Kern::Alloc((aNum>=0?aNum:-aNum) * sizeof(TInt32));
630 if (args[3]) // aTypes
633 types = (TSettingType*) Kern::Alloc((aNum>=0?aNum:-aNum) *
634 sizeof(TSettingType));
637 if (types == NULL && args[3])
643 if (args[4]) // aErrors
646 errors = (TInt*) Kern::Alloc((aNum>=0?aNum:-aNum) * sizeof(TInt));
649 if (errors == NULL && args[4])
656 r = GetWordSettings(aNum, ids, vals, types, errors);
657 // Send values back to client
660 TEST_MEMPUT(args[1], ids, aNum * sizeof(SSettingId));
661 TEST_MEMPUT(args[2], vals, aNum * sizeof(TInt32));
664 TEST_MEMPUT(args[3], types,(aNum>=0?aNum:-aNum) * sizeof(TSettingType));
668 TEST_MEMPUT(args[4], errors, (aNum>=0?aNum:-aNum) * sizeof(TInt));
698 case RHcrSimTestChannel::EHcrGetInt64:
702 TEST_MEMGET(a1, &setting, sizeof(TSettingId));
703 r = GetInt(setting, value);
704 TEST_MEMPUT(a2, &value, sizeof(value));
707 case RHcrSimTestChannel::EHcrGetInt32:
711 TEST_MEMGET(a1, &setting, sizeof(TSettingId));
712 r = GetInt(setting, value);
713 TEST_MEMPUT(a2, &value, sizeof(value));
716 case RHcrSimTestChannel::EHcrGetInt16:
720 TEST_MEMGET(a1, &setting, sizeof(TSettingId));
721 r = GetInt(setting, value);
722 TEST_MEMPUT(a2, &value, sizeof(value));
725 case RHcrSimTestChannel::EHcrGetInt8:
729 TEST_MEMGET(a1, &setting, sizeof(TSettingId));
730 r = GetInt(setting, value);
731 TEST_MEMPUT(a2, &value, sizeof(value));
734 case RHcrSimTestChannel::EHcrGetBool:
738 TEST_MEMGET(a1, &setting, sizeof(TSettingId));
739 r = GetBool(setting, value);
740 TEST_MEMPUT(a2, &value, sizeof(value));
743 case RHcrSimTestChannel::EHcrGetDataArray:
745 // Get list of pointers
747 TEST_MEMGET(a1, args, sizeof(args));
748 TUint maxlen = (TUint) args[1];
749 // Retrieve structures from client
751 TEST_MEMGET(args[0], &id, sizeof(TSettingId));
752 // Allocate temporary memory
756 value = (TUint8*) Kern::Alloc(maxlen * sizeof(TUint8));
765 r = GetData(id, (TUint16) maxlen,
767 // Send value back to client
770 TEST_MEMPUT(args[2], value, maxlen * sizeof(TUint8));
771 TEST_MEMPUT(args[3], &len, sizeof(TUint16));
779 case RHcrSimTestChannel::EHcrGetDataDes:
782 TEST_MEMGET(a1, &setting, sizeof(TSettingId));
783 TInt userdes[sizeof(TDes8) / sizeof(TInt) + 1];
784 TEST_MEMGET(a2, userdes, sizeof(TDes8));
787 value = HBuf8::New(userdes[1]);
795 r = GetData(setting, *value);
796 TEST_DESPUT(a2, *value);
803 case RHcrSimTestChannel::EHcrGetUInt64:
807 TEST_MEMGET(a1, &setting, sizeof(TSettingId));
808 r = GetUInt(setting, value);
809 TEST_MEMPUT(a2, &value, sizeof(value));
812 case RHcrSimTestChannel::EHcrGetUInt32:
816 TEST_MEMGET(a1, &setting, sizeof(TSettingId));
817 r = GetUInt(setting, value);
818 TEST_MEMPUT(a2, &value, sizeof(value));
821 case RHcrSimTestChannel::EHcrGetUInt16:
825 TEST_MEMGET(a1, &setting, sizeof(TSettingId));
826 r = GetUInt(setting, value);
827 TEST_MEMPUT(a2, &value, sizeof(value));
830 case RHcrSimTestChannel::EHcrGetUInt8:
834 TEST_MEMGET(a1, &setting, sizeof(TSettingId));
835 r = GetUInt(setting, value);
836 TEST_MEMPUT(a2, &value, sizeof(value));
839 case RHcrSimTestChannel::EHcrGetArrayInt:
841 // Get list of pointers
843 TEST_MEMGET(a1, args, sizeof(args));
844 TUint maxlen = (TUint) args[1];
845 // Retrieve structures from client
847 TEST_MEMGET(args[0], &id, sizeof(TSettingId));
848 // Allocate temporary memory
852 value = (TInt32*) Kern::Alloc(maxlen);
861 r = GetArray(id, (TUint16) maxlen,
863 // Send value back to client
866 TEST_MEMPUT(args[2], value, maxlen);
867 TEST_MEMPUT(args[3], &len, sizeof(TUint16));
875 case RHcrSimTestChannel::EHcrGetArrayUInt:
877 // Get list of pointers
879 TEST_MEMGET(a1, args, sizeof(args));
880 TUint maxlen = (TUint) args[1];
881 // Retrieve structures from client
883 TEST_MEMGET(args[0], &id, sizeof(TSettingId));
884 // Allocate temporary memory
888 value = (TUint32*) Kern::Alloc(maxlen);
897 r = GetArray(id, (TUint16) maxlen,
899 // Send value back to client
902 TEST_MEMPUT(args[2], value, maxlen);
903 TEST_MEMPUT(args[3], &len, sizeof(TUint16));
911 case RHcrSimTestChannel::EHcrGetStringArray:
913 // Get list of pointers
915 TEST_MEMGET(a1, args, sizeof(args));
916 TUint maxlen = (TUint) args[1];
917 // Retrieve structures from client
919 TEST_MEMGET(args[0], &id, sizeof(TSettingId));
920 // Allocate temporary memory
924 value = (TText8*) Kern::Alloc(maxlen * sizeof(TText8));
933 r = GetString(id, (TUint16) maxlen,
935 // Send value back to client
938 TEST_MEMPUT(args[2], value, maxlen * sizeof(TText8));
939 TEST_MEMPUT(args[3], &len, sizeof(TUint16));
947 case RHcrSimTestChannel::EHcrGetStringDes:
950 TEST_MEMGET(a1, &setting, sizeof(TSettingId));
951 TInt userdes[sizeof(TDes8) / sizeof(TInt) + 1];
952 TEST_MEMGET(a2, userdes, sizeof(TDes8));
955 value = HBuf8::New(userdes[1]);
963 r = GetString(setting, *value);
964 TEST_DESPUT(a2, *value);
971 #ifndef HCRTEST_USERSIDE_INTERFACE
972 case RHcrSimTestChannel::EHcrInitExtension:
974 PslConfigurationFlags = (TInt) a1;
980 case RHcrSimTestChannel::EHcrSwitchRepository:
983 TEST_DESGET(a1, filename);
985 memcpy(filestr, filename.Ptr(), filename.Length());
986 filestr[filename.Length()] = 0; // Zero-terminate string
987 TText8* pfile = filestr;
988 if (filename.Length() == 0)
992 if ((TUint) a2 == HCRInternal::ECoreRepos)
994 r = HCRSingleton->SwitchRepository(pfile, HCRInternal::ECoreRepos);
996 else if ((TUint) a2 == HCRInternal::EOverrideRepos)
998 r = HCRSingleton->SwitchRepository(pfile, HCRInternal::EOverrideRepos);
1002 case RHcrSimTestChannel::EHcrCheckIntegrity:
1004 r = HCRSingleton->CheckIntegrity();
1007 #endif // HCRTEST_USERSIDE_INTERFACE
1008 case RHcrSimTestChannel::EHcrGetInitExtensionTestResults:
1011 TEST_MEMPUT(a1, (TAny*) &TestKernExtensionTestLine, sizeof(TInt));
1012 TEST_MEMPUT(a2, (TAny*) &TestKernExtensionTestError, sizeof(TInt));
1015 case RHcrSimTestChannel::EHcrHasRepositoryInSmr:
1020 HasRepositoryInSmr(smr, smrrep);
1021 TEST_MEMPUT(a1, (TAny*) &smr, sizeof(TBool));
1022 TEST_MEMPUT(a2, (TAny*) &smrrep, sizeof(TBool));
1025 case RHcrSimTestChannel::EHcrBenchmarkGetSettingInt:
1031 TEST_MEMGET(a1, &setting, sizeof(TSettingId));
1033 TUint32 start = NKern::TickCount();
1034 for (i = 0; i < KTestBenchmarkIterations; i++)
1036 r |= GetInt(setting, value);
1038 TUint32 end = NKern::TickCount();
1041 ms = ((end - start) * NKern::TickPeriod()) / 1000;
1042 TEST_MEMPUT(a2, (TAny*) &ms, sizeof(TUint32));
1045 case RHcrSimTestChannel::EHcrBenchmarkGetSettingArray:
1051 TEST_MEMGET(a1, &setting, sizeof(TSettingId));
1052 // Allocate temporary memory
1054 value = (TText8*) Kern::Alloc(KMaxSettingLength);
1063 TUint32 start = NKern::TickCount();
1064 for (i = 0; i < KTestBenchmarkIterations; i++)
1066 r |= GetString(setting, (TUint16) KMaxSettingLength, value, len);
1068 TUint32 end = NKern::TickCount();
1071 ms = ((end - start) * NKern::TickPeriod()) / 1000;
1072 TEST_MEMPUT(a2, (TAny*) &ms, sizeof(TUint32));
1079 case RHcrSimTestChannel::EHcrBenchmarkGetSettingDes:
1084 TBuf8<KMaxSettingLength> value;
1085 TEST_MEMGET(a1, &setting, sizeof(TSettingId));
1086 TUint32 start = NKern::TickCount();
1087 for (i = 0; i < KTestBenchmarkIterations; i++)
1089 r |= GetString(setting, value);
1091 TUint32 end = NKern::TickCount();
1094 ms = ((end - start) * NKern::TickPeriod()) / 1000;
1095 TEST_MEMPUT(a2, (TAny*) &ms, sizeof(TUint32));
1098 case RHcrSimTestChannel::EHcrBenchmarkFindNumSettingsInCategory:
1102 TUint32 start = NKern::TickCount();
1103 for (i = 0; i < KTestBenchmarkIterations; i++)
1105 r |= FindNumSettingsInCategory((TCategoryUid) a1);
1107 TUint32 end = NKern::TickCount();
1110 ms = ((end - start) * NKern::TickPeriod()) / 1000;
1111 TEST_MEMPUT(a2, (TAny*) &ms, sizeof(TUint32));
1114 case RHcrSimTestChannel::EHcrBenchmarkFindSettings:
1120 TSettingType* types;
1123 ids = (TElementId*) Kern::Alloc(KTestBenchmarkNumberOfSettingsInCategory * sizeof(TElementId));
1134 types = (TSettingType*) Kern::Alloc(KTestBenchmarkNumberOfSettingsInCategory * sizeof(TSettingType));
1144 lens = (TUint16*) Kern::Alloc(KTestBenchmarkNumberOfSettingsInCategory * sizeof(TUint16));
1154 TUint32 start = NKern::TickCount();
1155 for (i = 0; i < KTestBenchmarkIterations; i++)
1157 r |= FindSettings((TCategoryUid) a1,
1158 KTestBenchmarkNumberOfSettingsInCategory,
1161 TUint32 end = NKern::TickCount();
1165 ms = ((end - start) * NKern::TickPeriod()) / 1000;
1166 TEST_MEMPUT(a2, (TAny*) &ms, sizeof(TUint32));
1181 case RHcrSimTestChannel::EHcrBenchmarkGetTypeAndSize:
1188 TEST_MEMGET(a1, &setting, sizeof(TSettingId));
1190 TUint32 start = NKern::TickCount();
1191 for (i = 0; i < KTestBenchmarkIterations; i++)
1193 r |= GetTypeAndSize(setting, type, len);
1195 TUint32 end = NKern::TickCount();
1198 ms = ((end - start) * NKern::TickPeriod()) / 1000;
1199 TEST_MEMPUT(a2, (TAny*) &ms, sizeof(TUint32));
1202 case RHcrSimTestChannel::EHcrBenchmarkGetWordSettings:
1207 TSettingType* types;
1208 TCategoryUid catId = (TCategoryUid)a1;
1212 //We allocate here KTestBenchmarkNumberOfSettingsInCategory - 1 because
1213 //last element in the category is a large setting
1214 ids = (SSettingId*) Kern::Alloc((KTestBenchmarkNumberOfSettingsInCategory - 1) * sizeof(SSettingId));
1223 for(TUint eId =0; eId < KTestBenchmarkNumberOfSettingsInCategory - 1; eId++ )
1225 ids[eId].iCat = catId;
1226 //First element has value 1, second 2, third 3 and so on
1227 ids[eId].iKey = eId + 1;
1230 types = (TSettingType*) Kern::Alloc((KTestBenchmarkNumberOfSettingsInCategory - 1) * sizeof(TSettingType));
1240 values = (TInt32*) Kern::Alloc((KTestBenchmarkNumberOfSettingsInCategory - 1) * sizeof(TInt32));
1250 errors = (TInt*) Kern::Alloc((KTestBenchmarkNumberOfSettingsInCategory - 1) * sizeof(TInt));
1259 TUint32 start = NKern::TickCount();
1260 for (i = 0; i < KTestGetMultipleBenchmarkIterations; i++)
1262 r |= GetWordSettings(KTestBenchmarkNumberOfSettingsInCategory - 1, ids, values, types, errors);
1264 TUint32 end = NKern::TickCount();
1267 ms = ((end - start) * NKern::TickPeriod()) / 1000;
1268 TEST_MEMPUT(a2, (TAny*) &ms, sizeof(TUint32));