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