kerneltest/e32test/hcr/d_hcrsim.h
changeset 0 a41df078684a
child 31 56f325a607ea
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     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 #ifndef __KERNEL_MODE__
       
    28 using namespace HCR;
       
    29 #endif // __KERNEL_MODE__
       
    30 
       
    31 // Device driver name
       
    32 _LIT(KTestHcrSim, "d_hcrsim");
       
    33 
       
    34 // The following flags are used when calling InitExtension() in order to modify
       
    35 // the behaviour of the test PSL.
       
    36 enum TTestPslConfiguration {
       
    37 	// Make PSL return NULL when asked for the address of the Compiled Repository
       
    38 	ETestNullRepository = 0x1,
       
    39 
       
    40 	// Compiled Repository contains 0 element
       
    41 	ETestEmptyRepository = 0x2,
       
    42 
       
    43 	// PSL's IgnoreCoreImgRepository() returns ETrue when this is set
       
    44 	ETestIgnoreCoreImgRepository = 0x4,
       
    45 
       
    46 	// Use Corrupt Repository (not ordered)
       
    47 	ETestCorruptRepository1 = 0x8,
       
    48 
       
    49 	// Use Corrupt Repository (has duplicates)
       
    50 	ETestCorruptRepository2 = 0x10,
       
    51 
       
    52 	// Set Override Repository address to the Empty Compiled Repository
       
    53 	ETestEnableOverrideRepository = 0x20,
       
    54 };
       
    55 
       
    56 class RHcrSimTestChannel : public RBusLogicalChannel
       
    57 	{
       
    58 public:
       
    59 	enum TTestControl
       
    60 		{
       
    61 		// HCR Published API's
       
    62 		EHcrGetLinAddr,
       
    63 		EHcrFindNumSettingsInCategory,
       
    64 		EHcrFindSettingsCategory,
       
    65 		EHcrFindSettingsPattern,
       
    66 		EHcrGetTypeAndSize,
       
    67 		EHcrGetWordSettings,
       
    68 		EHcrGetInt64,
       
    69 		EHcrGetInt32,
       
    70 		EHcrGetInt16,
       
    71 		EHcrGetInt8,
       
    72 		EHcrGetBool,
       
    73 		EHcrGetDataArray,
       
    74 		EHcrGetDataDes,
       
    75 		EHcrGetUInt64,
       
    76 		EHcrGetUInt32,
       
    77 		EHcrGetUInt16,
       
    78 		EHcrGetUInt8,
       
    79 		EHcrGetArrayInt,
       
    80 		EHcrGetArrayUInt,
       
    81 		EHcrGetStringArray,
       
    82 		EHcrGetStringDes,
       
    83 		// HCR Internal API's
       
    84 		EHcrInitExtension,
       
    85 		EHcrSwitchRepository,
       
    86 		EHcrClearRepository,
       
    87 		EHcrCheckIntegrity,
       
    88 		};
       
    89  
       
    90 #ifndef __KERNEL_MODE__
       
    91 	inline TInt Open();
       
    92 	inline TInt GetLinAddr(const TSettingId& aId, TLinAddr& aValue);
       
    93 	inline TInt FindNumSettingsInCategory(TCategoryUid aCatUid);
       
    94 	inline TInt FindSettings(TCategoryUid aCatUid,
       
    95 							TInt aMaxNum, TUint32& aNumFound,
       
    96 							TElementId* aElIds, TSettingType* aTypes, TUint16* aLens);
       
    97 	inline TInt FindSettings(TCategoryUid aCat,
       
    98 							TInt aMaxNum, TUint32 aAtId,
       
    99 							TUint32 aMask, TUint32 aPattern, TUint32& aNumFound,
       
   100 							TElementId* aElIds, TSettingType* aTypes, TUint16* aLens);
       
   101 	inline TInt GetTypeAndSize(const TSettingId& aId,
       
   102 							TSettingType& aType, TUint16& aLen);
       
   103 	inline TInt GetWordSettings(TInt aNum, const SSettingId aIds[],
       
   104 							TInt32 aValues[], TSettingType aTypes[],
       
   105 							TInt aErrors[]);
       
   106 	inline TInt GetInt(const TSettingId& aId, TInt64& aValue);
       
   107 	inline TInt GetInt(const TSettingId& aId, TInt32& aValue);
       
   108 	inline TInt GetInt(const TSettingId& aId, TInt16& aValue);
       
   109 	inline TInt GetInt(const TSettingId& aId, TInt8& aValue);
       
   110 	inline TInt GetBool(const TSettingId& aId, TBool& aValue);
       
   111 	inline TInt GetData(const TSettingId& aId, TDes8& aValue);
       
   112 	inline TInt GetData(const TSettingId& aId, TUint16 aMaxLen,
       
   113 							TUint8* aValue, TUint16& aLen);
       
   114 	inline TInt GetUInt(const TSettingId& aId, TUint64& aValue);
       
   115 	inline TInt GetUInt(const TSettingId& aId, TUint32& aValue);
       
   116 	inline TInt GetUInt(const TSettingId& aId, TUint16& aValue);
       
   117 	inline TInt GetUInt(const TSettingId& aId, TUint8& aValue);
       
   118 	inline TInt GetArray(const TSettingId& aId, TUint16 aMaxLen,
       
   119 							TInt32* aValue, TUint16& aLen);
       
   120 	inline TInt GetArray(const TSettingId& aId, TUint16 aMaxLen,
       
   121 							TUint32* aValue, TUint16& aLen);
       
   122 	inline TInt GetString(const TSettingId& aId, TDes8& aValue);
       
   123 	inline TInt GetString(const TSettingId& aId, TUint16 aMaxLen,
       
   124 							TText8* aValue, TUint16& aLen);
       
   125 	inline TInt InitExtension(const TUint32 aFlags = 0);
       
   126 	inline TInt SwitchRepository(const TDesC8& aFileName, HCRInternal::TReposId aId);
       
   127 	inline TInt CheckIntegrity();
       
   128 #endif // __KERNEL_MODE__
       
   129 	};
       
   130 
       
   131 #ifndef __KERNEL_MODE__
       
   132 inline TInt RHcrSimTestChannel::Open()
       
   133 	{return (DoCreate(KTestHcrSim(), TVersion(1, 0, KE32BuildVersionNumber), KNullUnit, NULL, NULL, EOwnerThread));}
       
   134 inline TInt RHcrSimTestChannel::GetLinAddr(const TSettingId& aId, TLinAddr& aValue)
       
   135 	{return DoControl(EHcrGetLinAddr, (TAny*) &aId, (TAny*) &aValue);}
       
   136 inline TInt RHcrSimTestChannel::FindNumSettingsInCategory(TCategoryUid aCatUid)
       
   137 	{return DoControl(EHcrFindNumSettingsInCategory, (TAny*) aCatUid);}
       
   138 inline TInt RHcrSimTestChannel::FindSettings(TCategoryUid aCatUid,
       
   139 					TInt aMaxNum, TUint32& aNumFound,
       
   140 					TElementId* aElIds, TSettingType* aTypes, TUint16* aLens)
       
   141 	{
       
   142 	TAny* args[6];
       
   143 	args[0] = (TAny*) aCatUid;
       
   144 	args[1] = (TAny*) aMaxNum;
       
   145 	args[2] = (TAny*) &aNumFound;
       
   146 	args[3] = (TAny*) aElIds;
       
   147 	args[4] = (TAny*) aTypes;
       
   148 	args[5] = (TAny*) aLens;
       
   149 	return DoControl(EHcrFindSettingsCategory, (TAny*) args);
       
   150 	}
       
   151 inline TInt RHcrSimTestChannel::FindSettings(TCategoryUid aCat,
       
   152 					TInt aMaxNum, TUint32 aAtId,
       
   153 					TUint32 aMask, TUint32 aPattern, TUint32& aNumFound,
       
   154 					TElementId* aElIds, TSettingType* aTypes, TUint16* aLens)
       
   155 	{
       
   156 	TAny* args[9];
       
   157 	args[0] = (TAny*) aCat;
       
   158 	args[1] = (TAny*) aMaxNum;
       
   159 	args[2] = (TAny*) aAtId;
       
   160 	args[3] = (TAny*) aMask;
       
   161 	args[4] = (TAny*) aPattern;
       
   162 	args[5] = (TAny*) &aNumFound;
       
   163 	args[6] = (TAny*) aElIds;
       
   164 	args[7] = (TAny*) aTypes;
       
   165 	args[8] = (TAny*) aLens;
       
   166 	return DoControl(EHcrFindSettingsPattern, (TAny*) args);
       
   167 	}
       
   168 inline TInt RHcrSimTestChannel::GetTypeAndSize(const TSettingId& aId,
       
   169 						TSettingType& aType, TUint16& aLen)
       
   170 	{
       
   171 	TAny* args[3];
       
   172 	args[0] = (TAny*) &aId;
       
   173 	args[1] = (TAny*) &aType;
       
   174 	args[2] = (TAny*) &aLen;
       
   175 	return DoControl(EHcrGetTypeAndSize, (TAny*) args);
       
   176 	}
       
   177 inline TInt RHcrSimTestChannel::GetWordSettings(TInt aNum, const SSettingId aIds[],
       
   178 						TInt32 aValues[], TSettingType aTypes[],
       
   179 						TInt aErrors[])
       
   180 	{
       
   181 	TAny* args[5];
       
   182 	args[0] = (TAny*) aNum;
       
   183 	args[1] = (TAny*) aIds;
       
   184 	args[2] = (TAny*) aValues;
       
   185 	args[3] = (TAny*) aTypes;
       
   186 	args[4] = (TAny*) aErrors;
       
   187 	return DoControl(EHcrGetWordSettings, (TAny*) args);
       
   188 	}
       
   189 inline TInt RHcrSimTestChannel::GetInt(const TSettingId& aId, TInt64& aValue)
       
   190 	{return DoControl(EHcrGetInt64, (TAny*) &aId, (TAny*) &aValue);}
       
   191 inline TInt RHcrSimTestChannel::GetInt(const TSettingId& aId, TInt32& aValue)
       
   192 	{return DoControl(EHcrGetInt32, (TAny*) &aId, (TAny*) &aValue);}
       
   193 inline TInt RHcrSimTestChannel::GetInt(const TSettingId& aId, TInt16& aValue)
       
   194 	{return DoControl(EHcrGetInt16, (TAny*) &aId, (TAny*) &aValue);}
       
   195 inline TInt RHcrSimTestChannel::GetInt(const TSettingId& aId, TInt8& aValue)
       
   196 	{return DoControl(EHcrGetInt8, (TAny*) &aId, (TAny*) &aValue);}
       
   197 inline TInt RHcrSimTestChannel::GetBool(const TSettingId& aId, TBool& aValue)
       
   198 	{return DoControl(EHcrGetBool, (TAny*) &aId, (TAny*) &aValue);}
       
   199 inline TInt RHcrSimTestChannel::GetData(const TSettingId& aId, TDes8& aValue)
       
   200 	{return DoControl(EHcrGetDataDes, (TAny*) &aId, (TAny*) &aValue);}
       
   201 inline TInt RHcrSimTestChannel::GetData(const TSettingId& aId, TUint16 aMaxLen,
       
   202 						TUint8* aValue, TUint16& aLen)
       
   203 	{
       
   204 	TAny* args[4];
       
   205 	args[0] = (TAny*) &aId;
       
   206 	args[1] = (TAny*) ((TUint) aMaxLen);
       
   207 	args[2] = (TAny*) aValue;
       
   208 	args[3] = (TAny*) &aLen;
       
   209 	return DoControl(EHcrGetDataArray, (TAny*) args);
       
   210 	}
       
   211 inline TInt RHcrSimTestChannel::GetUInt(const TSettingId& aId, TUint64& aValue)
       
   212 	{return DoControl(EHcrGetUInt64, (TAny*) &aId, (TAny*) &aValue);}
       
   213 inline TInt RHcrSimTestChannel::GetUInt(const TSettingId& aId, TUint32& aValue)
       
   214 	{return DoControl(EHcrGetUInt32, (TAny*) &aId, (TAny*) &aValue);}
       
   215 inline TInt RHcrSimTestChannel::GetUInt(const TSettingId& aId, TUint16& aValue)
       
   216 	{return DoControl(EHcrGetUInt16, (TAny*) &aId, (TAny*) &aValue);}
       
   217 inline TInt RHcrSimTestChannel::GetUInt(const TSettingId& aId, TUint8& aValue)
       
   218 	{return DoControl(EHcrGetUInt8, (TAny*) &aId, (TAny*) &aValue);}
       
   219 inline TInt RHcrSimTestChannel::GetArray(const TSettingId& aId, TUint16 aMaxLen,
       
   220 						TInt32* aValue, TUint16& aLen)
       
   221 	{
       
   222 	TAny* args[4];
       
   223 	args[0] = (TAny*) &aId;
       
   224 	args[1] = (TAny*) ((TUint) aMaxLen);
       
   225 	args[2] = (TAny*) aValue;
       
   226 	args[3] = (TAny*) &aLen;
       
   227 	return DoControl(EHcrGetArrayInt, (TAny*) args);
       
   228 	}
       
   229 inline TInt RHcrSimTestChannel::GetArray(const TSettingId& aId, TUint16 aMaxLen,
       
   230 						TUint32* aValue, TUint16& aLen)
       
   231 	{
       
   232 	TAny* args[4];
       
   233 	args[0] = (TAny*) &aId;
       
   234 	args[1] = (TAny*) ((TUint) aMaxLen);
       
   235 	args[2] = (TAny*) aValue;
       
   236 	args[3] = (TAny*) &aLen;
       
   237 	return DoControl(EHcrGetArrayUInt, (TAny*) args);
       
   238 	}
       
   239 inline TInt RHcrSimTestChannel::GetString(const TSettingId& aId, TDes8& aValue)
       
   240 	{return DoControl(EHcrGetStringDes, (TAny*) &aId, (TAny*) &aValue);}
       
   241 inline TInt RHcrSimTestChannel::GetString(const TSettingId& aId, TUint16 aMaxLen,
       
   242 						TText8* aValue, TUint16& aLen)
       
   243 	{
       
   244 	TAny* args[4];
       
   245 	args[0] = (TAny*) &aId;
       
   246 	args[1] = (TAny*) ((TUint) aMaxLen);
       
   247 	args[2] = (TAny*) aValue;
       
   248 	args[3] = (TAny*) &aLen;
       
   249 	return DoControl(EHcrGetStringArray, (TAny*) args);
       
   250 	}
       
   251 inline TInt RHcrSimTestChannel::InitExtension(const TUint32 aFlags)
       
   252 	{return DoControl(EHcrInitExtension, (TAny*) aFlags);}
       
   253 inline TInt RHcrSimTestChannel::SwitchRepository(const TDesC8& aFileName, HCRInternal::TReposId aId)
       
   254 	{return DoControl(EHcrSwitchRepository, (TAny*) &aFileName, (TAny*) aId);}
       
   255 inline TInt RHcrSimTestChannel::CheckIntegrity()
       
   256 	{return DoControl(EHcrCheckIntegrity);}
       
   257 #endif // __KERNEL_MODE__
       
   258 #endif // D_HCRSIM_H