os/kernelhwsrv/kerneltest/e32test/resourceman/d_rescontrolcli.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2007-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\resourceman\d_rescontrolcli.h
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#ifndef __D_RESCONTROLCLI_H__
sl@0
    19
#define __D_RESCONTROLCLI_H__
sl@0
    20
sl@0
    21
#include <e32cmn.h>
sl@0
    22
#include <e32ver.h>
sl@0
    23
#ifndef __KERNEL_MODE__
sl@0
    24
#include <e32std.h>
sl@0
    25
#endif   
sl@0
    26
sl@0
    27
#ifndef __KERNEL_MODE__
sl@0
    28
//Structure to pass the dependency information
sl@0
    29
struct SResourceDependencyInfo
sl@0
    30
	{
sl@0
    31
	TUint iResourceId;
sl@0
    32
	TUint8 iDependencyPriority;
sl@0
    33
	};
sl@0
    34
#endif
sl@0
    35
sl@0
    36
#define MAX_CLIENTS 50 //Maximum clients allowed
sl@0
    37
sl@0
    38
#ifndef PRM_ENABLE_EXTENDED_VERSION
sl@0
    39
_LIT(KLddName, "D_RESCONTROLCLI.LDD");
sl@0
    40
#else
sl@0
    41
_LIT(KLddName, "D_EXTENDEDRESCONTROLCLI.LDD");
sl@0
    42
#endif
sl@0
    43
sl@0
    44
/** Struture for passing information between user and kernel side.*/
sl@0
    45
struct TParameterListInfo
sl@0
    46
	{
sl@0
    47
	TUint iClientId;
sl@0
    48
	TAny* iPtr1;
sl@0
    49
	TAny* iPtr2;
sl@0
    50
	TAny* iPtr3;
sl@0
    51
	TAny* iPtr4;
sl@0
    52
	TAny* iPtr5;
sl@0
    53
	};
sl@0
    54
sl@0
    55
/** User side logical channel */
sl@0
    56
