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