os/kernelhwsrv/kerneltest/e32test/resourceman/resourceman_psl/rescontrol_psl.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) 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\resourceman_psl\rescontrol_psl.h
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#ifndef __RESCONTROL_PSL_H__
sl@0
    19
#define __RESCONTROL_PSL_H__
sl@0
    20
#include <drivers/resourcecontrol.h>
sl@0
    21
#include <kernel/kernel.h>
sl@0
    22
#include <kernel/kern_priv.h>
sl@0
    23
#define E_ON 0x1
sl@0
    24
#define E_OFF 0x0
sl@0
    25
sl@0
    26
//Specifies the number of pre-allocate the PIL data structures.
sl@0
    27
#define KERNEL_CLIENTS 0x32
sl@0
    28
#define USER_CLIENTS 0x10
sl@0
    29
#define CLIENT_LEVELS 0x32
sl@0
    30
#define REQUESTS 0x19
sl@0
    31
sl@0
    32
#define MAX_RESOURCE_COUNT 30
sl@0
    33
#define MAX_DEPENDENT_RESOURCE_COUNT 10
sl@0
    34
sl@0
    35
#define MAX_BLOCK_TIME 200 //Maximum block time
sl@0
    36
#define MIN_BLOCK_TIME 50 //Guaranteed minimum block
sl@0
    37
sl@0
    38
#define CLEAN_AND_RETURN(resCount, resArray, error)				\
sl@0
    39
	{															\
sl@0
    40
	for(TUint count = 0; count < resCount; count++)				\
sl@0
    41
		delete resArray[count];									\
sl@0
    42
	delete resArray;											\
sl@0
    43
	return error;												\
sl@0
    44
	}
sl@0
    45
sl@0
    46
const TUint KBinary = 0x0;
sl@0
    47
const TUint KMultiLevel = 0x1;
sl@0
    48
sl@0
    49
_LIT(KResmanName, "DSimulatedResMan");
sl@0
    50
/** Simulated resource controller class */
sl@0
    51
NONSHARABLE_CLASS(DSimulatedPowerResourceController): public DPowerResourceController
sl@0
    52
    {
sl@0
    53
public:
sl@0
    54
    DSimulatedPowerResourceController();
sl@0
    55
	~DSimulatedPowerResourceController();
sl@0
    56
    TInt DoInitController();
sl@0
    57
    TInt DoInitResources();
sl@0
    58
    TInt DoRegisterStaticResources(DStaticPowerResource**& aStaticResourceArray, TUint16& aStaticResourceCount);
sl@0
    59
	// Function to process instantaneous resources
sl@0
    60
    TInt ProcessInstantaneousResources(TPowerRequest& req, TInt& aClientLevel, TInt aMaxLevel, TInt aMinLevel, TInt aDefaultLevel);
sl@0
    61
	// Function to procces polled resources
sl@0
    62
    TInt ProcessPolledResources(TPowerRequest& req, TInt& aClientLevel, TInt aMaxLevel, TInt aMinLevel, TInt aDefaultLevel, TInt aBlockTime = 0);
sl@0
    63
	// Function to change the state of the resource
sl@0
    64
    TInt ChangeResource(TPowerRequest& req, TInt& aClientLevel, TInt aMaxLevel, TInt aMinLevel);
sl@0
    65
	// Function to process event driven resources
sl@0
    66
    TInt ProcessEventResources(TPowerRequest& req, TInt& aClientLevel, TInt aMaxLevel, TInt aMinLevel, TInt aDefaultLevel, TInt aBlockTime = 0);
sl@0
    67
    IMPORT_C static TInt CaptureIdleResourcesInfo(TUint aControllerId, TUint aNumResources, TPtr* aPtr);
sl@0
    68
	IMPORT_C static TInt CompleteResourceControllerInitialisation();
sl@0
    69
#ifdef PRM_ENABLE_EXTENDED_VERSION
sl@0
    70
	TInt DoRegisterStaticResourcesDependency(DStaticPowerResourceD**& aStaticResourceDArray, TUint16& aStaticResourceDCount);
sl@0
    71
	TInt CreateResourceDependency(DStaticPowerResourceD** pResArray);
sl@0
    72
#endif
sl@0
    73
private:
sl@0
    74
    static void TimerIsrFunc(TAny* ptr); //ISR Function called when specfied timer expires. This is for even driven resources
sl@0
    75
    static void EventDfcFunc(TAny* ptr); //Function to wakeup the fast semphore. This is called from timer ISR.
sl@0
    76
    DStaticPowerResource** iResources;
sl@0
    77
    TUint16 iStaticResourceCount;
sl@0
    78
    NFastSemaphore iEventFastSem; //Semphore to block the PIL of resource controller for event driven resource operations.
sl@0
    79
    TDfc iEventDfc; //Dfc to run to signal the event semaphore when the timer expires. Queued from timer ISR
sl@0
    80
#ifdef PRM_ENABLE_EXTENDED_VERSION
sl@0
    81
	DStaticPowerResourceD** iDependencyResources;
sl@0
    82
	TUint16 iStaticResDependencyCount;
sl@0
    83
	SNode* iNodeArray;
sl@0
    84
	TUint16 iNodeCount;
sl@0
    85
#endif
sl@0
    86
    };