class RTestResMan : public RBusLogicalChannel
sl@0
    57
	{
sl@0
    58
public:
sl@0
    59
	// Structure for holding driver capabilities information
sl@0
    60
	class TCaps
sl@0
    61
		{
sl@0
    62
	public:
sl@0
    63
		TVersion iVersion;
sl@0
    64
		};
sl@0
    65
sl@0
    66
private:
sl@0
    67
	enum TControl //Request types for synchronous operation.
sl@0
    68
		{ 
sl@0
    69
		ERegisterClient,
sl@0
    70
		EDeRegisterClient,
sl@0
    71
		EGetClientName,
sl@0
    72
		EGetClientId,
sl@0
    73
		EGetResourceId,
sl@0
    74
		EGetResourceInfo,
sl@0
    75
		EGetNumResourcesInUseByClient,
sl@0
    76
		EGetInfoOnResourcesInUseByClient,
sl@0
    77
		EGetNumClientsUsingResource,
sl@0
    78
		EGetInfoOnClientsUsingResource,
sl@0
    79
		EAllocReserve,
sl@0
    80
		ECheckNotifications,
sl@0
    81
		EChangeResourceStateSync,
sl@0
    82
		EGetResourceStateSync,
sl@0
    83
		ERegisterForIdleResourcesInfo,
sl@0
    84
		EGetIdleResourcesInfo,
sl@0
    85
		EDeRegisterClientLevelFromResource,
sl@0
    86
		ERequestNotificationCond,
sl@0
    87
		ERequestNotificationUncond,
sl@0
    88
		ECheckPostBootLevelNotifications,
sl@0
    89
		ECancelNotification, 
sl@0
    90
		EGetControllerVersion,
sl@0
    91
#ifdef PRM_ENABLE_EXTENDED_VERSION
sl@0
    92
		ERegisterDynamicResource,
sl@0
    93
		EDeRegisterDynamicResource,
sl@0
    94
		ERegisterResourceDependency,
sl@0
    95
		EDeRegisterResourceDependency,
sl@0
    96
		EGetNumDependentsForResource,
sl@0
    97
		EGetDependentsIdForResource,
sl@0
    98
#endif //PRM_ENABLE_EXTENDED_VERSION
sl@0
    99
		EMaxControl,
sl@0
   100
		};
sl@0
   101
	enum TRequest //Request types for asynchronous operation
sl@0
   102
		{
sl@0
   103
		EChangeResourceStateAsync = EMaxControl + 1,
sl@0
   104
	    EGetResourceStateAsync, 
sl@0
   105
#ifdef PRM_ENABLE_EXTENDED_VERSION
sl@0
   106
		EChangeResStateAndDeregisterDynamicRes,
sl@0
   107
		ECheckParallelExecutionForChangeResState
sl@0
   108
#endif
sl@0
   109
		};
sl@0
   110
	friend class DTestResManLdd;
sl@0
   111
public:
sl@0
   112
   	TInt Open();
sl@0
   113
    TInt RegisterClient(TUint& aClientId, const TDesC* aClientName, TOwnerType aType=EOwnerProcess);
sl@0
   114
    TInt DeRegisterClient(TUint aClientId);
sl@0
   115
    TInt GetClientName(TUint aClientId, TUint aTargetClientId, TDes8* aClientName);
sl@0
   116
    TInt GetClientId(TUint aClientId, TDesC8& aClientName, TUint& aTargetClientId);
sl@0
   117
    TInt GetResourceId(TUint aClientId, TDesC8& aResourceName, TUint& aResourceId);
sl@0
   118
    TInt GetResourceInfo(TUint aClientId, TUint aResourceId, TAny* aBuf);
sl@0
   119
    TInt GetNumResourcesInUseByClient(TUint aClientId, TUint aTargetClientId,TUint& aNumResources);
sl@0
   120
    TInt GetInfoOnResourcesInUseByClient(TUint aClientId, TUint aTargetClientId, TUint& aNumResources, TAny* info);
sl@0
   121
    TInt GetNumClientsUsingResource(TUint aClientId, TUint aResourceId, TUint& aNumClients);
sl@0
   122
    TInt GetInfoOnClientsUsingResource(TUint aClientId, TUint aResourceId, TUint& aNumClients, TAny* info);
sl@0
   123
    TInt AllocReserve(TUint aClientId, TUint8 aNumClientLevels, TUint8 aNumResources);
sl@0
   124
    TInt CheckNotifications(TUint aResourceId, TUint aUnconNoti, TUint aCondNoti);
sl@0
   125
    TInt ChangeResourceStateSync(TUint aClientId, TUint aResourceId, TInt aNewState);
sl@0
   126
    void ChangeResourceStateAsync(TUint aClientId, TUint aResourceId, TInt& aState, TRequestStatus& aStatus, TBool aReqCancel = EFalse);
sl@0
   127
    TInt GetResourceStateSync(TUint aClientId, TUint aResourceId, TBool aCached, TInt& aNewState, TInt& aLevelOwnerId);
sl@0
   128
    void GetResourceStateAsync(TUint aClientId, TUint aResourceId, TBool aCached, TRequestStatus& aStatus, TInt& aState, TInt& aLevelOwnerId, TBool aReqCancel = EFalse);
sl@0
   129
    TInt RequestNotification(TUint aClientId, TUint aResourceId);
sl@0
   130
    TInt RequestNotification(TUint aClientId, TUint aResourceId, TInt aDirection, TInt aThreshold);
sl@0
   131
    TInt CancelNotification(TUint aClientId, TUint aResourceId, TBool aType);
sl@0
   132
    TInt RegisterForIdleResourcesInfo(TUint aPowerControllerId, TUint aResourceNum, TAny* anInfo);
sl@0
   133
    TInt GetIdleResourcesInfo(TUint aResourceNum, TAny* info);
sl@0
   134
	TInt DeRegisterClientLevelFromResource(TInt aClientId, TUint aResId);
sl@0
   135
	TInt CheckPostBootLevelNotifications();
sl@0
   136
	TInt GetResourceControllerVersion(TUint aClientId, TUint& aVersion);
sl@0
   137
#ifdef PRM_ENABLE_EXTENDED_VERSION
sl@0
   138
	TInt RegisterDynamicResource(TUint aClientId, TUint& aResourceId);
sl@0
   139
	TInt DeRegisterDynamicResource(TUint aClientId, TUint aResourceId, TInt *aLevel);
sl@0
   140
	TInt RegisterResourceDependency(TUint aClientId, SResourceDependencyInfo aInfo1, SResourceDependencyInfo aInfo2);
sl@0
   141
	TInt DeRegisterResourceDependency(TUint aClientId, TUint aResourceId1, TUint aResourceId2);
sl@0
   142
	void ChangeResStateAndDeRegisterDynamicRes(TUint aClientId, TUint aResourceId, TInt &aLevel, TRequestStatus& aStatus);
sl@0
   143
	TInt GetNumDependentsForResource(TUint aClientId, TUint aResourceId, TUint& aNumDepResource);
sl@0
   144
	TInt GetDependentsIdForResource(TUint aClientId, TUint aResourceId, TAny* aResIdArray, TUint& aNumDepResources);
sl@0
   145
	void CheckParallelExecutionForChangeResState(TUint aClientId, TUint aDepResId, TInt& aDepLevel, TUint aResId, TInt aLevel, TRequestStatus& aStatus);
sl@0
   146
#endif //PRM_ENABLE_EXTENDED_VERSION
sl@0
   147
    inline static TVersion VersionRequired();
sl@0
   148
    };
sl@0
   149
sl@0
   150
inline TVersion RTestResMan::VersionRequired()
sl@0
   151
	{
sl@0
   152
	const TInt KMajorVersionNumber=1;
sl@0
   153
	const TInt KMinorVersionNumber=0;
sl@0
   154
	const TInt KBuildVersionNumber=KE32BuildVersionNumber;
sl@0
   155
	return TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);
sl@0
   156
	}
sl@0
   157
sl@0
   158
#ifndef __KERNEL_MODE__
sl@0
   159
sl@0
   160
/** Open a channel for the driver.This driver does not allow more than one channel open at a time. */ 
sl@0
   161
TInt RTestResMan::Open()
sl@0
   162
	{
sl@0
   163
    return DoCreate(KLddName, VersionRequired(),KNullUnit,NULL,NULL);
sl@0
   164
	}
sl@0
   165
sl@0
   166
/** Request to register a client with resource manager
sl@0
   167
	@Param	- aClientId, On Success with be updated with a valid unique clientID,
sl@0
   168
			- aClientName, Name of the client to register with RM,
sl@0
   169
			- aType, Defines ownership, can be either process relative or thread relative
sl@0
   170
	@return- KErrNone on Sucess or one of system wide errors.
sl@0
   171
	*/
