kerneltest/e32test/hcr/d_hcrsim.cpp
changeset 31 56f325a607ea
parent 0 a41df078684a
child 39 5d2844f35677
--- a/kerneltest/e32test/hcr/d_hcrsim.cpp	Mon Dec 21 16:14:42 2009 +0000
+++ b/kerneltest/e32test/hcr/d_hcrsim.cpp	Wed Dec 23 11:43:31 2009 +0000
@@ -17,15 +17,43 @@
 #include "d_hcrsim.h"
 #include <kernel/kernel.h>
 #include <plat_priv.h>
+#ifndef HCRTEST_USERSIDE_INTERFACE
 #include "hcr_debug.h"
 #include "hcr_hai.h"
 #include "hcr_pil.h"
+#endif // HCRTEST_USERSIDE_INTERFACE
+#include "hcr_uids.h"
 
 #define TEST(a)				CheckPoint(a, __LINE__)
 #define TEST_KERRNONE(a)	CheckPointError(a, __LINE__)
 
+#ifndef HCRTEST_USERSIDE_INTERFACE
 TInt InitExtension();
 extern TUint32 PslConfigurationFlags;
+#endif // HCRTEST_USERSIDE_INTERFACE
+
+#ifdef HCRTEST_CLIENT_THREAD
+#define TEST_ENTERCS()			NKern::ThreadEnterCS()
+#define TEST_LEAVECS()			NKern::ThreadLeaveCS()
+#define TEST_MEMGET(s, d, l)	kumemget(d, s, l)
+#define TEST_MEMPUT(d, s, l)	kumemput(d, s, l)
+#define TEST_DESGET(s, d)		Kern::KUDesGet(d, *(TDes8*) s)
+#define TEST_DESPUT(d, s)		Kern::KUDesPut(*(TDes8*) d, s)
+#else
+#define TEST_ENTERCS()
+#define TEST_LEAVECS()
+#define TEST_MEMGET(s, d, l)	Kern::ThreadRawRead(iClient, s, d, l)
+#define TEST_MEMPUT(d, s, l)	Kern::ThreadRawWrite(iClient, d, s, l)
+#define TEST_DESGET(s, d)		Kern::ThreadDesRead(iClient, s, d, 0)
+#define TEST_DESPUT(d, s)		Kern::ThreadDesWrite(iClient, d, s, 0)
+#endif // HCRTEST_CLIENT_THREAD
+
+// Test results for the Kernel Extension initialisation routine
+TInt TestKernExtensionTestLine = -1;
+TInt TestKernExtensionTestError = -1;
+
+const TUint KTestBenchmarkIterations = 10000;
+const TUint KTestGetMultipleBenchmarkIterations = 100;
 
 class DHcrSimTestDrvFactory : public DLogicalDevice
 	{
@@ -36,20 +64,31 @@
 	virtual void GetCaps(TDes8& aDes) const;
 	virtual TInt Create(DLogicalChannelBase*& aChannel);
 public:
+#ifndef HCRTEST_CLIENT_THREAD
 	TDynamicDfcQue* iDfcQ;
+#endif
 	};
 
+#ifdef HCRTEST_CLIENT_THREAD
+class DHcrSimTestDrvChannel : public DLogicalChannelBase
+#else
 class DHcrSimTestDrvChannel : public DLogicalChannel
+#endif
 	{
 public:
 	DHcrSimTestDrvChannel();
 	~DHcrSimTestDrvChannel();
 	// Inherited from DLogicalChannel
 	virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
+#ifdef HCRTEST_CLIENT_THREAD
+	// Inherited from DLogicalChannelBase: process all DoControl in the user's context
+	virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2);
+#else
 	TInt DoControl(TInt aReqNo, TAny* a1, TAny* a2);
 	virtual void HandleMsg(TMessageBase* aMsg);
 public:
 	DThread* iClient;
+#endif // HCRTEST_CLIENT_THREAD
 	};
 
 void CheckPoint(TInt aCondition, TInt aLine)
@@ -68,6 +107,51 @@
 		}
 	}
 
