33 { |
33 { |
34 if(aCount < iResourceLevelPoolCount) |
34 if(aCount < iResourceLevelPoolCount) |
35 iResourceLevelPoolCount = (TUint16)(iResourceLevelPoolCount - aCount); |
35 iResourceLevelPoolCount = (TUint16)(iResourceLevelPoolCount - aCount); |
36 else |
36 else |
37 { |
37 { |
38 TUint allocCount = (iStaticResDependencyCount / 2) + aCount; |
38 TUint allocCount = (iStaticResDependencyArray.Count() / 2) + aCount; |
39 // coverity[alloc_fn] |
39 // coverity[alloc_fn] |
40 SPowerResourceClientLevel* pCL = new SPowerResourceClientLevel[allocCount]; |
40 SPowerResourceClientLevel* pCL = new SPowerResourceClientLevel[allocCount]; |
41 if(!pCL) |
41 if(!pCL) |
42 return KErrNoMemory; |
42 return KErrNoMemory; |
43 for(TUint count = 0;count<(TUint)(allocCount);count++) |
43 for(TUint count = 0;count<(TUint)(allocCount);count++) |
44 LIST_PUSH(iResourceLevelPool, &pCL[count], iNextInList); |
44 LIST_PUSH(iResourceLevelPool, &pCL[count], iNextInList); |
45 iResourceLevelPoolCount= (TUint16)(iResourceLevelPoolCount + (iStaticResDependencyCount / 2)); |
45 iResourceLevelPoolCount= (TUint16)(iResourceLevelPoolCount + (iStaticResDependencyArray.Count() / 2)); |
46 #ifdef PRM_INSTRUMENTATION_MACRO |
46 #ifdef PRM_INSTRUMENTATION_MACRO |
47 TUint size = allocCount * sizeof(SPowerResourceClientLevel); |
47 TUint size = allocCount * sizeof(SPowerResourceClientLevel); |
48 PRM_MEMORY_USAGE_TRACE |
48 PRM_MEMORY_USAGE_TRACE |
49 #endif |
49 #endif |
50 } |
50 } |
77 if(!(aResourceId & KIdMaskResourceWithDependencies)) |
77 if(!(aResourceId & KIdMaskResourceWithDependencies)) |
78 return KErrNotSupported; |
78 return KErrNotSupported; |
79 SNode* pN; |
79 SNode* pN; |
80 if(aResourceId & KIdMaskDynamic) |
80 if(aResourceId & KIdMaskDynamic) |
81 { |
81 { |
82 DDynamicPowerResourceD* pDR = iDynamicResDependencyList[(TUint16)(aResourceId & ID_INDEX_BIT_MASK)]; |
82 DDynamicPowerResourceD* pDR = iDynamicResDependencyList[(aResourceId & ID_INDEX_BIT_MASK)]; |
83 if(!pDR) |
83 if(!pDR) |
84 return KErrNotFound; |
84 return KErrNotFound; |
85 pN = pDR->iDependencyList; |
85 pN = pDR->iDependencyList; |
86 } |
86 } |
87 else |
87 else |
88 { |
88 { |
89 if((aResourceId & ID_INDEX_BIT_MASK) > iStaticResDependencyCount) |
89 if((aResourceId & ID_INDEX_BIT_MASK) > (TUint)iStaticResDependencyArray.Count()) |
90 return KErrNotFound; |
90 return KErrNotFound; |
91 DStaticPowerResourceD* pDR = iStaticResDependencyArray[(TUint16)(aResourceId & ID_INDEX_BIT_MASK) - 1]; |
91 DStaticPowerResourceD* pDR = iStaticResDependencyArray[(aResourceId & ID_INDEX_BIT_MASK) - 1]; |
92 pN = pDR->iDependencyList; |
92 pN = pDR->iDependencyList; |
93 } |
93 } |
94 *aNumResources = 0; |
94 *aNumResources = 0; |
95 for(;pN != NULL; pN = pN->iNext) |
95 for(;pN != NULL; pN = pN->iNext) |
96 (*aNumResources)++; |
96 (*aNumResources)++; |
121 SResourceDependencyInfo sResDepInfo; |
121 SResourceDependencyInfo sResDepInfo; |
122 |
122 |
123 SNode* pN; |
123 SNode* pN; |
124 if(aResourceId & KIdMaskDynamic) |
124 if(aResourceId & KIdMaskDynamic) |
125 { |
125 { |
126 DDynamicPowerResourceD* pDR = iDynamicResDependencyList[(TUint16)(aResourceId & ID_INDEX_BIT_MASK)]; |
126 DDynamicPowerResourceD* pDR = iDynamicResDependencyList[(aResourceId & ID_INDEX_BIT_MASK)]; |
127 if(!pDR) |
127 if(!pDR) |
128 return KErrNotFound; |
128 return KErrNotFound; |
129 pN = pDR->iDependencyList; |
129 pN = pDR->iDependencyList; |
130 } |
130 } |
131 else |
131 else |
132 { |
132 { |
133 if((aResourceId & ID_INDEX_BIT_MASK) > iStaticResDependencyCount) |
133 if((aResourceId & ID_INDEX_BIT_MASK) > (TUint)iStaticResDependencyArray.Count()) |
134 return KErrNotFound; |
134 return KErrNotFound; |
135 DStaticPowerResourceD* pDR = iStaticResDependencyArray[(TUint16)(aResourceId & ID_INDEX_BIT_MASK) -1]; |
135 DStaticPowerResourceD* pDR = iStaticResDependencyArray[(aResourceId & ID_INDEX_BIT_MASK) -1]; |
136 pN = pDR->iDependencyList; |
136 pN = pDR->iDependencyList; |
137 } |
137 } |
138 TUint count = 0; |
138 TUint count = 0; |
139 TUint resCount = 0; |
139 TUint resCount = 0; |
140 |
140 |
182 SNode* pN1 = NULL; |
182 SNode* pN1 = NULL; |
183 SNode* pN2 = NULL; |
183 SNode* pN2 = NULL; |
184 //Retrieve resource1 from the corresponding list. |
184 //Retrieve resource1 from the corresponding list. |
185 if(aInfo1->iResourceId & KIdMaskDynamic) |
185 if(aInfo1->iResourceId & KIdMaskDynamic) |
186 { |
186 { |
187 pR1 = iDynamicResDependencyList[(TUint16)(aInfo1->iResourceId & ID_INDEX_BIT_MASK)]; |
187 pR1 = iDynamicResDependencyList[(aInfo1->iResourceId & ID_INDEX_BIT_MASK)]; |
188 if(!pR1) |
188 if(!pR1) |
189 return KErrNotFound; |
189 return KErrNotFound; |
190 pN1 = pR1->iDependencyList; |
190 pN1 = pR1->iDependencyList; |
191 } |
191 } |
192 else |
192 else |
193 { |
193 { |
194 if((aInfo1->iResourceId & ID_INDEX_BIT_MASK) > iStaticResDependencyCount) |
194 if((aInfo1->iResourceId & ID_INDEX_BIT_MASK) > (TUint)iStaticResDependencyArray.Count()) |
195 return KErrNotFound; |
195 return KErrNotFound; |
196 pR1 = (DDynamicPowerResourceD*)iStaticResDependencyArray[(TUint16)(aInfo1->iResourceId & ID_INDEX_BIT_MASK) - 1]; |
196 pR1 = (DDynamicPowerResourceD*)iStaticResDependencyArray[(aInfo1->iResourceId & ID_INDEX_BIT_MASK) - 1]; |
197 pN1 = ((DStaticPowerResourceD*)pR1)->iDependencyList; |
197 pN1 = ((DStaticPowerResourceD*)pR1)->iDependencyList; |
198 } |
198 } |
199 //Retrieve resource2 from the corresponding list. |
199 //Retrieve resource2 from the corresponding list. |
200 if(aInfo2->iResourceId & KIdMaskDynamic) |
200 if(aInfo2->iResourceId & KIdMaskDynamic) |
201 { |
201 { |
202 pR2 = iDynamicResDependencyList[(TUint16)(aInfo2->iResourceId & ID_INDEX_BIT_MASK)]; |
202 pR2 = iDynamicResDependencyList[(aInfo2->iResourceId & ID_INDEX_BIT_MASK)]; |
203 if(!pR2) |
203 if(!pR2) |
204 return KErrNotFound; |
204 return KErrNotFound; |
205 pN2 = pR2->iDependencyList; |
205 pN2 = pR2->iDependencyList; |
206 } |
206 } |
207 else |
207 else |
208 { |
208 { |
209 if((aInfo2->iResourceId & ID_INDEX_BIT_MASK) > iStaticResDependencyCount) |
209 if((aInfo2->iResourceId & ID_INDEX_BIT_MASK) > (TUint)iStaticResDependencyArray.Count()) |
210 return KErrNotFound; |
210 return KErrNotFound; |
211 pR2 = (DDynamicPowerResourceD*)iStaticResDependencyArray[(TUint16)(aInfo2->iResourceId & ID_INDEX_BIT_MASK) - 1]; |
211 pR2 = (DDynamicPowerResourceD*)iStaticResDependencyArray[(aInfo2->iResourceId & ID_INDEX_BIT_MASK) - 1]; |
212 pN2 = ((DStaticPowerResourceD*)pR2)->iDependencyList; |
212 pN2 = ((DStaticPowerResourceD*)pR2)->iDependencyList; |
213 } |
213 } |
214 |
214 |
215 //Only long latency resource is allowed to have dependents. |
215 //Only long latency resource is allowed to have dependents. |
216 if(!pR1->LatencySet()) |
216 if(!pR1->LatencySet()) |
323 return KErrNotSupported; |
323 return KErrNotSupported; |
324 |
324 |
325 //Get the resource from appropriate container |
325 //Get the resource from appropriate container |
326 if(aResourceId & KIdMaskResourceWithDependencies) |
326 if(aResourceId & KIdMaskResourceWithDependencies) |
327 { |
327 { |
328 pDR = iDynamicResDependencyList[(TUint16)(aResourceId & ID_INDEX_BIT_MASK)]; |
328 pDR = iDynamicResDependencyList[(aResourceId & ID_INDEX_BIT_MASK)]; |
329 if(!pDR) |
329 if(!pDR) |
330 return KErrNotFound; |
330 return KErrNotFound; |
331 } |
331 } |
332 else |
332 else |
333 { |
333 { |
334 pDR = iDynamicResourceList[(TUint16)(aResourceId & ID_INDEX_BIT_MASK)]; |
334 pDR = iDynamicResourceList[(aResourceId & ID_INDEX_BIT_MASK)]; |
335 if(!pDR) |
335 if(!pDR) |
336 return KErrNotFound; |
336 return KErrNotFound; |
337 } |
337 } |
338 //Client which registered the dynamic resource is only allowed to deregister. |
338 //Client which registered the dynamic resource is only allowed to deregister. |
339 if(aClientPtr->iClientId != pDR->iOwnerId) |
339 if(aClientPtr->iClientId != pDR->iOwnerId) |
458 SPowerResourceClient *pC; |
458 SPowerResourceClient *pC; |
459 for(SDblQueLink* pRC = pDR->iClientList.First(); pRC != &pDR->iClientList.iA; pRC = pRC->iNext) |
459 for(SDblQueLink* pRC = pDR->iClientList.First(); pRC != &pDR->iClientList.iA; pRC = pRC->iNext) |
460 { |
460 { |
461 pCL = (SPowerResourceClientLevel*)pRC; |
461 pCL = (SPowerResourceClientLevel*)pRC; |
462 if(pCL->iClientId & USER_SIDE_CLIENT_BIT_MASK) |
462 if(pCL->iClientId & USER_SIDE_CLIENT_BIT_MASK) |
463 pC = iUserSideClientList[(TUint16)(pCL->iClientId & ID_INDEX_BIT_MASK)]; |
463 pC = iUserSideClientList[(pCL->iClientId & ID_INDEX_BIT_MASK)]; |
464 else |
464 else |
465 pC = iClientList[(TUint16)(pCL->iClientId & ID_INDEX_BIT_MASK)]; |
465 pC = iClientList[(pCL->iClientId & ID_INDEX_BIT_MASK)]; |
466 LIST_REMOVE(pC->iLevelList, pCL, iNextInList, SPowerResourceClientLevel); |
466 LIST_REMOVE(pC->iLevelList, pCL, iNextInList, SPowerResourceClientLevel); |
467 LIST_PUSH(iClientLevelPool, pCL, iNextInList); |
467 LIST_PUSH(iClientLevelPool, pCL, iNextInList); |
468 if(pC->iUnderFlowClCount > 0) |
468 if(pC->iUnderFlowClCount > 0) |
469 { |
469 { |
470 pC->iUnderFlowClCount--; |
470 pC->iUnderFlowClCount--; |
475 } |
475 } |
476 //Decrement dynamic resource count in client |
476 //Decrement dynamic resource count in client |
477 aClientPtr->iDynamicResCount--; |
477 aClientPtr->iDynamicResCount--; |
478 if(aResourceId & KIdMaskResourceWithDependencies) |
478 if(aResourceId & KIdMaskResourceWithDependencies) |
479 { |
479 { |
480 iDynamicResDependencyList.Remove((DDynamicPowerResourceD*)pDR, (TUint16)(pDR->iResourceId & ID_INDEX_BIT_MASK)); |
480 iDynamicResDependencyList.Remove((DDynamicPowerResourceD*)pDR, (pDR->iResourceId & ID_INDEX_BIT_MASK)); |
481 iDynamicResDependencyCount--; |
481 iDynamicResDependencyCount--; |
482 } |
482 } |
483 else |
483 else |
484 { |
484 { |
485 iDynamicResourceList.Remove(pDR, (TUint16)(pDR->iResourceId & ID_INDEX_BIT_MASK)); |
485 iDynamicResourceList.Remove(pDR, (pDR->iResourceId & ID_INDEX_BIT_MASK)); |
486 iDynamicResourceCount--; |
486 iDynamicResourceCount--; |
487 } |
487 } |
488 __KTRACE_OPT(KRESMANAGER, Kern::Printf("<DExtendedResourceController::DeregisterDynamicResource")); |
488 __KTRACE_OPT(KRESMANAGER, Kern::Printf("<DExtendedResourceController::DeregisterDynamicResource")); |
489 #ifdef PRM_INSTRUMENTATION_MACRO |
489 #ifdef PRM_INSTRUMENTATION_MACRO |
490 TInt level = req->Level(); |
490 TInt level = req->Level(); |
496 /** |
496 /** |
497 @publishedPartner |
497 @publishedPartner |
498 @prototype 9.6 |
498 @prototype 9.6 |
499 Default implementation, PSL re-implements this if features supported. |
499 Default implementation, PSL re-implements this if features supported. |
500 */ |
500 */ |
501 TInt DPowerResourceController::DoRegisterStaticResourcesDependency(DStaticPowerResourceD**& aStaticResourceDArray, |
501 TInt DPowerResourceController::DoRegisterStaticResourcesDependency(RPointerArray <DStaticPowerResourceD> & aStaticResourceDArray) |
502 TUint16& aStaticResourceDCount) |
|
503 { |
502 { |
504 __KTRACE_OPT(KRESMANAGER, Kern::Printf("DExtendedResourceController::DoRegisterStaticResourcesDependency default implementation")); |
503 __KTRACE_OPT(KRESMANAGER, Kern::Printf("DExtendedResourceController::DoRegisterStaticResourcesDependency default implementation")); |
505 aStaticResourceDArray = NULL; |
504 aStaticResourceDArray.Reset(); |
506 aStaticResourceDCount = 0; |
|
507 return KErrNone; |
505 return KErrNone; |
508 } |
506 } |
509 |
507 |
510 /** |
508 /** |
511 This function checks for any closed loop dependency, if so panics. |
509 This function checks for any closed loop dependency, if so panics. |
706 { |
704 { |
707 if(aRequest.ClientId() & (1 << RESOURCE_BIT_IN_ID_CHECK)) |
705 if(aRequest.ClientId() & (1 << RESOURCE_BIT_IN_ID_CHECK)) |
708 { |
706 { |
709 DStaticPowerResourceD* pResource; |
707 DStaticPowerResourceD* pResource; |
710 if(aRequest.ClientId() & KIdMaskDynamic) |
708 if(aRequest.ClientId() & KIdMaskDynamic) |
711 pResource = (DStaticPowerResourceD*)iDynamicResDependencyList[(TUint16)(aRequest.ClientId() & ID_INDEX_BIT_MASK)]; |
709 pResource = (DStaticPowerResourceD*)iDynamicResDependencyList[(aRequest.ClientId() & ID_INDEX_BIT_MASK)]; |
712 else |
710 else |
713 pResource = iStaticResDependencyArray[(TUint16)(aRequest.ClientId() & ID_INDEX_BIT_MASK) - 1]; |
711 pResource = iStaticResDependencyArray[(aRequest.ClientId() & ID_INDEX_BIT_MASK) - 1]; |
714 name = pResource->iName; |
712 name = pResource->iName; |
715 } |
713 } |
716 else |
714 else |
717 { |
715 { |
718 SPowerResourceClient* pClient; |
716 SPowerResourceClient* pClient; |
719 if(aRequest.ClientId() & USER_SIDE_CLIENT_BIT_MASK) |
717 if(aRequest.ClientId() & USER_SIDE_CLIENT_BIT_MASK) |
720 pClient = iUserSideClientList[(TUint16)(aRequest.ClientId() & ID_INDEX_BIT_MASK)]; |
718 pClient = iUserSideClientList[(aRequest.ClientId() & ID_INDEX_BIT_MASK)]; |
721 else // coverity[returned_null] |
719 else // coverity[returned_null] |
722 pClient = iClientList[(TUint16)(aRequest.ClientId() & ID_INDEX_BIT_MASK)]; |
720 pClient = iClientList[(aRequest.ClientId() & ID_INDEX_BIT_MASK)]; |
723 name = pClient->iName; |
721 name = pClient->iName; |
724 } |
722 } |
725 } |
723 } |
726 |
724 |
727 if(pR->iResourceId & KIdMaskDynamic) |
725 if(pR->iResourceId & KIdMaskDynamic) |
760 if(!(aResId1 & KIdMaskResourceWithDependencies) || !(aResId2 & KIdMaskResourceWithDependencies)) |
758 if(!(aResId1 & KIdMaskResourceWithDependencies) || !(aResId2 & KIdMaskResourceWithDependencies)) |
761 UNLOCK_RETURN(KErrAccessDenied); |
759 UNLOCK_RETURN(KErrAccessDenied); |
762 |
760 |
763 if(aResId1 & KIdMaskDynamic) |
761 if(aResId1 & KIdMaskDynamic) |
764 { |
762 { |
765 pDR1 = iDynamicResDependencyList[(TUint16)(aResId1 & ID_INDEX_BIT_MASK)]; |
763 pDR1 = iDynamicResDependencyList[(aResId1 & ID_INDEX_BIT_MASK)]; |
766 if(!pDR1) |
764 if(!pDR1) |
767 UNLOCK_RETURN(KErrNotFound); |
765 UNLOCK_RETURN(KErrNotFound); |
768 pN1 = pDR1->iDependencyList; |
766 pN1 = pDR1->iDependencyList; |
769 pCL1 = pDR1->iResourceClientList; |
767 pCL1 = pDR1->iResourceClientList; |
770 } |
768 } |
771 else |
769 else |
772 { |
770 { |
773 if((aResId1 & ID_INDEX_BIT_MASK) > iStaticResDependencyCount) |
771 if((aResId1 & ID_INDEX_BIT_MASK) > (TUint)iStaticResDependencyArray.Count()) |
774 UNLOCK_RETURN(KErrNotFound); |
772 UNLOCK_RETURN(KErrNotFound); |
775 pDR1 = (DDynamicPowerResourceD*)iStaticResDependencyArray[(aResId1 & ID_INDEX_BIT_MASK) - 1]; |
773 pDR1 = (DDynamicPowerResourceD*)iStaticResDependencyArray[(aResId1 & ID_INDEX_BIT_MASK) - 1]; |
776 pN1 = ((DStaticPowerResourceD*)pDR1)->iDependencyList; |
774 pN1 = ((DStaticPowerResourceD*)pDR1)->iDependencyList; |
777 pCL1 = ((DStaticPowerResourceD*)pDR1)->iResourceClientList; |
775 pCL1 = ((DStaticPowerResourceD*)pDR1)->iResourceClientList; |
778 } |
776 } |
779 |
777 |
780 //Get second resource from list |
778 //Get second resource from list |
781 if(aResId2 & KIdMaskDynamic) |
779 if(aResId2 & KIdMaskDynamic) |
782 { |
780 { |
783 pDR2 = iDynamicResDependencyList[(TUint16)(aResId2 & ID_INDEX_BIT_MASK)]; |
781 pDR2 = iDynamicResDependencyList[(aResId2 & ID_INDEX_BIT_MASK)]; |
784 if(!pDR2) |
782 if(!pDR2) |
785 UNLOCK_RETURN(KErrNotFound); |
783 UNLOCK_RETURN(KErrNotFound); |
786 pN2 = pDR2->iDependencyList; |
784 pN2 = pDR2->iDependencyList; |
787 pCL2 = pDR2->iResourceClientList; |
785 pCL2 = pDR2->iResourceClientList; |
788 } |
786 } |
789 else |
787 else |
790 { |
788 { |
791 if((aResId2 & ID_INDEX_BIT_MASK)> iStaticResDependencyCount) |
789 if((aResId2 & ID_INDEX_BIT_MASK)> (TUint)iStaticResDependencyArray.Count()) |
792 UNLOCK_RETURN(KErrNotFound); |
790 UNLOCK_RETURN(KErrNotFound); |
793 pDR2 = (DDynamicPowerResourceD*)iStaticResDependencyArray[(TUint16)(aResId2 & ID_INDEX_BIT_MASK) - 1]; |
791 pDR2 = (DDynamicPowerResourceD*)iStaticResDependencyArray[(aResId2 & ID_INDEX_BIT_MASK) - 1]; |
794 pN2 = ((DStaticPowerResourceD*)pDR2)->iDependencyList; |
792 pN2 = ((DStaticPowerResourceD*)pDR2)->iDependencyList; |
795 pCL2 = ((DStaticPowerResourceD*)pDR2)->iResourceClientList; |
793 pCL2 = ((DStaticPowerResourceD*)pDR2)->iResourceClientList; |
796 } |
794 } |
797 |
795 |
798 //Check whether dependency exist between the two |
796 //Check whether dependency exist between the two |