sl@0
   172
TInt RTestResMan::RegisterClient(TUint& aClientId, const TDesC* aClientName, TOwnerType aType)
sl@0
   173
	{
sl@0
   174
    TParameterListInfo anInfo;
sl@0
   175
    anInfo.iPtr1 = (TAny*)&aClientId;
sl@0
   176
    anInfo.iPtr2 = (TAny*)aClientName;
sl@0
   177
    anInfo.iPtr3 = (TAny*)aType;
sl@0
   178
    return DoControl(ERegisterClient, (TAny*)&anInfo);
sl@0
   179
	}
sl@0
   180
sl@0
   181
/** Request to deregister a client from RM.
sl@0
   182
	@Param - aClientID, The ID of the Client to deregister
sl@0
   183
	@return- KErrNone on Sucess or one of system wide errors.
sl@0
   184
	*/
sl@0
   185
TInt RTestResMan::DeRegisterClient(TUint aClientId)
sl@0
   186
	{
sl@0
   187
    return DoControl(EDeRegisterClient, (TAny*)aClientId);
sl@0
   188
	}
sl@0
   189
sl@0
   190
/** Request to obtain the name of the specified client of the RM
sl@0
   191
	@Param	- aClientId, Requesting ClientId
sl@0
   192
			- aTargetClientId, Id of the client whose name is requested.
sl@0
   193
			- aClientName, On Success returned with client name.
sl@0
   194
	@return- KErrNone on Sucess or one of system wide errors.
sl@0
   195
	*/
sl@0
   196
TInt RTestResMan::GetClientName(TUint aClientId, TUint aTargetClientId, TDes8* aClientName)
sl@0
   197
	{
sl@0
   198
    TParameterListInfo anInfo;
sl@0
   199
    anInfo.iClientId = aClientId;
sl@0
   200
    anInfo.iPtr1 = (TAny*)aTargetClientId;
sl@0
   201
    anInfo.iPtr2 = (TAny*)aClientName;
sl@0
   202
    return DoControl(EGetClientName, (TAny*)&anInfo);
sl@0
   203
	}
sl@0
   204
sl@0
   205
/** Request to obtain the ID of the specified client of the RM
sl@0
   206
	@Param  - aClientId, Requesting ClientId,
sl@0
   207
			- aClientName, Client Name whose Id is being requested,
sl@0
   208
			- aTargetClientId, On Success with be updated with requested client Id
sl@0
   209
	@return- KErrNone on Sucess or one of system wide errors.	
sl@0
   210
	*/
sl@0
   211
TInt RTestResMan::GetClientId(TUint aClientId, TDesC8& aClientName, TUint& aTargetClientId)
sl@0
   212
	{
sl@0
   213
    TParameterListInfo anInfo;
sl@0
   214
    anInfo.iClientId = aClientId;
sl@0
   215
    anInfo.iPtr1 = (TAny*)&aClientName;
sl@0
   216
    anInfo.iPtr2 = (TAny*)&aTargetClientId;
sl@0
   217
    return DoControl(EGetClientId, (TAny*)&anInfo);
sl@0
   218
	}
sl@0
   219
sl@0
   220
/** Request to obtain the ID of the specified resource of the RM
sl@0
   221
	@Param	- aClientId, Requesting ClientId,
sl@0
   222
			- aResourceName, Resource name whose ID is being requested
sl@0
   223
			- aResourceId, On Success returned with resource id.
sl@0
   224
	@return- KErrNone on Sucess or one of system wide errors.
sl@0
   225
	*/
sl@0
   226
TInt RTestResMan::GetResourceId(TUint aClientId, TDesC8& aResourceName, TUint& aResourceId)
sl@0
   227
	{
sl@0
   228
    TParameterListInfo anInfo;
sl@0
   229
    anInfo.iClientId = aClientId;
sl@0
   230
    anInfo.iPtr1 = (TAny*)&aResourceName;
sl@0
   231
    anInfo.iPtr2 = (TAny*)&aResourceId;
sl@0
   232
    return DoControl(EGetResourceId, (TAny*)&anInfo);
sl@0
   233
	}
sl@0
   234
sl@0
   235
/** Request to obtain the information of the specified resource
sl@0
   236
	@Param	- aClientId, Requesting ClientId,
sl@0
   237
			- aResourceId, Resource Id whose information is requested
sl@0
   238
			- aBuf, On Success filled with resource information
sl@0
   239
	@return- KErrNone on Sucess or one of system wide errors.
sl@0
   240
	*/
sl@0
   241
TInt RTestResMan::GetResourceInfo(TUint aClientId, TUint aResourceId, TAny* aBuf)
sl@0
   242
	{
sl@0
   243
    TParameterListInfo anInfo;
sl@0
   244
    anInfo.iClientId = aClientId;
sl@0
   245
    anInfo.iPtr1 = (TAny*)aResourceId;
sl@0
   246
    anInfo.iPtr2 = aBuf;
sl@0
   247
    return DoControl(EGetResourceInfo, (TAny*)&anInfo);
sl@0
   248
	}
sl@0
   249
sl@0
   250
/** Request to obtain the number of resources the specified client has requirement on resource level.
sl@0
   251
	@Param	- aClientId, Requesting ClientId,
sl@0
   252
			- aTargetClientId, ClientId, the number of resources on which it has requirement is requested.
sl@0
   253
			- aNumResources, On Success contains the number of resources the client has requirement
sl@0
   254
	@return- KErrNone on Sucess or one of system wide errors.
sl@0
   255
	*/