+#ifdef HCRTEST_USERSIDE_INTERFACE
+#define KEXT_TESTKERRNONE(_r)						\
+	{												\
+	if ((_r) && !TestKernExtensionTestLine)			\
+		{											\
+		TestKernExtensionTestError = (_r);			\
+		TestKernExtensionTestLine = __LINE__;		\
+		}											\
+	}
+#define KEXT_TEST(_r)								\
+	{												\
+	if (!(_r) && !TestKernExtensionTestLine)		\
+		{											\
+		TestKernExtensionTestError = 1;				\
+		TestKernExtensionTestLine = __LINE__;		\
+		}											\
+	}
+
+void KextInitTests()
+	{
+	TInt r;
+	// Get last Setting in compiled repository
+	TUint32 value1;
+	HCR::TSettingId setting1(0xFFFFFFFF, 0xFFFFFFFF);
+	r = HCR::GetUInt(setting1, value1);
+	KEXT_TESTKERRNONE(r);
+	KEXT_TEST(value1==0x4C415354); // 'L', 'A', 'S', 'T'
+
+	// Get Setting in file repository
+	TUint32 value2;
+	HCR::TSettingId setting2(2, 2);
+	r = HCR::GetUInt(setting2, value2);
+	KEXT_TESTKERRNONE(r);
+	}
+
+DECLARE_EXTENSION_WITH_PRIORITY(KExtensionMaximumPriority)
+	{
+	// Set these to 0 so we know we've been here
+	TestKernExtensionTestLine = 0;
+	TestKernExtensionTestError = 0;
+	KextInitTests();
+	return KErrNone;
+	}
+#endif // HCRTEST_USERSIDE_INTERFACE
+
 DECLARE_EXTENSION_LDD()
 	{
 	return new DHcrSimTestDrvFactory;
@@ -82,19 +166,37 @@
 
 DHcrSimTestDrvFactory::~DHcrSimTestDrvFactory()
 	{
+#ifndef HCRTEST_CLIENT_THREAD
 	if (iDfcQ)
 		iDfcQ->Destroy();
+#endif
 	}
 
+#ifndef HCRTEST_CLIENT_THREAD
 const TInt KHcrSimTestThreadPriority = 1;
 _LIT(KHcrSimTestThread,"HcrSimTestThread");
+#endif
 
 TInt DHcrSimTestDrvFactory::Install()
 	{
-	TInt r = Kern::DynamicDfcQCreate(iDfcQ, KHcrSimTestThreadPriority, KHcrSimTestThread);
+	TInt r;
+#ifndef HCRTEST_CLIENT_THREAD
+	r = Kern::DynamicDfcQCreate(iDfcQ, KHcrSimTestThreadPriority, KHcrSimTestThread);
 	if (r != KErrNone)
 		return r;
-	return(SetName(&KTestHcrSim));
+#ifdef HCRTEST_USERSIDE_INTERFACE
+	r = SetName(&KTestHcrRealOwn);
+#else
+	r = SetName(&KTestHcrSimOwn);
+#endif // HCRTEST_USERSIDE_INTERFACE
+#else
+#ifdef HCRTEST_USERSIDE_INTERFACE
+	r = SetName(&KTestHcrRealClient);
+#else
+	r = SetName(&KTestHcrSimClient);
+#endif // HCRTEST_USERSIDE_INTERFACE
+#endif // HCRTEST_CLIENT_THREAD
+	return r;
 	}
 
 void DHcrSimTestDrvFactory::GetCaps(TDes8& /*aDes*/) const
@@ -112,22 +214,29 @@
 
 DHcrSimTestDrvChannel::DHcrSimTestDrvChannel()
 	{
+#ifndef HCRTEST_CLIENT_THREAD
 	iClient=&Kern::CurrentThread();
 	iClient->Open();
+#endif
 	}
 
 DHcrSimTestDrvChannel::~DHcrSimTestDrvChannel()
 	{
+#ifndef HCRTEST_CLIENT_THREAD
 	Kern::SafeClose((DObject*&)iClient, NULL);
+#endif
 	}
 
 TInt DHcrSimTestDrvChannel::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/)
 	{
+#ifndef HCRTEST_CLIENT_THREAD
 	SetDfcQ(((DHcrSimTestDrvFactory*)iDevice)->iDfcQ);
 	iMsgQ.Receive();
+#endif
 	return KErrNone;
 	}
 
+#ifndef HCRTEST_CLIENT_THREAD
 void DHcrSimTestDrvChannel::HandleMsg(TMessageBase* aMsg)
 	{
 	TInt r=KErrNone;
@@ -144,8 +253,13 @@
 		}
 	m.Complete(r,ETrue);
 	}
+#endif // HCRTEST_CLIENT_THREAD
 
+#ifdef HCRTEST_CLIENT_THREAD
+TInt DHcrSimTestDrvChannel::Request(TInt aReqNo, TAny* a1, TAny* a2)
+#else
 TInt DHcrSimTestDrvChannel::DoControl(TInt aReqNo, TAny* a1, TAny* a2)
+#endif
 	{
 	TInt r=KErrNotSupported;
 	switch (aReqNo)
@@ -154,9 +268,9 @@
 			{
 			HCR::TSettingId setting;
 			TLinAddr value;
-			Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId));
+			TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId));
 			r = HCR::GetLinAddr(setting, value);
-			Kern::ThreadRawWrite(iClient, a2, &value, sizeof(value));
+			TEST_MEMPUT(a2, &value, sizeof(value));
 			break;
 			}
 		case RHcrSimTestChannel::EHcrFindNumSettingsInCategory:
@@ -168,14 +282,16 @@
 			{
 			// Get list of pointers
 			TAny* args[6];
-			Kern::ThreadRawRead(iClient, a1, args, sizeof(args));
+			TEST_MEMGET(a1, args, sizeof(args));
 			TInt aMaxNum = (TInt) args[1];
 			// Allocate temporary memory
-			TUint32 numfound;
+		
 			HCR::TElementId* ids;
 			HCR::TSettingType* types = NULL;
 			TUint16* lens = NULL;
+			TEST_ENTERCS();
 			ids = (HCR::TElementId*) Kern::Alloc(aMaxNum * sizeof(HCR::TElementId));
+			TEST_LEAVECS();
 			if (ids == NULL)
 				{
 				r = KErrNoMemory;
@@ -184,7 +300,9 @@
 				{
 				if (args[4]) // aTypes
 					{
+					TEST_ENTERCS();
 					types = (HCR::TSettingType*) Kern::Alloc(aMaxNum * sizeof(HCR::TSettingType));
+					TEST_LEAVECS();
 					}
 				if (types == NULL && args[4])
 					{
@@ -194,7 +312,9 @@
 					{
 					if (args[5]) // aLens
 						{
+						TEST_ENTERCS();
 						lens = (TUint16*) Kern::Alloc(aMaxNum * sizeof(TUint16));
+						TEST_LEAVECS();
 						}
 					if (lens == NULL && args[5])
 						{
@@ -204,69 +324,81 @@
 						{
 						// Actual API call
 						r = HCR::FindSettings((HCR::TCategoryUid) args[0],
-							aMaxNum, numfound, ids, types, lens);
-						TEST_KERRNONE(r);
+							aMaxNum, ids, types, lens);
+						
 						// Send values back to client
-						if (!r)
+						if (r >= 0)
 							{
-							Kern::ThreadRawWrite(iClient, args[2], &numfound, sizeof(TUint32));
-							Kern::ThreadRawWrite(iClient, args[3], ids, aMaxNum * sizeof(HCR::TElementId));
+							TEST_MEMPUT(args[2], &r, sizeof(TUint32));
+							TEST_MEMPUT(args[3], ids, aMaxNum * sizeof(HCR::TElementId));
 							if (args[4])
 								{
-								Kern::ThreadRawWrite(iClient, args[4], types, aMaxNum * sizeof(HCR::TSettingType));
+								TEST_MEMPUT(args[4], types, aMaxNum * sizeof(HCR::TSettingType));
 								}
 							if (args[5])
 								{
-								Kern::ThreadRawWrite(iClient, args[5], lens, aMaxNum * sizeof(TUint16));
+								TEST_MEMPUT(args[5], lens, aMaxNum * sizeof(TUint16));
 								}
 							}
 						if (args[5])
 							{
+							TEST_ENTERCS();
 							Kern::Free(lens);
+							TEST_LEAVECS();
 							}
 						}
 					if (args[4])
 						{
+						TEST_ENTERCS();
 						Kern::Free(types);
+						TEST_LEAVECS();
 						}
 					}
+				TEST_ENTERCS();
 				Kern::Free(ids);
+				TEST_LEAVECS();
 				}
 			break;
 			}
 		case RHcrSimTestChannel::EHcrFindSettingsPattern:
 			{
 			// Get list of pointers
-			TAny* args[9];
-			Kern::ThreadRawRead(iClient, a1, args, sizeof(args));
+			TAny* args[8];
+			TEST_MEMGET(a1, args, sizeof(args));
 			TInt aMaxNum = (TInt) args[1];
 			// Allocate temporary memory
 			TUint32 numfound;
 			HCR::TElementId* ids;
 			HCR::TSettingType* types = NULL;
 			TUint16* lens = NULL;
+			TEST_ENTERCS();
 			ids = (HCR::TElementId*) Kern::Alloc(aMaxNum * sizeof(HCR::TElementId));
+			TEST_LEAVECS();
 			if (ids == NULL)
 				{
 				r = KErrNoMemory;
 				}
 			else
 				{
-				if (args[7]) // aTypes
+				if (args[6]) // aTypes
 					{
+					TEST_ENTERCS();
 					types = (HCR::TSettingType*) Kern::Alloc(aMaxNum * sizeof(HCR::TSettingType));
+					TEST_LEAVECS();
 					}
-				if (types == NULL && args[7])
+				if (types == NULL && args[6])
 					{
 					r = KErrNoMemory;
 					}
 				else
 					{
-					if (args[8]) // aLens
+					if (args[7]) // aLens
 						{
+						TEST_ENTERCS();
 						lens = (TUint16*) Kern::Alloc(aMaxNum * sizeof(TUint16));
+						TEST_LEAVECS();
 						}
-					if (lens == NULL && args[8])
+					if (lens == NULL && args[7])
 						{
 						r = KErrNoMemory;
 						}
@@ -274,34 +406,40 @@
 						{
 						// Actual API call
 						r = HCR::FindSettings((HCR::TCategoryUid) args[0],
-							aMaxNum, (TUint32) args[2], (TUint32) args[3], (TUint32) args[4],
-							numfound, ids, types, lens);
-						TEST_KERRNONE(r);
+							aMaxNum, (TUint32) args[2], (TUint32) args[3],
+							ids, types, lens);
+				
 						// Send values back to client
-						if (!r)
+						if (r > 0)
 							{
-							Kern::ThreadRawWrite(iClient, args[5], &numfound, sizeof(TUint32));
-							Kern::ThreadRawWrite(iClient, args[6], ids, aMaxNum * sizeof(HCR::TElementId));
+							TEST_MEMPUT(args[4], &numfound, sizeof(TUint32));
+							TEST_MEMPUT(args[5], ids, aMaxNum * sizeof(HCR::TElementId));
+							if (args[6])
+								{
+								TEST_MEMPUT(args[6], types, aMaxNum * sizeof(HCR::TSettingType));
+								}
 							if (args[7])
 								{
-								Kern::ThreadRawWrite(iClient, args[7], types, aMaxNum * sizeof(HCR::TSettingType));
-								}
-							if (args[8])
-								{
-								Kern::ThreadRawWrite(iClient, args[8], lens, aMaxNum * sizeof(TUint16));
+								TEST_MEMPUT(args[7], lens, aMaxNum * sizeof(TUint16));
 								}
 							}
-						if (args[8])
+						if (args[7])
 							{
+							TEST_ENTERCS();
 							Kern::Free(lens);
+							TEST_LEAVECS();
 							}
 						}
-					if (args[7])
+					if (args[6])
 						{
+						TEST_ENTERCS();
 						Kern::Free(types);
+						TEST_LEAVECS();
 						}
 					}
+				TEST_ENTERCS();
 				Kern::Free(ids);
+				TEST_LEAVECS();
 				}
 			break;
 			}
@@ -309,151 +447,188 @@
 			{
 			// Get list of pointers
 			TAny* args[3];
-			Kern::ThreadRawRead(iClient, a1, args, sizeof(args));
+			TEST_MEMGET(a1, args, sizeof(args));
 			HCR::TSettingId id;
-			Kern::ThreadRawRead(iClient, args[0], &id, sizeof(HCR::TSettingId));
+			TEST_MEMGET(args[0], &id, sizeof(HCR::TSettingId));
 			HCR::TSettingType type;
 			TUint16 len;
-			TEST_KERRNONE(r = HCR::GetTypeAndSize(id, type, len));
-			Kern::ThreadRawWrite(iClient, args[1], &type, sizeof(HCR::TSettingType));
-			Kern::ThreadRawWrite(iClient, args[2], &len, sizeof(TUint16));
+			r = HCR::GetTypeAndSize(id, type, len);
+			TEST_MEMPUT(args[1], &type, sizeof(HCR::TSettingType));
+			TEST_MEMPUT(args[2], &len, sizeof(TUint16));
 			break;
 			}
 		case RHcrSimTestChannel::EHcrGetWordSettings:
 			{
 			// Get list of pointers
 			TAny* args[5];
-			Kern::ThreadRawRead(iClient, a1, args, sizeof(args));
+			TEST_MEMGET(a1, args, sizeof(args));
 			TInt aNum = (TInt) args[0];
 			// Allocate temporary memory
 			HCR::SSettingId* ids;
+			HCR::SSettingId* inIds = (HCR::SSettingId*)args[1];
 			TInt32* vals;
 			HCR::TSettingType* types= NULL;
 			TInt* errors = NULL;
-			ids = (HCR::SSettingId*) Kern::Alloc(aNum * sizeof(HCR::SSettingId*));
-			if (ids == NULL)
-				{
-				r = KErrNoMemory;
-				}
+			
+			TEST_ENTERCS();
+			if(inIds)
+			    {
+			    ids = (HCR::SSettingId*) Kern::Alloc((aNum>=0?aNum:-aNum) * sizeof(HCR::SSettingId));
+			    //Read data from the user side
+			    if (ids == NULL)
+			        {
+			        r = KErrNoMemory;
+			        break;
+			        }
+
+			    TEST_MEMGET(inIds, ids, (aNum>=0?aNum:-aNum) * sizeof(HCR::SSettingId));
+			    }
+			else
+			    ids = NULL;
+			TEST_LEAVECS();
+
+			if (args[2]) //values
+			    {
+                TEST_ENTERCS();
+                vals = (TInt32*) Kern::Alloc((aNum>=0?aNum:-aNum) * sizeof(TInt32));
+                TEST_LEAVECS();
+                if (vals == NULL)
+                    {
+                    r = KErrNoMemory;
+                    break;
+                    }
+			    }
+			else
+			    vals = NULL;
+			
+			if (args[3]) // aTypes
+			    {
+			    TEST_ENTERCS();
+			    types = (HCR::TSettingType*) Kern::Alloc((aNum>=0?aNum:-aNum) * 
+                            sizeof(HCR::TSettingType));
+			    TEST_LEAVECS();
+			    }
+			if (types == NULL && args[3])
+			    {
+			    r = KErrNoMemory;
+			    }
 			else
-				{
-				vals = (TInt32*) Kern::Alloc(aNum * sizeof(TInt32));
-				if (vals == NULL)
-					{
-					r = KErrNoMemory;
-					}
-				else
-					{
-					if (args[3]) // aTypes
-						{
-						types = (HCR::TSettingType*) Kern::Alloc(aNum * sizeof(HCR::TSettingType));
-						}
-					if (types == NULL && args[3])
-						{
-						r = KErrNoMemory;
-						}
-					else
-						{
-						if (args[4]) // aErrors
-							{
-							errors = (TInt*) Kern::Alloc(aNum * sizeof(TInt));
-							}
-						if (errors == NULL && args[4])
-							{
-							r = KErrNoMemory;
-							}
-						else
-							{
-							// Actual API call
-							TEST_KERRNONE(r = HCR::GetWordSettings(aNum, ids, vals, types, errors));
-							// Send values back to client
-							if (!r)
-								{
-								Kern::ThreadRawWrite(iClient, args[1], ids, aNum * sizeof(HCR::SSettingId));
-								Kern::ThreadRawWrite(iClient, args[2], vals, aNum * sizeof(TInt32));
-								if (args[3])
-									{
-									Kern::ThreadRawWrite(iClient, args[3], types, aNum * sizeof(HCR::TSettingType));
-									}
-								if (args[4])
-									{
-									Kern::ThreadRawWrite(iClient, args[4], errors, aNum * sizeof(TInt));
-									}
-								}
-							if (args[4])
-								{
-								Kern::Free(errors);
-								}
-							}
-						if (args[3])
-							{
-							Kern::Free(types);
-							}
-						}
-					Kern::Free(vals);
-					}
-				Kern::Free(ids);
-				}
+			    {
+			    if (args[4]) // aErrors
+			        {
+			        TEST_ENTERCS();
+			        errors = (TInt*) Kern::Alloc((aNum>=0?aNum:-aNum) * sizeof(TInt));
+			        TEST_LEAVECS();
+			        }
+			    if (errors == NULL && args[4])
+			        {
+			        r = KErrNoMemory;
+			        }
+			    else
+			        {
+			        // Actual API call
+			        r = HCR::GetWordSettings(aNum, ids, vals, types, errors);
+			        // Send values back to client
+			        if (r >= 0)
+			            {
+			            TEST_MEMPUT(args[1], ids, aNum * sizeof(HCR::SSettingId));
+			            TEST_MEMPUT(args[2], vals, aNum * sizeof(TInt32));
+			            if (args[3])
+			                {
+			                TEST_MEMPUT(args[3], types,(aNum>=0?aNum:-aNum) * sizeof(HCR::TSettingType));
+			                }
+			            if (args[4])
+			                {
+			                TEST_MEMPUT(args[4], errors, (aNum>=0?aNum:-aNum) * sizeof(TInt));
+			                }
+			            }
+			        if (args[4])
+			            {
+			            TEST_ENTERCS();
+			            Kern::Free(errors);
+			            TEST_LEAVECS();
+			            }
+			        }
+			    if (args[3])
+			        {
+			        TEST_ENTERCS();
+			        Kern::Free(types);
+			        TEST_LEAVECS();
+			        }
+			    }
+			if (args[2])
+			    {
+                TEST_ENTERCS();
+                Kern::Free(vals);
+                TEST_LEAVECS();
+			    }
+			TEST_ENTERCS();
+			if(inIds)
+			    Kern::Free(ids);
+			TEST_LEAVECS();
+
 			break;
 			}
 		case RHcrSimTestChannel::EHcrGetInt64:
 			{
 			HCR::TSettingId setting;
 			TInt64 value;
-			Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId));
+			TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId));
 			r = HCR::GetInt(setting, value);
