First public contribution.
1 // Copyright (c) 2007-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\resourceman\resourceman_psl\rescontrol_psl.h
18 #ifndef __RESCONTROL_PSL_H__
19 #define __RESCONTROL_PSL_H__
20 #include <drivers/resourcecontrol.h>
21 #include <kernel/kernel.h>
22 #include <kernel/kern_priv.h>
26 //Specifies the number of pre-allocate the PIL data structures.
27 #define KERNEL_CLIENTS 0x32
28 #define USER_CLIENTS 0x10
29 #define CLIENT_LEVELS 0x32
32 #define MAX_RESOURCE_COUNT 30
33 #define MAX_DEPENDENT_RESOURCE_COUNT 10
35 #define MAX_BLOCK_TIME 200 //Maximum block time
36 #define MIN_BLOCK_TIME 50 //Guaranteed minimum block
38 #define CLEAN_AND_RETURN(resCount, resArray, error) \
40 for(TUint count = 0; count < resCount; count++) \
41 delete resArray[count]; \
46 const TUint KBinary = 0x0;
47 const TUint KMultiLevel = 0x1;
49 _LIT(KResmanName, "DSimulatedResMan");
50 /** Simulated resource controller class */
51 NONSHARABLE_CLASS(DSimulatedPowerResourceController): public DPowerResourceController
54 DSimulatedPowerResourceController();
55 ~DSimulatedPowerResourceController();
56 TInt DoInitController();
57 TInt DoInitResources();
58 TInt DoRegisterStaticResources(DStaticPowerResource**& aStaticResourceArray, TUint16& aStaticResourceCount);
59 // Function to process instantaneous resources
60 TInt ProcessInstantaneousResources(TPowerRequest& req, TInt& aClientLevel, TInt aMaxLevel, TInt aMinLevel, TInt aDefaultLevel);
61 // Function to procces polled resources
62 TInt ProcessPolledResources(TPowerRequest& req, TInt& aClientLevel, TInt aMaxLevel, TInt aMinLevel, TInt aDefaultLevel, TInt aBlockTime = 0);
63 // Function to change the state of the resource
64 TInt ChangeResource(TPowerRequest& req, TInt& aClientLevel, TInt aMaxLevel, TInt aMinLevel);
65 // Function to process event driven resources
66 TInt ProcessEventResources(TPowerRequest& req, TInt& aClientLevel, TInt aMaxLevel, TInt aMinLevel, TInt aDefaultLevel, TInt aBlockTime = 0);
67 IMPORT_C static TInt CaptureIdleResourcesInfo(TUint aControllerId, TUint aNumResources, TPtr* aPtr);
68 IMPORT_C static TInt CompleteResourceControllerInitialisation();
69 #ifdef PRM_ENABLE_EXTENDED_VERSION
70 TInt DoRegisterStaticResourcesDependency(DStaticPowerResourceD**& aStaticResourceDArray, TUint16& aStaticResourceDCount);
71 TInt CreateResourceDependency(DStaticPowerResourceD** pResArray);
74 static void TimerIsrFunc(TAny* ptr); //ISR Function called when specfied timer expires. This is for even driven resources
75 static void EventDfcFunc(TAny* ptr); //Function to wakeup the fast semphore. This is called from timer ISR.
76 DStaticPowerResource** iResources;
77 TUint16 iStaticResourceCount;
78 NFastSemaphore iEventFastSem; //Semphore to block the PIL of resource controller for event driven resource operations.
79 TDfc iEventDfc; //Dfc to run to signal the event semaphore when the timer expires. Queued from timer ISR
80 #ifdef PRM_ENABLE_EXTENDED_VERSION
81 DStaticPowerResourceD** iDependencyResources;
82 TUint16 iStaticResDependencyCount;
88 #ifdef PRM_ENABLE_EXTENDED_VERSION
89 DSimulatedPowerResourceController* GetControllerPtr();
91 //class definition for Binary Single Instantaneous Positive resource
92 NONSHARABLE_CLASS(DBSIGISPResource) : public DStaticPowerResource
96 TInt DoRequest(TPowerRequest &req);
97 TInt GetInfo(TDes8* aInfo) const;
104 //class definition for multilevel single instantaneous positive resource
105 NONSHARABLE_CLASS(DMLSIGISPResource) : public DStaticPowerResource
109 TInt DoRequest(TPowerRequest &req);
110 TInt GetInfo(TDes8* aInfo) const;
117 //class definition for binary single instantaneous negative resource
118 NONSHARABLE_CLASS(DBSIGISNResource) : public DStaticPowerResource
122 TInt DoRequest(TPowerRequest &req);
123 TInt GetInfo(TDes8* aInfo) const;
130 //class definition for multilevel single instantaneous negative resource
131 NONSHARABLE_CLASS(DMLSIGISNResource) : public DStaticPowerResource
135 TInt DoRequest(TPowerRequest &req);
136 TInt GetInfo(TDes8* aInfo) const;
143 //class definition for binary single long latency positive resource
144 NONSHARABLE_CLASS(DBSLGLSPResource) : public DStaticPowerResource
148 TInt DoRequest(TPowerRequest &req);
149 TInt GetInfo(TDes8* aInfo) const;
155 TInt iBlockTime; //Time duration the thread will be blocked.
158 //class definition for multilevel single long latency positive resource
159 NONSHARABLE_CLASS(DMLSLGLSPResource) : public DStaticPowerResource
163 TInt DoRequest(TPowerRequest &req);
164 TInt GetInfo(TDes8* aInfo) const;
170 TInt iBlockTime; //Time duration the thread will be blocked.
173 //class definition for binary single long latency get & instantaneous set negative resource
174 NONSHARABLE_CLASS(DBSLGISNResource) : public DStaticPowerResource
178 TInt DoRequest(TPowerRequest &req);
179 TInt GetInfo(TDes8* aInfo) const;
185 TInt iBlockTime; //Time duration the thread will be blocked.
188 //class definition for multilevel single long latency get & instantaneous set negative resource
189 NONSHARABLE_CLASS(DMLSLGISNResource) : public DStaticPowerResource
193 TInt DoRequest(TPowerRequest &req);
194 TInt GetInfo(TDes8* aInfo) const;
200 TInt iBlockTime; //Time duration the thread will be blocked.
203 //class definition for binary single instantaneous get & long latency set positive resource
204 NONSHARABLE_CLASS(DBSIGLSPResource) : public DStaticPowerResource
208 TInt DoRequest(TPowerRequest &req);
209 TInt GetInfo(TDes8* aInfo) const;
215 TInt iBlockTime; //Time duration the thread will be blocked.
218 //class definition for multilevel single instantaneous get & long latency get positive resource
219 NONSHARABLE_CLASS(DMLSIGLSPResource) : public DStaticPowerResource
223 TInt DoRequest(TPowerRequest &req);
224 TInt GetInfo(TDes8* aInfo) const;
230 TInt iBlockTime; //Time duration the thread will be blocked.
233 //class definition for Binary Shared Instantaneous Positive resource
234 NONSHARABLE_CLASS(DBSHIGISPResource) : public DStaticPowerResource
238 TInt DoRequest(TPowerRequest &req);
239 TInt GetInfo(TDes8* aInfo) const;
246 //class definition for multilevel shared instantaneous positive resource
247 NONSHARABLE_CLASS(DMLSHIGISPResource) : public DStaticPowerResource
250 DMLSHIGISPResource();
251 TInt DoRequest(TPowerRequest &req);
252 TInt GetInfo(TDes8* aInfo) const;
259 //class definition for binary shared instantaneous negative resource
260 NONSHARABLE_CLASS(DBSHIGISNResource) : public DStaticPowerResource
264 TInt DoRequest(TPowerRequest &req);
265 TInt GetInfo(TDes8* aInfo) const;
272 //class definition for multilevel shared instantaneous negative resource
273 NONSHARABLE_CLASS(DMLSHIGISNResource) : public DStaticPowerResource
276 DMLSHIGISNResource();
277 TInt DoRequest(TPowerRequest &req);
278 TInt GetInfo(TDes8* aInfo) const;
285 //class definition for binary shared long latency positive resource
286 NONSHARABLE_CLASS(DBSHLGLSPResource) : public DStaticPowerResource
290 TInt DoRequest(TPowerRequest &req);
291 TInt GetInfo(TDes8* aInfo) const;
296 TBool iPolled; //ETrue if this is a polled resource, otherwise event driven type
297 TInt iBlockTime; //Time duration the thread will be blocked.
300 //class definition for multilevel shared long latency positive resource
301 NONSHARABLE_CLASS(DMLSHLGLSPResource) : public DStaticPowerResource
304 DMLSHLGLSPResource();
305 TInt DoRequest(TPowerRequest &req);
306 TInt GetInfo(TDes8* aInfo) const;
311 TBool iPolled; //ETrue if this is a polled resource, otherwise event driven type
312 TInt iBlockTime; //Time duration the thread will be blocked.
315 //class definition for binary shared long latency get & instantaneous set negative resource
316 NONSHARABLE_CLASS(DBSHLGISNResource) : public DStaticPowerResource
320 TInt DoRequest(TPowerRequest &req);
321 TInt GetInfo(TDes8* aInfo) const;
326 TBool iPolled; //ETrue if this is a polled resource, otherwise event driven type
327 TInt iBlockTime; //Time duration the thread will be blocked.
330 //class definition for multilevel shared long latency get & instantaneous set negative resource
331 NONSHARABLE_CLASS(DMLSHLGISNResource) : public DStaticPowerResource
334 DMLSHLGISNResource();
335 TInt DoRequest(TPowerRequest &req);
336 TInt GetInfo(TDes8* aInfo) const;
341 TBool iPolled; //ETrue if this is a polled resource, otherwise event driven type
342 TInt iBlockTime; //Time duration the thread will be blocked.
345 //class definition for binary shared instantaneous get & long latency set positive resource
346 NONSHARABLE_CLASS(DBSHIGLSPResource) : public DStaticPowerResource
350 TInt DoRequest(TPowerRequest &req);
351 TInt GetInfo(TDes8* aInfo) const;
356 TBool iPolled; //ETrue if this is a polled resource, otherwise event driven type
357 TInt iBlockTime; //Time duration the thread will be blocked.
360 //class definition for multilevel shared instantaneous get & long latency get positive resource
361 NONSHARABLE_CLASS(DMLSHIGLSPResource) : public DStaticPowerResource
364 DMLSHIGLSPResource();
365 TInt DoRequest(TPowerRequest &req);
366 TInt GetInfo(TDes8* aInfo) const;
371 TBool iPolled; //ETrue if this is a polled resource, otherwise event driven type
372 TInt iBlockTime; //Time duration the thread will be blocked.
375 //class definition for binary shared long latency get & set custom resource
376 NONSHARABLE_CLASS(DBSHLGLSCResource) : public DStaticPowerResource
380 TInt DoRequest(TPowerRequest &req);
381 TInt GetInfo(TDes8* aInfo) const;
382 static TBool CustomFunction(TInt &aClientId, const TDesC8& aClientName,
384 TCustomOperation aCustomOperation, TInt &aLevel,
385 TAny* aLevelList, TAny* aReserved);
391 TBool iPolled; //ETrue if this is a polled resource, otherwise event driven type
392 TInt iBlockTime; //Time duration the thread will be blocked.
395 #endif //__RESCONTROL_PSL_H__