sl@0
   256
TInt RTestResMan::GetNumResourcesInUseByClient(TUint aClientId, TUint aTargetClientId,TUint& aNumResources)
sl@0
   257
	{
sl@0
   258
    TParameterListInfo anInfo;
sl@0
   259
    anInfo.iClientId = aClientId;
sl@0
   260
    anInfo.iPtr1 = (TAny*) aTargetClientId;
sl@0
   261
    anInfo.iPtr2 = (TAny*)&aNumResources;
sl@0
   262
    return DoControl(EGetNumResourcesInUseByClient, (TAny*)&anInfo);
sl@0
   263
	}
sl@0
   264
sl@0
   265
/** Request to obtain the information on resources
sl@0
   266
	@Param	- aClientId, Requesting ClientId,
sl@0
   267
			- aTargetClientId, ClientId, information on all the resources on which it has requirement is requested
sl@0
   268
			- aNumResources, Number of resources whose information needs to be filled (size of info)
sl@0
   269
			- info, On sucess will be filled with resources information.
sl@0
   270
	@return- KErrNone on Sucess or one of system wide errors.
sl@0
   271
	*/
sl@0
   272
TInt RTestResMan::GetInfoOnResourcesInUseByClient(TUint aClientId, TUint aTargetClientId, TUint& aNumResources, TAny* info)
sl@0
   273
	{
sl@0
   274
    TParameterListInfo anInfo;
sl@0
   275
    anInfo.iClientId = aClientId;
sl@0
   276
    anInfo.iPtr1 = (TAny*)aTargetClientId;
sl@0
   277
    anInfo.iPtr2 = (TAny*)&aNumResources;
sl@0
   278
    anInfo.iPtr3 = info;
sl@0
   279
    return DoControl(EGetInfoOnResourcesInUseByClient, (TAny*)&anInfo);
sl@0
   280
	}
sl@0
   281
sl@0
   282
/** Request to obtain the number of clients holding the specified resource.
sl@0
   283
	@Param	- aClientId, Requesting ClientId,
sl@0
   284
			- aResourceId, ID of the resource.
sl@0
   285
			- aNumClients, On Success contains the number of clients holding requirement on specified resource
sl@0
   286
	@return- KErrNone on Sucess or one of system wide errors.
sl@0
   287
	*/
sl@0
   288
TInt RTestResMan::GetNumClientsUsingResource(TUint aClientId, TUint aResourceId, TUint& aNumClients)
sl@0
   289
	{
sl@0
   290
    TParameterListInfo anInfo;
sl@0
   291
    anInfo.iClientId = aClientId;
sl@0
   292
    anInfo.iPtr1 = (TAny*)aResourceId;
sl@0
   293
    anInfo.iPtr2 = (TAny*)&aNumClients;
sl@0
   294
    return DoControl(EGetNumClientsUsingResource, (TAny*)&anInfo);
sl@0
   295
	}
sl@0
   296
sl@0
   297
/** Request to obtain the information on clients
sl@0
   298
	@Param	- aClientId, Requesting ClientId,
sl@0
   299
			- aResourceId, Id of the resource
sl@0
   300
			- aNumClients, Number of Clients whose information needs to be filled (size of info)
sl@0
   301
			- info, On sucess will be filled with client information.
sl@0
   302
	@return- KErrNone on Sucess or one of system wide errors.
sl@0
   303
	*/
sl@0
   304
TInt RTestResMan::GetInfoOnClientsUsingResource(TUint aClientId, TUint aResourceId, TUint& aNumClients, TAny* info)
sl@0
   305
	{
sl@0
   306
    TParameterListInfo anInfo;
sl@0
   307
    anInfo.iClientId = aClientId;
sl@0
   308
    anInfo.iPtr1 = (TAny*)aResourceId;
sl@0
   309
    anInfo.iPtr2 = (TAny*)&aNumClients;
sl@0
   310
    anInfo.iPtr3 = info;
sl@0
   311
    return DoControl(EGetInfoOnClientsUsingResource, (TAny*)&anInfo);
sl@0
   312
	}
sl@0
   313
sl@0
   314
/** Request to preallocate the clientlevel and requests RM internal structures.
sl@0
   315
	@Param	- aClientId, Requesting ClientId,
sl@0
   316
			- aNumClientLevels, Client Level objects to preallocate
sl@0
   317
			- aNumRequests, Request level objects to preallocate
sl@0
   318
	@return- KErrNone on Sucess or one of system wide errors.
sl@0
   319
	*/
sl@0
   320
TInt RTestResMan::AllocReserve(TUint aClientId, TUint8 aNumClientLevels, TUint8 aNumRequests)
sl@0
   321
	{
sl@0
   322
    TParameterListInfo anInfo;
sl@0
   323
    anInfo.iClientId = aClientId;
sl@0
   324
    anInfo.iPtr1 = (TAny*)aNumClientLevels;
sl@0
   325
    anInfo.iPtr2 = (TAny*)aNumRequests;
sl@0
   326
    return DoControl(EAllocReserve, (TAny*)&anInfo);
sl@0
   327
	}
sl@0
   328
sl@0
   329