-			Kern::ThreadRawWrite(iClient, a2, &value, sizeof(value));
+			TEST_MEMPUT(a2, &value, sizeof(value));
 			break;
 			}
 		case RHcrSimTestChannel::EHcrGetInt32:
 			{
 			HCR::TSettingId setting;
 			TInt32 value;
-			Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId));
+			TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId));
 			r = HCR::GetInt(setting, value);
-			Kern::ThreadRawWrite(iClient, a2, &value, sizeof(value));
+			TEST_MEMPUT(a2, &value, sizeof(value));
 			break;
 			}
 		case RHcrSimTestChannel::EHcrGetInt16:
 			{
 			HCR::TSettingId setting;
 			TInt16 value;
-			Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId));
+			TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId));
 			r = HCR::GetInt(setting, value);
-			Kern::ThreadRawWrite(iClient, a2, &value, sizeof(value));
+			TEST_MEMPUT(a2, &value, sizeof(value));
 			break;
 			}
 		case RHcrSimTestChannel::EHcrGetInt8:
 			{
 			HCR::TSettingId setting;
 			TInt8 value;
-			Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId));
+			TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId));
 			r = HCR::GetInt(setting, value);
-			Kern::ThreadRawWrite(iClient, a2, &value, sizeof(value));
+			TEST_MEMPUT(a2, &value, sizeof(value));
 			break;
 			}
 		case RHcrSimTestChannel::EHcrGetBool:
 			{
 			HCR::TSettingId setting;
 			TBool value;
-			Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId));
+			TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId));
 			r = HCR::GetBool(setting, value);
