kerneltest/e32test/hcr/d_hcrsim.h
changeset 9 96e5fb8b040d
child 13 46fffbe7b5a7
equal deleted inserted replaced
-1:000000000000 9:96e5fb8b040d
       
     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.h
       
    15 //
       
    16 //
       
    17 
       
    18 #ifndef D_HCRSIM_H
       
    19 #define D_HCRSIM_H
       
    20 
       
    21 #include <e32cmn.h>
       
    22 #include <e32ver.h>
       
    23 #include <drivers/hcr.h>
       
    24 #ifndef HCRTEST_USERSIDE_INTERFACE
       
    25 #include "hcr_hai.h"
       
    26 #include "hcr_pil.h"
       
    27 #endif // HCRTEST_USERSIDE_INTERFACE
       
    28 
       
    29 #ifndef __KERNEL_MODE__
       
    30 using namespace HCR;
       
    31 #endif // __KERNEL_MODE__
       
    32 
       
    33 // Device driver names
       
    34 _LIT(KTestHcrRealOwn, "d_hcrext_own");
       
    35 _LIT(KTestHcrSimOwn, "d_hcrsim_own");
       
    36 _LIT(KTestHcrRealClient, "d_hcrext_client");
       
    37 _LIT(KTestHcrSimClient, "d_hcrsim_client");
       
    38 
       
    39 const TUint KTestBenchmarkNumberOfSettingsInCategory = 1001;
       
    40 const HCR::TCategoryUid KTestBenchmarkCategoryId = 0x60000000;
       
    41 
       
    42 // The following flags are used when calling InitExtension() in order to modify
       
    43 // the behaviour of the test PSL.
       
    44 enum TTestPslConfiguration {
       
    45 	// Make PSL return NULL when asked for the address of the Compiled Repository
       
    46 	ETestNullRepository = 0x1,
       
    47 
       
    48 	// Compiled Repository contains 0 element
       
    49 	ETestEmptyRepository = 0x2,
       
    50 
       
    51 	// PSL's IgnoreCoreImgRepository() returns ETrue when this is set
       
    52 	ETestIgnoreCoreImgRepository = 0x4,
       
    53 
       
    54 	// Use Corrupt Repository (not ordered)
       
    55 	ETestCorruptRepository1 = 0x8,
       
    56 
       
    57 	// Use Corrupt Repository (has duplicates)
       
    58 	ETestCorruptRepository2 = 0x10,
       
    59 
       
    60 	// Set Override Repository address to the Empty Compiled Repository
       
    61 	ETestEnableOverrideRepository = 0x20,
       
    62 
       
    63 	// Make PSL fail to create a variant object
       
    64 	ETestVariantObjectCreateFail = 0x40,
       
    65 
       
    66 	// Make PSL initialisation fail
       
    67 	ETestInitialisationFail = 0x80,
       
    68 
       
    69 	// Use bad repository with NULL ordered list
       
    70 	ETestNullOrderedList = 0x100,
       
    71 
       
    72 	// Make PSL return NULL when asked for the address of the Compiled Repository
       
    73 	// but return KErrNone
       
    74 	ETestNullRepositoryKErrNone = 0x200,
       
    75 
       
    76 	// GetCompiledRepositoryAddress return wrong error code
       
    77 	ETestBadErrorCode = 0x400,
       
    78 };
       
    79 
       
    80 class RHcrSimTestChannel : public RBusLogicalChannel
       
    81 	{
       
    82 public:
       
    83 	enum TTestControl
       
    84 		{
       
    85 		// HCR Published API's
       
    86 		EHcrGetLinAddr,
       
    87 		EHcrFindNumSettingsInCategory,
       
    88 		EHcrFindSettingsCategory,
       
    89 		EHcrFindSettingsPattern,
       
    90 		EHcrGetTypeAndSize,
       
    91 		EHcrGetWordSettings,
       
    92 		EHcrGetInt64,
       
    93 		EHcrGetInt32,
       
    94 		EHcrGetInt16,
       
    95 		EHcrGetInt8,
       
    96 		EHcrGetBool,
       
    97 		EHcrGetDataArray,
       
    98 		EHcrGetDataDes,
       
    99 		EHcrGetUInt64,
       
   100 		EHcrGetUInt32,
       
   101 		EHcrGetUInt16,
       
   102 		EHcrGetUInt8,
       
   103 		EHcrGetArrayInt,
       
   104 		EHcrGetArrayUInt,
       
   105 		EHcrGetStringArray,
       
   106 		EHcrGetStringDes,
       
   107 		// HCR Internal API's
       
   108 		EHcrInitExtension,
       
   109 		EHcrSwitchRepository,
       
   110 		EHcrClearRepository,
       
   111 		EHcrCheckIntegrity,
       
   112 		// Others
       
   113 		EHcrGetInitExtensionTestResults,
       
   114 		EHcrBenchmarkGetSettingInt,
       
   115 		EHcrBenchmarkGetSettingArray,
       
   116 		EHcrBenchmarkGetSettingDes,
       
   117 		EHcrBenchmarkFindNumSettingsInCategory,
       
   118 		EHcrBenchmarkFindSettings,
       
   119 		EHcrBenchmarkGetTypeAndSize,
       
   120 		EHcrBenchmarkGetWordSettings,
       
   121 		};
       
   122 
       
   123 #ifndef __KERNEL_MODE__
       
   124 	inline TInt Open(const TDesC& aLdd);
       
   125 	inline TInt GetLinAddr(const TSettingId& aId, TLinAddr& aValue);
       
   126 	inline TInt FindNumSettingsInCategory(TCategoryUid aCatUid);
       
   127 	inline TInt FindSettings(TCategoryUid aCatUid,
       
   128 							TInt aMaxNum, TUint32& aNumFound,
       
   129 							TElementId* aElIds, TSettingType* aTypes, TUint16* aLens);
       
   130 	inline TInt FindSettings(TCategoryUid aCat,	TInt aMaxNum,
       
   131 							TUint32 aMask, TUint32 aPattern, TUint32& aNumFound,
       
   132 							TElementId* aElIds, TSettingType* aTypes, TUint16* aLens);
       
   133 	inline TInt GetTypeAndSize(const TSettingId& aId,
       
   134 							TSettingType& aType, TUint16& aLen);
       
   135 	inline TInt GetWordSettings(TInt aNum, const SSettingId aIds[],
       
   136 							TInt32 aValues[], TSettingType aTypes[],
       
   137 							TInt aErrors[]);
       
   138 	inline TInt GetInt(const TSettingId& aId, TInt64& aValue);
       
   139 	inline TInt GetInt(const TSettingId& aId, TInt32& aValue);
       
   140 	inline TInt GetInt(const TSettingId& aId, TInt16& aValue);
       
   141 	inline TInt GetInt(const TSettingId& aId, TInt8& aValue);
       
   142 	inline TInt GetBool(const TSettingId& aId, TBool& aValue);
       
   143 	inline TInt GetData(const TSettingId& aId, TDes8& aValue);
       
   144 	inline TInt GetData(const TSettingId& aId, TUint16 aMaxLen,
       
   145 							TUint8* aValue, TUint16& aLen);
       
   146 	inline TInt GetUInt(const TSettingId& aId, TUint64& aValue);
       
   147 	inline TInt GetUInt(const TSettingId& aId, TUint32& aValue);
       
   148 	inline TInt GetUInt(const TSettingId& aId, TUint16& aValue);
       
   149 	inline TInt GetUInt(const TSettingId& aId, TUint8& aValue);
       
   150 	inline TInt GetArray(const TSettingId& aId, TUint16 aMaxLen,
       
   151 							TInt32* aValue, TUint16& aLen);
       
   152 	inline TInt GetArray(const TSettingId& aId, TUint16 aMaxLen,
       
   153 							TUint32* aValue, TUint16& aLen);
       
   154 	inline TInt GetString(const TSettingId& aId, TDes8& aValue);
       
   155 	inline TInt GetString(const TSettingId& aId, TUint16 aMaxLen,
       
   156 							TText8* aValue, TUint16& aLen);
       
   157 	inline TInt InitExtension(const TUint32 aFlags = 0);
       
   158 	inline TInt SwitchRepository(const TDesC8& aFileName, HCRInternal::TReposId aId);
       
   159 	inline TInt CheckIntegrity();
       
   160 	inline TInt GetInitExtensionTestResults(TInt& aLine, TInt& aError);
       
   161 	inline TInt BenchmarkGetSettingInt(const TSettingId& aId, TUint32& aTimeMs);
       
   162 	inline TInt BenchmarkGetSettingArray(const TSettingId& aId, TUint32& aTimeMs);
       
   163 	inline TInt BenchmarkGetSettingDes(const TSettingId& aId, TUint32& aTimeMs);
       
   164 	inline TInt BenchmarkFindNumSettingsInCategory(const TCategoryUid aCatUid, TUint32& aTimeMs);
       
   165 	inline TInt BenchmarkFindSettings(const TCategoryUid aCatUid, TUint32& aTimeMs);
       
   166 	inline TInt BenchmarkGetTypeAndSize(const TSettingId& aId, TUint32& aTimeMs);
       
   167 	inline TInt BenchmarkGetWordSettings(const TCategoryUid aCatUid, TUint32& aTimeMs);
       
   168 #endif // __KERNEL_MODE__
       
   169 	};
       
   170 
       
   171 #ifndef __KERNEL_MODE__
       
   172 inline TInt RHcrSimTestChannel::Open(const TDesC& aLdd)
       
   173 	{return (DoCreate(aLdd, TVersion(1, 0, KE32BuildVersionNumber), KNullUnit, NULL, NULL, EOwnerThread));}
       
   174 inline TInt RHcrSimTestChannel::GetLinAddr(const TSettingId& aId, TLinAddr& aValue)
       
   175 	{return DoControl(EHcrGetLinAddr, (TAny*) &aId, (TAny*) &aValue);}
       
   176 inline TInt RHcrSimTestChannel::FindNumSettingsInCategory(TCategoryUid aCatUid)
       
   177 	{return DoControl(EHcrFindNumSettingsInCategory, (TAny*) aCatUid);}
       
   178 inline TInt RHcrSimTestChannel::FindSettings(TCategoryUid aCatUid,
       
   179 					TInt aMaxNum, TUint32& aNumFound,
       
   180 					TElementId* aElIds, TSettingType* aTypes, TUint16* aLens)
       
   181 	{
       
   182 	TAny* args[6];
       
   183 	args[0] = (TAny*) aCatUid;
       
   184 	args[1] = (TAny*) aMaxNum;
       
   185 	args[2] = (TAny*) &aNumFound;
       
   186 	args[3] = (TAny*) aElIds;
       
   187 	args[4] = (TAny*) aTypes;
       
   188 	args[5] = (TAny*) aLens;
       
   189 	return DoControl(EHcrFindSettingsCategory, (TAny*) args);
       
   190 	}
       
   191 inline TInt RHcrSimTestChannel::FindSettings(TCategoryUid aCat,	TInt aMaxNum, 
       
   192 					TUint32 aMask, TUint32 aPattern, TUint32& aNumFound,
       
   193 					TElementId* aElIds, TSettingType* aTypes, TUint16* aLens)
       
   194 	{
       
   195 	TAny* args[8];
       
   196 	args[0] = (TAny*) aCat;
       
   197 	args[1] = (TAny*) aMaxNum;
       
   198 	args[2] = (TAny*) aMask;
       
   199 	args[3] = (TAny*) aPattern;
       
   200 	args[4] = (TAny*) &aNumFound;
       
   201 	args[5] = (TAny*) aElIds;
       
   202 	args[6] = (TAny*) aTypes;
       
   203 	args[7] = (TAny*) aLens;
       
   204 	return DoControl(EHcrFindSettingsPattern, (TAny*) args);
       
   205 	}
       
   206 inline TInt RHcrSimTestChannel::GetTypeAndSize(const TSettingId& aId,
       
   207 						TSettingType& aType, TUint16& aLen)
       
   208 	{
       
   209 	TAny* args[3];
       
   210 	args[0] = (TAny*) &aId;
       
   211 	args[1] = (TAny*) &aType;
       
   212 	args[2] = (TAny*) &aLen;
       
   213 	return DoControl(EHcrGetTypeAndSize, (TAny*) args);
       
   214 	}
       
   215 inline TInt RHcrSimTestChannel::GetWordSettings(TInt aNum, const SSettingId aIds[],
       
   216 						TInt32 aValues[], TSettingType aTypes[],
       
   217 						TInt aErrors[])
       
   218 	{
       
   219 	TAny* args[5];
       
   220 	args[0] = (TAny*) aNum;
       
   221 	args[1] = (TAny*) aIds;
       
   222 	args[2] = (TAny*) aValues;
       
   223 	args[3] = (TAny*) aTypes;
       
   224 	args[4] = (TAny*) aErrors;
       
   225 	return DoControl(EHcrGetWordSettings, (TAny*) args);
       
   226 	}
       
   227 inline TInt RHcrSimTestChannel::GetInt(const TSettingId& aId, TInt64& aValue)
       
   228 	{return DoControl(EHcrGetInt64, (TAny*) &aId, (TAny*) &aValue);}
       
   229 inline TInt RHcrSimTestChannel::GetInt(const TSettingId& aId, TInt32& aValue)
       
   230 	{return DoControl(EHcrGetInt32, (TAny*) &aId, (TAny*) &aValue);}
       
   231 inline TInt RHcrSimTestChannel::GetInt(const TSettingId& aId, TInt16& aValue)
       
   232 	{return DoControl(EHcrGetInt16, (TAny*) &aId, (TAny*) &aValue);}
       
   233 inline TInt RHcrSimTestChannel::GetInt(const TSettingId& aId, TInt8& aValue)
       
   234 	{return DoControl(EHcrGetInt8, (TAny*) &aId, (TAny*) &aValue);}
       
   235 inline TInt RHcrSimTestChannel::GetBool(const TSettingId& aId, TBool& aValue)
       
   236 	{return DoControl(EHcrGetBool, (TAny*) &aId, (TAny*) &aValue);}
       
   237 inline TInt RHcrSimTestChannel::GetData(const TSettingId& aId, TDes8& aValue)
       
   238 	{return DoControl(EHcrGetDataDes, (TAny*) &aId, (TAny*) &aValue);}
       
   239 inline TInt RHcrSimTestChannel::GetData(const TSettingId& aId, TUint16 aMaxLen,
       
   240 						TUint8* aValue, TUint16& aLen)
       
   241 	{
       
   242 	TAny* args[4];
       
   243 	args[0] = (TAny*) &aId;
       
   244 	args[1] = (TAny*) ((TUint) aMaxLen);
       
   245 	args[2] = (TAny*) aValue;
       
   246 	args[3] = (TAny*) &aLen;
       
   247 	return DoControl(EHcrGetDataArray, (TAny*) args);
       
   248 	}
       
   249 inline TInt RHcrSimTestChannel::GetUInt(const TSettingId& aId, TUint64& aValue)
       
   250 	{return DoControl(EHcrGetUInt64, (TAny*) &aId, (TAny*) &aValue);}
       
   251 inline TInt RHcrSimTestChannel::GetUInt(const TSettingId& aId, TUint32& aValue)
       
   252 	{return DoControl(EHcrGetUInt32, (TAny*) &aId, (TAny*) &aValue);}
       
   253 inline TInt RHcrSimTestChannel::GetUInt(const TSettingId& aId, TUint16& aValue)
       
   254 	{return DoControl(EHcrGetUInt16, (TAny*) &aId, (TAny*) &aValue);}
       
   255 inline TInt RHcrSimTestChannel::GetUInt(const TSettingId& aId, TUint8& aValue)
       
   256 	{return DoControl(EHcrGetUInt8, (TAny*) &aId, (TAny*) &aValue);}
       
   257 inline TInt RHcrSimTestChannel::GetArray(const TSettingId& aId, TUint16 aMaxLen,
       
   258 						TInt32* aValue, TUint16& aLen)
       
   259 	{
       
   260 	TAny* args[4];
       
   261 	args[0] = (TAny*) &aId;
       
   262 	args[1] = (TAny*) ((TUint) aMaxLen);
       
   263 	args[2] = (TAny*) aValue;
       
   264 	args[3] = (TAny*) &aLen;
       
   265 	return DoControl(EHcrGetArrayInt, (TAny*) args);
       
   266 	}
       
   267 inline TInt RHcrSimTestChannel::GetArray(const TSettingId& aId, TUint16 aMaxLen,
       
   268 						TUint32* aValue, TUint16& aLen)
       
   269 	{
       
   270 	TAny* args[4];
       
   271 	args[0] = (TAny*) &aId;
       
   272 	args[1] = (TAny*) ((TUint) aMaxLen);
       
   273 	args[2] = (TAny*) aValue;
       
   274 	args[3] = (TAny*) &aLen;
       
   275 	return DoControl(EHcrGetArrayUInt, (TAny*) args);
       
   276 	}
       
   277 inline TInt RHcrSimTestChannel::GetString(const TSettingId& aId, TDes8& aValue)
       
   278 	{return DoControl(EHcrGetStringDes, (TAny*) &aId, (TAny*) &aValue);}
       
   279 inline TInt RHcrSimTestChannel::GetString(const TSettingId& aId, TUint16 aMaxLen,
       
   280 						TText8* aValue, TUint16& aLen)
       
   281 	{
       
   282 	TAny* args[4];
       
   283 	args[0] = (TAny*) &aId;
       
   284 	args[1] = (TAny*) ((TUint) aMaxLen);
       
   285 	args[2] = (TAny*) aValue;
       
   286 	args[3] = (TAny*) &aLen;
       
   287 	return DoControl(EHcrGetStringArray, (TAny*) args);
       
   288 	}
       
   289 inline TInt RHcrSimTestChannel::InitExtension(const TUint32 aFlags)
       
   290 	{return DoControl(EHcrInitExtension, (TAny*) aFlags);}
       
   291 inline TInt RHcrSimTestChannel::SwitchRepository(const TDesC8& aFileName, HCRInternal::TReposId aId)
       
   292 	{return DoControl(EHcrSwitchRepository, (TAny*) &aFileName, (TAny*) aId);}
       
   293 inline TInt RHcrSimTestChannel::CheckIntegrity()
       
   294 	{return DoControl(EHcrCheckIntegrity);}
       
   295 inline TInt RHcrSimTestChannel::GetInitExtensionTestResults(TInt& aLine, TInt& aError)
       
   296 	{return DoControl(EHcrGetInitExtensionTestResults, (TAny*) &aLine, (TAny*) &aError);}
       
   297 inline TInt RHcrSimTestChannel::BenchmarkGetSettingInt(const TSettingId& aId, TUint32& aTimeMs)
       
   298 	{return DoControl(EHcrBenchmarkGetSettingInt, (TAny*) &aId, (TAny*) &aTimeMs);}
       
   299 inline TInt RHcrSimTestChannel::BenchmarkGetSettingArray(const TSettingId& aId, TUint32& aTimeMs)
       
   300 	{return DoControl(EHcrBenchmarkGetSettingArray, (TAny*) &aId, (TAny*) &aTimeMs);}
       
   301 inline TInt RHcrSimTestChannel::BenchmarkGetSettingDes(const TSettingId& aId, TUint32& aTimeMs)
       
   302 	{return DoControl(EHcrBenchmarkGetSettingDes, (TAny*) &aId, (TAny*) &aTimeMs);}
       
   303 inline TInt RHcrSimTestChannel::BenchmarkFindNumSettingsInCategory(const TCategoryUid aCatUid, TUint32& aTimeMs)
       
   304 	{return DoControl(EHcrBenchmarkFindNumSettingsInCategory, (TAny*) aCatUid, (TAny*) &aTimeMs);}
       
   305 inline TInt RHcrSimTestChannel::BenchmarkFindSettings(const TCategoryUid aCatUid, TUint32& aTimeMs)
       
   306 	{return DoControl(EHcrBenchmarkFindSettings, (TAny*) aCatUid, (TAny*) &aTimeMs);}
       
   307 inline TInt RHcrSimTestChannel::BenchmarkGetTypeAndSize(const TSettingId& aId, TUint32& aTimeMs)
       
   308 	{return DoControl(EHcrBenchmarkGetTypeAndSize, (TAny*) &aId, (TAny*) &aTimeMs);}
       
   309 inline TInt RHcrSimTestChannel::BenchmarkGetWordSettings(const TCategoryUid aCatUid, TUint32& aTimeMs)
       
   310 	{return DoControl(EHcrBenchmarkGetWordSettings, (TAny*) aCatUid, (TAny*) &aTimeMs);}
       
   311 #endif // __KERNEL_MODE__
       
   312 #endif // D_HCRSIM_H