/** Function to verify the notification sent for the earlier resource state change.
sl@0
   330
	@Param	- aResourceId, Id of the resource whose notifications are verified.
sl@0
   331
			- aUncondNoti, Number of expected unconditional notification
sl@0
   332
			- aCondNoti, Number of expected conditional notification
sl@0
   333
	@return- KErrNone on Sucess or KErrUnderflow
sl@0
   334
	*/
sl@0
   335
TInt RTestResMan::CheckNotifications(TUint aResourceId, TUint aUncondNoti, TUint aCondNoti)
sl@0
   336
	{
sl@0
   337
    TParameterListInfo anInfo;
sl@0
   338
    anInfo.iPtr1 = (TAny*)aResourceId;
sl@0
   339
    anInfo.iPtr2 = (TAny*)aUncondNoti;
sl@0
   340
    anInfo.iPtr3 = (TAny*)aCondNoti;
sl@0
   341
    return DoControl(ECheckNotifications, (TAny*)&anInfo);
sl@0
   342
	}
sl@0
   343
sl@0
   344
/** Request to change the state of the resource synchronously
sl@0
   345
	@Param	- aClientId, Requesting clientId
sl@0
   346
			- aResourceId, Id of the resource whose state change is requested.
sl@0
   347
			- aNewState, Requested new state
sl@0
   348
	@return- KErrNone on Sucess or one of system wide errors.
sl@0
   349
	*/
sl@0
   350
TInt RTestResMan::ChangeResourceStateSync(TUint aClientId, TUint aResourceId, TInt aNewState)
sl@0
   351
	{
sl@0
   352
    TParameterListInfo anInfo;
sl@0
   353
    anInfo.iClientId = aClientId;
sl@0
   354
    anInfo.iPtr1 = (TAny*)aResourceId;
sl@0
   355
    anInfo.iPtr2 = (TAny*)aNewState;
sl@0
   356
    return DoControl(EChangeResourceStateSync, (TAny*)&anInfo);
sl@0
   357
	}
sl@0
   358
sl@0
   359
/** Request to change the state of the resource asynchronously
sl@0
   360
	@Param	- aClientId, Requesting clientId
sl@0
   361
			- aResourceId, Id of the resource whose state change is requested.
sl@0
   362
			- aState, Requested new state
sl@0
   363
			- aStatus, TRequestStatus object to indicate completion of operation
sl@0
   364
			- aReqCancel, If true CancelAsyncOperation API of RM is called immediately after asynchronos request operation
sl@0
   365
	*/
sl@0
   366
void RTestResMan::ChangeResourceStateAsync(TUint aClientId, TUint aResourceId, TInt& aState, TRequestStatus& aStatus, TBool aReqCancel)
sl@0
   367
	{
sl@0
   368
    TParameterListInfo anInfo;
sl@0
   369
    anInfo.iClientId = aClientId;
sl@0
   370
    anInfo.iPtr1 = (TAny*)aResourceId;
sl@0
   371
    anInfo.iPtr2 = (TAny*)&aState;
sl@0
   372
    anInfo.iPtr3 = (TAny*)aReqCancel;
sl@0
   373
    DoRequest(EChangeResourceStateAsync, aStatus, (TAny*)&anInfo);
sl@0
   374
	}
sl@0
   375
sl@0
   376
/** Request to obtain the state of the resource synchronously
sl@0
   377
	@Param	- aClientId, Requesting clientId
sl@0
   378
			- aResourceId, Id of the resource whose state change is requested.
sl@0
   379
			- aCached, if true requesting for cached value
sl@0
   380
			- aNewState, On success returns the new state
sl@0
   381
			- aLevelOwnerId, On success returns the Id of the client currently holding the resource.
sl@0
   382
	@return- KErrNone on Sucess or one of system wide errors.
sl@0
   383
	*/
sl@0
   384
TInt RTestResMan::GetResourceStateSync(TUint aClientId, TUint aResourceId, TBool aCached, TInt& aNewState, TInt& aLevelOwnerId)
sl@0
   385
	{
sl@0
   386
    TParameterListInfo anInfo;
sl@0
   387
    anInfo.iClientId = aClientId;
sl@0
   388
    anInfo.iPtr1 = (TAny*)aResourceId;
sl@0
   389
    anInfo.iPtr2 = (TAny*)aCached;
sl@0
   390
    anInfo.iPtr3 = (TAny*)&aNewState;
sl@0
   391
	anInfo.iPtr4 = (TAny*)&aLevelOwnerId;
sl@0
   392
    return DoControl(EGetResourceStateSync, (TAny*)&anInfo);
sl@0
   393
	}
sl@0
   394
sl@0
   395
/** Request to obtain the state of the resource asynchronously
sl@0
   396
	@Param	- aClientId, Requesting clientId
sl@0
   397
			- aResourceId, Id of the resource whose state change is requested.
sl@0
   398
			- aCached, if true requesting for cached value
sl@0
   399
			- aStatus, TRequestStatus object to indicate completion of operation
sl@0
   400
			- aReqCancel, If true CancelAsyncOperation API of RM is called immediately after asynchronos request operation
sl@0
   401
	*/
sl@0
   402
