30 #define REQUESTS 0x19 |
30 #define REQUESTS 0x19 |
31 |
31 |
32 #define MAX_RESOURCE_COUNT 30 |
32 #define MAX_RESOURCE_COUNT 30 |
33 #define MAX_DEPENDENT_RESOURCE_COUNT 10 |
33 #define MAX_DEPENDENT_RESOURCE_COUNT 10 |
34 |
34 |
35 #define MAX_BLOCK_TIME 400 //Maximum block time |
35 #define MAX_BLOCK_TIME 200 //Maximum block time |
36 #define MIN_BLOCK_TIME 200 //Guaranteed minimum block |
36 #define MIN_BLOCK_TIME 50 //Guaranteed minimum block |
37 |
37 |
38 template <class T> |
38 #define CLEAN_AND_RETURN(resCount, resArray, error) \ |
39 inline TBool SafeAppend(RPointerArray <T> & aStaticResourceArray, T* pR) |
39 { \ |
40 { |
40 for(TUint count = 0; count < resCount; count++) \ |
41 if(pR) |
41 delete resArray[count]; \ |
42 { |
42 delete resArray; \ |
43 if(aStaticResourceArray.Append(pR) == KErrNone) |
43 return error; \ |
44 return ETrue; |
|
45 else |
|
46 delete pR; |
|
47 } |
|
48 return EFalse; |
|
49 } |
44 } |
50 |
45 |
51 const TUint KBinary = 0x0; |
46 const TUint KBinary = 0x0; |
52 const TUint KMultiLevel = 0x1; |
47 const TUint KMultiLevel = 0x1; |
53 |
48 |
58 public: |
53 public: |
59 DSimulatedPowerResourceController(); |
54 DSimulatedPowerResourceController(); |
60 ~DSimulatedPowerResourceController(); |
55 ~DSimulatedPowerResourceController(); |
61 TInt DoInitController(); |
56 TInt DoInitController(); |
62 TInt DoInitResources(); |
57 TInt DoInitResources(); |
63 TInt DoRegisterStaticResources(RPointerArray <DStaticPowerResource> & aStaticResourceArray); |
58 TInt DoRegisterStaticResources(DStaticPowerResource**& aStaticResourceArray, TUint16& aStaticResourceCount); |
64 // Function to process instantaneous resources |
59 // Function to process instantaneous resources |
65 TInt ProcessInstantaneousResources(TPowerRequest& req, TInt& aClientLevel, TInt aMaxLevel, TInt aMinLevel, TInt aDefaultLevel); |
60 TInt ProcessInstantaneousResources(TPowerRequest& req, TInt& aClientLevel, TInt aMaxLevel, TInt aMinLevel, TInt aDefaultLevel); |
66 // Function to process polled resources |
61 // Function to procces polled resources |
67 TInt ProcessPolledResources(TPowerRequest& req, TInt& aClientLevel, TInt aMaxLevel, TInt aMinLevel, TInt aDefaultLevel, TInt aBlockTime = 0); |
62 TInt ProcessPolledResources(TPowerRequest& req, TInt& aClientLevel, TInt aMaxLevel, TInt aMinLevel, TInt aDefaultLevel, TInt aBlockTime = 0); |
68 // Function to change the state of the resource |
63 // Function to change the state of the resource |
69 TInt ChangeResource(TPowerRequest& req, TInt& aClientLevel, TInt aMaxLevel, TInt aMinLevel); |
64 TInt ChangeResource(TPowerRequest& req, TInt& aClientLevel, TInt aMaxLevel, TInt aMinLevel); |
70 // Function to process event driven resources |
65 // Function to process event driven resources |
71 TInt ProcessEventResources(TPowerRequest& req, TInt& aClientLevel, TInt aMaxLevel, TInt aMinLevel, TInt aDefaultLevel, TInt aBlockTime = 0); |
66 TInt ProcessEventResources(TPowerRequest& req, TInt& aClientLevel, TInt aMaxLevel, TInt aMinLevel, TInt aDefaultLevel, TInt aBlockTime = 0); |
72 IMPORT_C static TInt CaptureIdleResourcesInfo(TUint aControllerId, TUint aNumResources, TPtr* aPtr); |
67 IMPORT_C static TInt CaptureIdleResourcesInfo(TUint aControllerId, TUint aNumResources, TPtr* aPtr); |
73 IMPORT_C static TInt CompleteResourceControllerInitialisation(); |
68 IMPORT_C static TInt CompleteResourceControllerInitialisation(); |
74 #ifdef PRM_ENABLE_EXTENDED_VERSION |
69 #ifdef PRM_ENABLE_EXTENDED_VERSION |
75 TInt DoRegisterStaticResourcesDependency(RPointerArray <DStaticPowerResourceD> & aStaticResourceDArray); |
70 TInt DoRegisterStaticResourcesDependency(DStaticPowerResourceD**& aStaticResourceDArray, TUint16& aStaticResourceDCount); |
76 TInt CreateResourceDependency(RPointerArray <DStaticPowerResourceD> & pResArray); |
71 TInt CreateResourceDependency(DStaticPowerResourceD** pResArray); |
77 #endif |
72 #endif |
78 private: |
73 private: |
79 static void TimerIsrFunc(TAny* ptr); //ISR Function called when specified timer expires. This is for even driven resources |
74 static void TimerIsrFunc(TAny* ptr); //ISR Function called when specfied timer expires. This is for even driven resources |
80 static void EventDfcFunc(TAny* ptr); //Function to wake up the fast semaphore. This is called from timer ISR. |
75 static void EventDfcFunc(TAny* ptr); //Function to wakeup the fast semphore. This is called from timer ISR. |
81 NFastSemaphore iEventFastSem; //Semaphore to block the PIL of resource controller for event driven resource operations. |
76 DStaticPowerResource** iResources; |
|
77 TUint16 iStaticResourceCount; |
|
78 NFastSemaphore iEventFastSem; //Semphore to block the PIL of resource controller for event driven resource operations. |
82 TDfc iEventDfc; //Dfc to run to signal the event semaphore when the timer expires. Queued from timer ISR |
79 TDfc iEventDfc; //Dfc to run to signal the event semaphore when the timer expires. Queued from timer ISR |
83 #ifdef PRM_ENABLE_EXTENDED_VERSION |
80 #ifdef PRM_ENABLE_EXTENDED_VERSION |
|
81 DStaticPowerResourceD** iDependencyResources; |
|
82 TUint16 iStaticResDependencyCount; |
84 SNode* iNodeArray; |
83 SNode* iNodeArray; |
85 TUint16 iNodeCount; |
84 TUint16 iNodeCount; |
86 #endif |
85 #endif |
87 }; |
86 }; |
88 |
87 |