sl@0
    87
sl@0
    88
#ifdef PRM_ENABLE_EXTENDED_VERSION
sl@0
    89
DSimulatedPowerResourceController* GetControllerPtr();
sl@0
    90
#endif
sl@0
    91
//class definition for Binary Single Instantaneous Positive resource
sl@0
    92
NONSHARABLE_CLASS(DBSIGISPResource) : public DStaticPowerResource
sl@0
    93
	{
sl@0
    94
public:
sl@0
    95
    DBSIGISPResource();
sl@0
    96
    TInt DoRequest(TPowerRequest &req);
sl@0
    97
    TInt GetInfo(TDes8* aInfo) const;
sl@0
    98
private:
sl@0
    99
    TInt iMinLevel;
sl@0
   100
    TInt iMaxLevel;
sl@0
   101
    TInt iCurrentLevel;
sl@0
   102
	};
sl@0
   103
sl@0
   104
//class definition for multilevel single instantaneous positive resource
sl@0
   105
NONSHARABLE_CLASS(DMLSIGISPResource) : public DStaticPowerResource
sl@0
   106
	{
sl@0
   107
public:
sl@0
   108
    DMLSIGISPResource();
sl@0
   109
    TInt DoRequest(TPowerRequest &req);
sl@0
   110
    TInt GetInfo(TDes8* aInfo) const;
sl@0
   111
private:
sl@0
   112
    TInt iMinLevel;
sl@0
   113
    TInt iMaxLevel;
sl@0
   114
    TInt iCurrentLevel;
sl@0
   115
	};
sl@0
   116
sl@0
   117
//class definition for binary single instantaneous negative resource
sl@0
   118
NONSHARABLE_CLASS(DBSIGISNResource) : public DStaticPowerResource
sl@0
   119
	{
sl@0
   120
public:
sl@0
   121
    DBSIGISNResource();
sl@0
   122
    TInt DoRequest(TPowerRequest &req);
sl@0
   123
    TInt GetInfo(TDes8* aInfo) const;
sl@0
   124
private:
sl@0
   125
    TInt iMinLevel;
sl@0
   126
    TInt iMaxLevel;
sl@0
   127
    TInt iCurrentLevel;
sl@0
   128
	};
sl@0
   129
sl@0
   130
//class definition for multilevel single instantaneous negative resource
sl@0
   131
NONSHARABLE_CLASS(DMLSIGISNResource) : public DStaticPowerResource
sl@0
   132
	{
sl@0
   133
public:
sl@0
   134
    DMLSIGISNResource();
sl@0
   135
    TInt DoRequest(TPowerRequest &req);
sl@0
   136
    TInt GetInfo(TDes8* aInfo) const;
sl@0
   137
private:
sl@0
   138
    TInt iMinLevel;
sl@0
   139
    TInt iMaxLevel;
sl@0
   140
    TInt iCurrentLevel;
sl@0
   141
	};
sl@0
   142
sl@0
   143
//class definition for binary single long latency positive resource
sl@0
   144
NONSHARABLE_CLASS(DBSLGLSPResource) : public DStaticPowerResource
sl@0
   145
	{
sl@0
   146
public:
sl@0
   147
    DBSLGLSPResource();
sl@0
   148
    TInt DoRequest(TPowerRequest &req);
sl@0
   149
    TInt GetInfo(TDes8* aInfo) const;
sl@0
   150
private:
sl@0
   151
    TInt iMinLevel;
sl@0
   152
    TInt iMaxLevel;
sl@0
   153
    TInt iCurrentLevel;
sl@0
   154
    TBool iPolled;
sl@0
   155
	TInt iBlockTime; //Time duration the thread will be blocked. 
sl@0
   156
	};