-			Kern::ThreadRawWrite(iClient, a2, &value, sizeof(value));
+			TEST_MEMPUT(a2, &value, sizeof(value));
 			break;
 			}
 		case RHcrSimTestChannel::EHcrGetDataArray:
 			{
 			// Get list of pointers
 			TAny* args[4];
-			Kern::ThreadRawRead(iClient, a1, args, sizeof(args));
+			TEST_MEMGET(a1, args, sizeof(args));
 			TUint maxlen = (TUint) args[1];
 			// Retrieve structures from client
 			HCR::TSettingId id;
-			Kern::ThreadRawRead(iClient, args[0], &id, sizeof(HCR::TSettingId));
+			TEST_MEMGET(args[0], &id, sizeof(HCR::TSettingId));
 			// Allocate temporary memory
 			TUint16 len;
 			TUint8* value;
+			TEST_ENTERCS();
 			value = (TUint8*) Kern::Alloc(maxlen * sizeof(TUint8));
+			TEST_LEAVECS();
 			if (value == NULL)
 				{
 				r = KErrNoMemory;
@@ -466,71 +641,90 @@
 				// Send value back to client
 				if (!r)
 					{
-					Kern::ThreadRawWrite(iClient, args[2], value, maxlen * sizeof(TUint8));
-					Kern::ThreadRawWrite(iClient, args[3], &len, sizeof(TUint16));
+					TEST_MEMPUT(args[2], value, maxlen * sizeof(TUint8));
+					TEST_MEMPUT(args[3], &len, sizeof(TUint16));
 					}
+				TEST_ENTERCS();
 				Kern::Free(value);
+				TEST_LEAVECS();
 				}
 			break;
 			}
 		case RHcrSimTestChannel::EHcrGetDataDes:
 			{
 			HCR::TSettingId setting;
-			TBuf8<HCR::KMaxSettingLength> value;
-			Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId));
-			r = HCR::GetData(setting, value);
-			Kern::ThreadDesWrite(iClient, a2, value, 0);
+			TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId));
+			TInt userdes[sizeof(TDes8) / sizeof(TInt) + 1];
+			TEST_MEMGET(a2, userdes, sizeof(TDes8));
+			HBuf8* value;
+			TEST_ENTERCS();
+			value = HBuf8::New(userdes[1]);
+			TEST_LEAVECS();
+			if (value == NULL)
+				{
+				r = KErrNoMemory;
+				}
+			else
+				{
+				r = HCR::GetData(setting, *value);
+				TEST_DESPUT(a2, *value);
+				TEST_ENTERCS();
+				delete value;
+				TEST_LEAVECS();
+				}
 			break;
 			}
 		case RHcrSimTestChannel::EHcrGetUInt64:
 			{
 			HCR::TSettingId setting;
 			TUint64 value;
-			Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId));
+			TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId));
 			r = HCR::GetUInt(setting, value);
-			Kern::ThreadRawWrite(iClient, a2, &value, sizeof(value));
+			TEST_MEMPUT(a2, &value, sizeof(value));
 			break;
 			}
 		case RHcrSimTestChannel::EHcrGetUInt32:
 			{
 			HCR::TSettingId setting;
 			TUint32 value;
-			Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId));
+			TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId));
 			r = HCR::GetUInt(setting, value);
