sl@0: // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test/hcr/d_hcrsim.h sl@0: // sl@0: // sl@0: sl@0: #ifndef D_HCRSIM_H sl@0: #define D_HCRSIM_H sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include "hcr_hai.h" sl@0: #include "hcr_pil.h" sl@0: sl@0: using namespace HCR; sl@0: sl@0: //Local helper macros sl@0: #define _ABS(x) (x > 0 ? x : -x) sl@0: sl@0: // Device driver names sl@0: _LIT(KTestHcrRealOwn, "d_hcrext_own"); sl@0: _LIT(KTestHcrSimOwn, "d_hcrsim_own"); sl@0: _LIT(KTestHcrRealClient, "d_hcrext_client"); sl@0: _LIT(KTestHcrSimClient, "d_hcrsim_client"); sl@0: sl@0: const TUint KTestBenchmarkNumberOfSettingsInCategory = 1001; sl@0: const HCR::TCategoryUid KTestBenchmarkCategoryId = 0x60000000; sl@0: sl@0: // The following flags are used when calling InitExtension() in order to modify sl@0: // the behaviour of the test PSL. sl@0: enum TTestPslConfiguration { sl@0: // Make PSL return NULL when asked for the address of the Compiled Repository sl@0: ETestNullRepository = 0x1, sl@0: sl@0: // Compiled Repository contains 0 element sl@0: ETestEmptyRepository = 0x2, sl@0: sl@0: // PSL's IgnoreCoreImgRepository() returns ETrue when this is set sl@0: ETestIgnoreCoreImgRepository = 0x4, sl@0: sl@0: // Use Corrupt Repository (not ordered) sl@0: ETestCorruptRepository1 = 0x8, sl@0: sl@0: // Use Corrupt Repository (has duplicates) sl@0: ETestCorruptRepository2 = 0x10, sl@0: sl@0: // Set Override Repository address to the Empty Compiled Repository sl@0: ETestEnableOverrideRepository = 0x20, sl@0: sl@0: // Make PSL fail to create a variant object sl@0: ETestVariantObjectCreateFail = 0x40, sl@0: sl@0: // Make PSL initialisation fail sl@0: ETestInitialisationFail = 0x80, sl@0: sl@0: // Use bad repository with NULL ordered list sl@0: ETestNullOrderedList = 0x100, sl@0: sl@0: // Make PSL return NULL when asked for the address of the Compiled Repository sl@0: // but return KErrNone sl@0: ETestNullRepositoryKErrNone = 0x200, sl@0: sl@0: // GetCompiledRepositoryAddress return wrong error code sl@0: ETestBadErrorCode = 0x400, sl@0: }; sl@0: sl@0: class RHcrSimTestChannel : public RBusLogicalChannel sl@0: { sl@0: public: sl@0: enum TTestControl sl@0: { sl@0: // HCR Published API's sl@0: EHcrGetLinAddr, sl@0: EHcrFindNumSettingsInCategory, sl@0: EHcrFindSettingsCategory, sl@0: EHcrFindSettingsPattern, sl@0: EHcrGetTypeAndSize, sl@0: EHcrGetWordSettings, sl@0: EHcrGetInt64, sl@0: EHcrGetInt32, sl@0: EHcrGetInt16, sl@0: EHcrGetInt8, sl@0: EHcrGetBool, sl@0: EHcrGetDataArray, sl@0: EHcrGetDataDes, sl@0: EHcrGetUInt64, sl@0: EHcrGetUInt32, sl@0: EHcrGetUInt16, sl@0: EHcrGetUInt8, sl@0: EHcrGetArrayInt, sl@0: EHcrGetArrayUInt, sl@0: EHcrGetStringArray, sl@0: EHcrGetStringDes, sl@0: // HCR Internal API's sl@0: EHcrInitExtension, sl@0: EHcrSwitchRepository, sl@0: EHcrClearRepository, sl@0: EHcrCheckIntegrity, sl@0: // Others sl@0: EHcrGetInitExtensionTestResults, sl@0: EHcrHasRepositoryInSmr, sl@0: EHcrBenchmarkGetSettingInt, sl@0: EHcrBenchmarkGetSettingArray, sl@0: EHcrBenchmarkGetSettingDes, sl@0: EHcrBenchmarkFindNumSettingsInCategory, sl@0: EHcrBenchmarkFindSettings, sl@0: EHcrBenchmarkGetTypeAndSize, sl@0: EHcrBenchmarkGetWordSettings, sl@0: }; sl@0: sl@0: #ifndef __KERNEL_MODE__ sl@0: inline TInt Open(const TDesC& aLdd); sl@0: inline TInt GetLinAddr(const TSettingId& aId, TLinAddr& aValue); sl@0: inline TInt FindNumSettingsInCategory(TCategoryUid aCatUid); sl@0: inline TInt FindSettings(TCategoryUid aCatUid, sl@0: TInt aMaxNum, TElementId* aElIds, TSettingType* aTypes, sl@0: TUint16* aLens); sl@0: inline TInt FindSettings(TCategoryUid aCat, TInt aMaxNum, sl@0: TUint32 aMask, TUint32 aPattern, TElementId* aElIds, sl@0: TSettingType* aTypes, TUint16* aLens); sl@0: inline TInt GetTypeAndSize(const TSettingId& aId, sl@0: TSettingType& aType, TUint16& aLen); sl@0: inline TInt GetWordSettings(TInt aNum, const SSettingId aIds[], sl@0: TInt32 aValues[], TSettingType aTypes[], sl@0: TInt aErrors[]); sl@0: inline TInt GetInt(const TSettingId& aId, TInt64& aValue); sl@0: inline TInt GetInt(const TSettingId& aId, TInt32& aValue); sl@0: inline TInt GetInt(const TSettingId& aId, TInt16& aValue); sl@0: inline TInt GetInt(const TSettingId& aId, TInt8& aValue); sl@0: inline TInt GetBool(const TSettingId& aId, TBool& aValue); sl@0: inline TInt GetData(const TSettingId& aId, TDes8& aValue); sl@0: inline TInt GetData(const TSettingId& aId, TUint16 aMaxLen, sl@0: TUint8* aValue, TUint16& aLen); sl@0: inline TInt GetUInt(const TSettingId& aId, TUint64& aValue); sl@0: inline TInt GetUInt(const TSettingId& aId, TUint32& aValue); sl@0: inline TInt GetUInt(const TSettingId& aId, TUint16& aValue); sl@0: inline TInt GetUInt(const TSettingId& aId, TUint8& aValue); sl@0: inline TInt GetArray(const TSettingId& aId, TUint16 aMaxLen, sl@0: TInt32* aValue, TUint16& aLen); sl@0: inline TInt GetArray(const TSettingId& aId, TUint16 aMaxLen, sl@0: TUint32* aValue, TUint16& aLen); sl@0: inline TInt GetString(const TSettingId& aId, TDes8& aValue); sl@0: inline TInt GetString(const TSettingId& aId, TUint16 aMaxLen, sl@0: TText8* aValue, TUint16& aLen); sl@0: inline TInt InitExtension(const TUint32 aFlags = 0); sl@0: inline TInt SwitchRepository(const TDesC8& aFileName, HCRInternal::TReposId aId); sl@0: inline TInt CheckIntegrity(); sl@0: inline TInt GetInitExtensionTestResults(TInt& aLine, TInt& aError); sl@0: inline TInt HasRepositoryInSmr(TBool& aHasSmr, TBool& aHasSmrRep); sl@0: inline TInt BenchmarkGetSettingInt(const TSettingId& aId, TUint32& aTimeMs); sl@0: inline TInt BenchmarkGetSettingArray(const TSettingId& aId, TUint32& aTimeMs); sl@0: inline TInt BenchmarkGetSettingDes(const TSettingId& aId, TUint32& aTimeMs); sl@0: inline TInt BenchmarkFindNumSettingsInCategory(const TCategoryUid aCatUid, TUint32& aTimeMs); sl@0: inline TInt BenchmarkFindSettings(const TCategoryUid aCatUid, TUint32& aTimeMs); sl@0: inline TInt BenchmarkGetTypeAndSize(const TSettingId& aId, TUint32& aTimeMs); sl@0: inline TInt BenchmarkGetWordSettings(const TCategoryUid aCatUid, TUint32& aTimeMs); sl@0: #endif // __KERNEL_MODE__ sl@0: }; sl@0: sl@0: #ifndef __KERNEL_MODE__ sl@0: inline TInt RHcrSimTestChannel::Open(const TDesC& aLdd) sl@0: {return (DoCreate(aLdd, TVersion(1, 0, KE32BuildVersionNumber), KNullUnit, NULL, NULL, EOwnerThread));} sl@0: inline TInt RHcrSimTestChannel::GetLinAddr(const TSettingId& aId, TLinAddr& aValue) sl@0: {return DoControl(EHcrGetLinAddr, (TAny*) &aId, (TAny*) &aValue);} sl@0: inline TInt RHcrSimTestChannel::FindNumSettingsInCategory(TCategoryUid aCatUid) sl@0: {return DoControl(EHcrFindNumSettingsInCategory, (TAny*) aCatUid);} sl@0: inline TInt RHcrSimTestChannel::FindSettings(TCategoryUid aCatUid, sl@0: TInt aMaxNum, TElementId* aElIds, TSettingType* aTypes, TUint16* aLens) sl@0: { sl@0: TAny* args[6]; sl@0: args[0] = (TAny*) aCatUid; sl@0: args[1] = (TAny*) aMaxNum; sl@0: args[2] = 0; //It's not used sl@0: args[3] = (TAny*) aElIds; sl@0: args[4] = (TAny*) aTypes; sl@0: args[5] = (TAny*) aLens; sl@0: return DoControl(EHcrFindSettingsCategory, (TAny*) args); sl@0: } sl@0: inline TInt RHcrSimTestChannel::FindSettings(TCategoryUid aCat, TInt aMaxNum, sl@0: TUint32 aMask, TUint32 aPattern, TElementId* aElIds, sl@0: TSettingType* aTypes, TUint16* aLens) sl@0: { sl@0: TAny* args[8]; sl@0: args[0] = (TAny*) aCat; sl@0: args[1] = (TAny*) aMaxNum; sl@0: args[2] = (TAny*) aMask; sl@0: args[3] = (TAny*) aPattern; sl@0: args[4] = 0; //It's not used sl@0: args[5] = (TAny*) aElIds; sl@0: args[6] = (TAny*) aTypes; sl@0: args[7] = (TAny*) aLens; sl@0: return DoControl(EHcrFindSettingsPattern, (TAny*) args); sl@0: } sl@0: inline TInt RHcrSimTestChannel::GetTypeAndSize(const TSettingId& aId, sl@0: TSettingType& aType, TUint16& aLen) sl@0: { sl@0: TAny* args[3]; sl@0: args[0] = (TAny*) &aId; sl@0: args[1] = (TAny*) &aType; sl@0: args[2] = (TAny*) &aLen; sl@0: return DoControl(EHcrGetTypeAndSize, (TAny*) args); sl@0: } sl@0: inline TInt RHcrSimTestChannel::GetWordSettings(TInt aNum, const SSettingId aIds[], sl@0: TInt32 aValues[], TSettingType aTypes[], sl@0: TInt aErrors[]) sl@0: { sl@0: TAny* args[5]; sl@0: args[0] = (TAny*) aNum; sl@0: args[1] = (TAny*) aIds; sl@0: args[2] = (TAny*) aValues; sl@0: args[3] = (TAny*) aTypes; sl@0: args[4] = (TAny*) aErrors; sl@0: return DoControl(EHcrGetWordSettings, (TAny*) args); sl@0: } sl@0: inline TInt RHcrSimTestChannel::GetInt(const TSettingId& aId, TInt64& aValue) sl@0: {return DoControl(EHcrGetInt64, (TAny*) &aId, (TAny*) &aValue);} sl@0: inline TInt RHcrSimTestChannel::GetInt(const TSettingId& aId, TInt32& aValue) sl@0: {return DoControl(EHcrGetInt32, (TAny*) &aId, (TAny*) &aValue);} sl@0: inline TInt RHcrSimTestChannel::GetInt(const TSettingId& aId, TInt16& aValue) sl@0: {return DoControl(EHcrGetInt16, (TAny*) &aId, (TAny*) &aValue);} sl@0: inline TInt RHcrSimTestChannel::GetInt(const TSettingId& aId, TInt8& aValue) sl@0: {return DoControl(EHcrGetInt8, (TAny*) &aId, (TAny*) &aValue);} sl@0: inline TInt RHcrSimTestChannel::GetBool(const TSettingId& aId, TBool& aValue) sl@0: {return DoControl(EHcrGetBool, (TAny*) &aId, (TAny*) &aValue);} sl@0: inline TInt RHcrSimTestChannel::GetData(const TSettingId& aId, TDes8& aValue) sl@0: {return DoControl(EHcrGetDataDes, (TAny*) &aId, (TAny*) &aValue);} sl@0: inline TInt RHcrSimTestChannel::GetData(const TSettingId& aId, TUint16 aMaxLen, sl@0: TUint8* aValue, TUint16& aLen) sl@0: { sl@0: TAny* args[4]; sl@0: args[0] = (TAny*) &aId; sl@0: args[1] = (TAny*) ((TUint) aMaxLen); sl@0: args[2] = (TAny*) aValue; sl@0: args[3] = (TAny*) &aLen; sl@0: return DoControl(EHcrGetDataArray, (TAny*) args); sl@0: } sl@0: inline TInt RHcrSimTestChannel::GetUInt(const TSettingId& aId, TUint64& aValue) sl@0: {return DoControl(EHcrGetUInt64, (TAny*) &aId, (TAny*) &aValue);} sl@0: inline TInt RHcrSimTestChannel::GetUInt(const TSettingId& aId, TUint32& aValue) sl@0: {return DoControl(EHcrGetUInt32, (TAny*) &aId, (TAny*) &aValue);} sl@0: inline TInt RHcrSimTestChannel::GetUInt(const TSettingId& aId, TUint16& aValue) sl@0: {return DoControl(EHcrGetUInt16, (TAny*) &aId, (TAny*) &aValue);} sl@0: inline TInt RHcrSimTestChannel::GetUInt(const TSettingId& aId, TUint8& aValue) sl@0: {return DoControl(EHcrGetUInt8, (TAny*) &aId, (TAny*) &aValue);} sl@0: inline TInt RHcrSimTestChannel::GetArray(const TSettingId& aId, TUint16 aMaxLen, sl@0: TInt32* aValue, TUint16& aLen) sl@0: { sl@0: TAny* args[4]; sl@0: args[0] = (TAny*) &aId; sl@0: args[1] = (TAny*) ((TUint) aMaxLen); sl@0: args[2] = (TAny*) aValue; sl@0: args[3] = (TAny*) &aLen; sl@0: return DoControl(EHcrGetArrayInt, (TAny*) args); sl@0: } sl@0: inline TInt RHcrSimTestChannel::GetArray(const TSettingId& aId, TUint16 aMaxLen, sl@0: TUint32* aValue, TUint16& aLen) sl@0: { sl@0: TAny* args[4]; sl@0: args[0] = (TAny*) &aId; sl@0: args[1] = (TAny*) ((TUint) aMaxLen); sl@0: args[2] = (TAny*) aValue; sl@0: args[3] = (TAny*) &aLen; sl@0: return DoControl(EHcrGetArrayUInt, (TAny*) args); sl@0: } sl@0: inline TInt RHcrSimTestChannel::GetString(const TSettingId& aId, TDes8& aValue) sl@0: {return DoControl(EHcrGetStringDes, (TAny*) &aId, (TAny*) &aValue);} sl@0: inline TInt RHcrSimTestChannel::GetString(const TSettingId& aId, TUint16 aMaxLen, sl@0: TText8* aValue, TUint16& aLen) sl@0: { sl@0: TAny* args[4]; sl@0: args[0] = (TAny*) &aId; sl@0: args[1] = (TAny*) ((TUint) aMaxLen); sl@0: args[2] = (TAny*) aValue; sl@0: args[3] = (TAny*) &aLen; sl@0: return DoControl(EHcrGetStringArray, (TAny*) args); sl@0: } sl@0: inline TInt RHcrSimTestChannel::InitExtension(const TUint32 aFlags) sl@0: {return DoControl(EHcrInitExtension, (TAny*) aFlags);} sl@0: inline TInt RHcrSimTestChannel::SwitchRepository(const TDesC8& aFileName, HCRInternal::TReposId aId) sl@0: {return DoControl(EHcrSwitchRepository, (TAny*) &aFileName, (TAny*) aId);} sl@0: inline TInt RHcrSimTestChannel::CheckIntegrity() sl@0: {return DoControl(EHcrCheckIntegrity);} sl@0: inline TInt RHcrSimTestChannel::GetInitExtensionTestResults(TInt& aLine, TInt& aError) sl@0: {return DoControl(EHcrGetInitExtensionTestResults, (TAny*) &aLine, (TAny*) &aError);} sl@0: inline TInt RHcrSimTestChannel::HasRepositoryInSmr(TBool& aHasSmr, TBool& aHasSmrRep) sl@0: {return DoControl(EHcrHasRepositoryInSmr, (TAny*) &aHasSmr, (TAny*) &aHasSmrRep);} sl@0: inline TInt RHcrSimTestChannel::BenchmarkGetSettingInt(const TSettingId& aId, TUint32& aTimeMs) sl@0: {return DoControl(EHcrBenchmarkGetSettingInt, (TAny*) &aId, (TAny*) &aTimeMs);} sl@0: inline TInt RHcrSimTestChannel::BenchmarkGetSettingArray(const TSettingId& aId, TUint32& aTimeMs) sl@0: {return DoControl(EHcrBenchmarkGetSettingArray, (TAny*) &aId, (TAny*) &aTimeMs);} sl@0: inline TInt RHcrSimTestChannel::BenchmarkGetSettingDes(const TSettingId& aId, TUint32& aTimeMs) sl@0: {return DoControl(EHcrBenchmarkGetSettingDes, (TAny*) &aId, (TAny*) &aTimeMs);} sl@0: inline TInt RHcrSimTestChannel::BenchmarkFindNumSettingsInCategory(const TCategoryUid aCatUid, TUint32& aTimeMs) sl@0: {return DoControl(EHcrBenchmarkFindNumSettingsInCategory, (TAny*) aCatUid, (TAny*) &aTimeMs);} sl@0: inline TInt RHcrSimTestChannel::BenchmarkFindSettings(const TCategoryUid aCatUid, TUint32& aTimeMs) sl@0: {return DoControl(EHcrBenchmarkFindSettings, (TAny*) aCatUid, (TAny*) &aTimeMs);} sl@0: inline TInt RHcrSimTestChannel::BenchmarkGetTypeAndSize(const TSettingId& aId, TUint32& aTimeMs) sl@0: {return DoControl(EHcrBenchmarkGetTypeAndSize, (TAny*) &aId, (TAny*) &aTimeMs);} sl@0: inline TInt RHcrSimTestChannel::BenchmarkGetWordSettings(const TCategoryUid aCatUid, TUint32& aTimeMs) sl@0: {return DoControl(EHcrBenchmarkGetWordSettings, (TAny*) aCatUid, (TAny*) &aTimeMs);} sl@0: #endif // __KERNEL_MODE__ sl@0: #endif // D_HCRSIM_H