sl@0
   157
sl@0
   158
//class definition for multilevel single long latency positive resource
sl@0
   159
NONSHARABLE_CLASS(DMLSLGLSPResource) : public DStaticPowerResource
sl@0
   160
	{
sl@0
   161
public:
sl@0
   162
    DMLSLGLSPResource();
sl@0
   163
    TInt DoRequest(TPowerRequest &req);
sl@0
   164
    TInt GetInfo(TDes8* aInfo) const;
sl@0
   165
private:
sl@0
   166
    TInt iMinLevel;
sl@0
   167
    TInt iMaxLevel;
sl@0
   168
    TInt iCurrentLevel;
sl@0
   169
    TBool iPolled; 
sl@0
   170
	TInt iBlockTime; //Time duration the thread will be blocked. 
sl@0
   171
	};
sl@0
   172
sl@0
   173
//class definition for binary single long latency get & instantaneous set negative resource
sl@0
   174
NONSHARABLE_CLASS(DBSLGISNResource) : public DStaticPowerResource
sl@0
   175
	{
sl@0
   176
public:
sl@0
   177
    DBSLGISNResource();
sl@0
   178
    TInt DoRequest(TPowerRequest &req);
sl@0
   179
    TInt GetInfo(TDes8* aInfo) const;
sl@0
   180
private:
sl@0
   181
    TInt iMinLevel;
sl@0
   182
    TInt iMaxLevel;
sl@0
   183
    TInt iCurrentLevel;
sl@0
   184
    TBool iPolled;
sl@0
   185
	TInt iBlockTime; //Time duration the thread will be blocked. 
sl@0
   186
	};
sl@0
   187
sl@0
   188
//class definition for multilevel single long latency get & instantaneous set negative resource
sl@0
   189
NONSHARABLE_CLASS(DMLSLGISNResource) : public DStaticPowerResource
sl@0
   190
	{
sl@0
   191
public:
sl@0
   192
    DMLSLGISNResource();
sl@0
   193
    TInt DoRequest(TPowerRequest &req);
sl@0
   194
    TInt GetInfo(TDes8* aInfo) const;
sl@0
   195
private:
sl@0
   196
    TInt iMinLevel;
sl@0
   197
    TInt iMaxLevel;
sl@0
   198
    TInt iCurrentLevel;
sl@0
   199
    TBool iPolled;
sl@0
   200
	TInt iBlockTime; //Time duration the thread will be blocked. 
sl@0
   201
	};
sl@0
   202
sl@0
   203
//class definition for binary single instantaneous get & long latency set positive resource
sl@0
   204
NONSHARABLE_CLASS(DBSIGLSPResource) : public DStaticPowerResource
sl@0
   205
	{
sl@0
   206
public:
sl@0
   207
    DBSIGLSPResource();
sl@0
   208
    TInt DoRequest(TPowerRequest &req);
sl@0
   209
    TInt GetInfo(TDes8* aInfo) const;
sl@0
   210
private:
sl@0
   211
    TInt iMinLevel;
sl@0
   212
    TInt iMaxLevel;
sl@0
   213
    TInt iCurrentLevel;
sl@0
   214
    TBool iPolled;
sl@0
   215
	TInt iBlockTime; //Time duration the thread will be blocked. 
sl@0
   216
	};
sl@0
   217
sl@0
   218
//class definition for multilevel single instantaneous get & long latency get positive resource
sl@0
   219
NONSHARABLE_CLASS(DMLSIGLSPResource) : public DStaticPowerResource
sl@0
   220
	{
sl@0
   221
public:
sl@0
   222
    DMLSIGLSPResource();
sl@0
   223
    TInt DoRequest(TPowerRequest &req);
sl@0
   224
    TInt GetInfo(TDes8* aInfo) const;
sl@0
   225
private:
sl@0
   226
    TInt iMinLevel;
sl@0
   227
    TInt iMaxLevel;
sl@0
   228
    TInt iCurrentLevel;
sl@0
   229
    TBool iPolled;
sl@0
   230
	TInt iBlockTime; //Time duration the thread will be blocked. 
sl@0
   231
	};
sl@0
   232
sl@0
   233
//class definition for Binary Shared Instantaneous Positive resource
sl@0
   234