-			Kern::ThreadRawWrite(iClient, a2, &value, sizeof(value));
+			TEST_MEMPUT(a2, &value, sizeof(value));
 			break;
 			}
 		case RHcrSimTestChannel::EHcrGetUInt16:
 			{
 			HCR::TSettingId setting;
 			TUint16 value;
-			Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId));
+			TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId));
 			r = HCR::GetUInt(setting, value);
-			Kern::ThreadRawWrite(iClient, a2, &value, sizeof(value));
+			TEST_MEMPUT(a2, &value, sizeof(value));
 			break;
 			}
 		case RHcrSimTestChannel::EHcrGetUInt8:
 			{
 			HCR::TSettingId setting;
 			TUint8 value;
-			Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId));
+			TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId));
 			r = HCR::GetUInt(setting, value);
-			Kern::ThreadRawWrite(iClient, a2, &value, sizeof(value));
+			TEST_MEMPUT(a2, &value, sizeof(value));
 			break;
 			}
 		case RHcrSimTestChannel::EHcrGetArrayInt:
 			{
 			// Get list of pointers
 			TAny* args[4];
-			Kern::ThreadRawRead(iClient, a1, args, sizeof(args));
+			TEST_MEMGET(a1, args, sizeof(args));
 			TUint maxlen = (TUint) args[1];
 			// Retrieve structures from client
 			HCR::TSettingId id;
-			Kern::ThreadRawRead(iClient, args[0], &id, sizeof(HCR::TSettingId));
+			TEST_MEMGET(args[0], &id, sizeof(HCR::TSettingId));
 			// Allocate temporary memory
 			TUint16 len;
 			TInt32* value;
+			TEST_ENTERCS();
 			value = (TInt32*) Kern::Alloc(maxlen);
+			TEST_LEAVECS();
 			if (value == NULL)
 				{
 				r = KErrNoMemory;
@@ -543,10 +737,12 @@
 				// Send value back to client
 				if (!r)
 					{
-					Kern::ThreadRawWrite(iClient, args[2], value, maxlen);
-					Kern::ThreadRawWrite(iClient, args[3], &len, sizeof(TUint16));
+					TEST_MEMPUT(args[2], value, maxlen);
+					TEST_MEMPUT(args[3], &len, sizeof(TUint16));
 					}
+				TEST_ENTERCS();
 				Kern::Free(value);
+				TEST_LEAVECS();
 				}
 			break;
 			}
@@ -554,15 +750,17 @@
 			{
 			// Get list of pointers
 			TAny* args[4];
-			Kern::ThreadRawRead(iClient, a1, args, sizeof(args));
+			TEST_MEMGET(a1, args, sizeof(args));
 			TUint maxlen = (TUint) args[1];
 			// Retrieve structures from client
 			HCR::TSettingId id;
-			Kern::ThreadRawRead(iClient, args[0], &id, sizeof(HCR::TSettingId));
+			TEST_MEMGET(args[0], &id, sizeof(HCR::TSettingId));
 			// Allocate temporary memory
 			TUint16 len;
 			TUint32* value;
+			TEST_ENTERCS();
 			value = (TUint32*) Kern::Alloc(maxlen);
+			TEST_LEAVECS();
 			if (value == NULL)
 				{
 				r = KErrNoMemory;
@@ -575,10 +773,12 @@
 				// Send value back to client
 				if (!r)
 					{
-					Kern::ThreadRawWrite(iClient, args[2], value, maxlen);
-					Kern::ThreadRawWrite(iClient, args[3], &len, sizeof(TUint16));
+					TEST_MEMPUT(args[2], value, maxlen);
+					TEST_MEMPUT(args[3], &len, sizeof(TUint16));
 					}
+				TEST_ENTERCS();
 				Kern::Free(value);
+				TEST_LEAVECS();
 				}
 			break;
 			}
@@ -586,15 +786,17 @@
 			{
 			// Get list of pointers
 			TAny* args[4];
-			Kern::ThreadRawRead(iClient, a1, args, sizeof(args));
+			TEST_MEMGET(a1, args, sizeof(args));
 			TUint maxlen = (TUint) args[1];
 			// Retrieve structures from client
 			HCR::TSettingId id;
-			Kern::ThreadRawRead(iClient, args[0], &id, sizeof(HCR::TSettingId));
+			TEST_MEMGET(args[0], &id, sizeof(HCR::TSettingId));
 			// Allocate temporary memory
 			TUint16 len;
 			TText8* value;
+			TEST_ENTERCS();
 			value = (TText8*) Kern::Alloc(maxlen * sizeof(TText8));
+			TEST_LEAVECS();
 			if (value == NULL)
 				{
 				r = KErrNoMemory;
@@ -607,32 +809,52 @@
 				// Send value back to client
 				if (!r)
 					{
-					Kern::ThreadRawWrite(iClient, args[2], value, maxlen * sizeof(TText8));
-					Kern::ThreadRawWrite(iClient, args[3], &len, sizeof(TUint16));
+					TEST_MEMPUT(args[2], value, maxlen * sizeof(TText8));
+					TEST_MEMPUT(args[3], &len, sizeof(TUint16));
 					}
+				TEST_ENTERCS();
 				Kern::Free(value);
+				TEST_LEAVECS();
 				}
 			break;
 			}
 		case RHcrSimTestChannel::EHcrGetStringDes:
 			{
 			HCR::TSettingId setting;
-			TBuf8<HCR::KMaxSettingLength> value;
-			Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId));
-			r = HCR::GetString(setting, value);
-			Kern::ThreadDesWrite(iClient, a2, value, 0);
+			TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId));
+			TInt userdes[sizeof(TDes8) / sizeof(TInt) + 1];
+			TEST_MEMGET(a2, userdes, sizeof(TDes8));
+			HBuf8* value;
+			TEST_ENTERCS();
+			value = HBuf8::New(userdes[1]);
+			TEST_LEAVECS();
+			if (value == NULL)
+				{
+				r = KErrNoMemory;
+				}
+			else
+				{
+				r = HCR::GetString(setting, *value);
+				TEST_DESPUT(a2, *value);
+				TEST_ENTERCS();
+				delete value;
+				TEST_LEAVECS();
+				}
 			break;
 			}