void RTestResMan::GetResourceStateAsync(TUint aClientId, TUint aResourceId, TBool aCached, TRequestStatus& aStatus, TInt& aState, TInt& aLevelOwnerId, TBool aReqCancel)
sl@0
   403
	{
sl@0
   404
    TParameterListInfo anInfo;
sl@0
   405
    anInfo.iClientId = aClientId;
sl@0
   406
    anInfo.iPtr1 = (TAny*)aResourceId;
sl@0
   407
    anInfo.iPtr2 = (TAny*)aCached;
sl@0
   408
    anInfo.iPtr3 = (TAny*)aReqCancel;
sl@0
   409
	anInfo.iPtr4 = (TAny*)&aState;
sl@0
   410
	anInfo.iPtr5 = (TAny*)&aLevelOwnerId;
sl@0
   411
    DoRequest(EGetResourceStateAsync, aStatus, (TAny*)&anInfo);
sl@0
   412
	}
sl@0
   413
sl@0
   414
/** Request to notify when the state of the specified resource changes
sl@0
   415
	@Param	- aClientId, Requesting clientId,
sl@0
   416
			- aResourceId, ID of the resource
sl@0
   417
	@return- KErrNone on Sucess or one of system wide errors.
sl@0
   418
	*/
sl@0
   419
TInt RTestResMan::RequestNotification(TUint aClientId, TUint aResourceId)
sl@0
   420
	{
sl@0
   421
    return DoControl(ERequestNotificationUncond, (TAny*)aClientId, (TAny*)aResourceId);
sl@0
   422
	}
sl@0
   423
sl@0
   424
/** Request to notify when the state of the specified resource change crosses the threshold in the specified direction
sl@0
   425
	@Param	- aClientId, Requesting clientId,
sl@0
   426
			- aResourceId, ID of the resource,
sl@0
   427
			- aDirection, Direction of change of the resource state that will trigger the notification
sl@0
   428
			- aThreshold, Level of resource state that will trigger the notifications when reached.
sl@0
   429
	@return- KErrNone on Sucess or one of system wide errors.
sl@0
   430
	*/
sl@0
   431
TInt RTestResMan::RequestNotification(TUint aClientId, TUint aResourceId, TInt aDirection, TInt aThreshold)
sl@0
   432
	{
sl@0
   433
    TParameterListInfo anInfo;
sl@0
   434
    anInfo.iClientId = aClientId;
sl@0
   435
    anInfo.iPtr1 = (TAny*)aResourceId;
sl@0
   436
    anInfo.iPtr2 = (TAny*)aThreshold;
sl@0
   437
    anInfo.iPtr3 = (TAny*)aDirection;
sl@0
   438
    return DoControl(ERequestNotificationCond, (TAny*)&anInfo);
sl@0
   439
	}
sl@0
   440
sl@0
   441
/** Request to cancel the previously requested notification
sl@0
   442
	@Param	- aClientId, Requesting clientId
sl@0
   443
			- aResourceId, ID of the resource
sl@0
   444
			- aType, ETrue Conditional
sl@0
   445
	@return- KErrCancel on Sucess or one of system wide errors.
sl@0
   446
	*/
sl@0
   447
TInt RTestResMan::CancelNotification(TUint aClientId, TUint aResourceId, TBool aType)
sl@0
   448
	{
sl@0
   449
    TParameterListInfo anInfo;
sl@0
   450
    anInfo.iClientId = aClientId;
sl@0
   451
    anInfo.iPtr1 = (TAny*)aResourceId;
sl@0
   452
    anInfo.iPtr2 = (TAny*)aType;
sl@0
   453
    return DoControl(ECancelNotification, (TAny*)&anInfo);
sl@0
   454
	}
sl@0
   455
sl@0
   456
/** Request to register the specified number of resources to RM to keep the list updated with the
sl@0
   457
	cached value of the resources and owner of the resources. This is used for testing of the API.
sl@0
   458
	@Param	- aResourceNum - Number of resource, whose information needs to be cached
sl@0
   459
	@return- KErrNone on Sucess or one of system wide errors.
sl@0
   460
	*/
sl@0
   461
TInt RTestResMan::RegisterForIdleResourcesInfo(TUint aPowerControllerId, TUint aResourceNum, TAny* aPtr)
sl@0
   462
     {
sl@0
   463
	 TParameterListInfo anInfo;
sl@0
   464
	 anInfo.iClientId = aPowerControllerId;
sl@0
   465
	 anInfo.iPtr1 = (TAny*)aResourceNum;
sl@0
   466
	 anInfo.iPtr2 = (TAny*)aPtr;
sl@0
   467
     return DoControl(ERegisterForIdleResourcesInfo, (TAny*)&anInfo);
sl@0
   468
     }
sl@0
   469
sl@0
   470
/** Request to Deregister client level from resource. 
sl@0
   471
	@Param - aClientId - ID of the client requesting deregistration.
sl@0
   472
	@Param - aResId - ID of the resource from which to deregister the client level of requested client.
sl@0
   473
	@return KErrNone on Sucess or one of system wide errors.
sl@0
   474
	*/
sl@0
   475
TInt RTestResMan::DeRegisterClientLevelFromResource(TInt aClientId, TUint aResId)
sl@0
   476
	{
sl@0
   477
	return DoControl(EDeRegisterClientLevelFromResource, (TAny*)aClientId, (TAny*)aResId);
sl@0
   478
	}
sl@0
   479
sl@0
   480
sl@0
   481
/** Request to get the information of the all the resources cached by RM as requested by 
sl@0
   482
	RegisterForIdleResourcesInfo API
sl@0
   483
	@Param	- aResourceNum - Number of resources (size of info)
sl@0
   484
			- info, On success returns with resource infomations
sl@0
   485
	@return- KErrNone on Sucess or one of system wide errors.
sl@0
   486
	*/