NONSHARABLE_CLASS(DBSHIGISPResource) : public DStaticPowerResource
sl@0
   235
	{
sl@0
   236
public:
sl@0
   237
    DBSHIGISPResource();
sl@0
   238
    TInt DoRequest(TPowerRequest &req);
sl@0
   239
    TInt GetInfo(TDes8* aInfo) const;
sl@0
   240
private:
sl@0
   241
    TInt iMinLevel;
sl@0
   242
    TInt iMaxLevel;
sl@0
   243
    TInt iCurrentLevel;
sl@0
   244
	};
sl@0
   245
sl@0
   246
//class definition for multilevel shared instantaneous positive resource
sl@0
   247
NONSHARABLE_CLASS(DMLSHIGISPResource) : public DStaticPowerResource
sl@0
   248
	{
sl@0
   249
public:
sl@0
   250
    DMLSHIGISPResource();
sl@0
   251
    TInt DoRequest(TPowerRequest &req);
sl@0
   252
    TInt GetInfo(TDes8* aInfo) const;
sl@0
   253
private:
sl@0
   254
    TInt iMinLevel;
sl@0
   255
    TInt iMaxLevel;
sl@0
   256
    TInt iCurrentLevel;
sl@0
   257
	};
sl@0
   258
sl@0
   259
//class definition for binary shared instantaneous negative resource
sl@0
   260
NONSHARABLE_CLASS(DBSHIGISNResource) : public DStaticPowerResource
sl@0
   261
	{
sl@0
   262
public:
sl@0
   263
    DBSHIGISNResource();
sl@0
   264
    TInt DoRequest(TPowerRequest &req);
sl@0
   265
    TInt GetInfo(TDes8* aInfo) const;
sl@0
   266
private:
sl@0
   267
    TInt iMinLevel;
sl@0
   268
    TInt iMaxLevel;
sl@0
   269
    TInt iCurrentLevel;
sl@0
   270
	};
sl@0
   271
sl@0
   272
//class definition for multilevel shared instantaneous negative resource
sl@0
   273
NONSHARABLE_CLASS(DMLSHIGISNResource) : public DStaticPowerResource
sl@0
   274
	{
sl@0
   275
public:
sl@0
   276
    DMLSHIGISNResource();
sl@0
   277
    TInt DoRequest(TPowerRequest &req);
sl@0
   278
    TInt GetInfo(TDes8* aInfo) const;
sl@0
   279
private:
sl@0
   280
    TInt iMinLevel;
sl@0
   281
    TInt iMaxLevel;
sl@0
   282
    TInt iCurrentLevel;
sl@0
   283
	};
sl@0
   284
sl@0
   285
//class definition for binary shared long latency positive resource
sl@0
   286
NONSHARABLE_CLASS(DBSHLGLSPResource) : public DStaticPowerResource
sl@0
   287
	{
sl@0
   288
public:
sl@0
   289
    DBSHLGLSPResource();
sl@0
   290
    TInt DoRequest(TPowerRequest &req);
sl@0
   291
    TInt GetInfo(TDes8* aInfo) const;
sl@0
   292
private:
sl@0
   293
    TInt iMinLevel;
sl@0
   294
    TInt iMaxLevel;
sl@0
   295
    TInt iCurrentLevel;
sl@0
   296
    TBool iPolled; //ETrue if this is a polled resource, otherwise event driven type
sl@0
   297
	TInt iBlockTime; //Time duration the thread will be blocked. 
sl@0
   298
	};
sl@0
   299
sl@0
   300
//class definition for multilevel shared long latency positive resource
sl@0
   301
NONSHARABLE_CLASS(DMLSHLGLSPResource) : public DStaticPowerResource
sl@0
   302
	{
sl@0
   303
public:
sl@0
   304
    DMLSHLGLSPResource();
sl@0
   305
    TInt DoRequest(TPowerRequest &req);
sl@0
   306
    TInt GetInfo(TDes8* aInfo) const;
sl@0
   307
private:
sl@0
   308
    TInt iMinLevel;
sl@0
   309
    TInt iMaxLevel;
sl@0
   310
    TInt iCurrentLevel;
sl@0
   311
    TBool iPolled; //ETrue if this is a polled resource, otherwise event driven type
sl@0
   312
	TInt iBlockTime; //Time duration the thread will be blocked. 
sl@0
   313
	};
sl@0
   314
sl@0
   315
//class definition for binary shared long latency get & instantaneous set negative resource
sl@0
   316