+#ifndef HCRTEST_USERSIDE_INTERFACE
 		case RHcrSimTestChannel::EHcrInitExtension:
 			{
 			PslConfigurationFlags = (TInt) a1;
+			TEST_ENTERCS();
 			r = InitExtension();
+			TEST_LEAVECS();
 			break;
 			}
 		case RHcrSimTestChannel::EHcrSwitchRepository:
 			{
 			TBuf8<80> filename;
-			Kern::ThreadDesRead(iClient, a1, filename, 0);
+			TEST_DESGET(a1, filename);
 			TText8 filestr[81];
 			memcpy(filestr, filename.Ptr(), filename.Length());
 			filestr[filename.Length()] = 0; // Zero-terminate string
@@ -656,6 +878,276 @@
 			r = HCRSingleton->CheckIntegrity();
 			break;
 			}
+#endif // HCRTEST_USERSIDE_INTERFACE
+		case RHcrSimTestChannel::EHcrGetInitExtensionTestResults:
+			{
+			r = KErrNone;
+			TEST_MEMPUT(a1, (TAny*) &TestKernExtensionTestLine, sizeof(TInt));
+			TEST_MEMPUT(a2, (TAny*) &TestKernExtensionTestError, sizeof(TInt));
+			}
+			break;
+		case RHcrSimTestChannel::EHcrBenchmarkGetSettingInt:
+			{
+			r = KErrNone;
+			TUint i;
+			HCR::TSettingId setting;
+			TInt32 value;
+			TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId));
+			//
+			TUint32 start = NKern::TickCount();
+			for (i = 0; i < KTestBenchmarkIterations; i++)
+				{
+				r |= HCR::GetInt(setting, value);
+				}
+			TUint32 end = NKern::TickCount();
+			//
+			TUint32 ms;
+			ms = ((end - start) * NKern::TickPeriod()) / 1000;
+			TEST_MEMPUT(a2, (TAny*) &ms, sizeof(TUint32));
+			}
+			break;
+		case RHcrSimTestChannel::EHcrBenchmarkGetSettingArray:
+			{
+			r = KErrNone;
+			TUint i;
+			HCR::TSettingId setting;
+			TText8* value;
+			TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId));
+			// Allocate temporary memory
+			TEST_ENTERCS();
+			value = (TText8*) Kern::Alloc(HCR::KMaxSettingLength);
+			TEST_LEAVECS();
+			if (value == NULL)
+				{
+				r = KErrNoMemory;
+				}
+			else
+				{
+				TUint16 len;
+				TUint32 start = NKern::TickCount();
+				for (i = 0; i < KTestBenchmarkIterations; i++)
+					{
+					r |= HCR::GetString(setting, (TUint16) HCR::KMaxSettingLength, value, len);
+					}
+				TUint32 end = NKern::TickCount();
+				//
+				TUint32 ms;
+				ms = ((end - start) * NKern::TickPeriod()) / 1000;
+				TEST_MEMPUT(a2, (TAny*) &ms, sizeof(TUint32));
+				TEST_ENTERCS();
+				Kern::Free(value);
+				TEST_LEAVECS();
+				}
+			}
+			break;
+		case RHcrSimTestChannel::EHcrBenchmarkGetSettingDes:
+			{
+			r = KErrNone;
+			TUint i;
+			HCR::TSettingId setting;
+			TBuf8<HCR::KMaxSettingLength> value;
+			TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId));
+			TUint32 start = NKern::TickCount();
+			for (i = 0; i < KTestBenchmarkIterations; i++)
+				{
+				r |= HCR::GetString(setting, value);
+				}
+			TUint32 end = NKern::TickCount();
+			//
+			TUint32 ms;
+			ms = ((end - start) * NKern::TickPeriod()) / 1000;
+			TEST_MEMPUT(a2, (TAny*) &ms, sizeof(TUint32));
+			}
+			break;
+		case RHcrSimTestChannel::EHcrBenchmarkFindNumSettingsInCategory:
+			{
+			r = 0;
+			TUint i;
+			TUint32 start = NKern::TickCount();
+			for (i = 0; i < KTestBenchmarkIterations; i++)
+				{
+				r |= HCR::FindNumSettingsInCategory((HCR::TCategoryUid) a1);
+				}
+			TUint32 end = NKern::TickCount();
+			//
+			TUint32 ms;
+			ms = ((end - start) * NKern::TickPeriod()) / 1000;
+			TEST_MEMPUT(a2, (TAny*) &ms, sizeof(TUint32));
+			}
+			break;
+		case RHcrSimTestChannel::EHcrBenchmarkFindSettings:
+			{
+			r = 0;
+			TUint i;
+
+			HCR::TElementId* ids;
+			HCR::TSettingType* types;
+			TUint16* lens;
+			TEST_ENTERCS();
+			ids = (HCR::TElementId*) Kern::Alloc(KTestBenchmarkNumberOfSettingsInCategory * sizeof(HCR::TElementId));
+			TEST_LEAVECS();
+			if (!ids)
+				{
+				TEST(EFalse);
+				r = KErrNoMemory;
+				}
+			else
+				{
+				
+				TEST_ENTERCS();
+				types = (HCR::TSettingType*) Kern::Alloc(KTestBenchmarkNumberOfSettingsInCategory * sizeof(HCR::TSettingType));
+				TEST_LEAVECS();
+				if (!types)
+					{
+					TEST(EFalse);
+					r = KErrNoMemory;
+					}
+				else
+					{
+					TEST_ENTERCS();
+					lens = (TUint16*) Kern::Alloc(KTestBenchmarkNumberOfSettingsInCategory * sizeof(TUint16));
+					TEST_LEAVECS();
+					if (!lens)
+						{
+						TEST(EFalse);
+						r = KErrNoMemory;
+						}
+					else
+						{
+
+						TUint32 start = NKern::TickCount();
+						for (i = 0; i < KTestBenchmarkIterations; i++)
+							{
+							r |= HCR::FindSettings((HCR::TCategoryUid) a1,
+										KTestBenchmarkNumberOfSettingsInCategory,
+										ids, types, lens);
+							}
+						TUint32 end = NKern::TickCount();
+						//
+						
+						TUint32 ms;
+						ms = ((end - start) * NKern::TickPeriod()) / 1000;
+						TEST_MEMPUT(a2, (TAny*) &ms, sizeof(TUint32));
+						TEST_ENTERCS();
+						Kern::Free(lens);
+						TEST_LEAVECS();
+						}
+					TEST_ENTERCS();
+					Kern::Free(types);
+					TEST_LEAVECS();
+					}
+				TEST_ENTERCS();
+				Kern::Free(ids);
+				TEST_LEAVECS();
+				}
+			}
+			break;
+		case RHcrSimTestChannel::EHcrBenchmarkGetTypeAndSize:
+			{
+			r = KErrNone;
+			TUint i;
+			HCR::TSettingId setting;
+			HCR::TSettingType type;
+			TUint16 len;
+			TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId));
+			//
+			TUint32 start = NKern::TickCount();
+			for (i = 0; i < KTestBenchmarkIterations; i++)
+				{
+				r |= HCR::GetTypeAndSize(setting, type, len);
+				}
+			TUint32 end = NKern::TickCount();
+			//
+			TUint32 ms;
+			ms = ((end - start) * NKern::TickPeriod()) / 1000;
+			TEST_MEMPUT(a2, (TAny*) &ms, sizeof(TUint32));
+			}
+			break;
+		case RHcrSimTestChannel::EHcrBenchmarkGetWordSettings:
+			{
+			r = 0;
+			TUint i;
+			HCR::SSettingId* ids;
+			HCR::TSettingType* types;
+			HCR::TCategoryUid catId = (HCR::TCategoryUid)a1;
+			TInt32* values;
+			TInt* errors;
+			TEST_ENTERCS();
+			//We allocate here KTestBenchmarkNumberOfSettingsInCategory - 1 because
+			//last element in the category is a large setting
+			ids = (HCR::SSettingId*) Kern::Alloc((KTestBenchmarkNumberOfSettingsInCategory - 1) * sizeof(HCR::SSettingId));
+			TEST_LEAVECS();
+			if (!ids)
+				{
+				TEST(EFalse);
+				r = KErrNoMemory;
+				}
+			else
+				{
+				for(TUint eId =0; eId < KTestBenchmarkNumberOfSettingsInCategory - 1; eId++ )
+				    {
+				    ids[eId].iCat = catId;
+				    //First element has value 1, second 2, third 3 and so on
+				    ids[eId].iKey = eId + 1;
+				    }
+				TEST_ENTERCS();
+				types = (HCR::TSettingType*) Kern::Alloc((KTestBenchmarkNumberOfSettingsInCategory - 1) * sizeof(HCR::TSettingType));
+				TEST_LEAVECS();
+				if (!types)
+					{
+					TEST(EFalse);
+					r = KErrNoMemory;
+					}
+				else
+					{
+					TEST_ENTERCS();
+					values = (TInt32*) Kern::Alloc((KTestBenchmarkNumberOfSettingsInCategory - 1) * sizeof(TInt32));
+					TEST_LEAVECS();
+					if (!values)
+						{
+						TEST(EFalse);
+						r = KErrNoMemory;
+						}
+					else
+						{
+						TEST_ENTERCS();
+						errors = (TInt*) Kern::Alloc((KTestBenchmarkNumberOfSettingsInCategory - 1) * sizeof(TInt));
+						TEST_LEAVECS();
+						if (!errors)
+							{
+							TEST(EFalse);
+							r = KErrNoMemory;
+							}
+						else
+							{
+							TUint32 start = NKern::TickCount();
+							for (i = 0; i < KTestGetMultipleBenchmarkIterations; i++)
+								{
+								r |= HCR::GetWordSettings(KTestBenchmarkNumberOfSettingsInCategory - 1, ids, values, types, errors);
+								}
+							TUint32 end = NKern::TickCount();
+							//
+							TUint32 ms;
+							ms = ((end - start) * NKern::TickPeriod()) / 1000;
+							TEST_MEMPUT(a2, (TAny*) &ms, sizeof(TUint32));
+							TEST_ENTERCS();
+							Kern::Free(errors);
+							TEST_LEAVECS();
+							}
+						TEST_ENTERCS();
+						Kern::Free(values);
+						TEST_LEAVECS();
+						}
+					TEST_ENTERCS();
+					Kern::Free(types);
+					TEST_LEAVECS();
+					}
+				TEST_ENTERCS();
+				Kern::Free(ids);
+				TEST_LEAVECS();
+				}
+			}
+			break;
 		}
 	return r;
 	}