os/kernelhwsrv/kerneltest/e32test/hcr/d_hcrsim.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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 #include "hcr_hai.h"
    25 #include "hcr_pil.h"
    26 
    27 using namespace HCR;
    28 
    29 //Local helper macros
    30 #define _ABS(x)     (x > 0 ? x : -x)
    31 
    32 // Device driver names
    33 _LIT(KTestHcrRealOwn, "d_hcrext_own");
    34 _LIT(KTestHcrSimOwn, "d_hcrsim_own");
    35 _LIT(KTestHcrRealClient, "d_hcrext_client");
    36 _LIT(KTestHcrSimClient, "d_hcrsim_client");
    37 
    38 const TUint KTestBenchmarkNumberOfSettingsInCategory = 1001;
    39 const HCR::TCategoryUid KTestBenchmarkCategoryId = 0x60000000;
    40 
    41 // The following flags are used when calling InitExtension() in order to modify
    42 // the behaviour of the test PSL.
    43 enum TTestPslConfiguration {
    44 	// Make PSL return NULL when asked for the address of the Compiled Repository
    45 	ETestNullRepository = 0x1,
    46 
    47 	// Compiled Repository contains 0 element
    48 	ETestEmptyRepository = 0x2,
    49 
    50 	// PSL's IgnoreCoreImgRepository() returns ETrue when this is set
    51 	ETestIgnoreCoreImgRepository = 0x4,
    52 
    53 	// Use Corrupt Repository (not ordered)
    54 	ETestCorruptRepository1 = 0x8,
    55 
    56 	// Use Corrupt Repository (has duplicates)
    57 	ETestCorruptRepository2 = 0x10,
    58 
    59 	// Set Override Repository address to the Empty Compiled Repository
    60 	ETestEnableOverrideRepository = 0x20,
    61 
    62 	// Make PSL fail to create a variant object
    63 	ETestVariantObjectCreateFail = 0x40,
    64 
    65 	// Make PSL initialisation fail
    66 	ETestInitialisationFail = 0x80,
    67 
    68 	// Use bad repository with NULL ordered list
    69 	ETestNullOrderedList = 0x100,
    70 
    71 	// Make PSL return NULL when asked for the address of the Compiled Repository
    72 	// but return KErrNone
    73 	ETestNullRepositoryKErrNone = 0x200,
    74 
    75 	// GetCompiledRepositoryAddress return wrong error code
    76 	ETestBadErrorCode = 0x400,
    77 };
    78 
    79 class RHcrSimTestChannel : public RBusLogicalChannel
    80 	{
    81 public:
    82 	enum TTestControl
    83 		{
    84 		// HCR Published API's
    85 		EHcrGetLinAddr,
    86 		EHcrFindNumSettingsInCategory,
    87 		EHcrFindSettingsCategory,
    88 		EHcrFindSettingsPattern,
    89 		EHcrGetTypeAndSize,
    90 		EHcrGetWordSettings,
    91 		EHcrGetInt64,
    92 		EHcrGetInt32,
    93 		EHcrGetInt16,
    94 		EHcrGetInt8,
    95 		EHcrGetBool,
    96 		EHcrGetDataArray,
    97 		EHcrGetDataDes,
    98 		EHcrGetUInt64,
    99 		EHcrGetUInt32,
   100 		EHcrGetUInt16,
   101 		EHcrGetUInt8,
   102 		EHcrGetArrayInt,
   103 		EHcrGetArrayUInt,
   104 		EHcrGetStringArray,
   105 		EHcrGetStringDes,
   106 		// HCR Internal API's
   107 		EHcrInitExtension,
   108 		EHcrSwitchRepository,
   109 		EHcrClearRepository,
   110 		EHcrCheckIntegrity,
   111 		// Others
   112 		EHcrGetInitExtensionTestResults,
   113 		EHcrHasRepositoryInSmr,
   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, TElementId* aElIds, TSettingType* aTypes,
   129 							TUint16* aLens);
   130 	inline TInt FindSettings(TCategoryUid aCat,	TInt aMaxNum,
   131 							TUint32 aMask, TUint32 aPattern, TElementId* aElIds,
   132 							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 HasRepositoryInSmr(TBool& aHasSmr, TBool& aHasSmrRep);
   162 	inline TInt BenchmarkGetSettingInt(const TSettingId& aId, TUint32& aTimeMs);
   163 	inline TInt BenchmarkGetSettingArray(const TSettingId& aId, TUint32& aTimeMs);
   164 	inline TInt BenchmarkGetSettingDes(const TSettingId& aId, TUint32& aTimeMs);
   165 	inline TInt BenchmarkFindNumSettingsInCategory(const TCategoryUid aCatUid, TUint32& aTimeMs);
   166 	inline TInt BenchmarkFindSettings(const TCategoryUid aCatUid, TUint32& aTimeMs);
   167 	inline TInt BenchmarkGetTypeAndSize(const TSettingId& aId, TUint32& aTimeMs);
   168 	inline TInt BenchmarkGetWordSettings(const TCategoryUid aCatUid, TUint32& aTimeMs);
   169 #endif // __KERNEL_MODE__
   170 	};
   171 
   172 #ifndef __KERNEL_MODE__
   173 inline TInt RHcrSimTestChannel::Open(const TDesC& aLdd)
   174 	{return (DoCreate(aLdd, TVersion(1, 0, KE32BuildVersionNumber), KNullUnit, NULL, NULL, EOwnerThread));}
   175 inline TInt RHcrSimTestChannel::GetLinAddr(const TSettingId& aId, TLinAddr& aValue)
   176 	{return DoControl(EHcrGetLinAddr, (TAny*) &aId, (TAny*) &aValue);}
   177 inline TInt RHcrSimTestChannel::FindNumSettingsInCategory(TCategoryUid aCatUid)
   178 	{return DoControl(EHcrFindNumSettingsInCategory, (TAny*) aCatUid);}
   179 inline TInt RHcrSimTestChannel::FindSettings(TCategoryUid aCatUid,
   180 					TInt aMaxNum, TElementId* aElIds, TSettingType* aTypes, TUint16* aLens)
   181 	{
   182 	TAny* args[6];
   183 	args[0] = (TAny*) aCatUid;
   184 	args[1] = (TAny*) aMaxNum;
   185 	args[2] =  0; //It's not used
   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, TElementId* aElIds, 
   193 					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] =  0; //It's not used
   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::HasRepositoryInSmr(TBool& aHasSmr, TBool& aHasSmrRep)
   298 	{return DoControl(EHcrHasRepositoryInSmr, (TAny*) &aHasSmr, (TAny*) &aHasSmrRep);}
   299 inline TInt RHcrSimTestChannel::BenchmarkGetSettingInt(const TSettingId& aId, TUint32& aTimeMs)
   300 	{return DoControl(EHcrBenchmarkGetSettingInt, (TAny*) &aId, (TAny*) &aTimeMs);}
   301 inline TInt RHcrSimTestChannel::BenchmarkGetSettingArray(const TSettingId& aId, TUint32& aTimeMs)
   302 	{return DoControl(EHcrBenchmarkGetSettingArray, (TAny*) &aId, (TAny*) &aTimeMs);}
   303 inline TInt RHcrSimTestChannel::BenchmarkGetSettingDes(const TSettingId& aId, TUint32& aTimeMs)
   304 	{return DoControl(EHcrBenchmarkGetSettingDes, (TAny*) &aId, (TAny*) &aTimeMs);}
   305 inline TInt RHcrSimTestChannel::BenchmarkFindNumSettingsInCategory(const TCategoryUid aCatUid, TUint32& aTimeMs)
   306 	{return DoControl(EHcrBenchmarkFindNumSettingsInCategory, (TAny*) aCatUid, (TAny*) &aTimeMs);}
   307 inline TInt RHcrSimTestChannel::BenchmarkFindSettings(const TCategoryUid aCatUid, TUint32& aTimeMs)
   308 	{return DoControl(EHcrBenchmarkFindSettings, (TAny*) aCatUid, (TAny*) &aTimeMs);}
   309 inline TInt RHcrSimTestChannel::BenchmarkGetTypeAndSize(const TSettingId& aId, TUint32& aTimeMs)
   310 	{return DoControl(EHcrBenchmarkGetTypeAndSize, (TAny*) &aId, (TAny*) &aTimeMs);}
   311 inline TInt RHcrSimTestChannel::BenchmarkGetWordSettings(const TCategoryUid aCatUid, TUint32& aTimeMs)
   312 	{return DoControl(EHcrBenchmarkGetWordSettings, (TAny*) aCatUid, (TAny*) &aTimeMs);}
   313 #endif // __KERNEL_MODE__
   314 #endif // D_HCRSIM_H