NONSHARABLE_CLASS(DBSHLGISNResource) : public DStaticPowerResource
sl@0
   317
	{
sl@0
   318
public:
sl@0
   319
    DBSHLGISNResource();
sl@0
   320
    TInt DoRequest(TPowerRequest &req);
sl@0
   321
    TInt GetInfo(TDes8* aInfo) const;
sl@0
   322
private:
sl@0
   323
    TInt iMinLevel;
sl@0
   324
    TInt iMaxLevel;
sl@0
   325
    TInt iCurrentLevel;
sl@0
   326
    TBool iPolled; //ETrue if this is a polled resource, otherwise event driven type
sl@0
   327
	TInt iBlockTime; //Time duration the thread will be blocked. 
sl@0
   328
	};
sl@0
   329
sl@0
   330
//class definition for multilevel shared long latency get & instantaneous set negative resource
sl@0
   331
NONSHARABLE_CLASS(DMLSHLGISNResource) : public DStaticPowerResource
sl@0
   332
	{
sl@0
   333
public:
sl@0
   334
    DMLSHLGISNResource();
sl@0
   335
    TInt DoRequest(TPowerRequest &req);
sl@0
   336
    TInt GetInfo(TDes8* aInfo) const;
sl@0
   337
private:
sl@0
   338
    TInt iMinLevel;
sl@0
   339
    TInt iMaxLevel;
sl@0
   340
    TInt iCurrentLevel;
sl@0
   341
    TBool iPolled; //ETrue if this is a polled resource, otherwise event driven type
sl@0
   342
	TInt iBlockTime; //Time duration the thread will be blocked. 
sl@0
   343
	};
sl@0
   344
sl@0
   345
//class definition for binary shared instantaneous get & long latency set positive resource
sl@0
   346
NONSHARABLE_CLASS(DBSHIGLSPResource) : public DStaticPowerResource
sl@0
   347
	{
sl@0
   348
public:
sl@0
   349
    DBSHIGLSPResource();
sl@0
   350
    TInt DoRequest(TPowerRequest &req);
sl@0
   351
    TInt GetInfo(TDes8* aInfo) const;
sl@0
   352
private:
sl@0
   353
    TInt iMinLevel;
sl@0
   354
    TInt iMaxLevel;
sl@0
   355
    TInt iCurrentLevel;
sl@0
   356
    TBool iPolled; //ETrue if this is a polled resource, otherwise event driven type
sl@0
   357
	TInt iBlockTime; //Time duration the thread will be blocked. 
sl@0
   358
	};
sl@0
   359
sl@0
   360
//class definition for multilevel shared instantaneous get & long latency get positive resource
sl@0
   361
NONSHARABLE_CLASS(DMLSHIGLSPResource) : public DStaticPowerResource
sl@0
   362
	{
sl@0
   363
public:
sl@0
   364
    DMLSHIGLSPResource();
sl@0
   365
    TInt DoRequest(TPowerRequest &req);
sl@0
   366
    TInt GetInfo(TDes8* aInfo) const;
sl@0
   367
private:
sl@0
   368
    TInt iMinLevel;
sl@0
   369
    TInt iMaxLevel;
sl@0
   370
    TInt iCurrentLevel;
sl@0
   371
    TBool iPolled; //ETrue if this is a polled resource, otherwise event driven type
sl@0
   372
	TInt iBlockTime; //Time duration the thread will be blocked. 
sl@0
   373
	};
sl@0
   374
sl@0
   375
//class definition for binary shared long latency get & set custom resource
sl@0
   376
NONSHARABLE_CLASS(DBSHLGLSCResource) : public DStaticPowerResource
sl@0
   377
	{
sl@0
   378
public:
sl@0
   379
    DBSHLGLSCResource();
sl@0
   380
    TInt DoRequest(TPowerRequest &req);
sl@0
   381
    TInt GetInfo(TDes8* aInfo) const;
sl@0
   382
    static TBool CustomFunction(TInt &aClientId, const TDesC8& aClientName,
sl@0
   383
                                TUint aResourceId,
sl@0
   384
                                TCustomOperation aCustomOperation, TInt &aLevel, 
sl@0
   385
								TAny* aLevelList, TAny* aReserved);
sl@0
   386
sl@0
   387
private:
sl@0
   388
    TInt iMinLevel;
sl@0
   389
    TInt iMaxLevel;
sl@0
   390
    TInt iCurrentLevel;
sl@0
   391
    TBool iPolled; //ETrue if this is a polled resource, otherwise event driven type
sl@0
   392
	TInt iBlockTime; //Time duration the thread will be blocked. 
sl@0
   393
	};
sl@0
   394
sl@0
   395
#endif //__RESCONTROL_PSL_H__