sl@0
   487
TInt RTestResMan::GetIdleResourcesInfo(TUint aResourceNum, TAny* info)
sl@0
   488
     {
sl@0
   489
     return DoControl(EGetIdleResourcesInfo, (TAny*)aResourceNum, (TAny*)info);
sl@0
   490
     }
sl@0
   491
sl@0
   492
/** Request to check the notifications recieved as a result of postboot level setting. 
sl@0
   493
	@return KErrNone on success or one of system wide errors.
sl@0
   494
	*/
sl@0
   495
TInt RTestResMan::CheckPostBootLevelNotifications()
sl@0
   496
	{
sl@0
   497
	return DoControl(ECheckPostBootLevelNotifications, (TAny*)NULL, (TAny*)NULL);
sl@0
   498
	}
sl@0
   499
sl@0
   500
/** Get the version of Resource Controller
sl@0
   501
	@Param - aClientId - Id of the client requesting version information
sl@0
   502
	@Param - aVersion - Version will be updated. 0 - Basic, 1- extended version
sl@0
   503
	@return KErrNone on success or one of system wide errors.
sl@0
   504
	*/
sl@0
   505
TInt RTestResMan::GetResourceControllerVersion(TUint aClientId, TUint& aVersion)
sl@0
   506
	{
sl@0
   507
	return DoControl(EGetControllerVersion, (TAny*)aClientId, (TAny*)&aVersion);
sl@0
   508
	}
sl@0
   509
sl@0
   510
#ifdef PRM_ENABLE_EXTENDED_VERSION
sl@0
   511
/** Register dynamic resource.
sl@0
   512
	@Param - aClientId - Id of the client that is registering the dynamic resource
sl@0
   513
	@Param - aResourceId - On success will be updated with the resource id allocated for this resource
sl@0
   514
	@return KErrNone on success or one of system wide errors.
sl@0
   515
	*/
sl@0
   516
TInt RTestResMan::RegisterDynamicResource(TUint aClientId, TUint& aResourceId)
sl@0
   517
	{
sl@0
   518
	return DoControl(ERegisterDynamicResource, (TAny*)aClientId, (TAny*)&aResourceId);
sl@0
   519
	}
sl@0
   520
sl@0
   521
/** Deregister dynamic resource.
sl@0
   522
	@Param - aClientId - Id of the client that is deregistering the dynamic resource
sl@0
   523
	@Param - aResourceId - Id of the dynamic resource to deregister
sl@0
   524
	@Param - aLevel - Pointer to the required final state. 
sl@0
   525
	@return KErrNone on success or one of system wide errors.
sl@0
   526
	*/
sl@0
   527
TInt RTestResMan::DeRegisterDynamicResource(TUint aClientId, TUint aResourceId, TInt *aLevel)
sl@0
   528
	{
sl@0
   529
    TParameterListInfo anInfo;
sl@0
   530
    anInfo.iClientId = aClientId;
sl@0
   531
    anInfo.iPtr1 = (TAny*)aResourceId;
sl@0
   532
    anInfo.iPtr2 = (TAny*)aLevel;
sl@0
   533
    return DoControl(EDeRegisterDynamicResource, (TAny*)&anInfo);
sl@0
   534
	}
sl@0
   535
sl@0
   536
/** Change the resource state asynchronously and immediately try to deregister dynamic resource.
sl@0
   537
	@Param - aClientId - Id of the client that is requesting the resource state change.
sl@0
   538
	@Param - aResourceId - Id of the resource whose state change is requested.
sl@0
   539
	@Param - aLevel - Requested new state
sl@0
   540
	@Param - aStatus, TRequestStatus object to indicate completion of operation
sl@0
   541
	@return KErrNone on success or one of system wide errors.
sl@0
   542
	*/
sl@0
   543
void RTestResMan::ChangeResStateAndDeRegisterDynamicRes(TUint aClientId, TUint aResourceId, TInt &aLevel, TRequestStatus &aStatus)
sl@0
   544
	{
sl@0
   545
    TParameterListInfo anInfo;
sl@0
   546
    anInfo.iClientId = aClientId;
sl@0
   547
    anInfo.iPtr1 = (TAny*)aResourceId;
sl@0
   548
    anInfo.iPtr2 = (TAny*)&aLevel;
sl@0
   549
    DoRequest(EChangeResStateAndDeregisterDynamicRes, aStatus, (TAny*)&anInfo);
sl@0
   550
	}
sl@0
   551
sl@0
   552
/** Register depedency between resources.
sl@0
   553
	@Param - aClientId - Id of the client that is establishing the dependency.
sl@0
   554
	@Param - aInfo1 - Infomation about the first resource in the dependency link.
sl@0
   555
	@Param - aInfo2 - Information about the second resource in the dependency link.
sl@0
   556
	@return KErrNone on success or one of the system wide errors.
sl@0
   557
    */
sl@0
   558
TInt RTestResMan::RegisterResourceDependency(TUint aClientId, SResourceDependencyInfo aInfo1, SResourceDependencyInfo aInfo2)
sl@0
   559
	{
sl@0
   560
    TParameterListInfo anInfo;
sl@0
   561
    anInfo.iClientId = aClientId;
sl@0
   562
    anInfo.iPtr1 = (TAny*)&aInfo1;
sl@0
   563
    anInfo.iPtr2 = (TAny*)&aInfo2;
sl@0
   564
    return DoControl(ERegisterResourceDependency, (TAny*)&anInfo);
sl@0
   565
	}
