kernel/eka/include/drivers/resourcecontrol.h
branchRCL_3
changeset 44 3e88ff8f41d5
parent 43 c1f20ce4abcf
--- a/kernel/eka/include/drivers/resourcecontrol.h	Tue Aug 31 16:34:26 2010 +0300
+++ b/kernel/eka/include/drivers/resourcecontrol.h	Wed Sep 01 12:34:56 2010 +0100
@@ -12,7 +12,7 @@
 //
 // Description:
 // e32\include\drivers\resourcecontrol.h
-//
+// 
 // WARNING: This file contains some APIs which are internal and are subject
 //          to change without notice. Such APIs should therefore not be used
 //          outside the Kernel and Hardware Services package.
@@ -133,22 +133,16 @@
 /* Macro to add dynamic resource to appropriate containers. Used only in extended version */
 #define ADD_TO_RESOURCE_CONTAINER(list, res, resId, resIdCount)				\
 	{																		\
-	TInt growBy = (list).GrowBy();										\
+	TUint16 growBy = (list).GrowBy();										\
 	if(!growBy)																\
-		(list).Initialise(PRM_DYNAMIC_RESOURCE_INITIAL_SIZE);		\
-    TInt r = (list).Add(res, resId);                                        \
-	if(r == KErrNoMemory)								                    \
+		(list).Initialise((TUint16)PRM_DYNAMIC_RESOURCE_INITIAL_SIZE);		\
+	if((list).Add(res, resId) == KErrNoMemory)								\
 		{																	\
-		r = (list).ReSize(growBy);										    \
-        if(r == KErrNone)                                                   \
-            {                                                               \
-            r = (list).Add(res, resId);										\
-            }                                                               \
+		TInt r = (list).ReSize(growBy);										\
+		if(r != KErrNone)													\
+			return r;														\
+		(list).Add(res, resId);												\
 		}																	\
-    if(r != KErrNone)                                                       \
-        {                                                                   \
-        return r;                                                           \
-        }                                                                   \
 	res->iResourceId |= resId;												\
 	resId = res->iResourceId;												\
 	resIdCount++;															\
@@ -160,24 +154,24 @@
 	switch((resId >> RESOURCE_BIT_IN_ID_CHECK) & 0x3)											\
 		{																						\
 		case PRM_STATIC_RESOURCE:																\
-			if((TInt)resId > iStaticResourceArray.Count())										\
+			if(resId > iStaticResourceArrayEntries)												\
 				UNLOCK_RETURN(KErrNotFound);													\
 			res = iStaticResourceArray[resId - 1];												\
 			if(!res)																			\
 				UNLOCK_RETURN(KErrNotFound);													\
 			break;																				\
 		case PRM_STATIC_DEPENDENCY_RESOURCE:													\
-			if((TInt)(resId & ID_INDEX_BIT_MASK) > iStaticResDependencyArray.Count())	\
+			if((TUint16)(resId & ID_INDEX_BIT_MASK) > iStaticResDependencyCount)				\
 				UNLOCK_RETURN(KErrNotFound);													\
-			res = iStaticResDependencyArray[(resId & ID_INDEX_BIT_MASK)  - 1];			\
+			res = iStaticResDependencyArray[(TUint16)(resId & ID_INDEX_BIT_MASK)  - 1];			\
 			break;																				\
 		case PRM_DYNAMIC_RESOURCE:																\
-			res = iDynamicResourceList[(resId & ID_INDEX_BIT_MASK)];					\
+			res = iDynamicResourceList[(TUint16)(resId & ID_INDEX_BIT_MASK)];					\
 			if(!res)																			\
 				UNLOCK_RETURN(KErrNotFound);													\
 			break;																				\
 		case PRM_DYNAMIC_DEPENDENCY_RESOURCE:													\
-			res = iDynamicResDependencyList[(resId & ID_INDEX_BIT_MASK)];				\
+			res = iDynamicResDependencyList[(TUint16)(resId & ID_INDEX_BIT_MASK)];				\
 			if(!res)																			\
 				UNLOCK_RETURN(KErrNotFound);													\
 			break;																				\
@@ -191,9 +185,9 @@
    it is called from the same thread. */
 #define VALIDATE_CLIENT(t)																						\
 	if(aClientId & USER_SIDE_CLIENT_BIT_MASK)																	\
-		pC = iUserSideClientList[(aClientId & ID_INDEX_BIT_MASK)];										\
+		pC = iUserSideClientList[(TUint16)(aClientId & ID_INDEX_BIT_MASK)];										\
 	else																										\
-		pC = iClientList[(aClientId & ID_INDEX_BIT_MASK)];												\
+		pC = iClientList[(TUint16)(aClientId & ID_INDEX_BIT_MASK)];												\
 	if(!pC)																										\
 		{																										\
 		__KTRACE_OPT(KRESMANAGER, Kern::Printf("Client ID not Found"));											\
@@ -216,9 +210,9 @@
 /** Macro to get the target client from appropriate client list based on bit 14 of client ID. */
 #define GET_TARGET_CLIENT()																				\
 	if(aTargetClientId & USER_SIDE_CLIENT_BIT_MASK) 													\
-		pC = iUserSideClientList[(aTargetClientId & ID_INDEX_BIT_MASK)];	    				\
+		pC = iUserSideClientList[(TUint16)(aTargetClientId & ID_INDEX_BIT_MASK)];	    				\
 	else																								\
-		pC = iClientList[(aTargetClientId & ID_INDEX_BIT_MASK)];								\
+		pC = iClientList[(TUint16)(aTargetClientId & ID_INDEX_BIT_MASK)];								\
 	if(!pC)																								\
 		{																								\
 		__KTRACE_OPT(KRESMANAGER, Kern::Printf("Target Client ID not found"));							\
@@ -324,16 +318,16 @@
 class DResourceCon : public DBase
 	{
 public:
-    inline TInt Initialise(TInt aInitialSize);
+    inline TInt Initialise(TUint16 aInitialSize);
     inline void Delete();
-    inline T*  operator[](TInt aIndex);
-    inline TInt Remove(T* aObj, TInt aIndex);
+    inline T*  operator[](TUint16 aIndex);
+    inline TInt Remove(T* aObj, TUint16 aIndex);
     inline TInt Add(T* aObj, TUint &aId);
     inline TInt Find(T*& anEntry, TDesC& aName);
-    inline TInt ReSize(TInt aGrowBy);
-    inline TInt Count() {return iCount;}
-    inline TInt Allocd() {return iAllocated;}
-	inline TInt GrowBy() {return iGrowBy;}
+    inline TInt ReSize(TUint16 aGrowBy);
+    inline TUint16 Count() {return iCount;}
+    inline TUint16 Allocd() {return iAllocated;}
+	inline TUint16 GrowBy() {return iGrowBy;}
 private:
     TUint16 iGrowBy; //Size to grow the size of the array.
     TUint16 iAllocated;  //Size of the array
@@ -460,6 +454,7 @@
     virtual TInt RegisterResourcesForIdle(TInt aPowerControllerId, TUint aNumResources, TPtr* aBuf);
     static void Panic(TUint8 aPanic);
     virtual TInt GetInterface(TUint aClientId, TUint aInterfaceId, TAny* aParam1, TAny* aParam2, TAny* aParam3);
+	virtual ~DPowerResourceController();
 	/**@internalComponent*/
 	void CompleteNotifications(TInt aClientId, DStaticPowerResource* aResource, TInt aState, TInt aReturnCode, TInt aLevelOwnerId, TBool aLock = ETrue);
 #ifdef PRM_ENABLE_EXTENDED_VERSION
@@ -486,12 +481,12 @@
 							  NKern::ThreadLeaveCS();}
 #ifdef PRM_ENABLE_EXTENDED_VERSION
 	//Default implementation, PSL re-implements these if features supported
-	virtual TInt DoRegisterStaticResourcesDependency(RPointerArray <DStaticPowerResourceD> & aStaticResourceDArray);
+	virtual TInt DoRegisterStaticResourcesDependency(DStaticPowerResourceD**& aStaticResourceDArray, TUint16& aStaticResourceDCount);
 #endif
 private:
     // pure virtual implemented by PSL - to be called by PIL
     virtual TInt DoInitController()=0;
-    virtual TInt DoRegisterStaticResources(RPointerArray <DStaticPowerResource> & aStaticResourceArray)=0;
+    virtual TInt DoRegisterStaticResources(DStaticPowerResource**& aStaticResourceArray, TUint16& aStaticResourceCount)=0;
     /**@internalComponent*/
     TInt CheckLevelAndAddClient(SPowerResourceClient* pC, TPowerRequest* Request);
     static void MsgQFunc(TAny* aPtr);
@@ -528,16 +523,18 @@
 	TInt GetDependentsIdForResource(TUint aResourceId, TAny* aInfo, TUint* aNumDepResources);
 	TInt HandleResourceRegistration(TPowerRequest& aReq);
 #endif
-protected:
+public:
 	DMutex* iResourceMutex;
-	TDfcQue* iDfcQ;
+protected:
+    TDfcQue* iDfcQ;
     TMessageQue *iMsgQ;
 #ifdef PRM_ENABLE_EXTENDED_VERSION
 	TDfcQue* iDfcQDependency;
 	TMessageQue* iMsgQDependency;
 	TBool iDfcQDependencyLock;
 #endif
-	RPointerArray <DStaticPowerResource> iStaticResourceArray;
+private:
+    DStaticPowerResource** iStaticResourceArray;
     DResourceCon<SPowerResourceClient> iClientList;
     DResourceCon<SPowerResourceClient> iUserSideClientList;
 #ifdef RESOURCE_MANAGER_SIMULATED_PSL
@@ -555,18 +552,19 @@
     TUint16 iClientLevelPoolGrowBy;
     TUint16 iRequestPoolCount;
     TUint16 iRequestPoolGrowBy;
+    TUint16 iStaticResourceArrayEntries; //Number of entries in the array including holes if any.
 	TUint16 iStaticResourceCount;  //Actual number of static resources registered (valid entries).
 	TUint	iReserved2; //Reserved for future use
 #ifdef PRM_ENABLE_EXTENDED_VERSION
-	DResourceCon<DDynamicPowerResource>   iDynamicResourceList;
-	DResourceCon<DDynamicPowerResourceD>  iDynamicResDependencyList;
-	RPointerArray <DStaticPowerResourceD> iStaticResDependencyArray;
+	DResourceCon<DDynamicPowerResource> iDynamicResourceList;
+	DResourceCon<DDynamicPowerResourceD> iDynamicResDependencyList;
+	DStaticPowerResourceD** iStaticResDependencyArray;
 	SPowerResourceClientLevel* iResourceLevelPool;
 	TUint16 iResourceLevelPoolCount;
+	TUint16 iStaticResDependencyCount;
 	TUint16 iDynamicResourceCount;
-	TUint8  iDynamicResDependencyCount;
-	TUint8  iSpare1;
-	TUint16 iSpare2;
+	TUint8 iDynamicResDependencyCount;
+	TUint8 iSpare2;
 	TUint  iReserved3; //Reserved for future use.
 #endif
 	};