sl@0
   566
sl@0
   567
/** Deregister dependency between resources.
sl@0
   568
	@Param - aClientId - Id of the client that is deregistering the resource dependency
sl@0
   569
	@Param - aResourceId1 - Id of the first resource in the dependency link that is being deregistered.
sl@0
   570
	@Param - aResourceId2 - Id of the second resource in the dependency link that is being deregistered.
sl@0
   571
	@return KErrNone on success or one of the system wide errors.
sl@0
   572
	*/
sl@0
   573
TInt RTestResMan::DeRegisterResourceDependency(TUint aClientId, TUint aResourceId1, TUint aResourceId2)
sl@0
   574
	{
sl@0
   575
    TParameterListInfo anInfo;
sl@0
   576
    anInfo.iClientId = aClientId;
sl@0
   577
    anInfo.iPtr1 = (TAny*)aResourceId1;
sl@0
   578
    anInfo.iPtr2 = (TAny*)aResourceId2;
sl@0
   579
    return DoControl(EDeRegisterResourceDependency, (TAny*)&anInfo);
sl@0
   580
	}
sl@0
   581
sl@0
   582
/** Get number of dependents for the specified resource
sl@0
   583
	@Param - aClientId - Id of the client that is requesting dependents count
sl@0
   584
	@Param - aResourceId - Id of the resource whose number of dependents is requested.
sl@0
   585
	@Param - aNumDepResource - On success will be updated with number of dependents.
sl@0
   586
	@return KErrNone on success or one of the system wide errors.
sl@0
   587
	*/
sl@0
   588
TInt RTestResMan::GetNumDependentsForResource(TUint aClientId, TUint aResourceId, TUint& aNumDepResource)
sl@0
   589
	{
sl@0
   590
	TParameterListInfo anInfo;
sl@0
   591
	anInfo.iClientId = aClientId;
sl@0
   592
	anInfo.iPtr1 = (TAny*)aResourceId;
sl@0
   593
	anInfo.iPtr2 = (TAny*)&aNumDepResource;
sl@0
   594
	return DoControl(EGetNumDependentsForResource, (TAny*)&anInfo);
sl@0
   595
	}
sl@0
   596
sl@0
   597
/** Get dependent resource id's for the specified resource
sl@0
   598
	@Param - aClientId - Id of the client that is requesting the dependent id list.
sl@0
   599
	@Param - aResIdArray - On success will be updated with dependent resource id.
sl@0
   600
	@Param - aNumDepResources - Will be updated with actual number of dependents.
sl@0
   601
	@return KErrNone on success or one of the system wide errors.
sl@0
   602
	*/
sl@0
   603
TInt RTestResMan::GetDependentsIdForResource(TUint aClientId, TUint aResourceId, TAny* aResIdArray, TUint& aNumDepResources)
sl@0
   604
	{
sl@0
   605
	TParameterListInfo anInfo;
sl@0
   606
	anInfo.iClientId = aClientId;
sl@0
   607
	anInfo.iPtr1 = (TAny*)aResourceId;
sl@0
   608
	anInfo.iPtr2 = (TAny*)aResIdArray;
sl@0
   609
	anInfo.iPtr3 = (TAny*)&aNumDepResources;
sl@0
   610
	return DoControl(EGetDependentsIdForResource, (TAny*)&anInfo);
sl@0
   611
	}
sl@0
   612
/** Checks for state change of dependency resource while deregistering the non-dependency resource.
sl@0
   613
	@Param - aClientId - Id of the client that is requesting this operation
sl@0
   614
	@Param - aDepResInfo - Embeds resource id, level and status for dependency resource
sl@0
   615
	@Param - aDepLevel - the level to which the dependency resource is moved to.
sl@0
   616
	@Param - aResId - Id of the static resource.
sl@0
   617
	@Param - aLevel - the level to which the static resource is moved to.
sl@0
   618
	@Param - aStatus - to recieve the status of asynchronous operation.
sl@0
   619
	@return KErrNone on success or one of the system wide errors.
sl@0
   620
	*/
sl@0
   621
void RTestResMan::CheckParallelExecutionForChangeResState(TUint aClientId, TUint aDepResId, TInt& aDepLevel, 
sl@0
   622
												TUint aResId, TInt aLevel, TRequestStatus& aStatus)
sl@0
   623
	{
sl@0
   624
	TParameterListInfo anInfo;
sl@0
   625
	anInfo.iClientId = aClientId;
sl@0
   626
	anInfo.iPtr1 = (TAny*)aDepResId;
sl@0
   627
	anInfo.iPtr2 = (TAny*)&aDepLevel;
sl@0
   628
	anInfo.iPtr3 = (TAny*)aResId;
sl@0
   629
	anInfo.iPtr4 = (TAny*)aLevel;
sl@0
   630
	DoRequest(ECheckParallelExecutionForChangeResState, aStatus, (TAny*)&anInfo);
sl@0
   631
	}
sl@0
   632
#endif //PRM_ENABLE_EXTENDED_VERSION
sl@0
   633
sl@0
   634
#endif //__KERNEL_MODE__
sl@0
   635
#endif //__D_RESCONTROLCLI_H__