311 { |
311 { |
312 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">TInterface::ControlIO")); |
312 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">TInterface::ControlIO")); |
313 return PowerResourceController->GetInterface(aClientId, aFunction, aParam1, aParam2, aParam3); |
313 return PowerResourceController->GetInterface(aClientId, aFunction, aParam1, aParam2, aParam3); |
314 } |
314 } |
315 |
315 |
316 /** Resouce controller panic */ |
316 /** Resource controller panic */ |
317 void DPowerResourceController::Panic(TUint8 aPanic) |
317 void DPowerResourceController::Panic(TUint8 aPanic) |
318 { |
318 { |
319 Kern::Fault("Power Resource Controller", aPanic); |
319 Kern::Fault("Power Resource Controller", aPanic); |
320 } |
320 } |
321 |
321 |
322 /** Constructor for power controller. Creates message queue and generates ID for power controller to use. */ |
322 /** Constructor for power controller. Creates message queue and generates ID for power controller to use. */ |
|
323 extern RPointerArray <DStaticPowerResource> *StaticResourceArrayPtr; |
|
324 #ifdef PRM_ENABLE_EXTENDED_VERSION |
|
325 extern RPointerArray <DStaticPowerResourceD> *StaticResourceDependencyArrayPtr; |
|
326 #endif |
323 DPowerResourceController::DPowerResourceController() |
327 DPowerResourceController::DPowerResourceController() |
324 { |
328 { |
325 __KTRACE_OPT(KRESMANAGER, Kern::Printf("DPowerResourceController::DPowerResouceController()")); |
329 __KTRACE_OPT(KRESMANAGER, Kern::Printf("DPowerResourceController::DPowerResouceController()")); |
326 //Constructor is expected to invoke multiple times (during creation, variant init 0 and extension init 1) |
330 // Constructor is expected to invoke multiple times, i.e.: |
327 if(PowerResourceController) |
331 // during creation: variant init 0(KModuleEntryReasonVariantInit0) and later extension init 1 (KModuleEntryReasonExtensionInit1) |
|
332 if(PowerResourceController) |
|
333 { |
|
334 // If InitController() was called in the Init3() static resource arrays were populated already and invocation of this |
|
335 // constructor has zeroed the dynamic pointer arrays (calling their default constructors). In such case we need to |
|
336 // restore these arrays from their temporary shadow copies (i.e. copies of RPointerArray objects, not their content) |
|
337 // (See comments in RegisterStaticResources()) |
|
338 if(StaticResourceArrayPtr) |
|
339 { |
|
340 // by making a (binary) copy of RPointerArray object (compiler's auto-generated code) |
|
341 // we are taking the ownership of content (pointers stored/owned by that array) of this temporary array |
|
342 iStaticResourceArray = *StaticResourceArrayPtr; |
|
343 } |
|
344 #ifdef PRM_ENABLE_EXTENDED_VERSION |
|
345 // the same applies to static resources with dependencies for extended version. |
|
346 // Temporary object are de-allocated in InitResources() |
|
347 if(StaticResourceDependencyArrayPtr) |
|
348 { |
|
349 iStaticResDependencyArray = *StaticResourceDependencyArrayPtr; |
|
350 } |
|
351 #endif |
328 return; |
352 return; |
|
353 } |
329 PowerResourceController = this; |
354 PowerResourceController = this; |
330 iClientList.Initialise(0); |
355 iClientList.Initialise(0); |
331 iUserSideClientList.Initialise(0); |
356 iUserSideClientList.Initialise(0); |
332 iInitialised = EResConCreated; |
357 iInitialised = EResConCreated; |
333 #ifdef PRM_ENABLE_EXTENDED_VERSION |
358 #ifdef PRM_ENABLE_EXTENDED_VERSION |
334 iDynamicResourceList.Initialise(0); |
359 iDynamicResourceList.Initialise(0); |
335 iDynamicResDependencyList.Initialise(0); |
360 iDynamicResDependencyList.Initialise(0); |
336 #endif |
361 #endif |
337 } |
|
338 |
|
339 /** Destructor for power controller. Frees the memory allocated in kernel heap. */ |
|
340 DPowerResourceController::~DPowerResourceController() |
|
341 { |
|
342 __KTRACE_OPT(KRESMANAGER, Kern::Printf("DPowerResourceController::~DPowerResourceController()")); |
|
343 #ifdef RESOURCE_MANAGER_SIMULATED_PSL |
|
344 iCleanList.ResetAndDestroy(); |
|
345 #endif |
|
346 iClientList.Delete(); |
|
347 iUserSideClientList.Delete(); |
|
348 |
|
349 |
|
350 |
|
351 #ifdef PRM_ENABLE_EXTENDED_VERSION |
|
352 iDynamicResourceList.Delete(); |
|
353 iDynamicResDependencyList.Delete(); |
|
354 #endif |
|
355 |
|
356 SPowerResourceClientLevel *pCL = iClientLevelPool; |
|
357 while(iClientLevelPool) //Find the starting position of array to delete |
|
358 { |
|
359 if(iClientLevelPool < pCL) |
|
360 pCL = iClientLevelPool; |
|
361 iClientLevelPool = iClientLevelPool->iNextInList; |
|
362 } |
|
363 //delete pCL; |
|
364 delete []pCL; |
|
365 SPowerRequest *pReq = iRequestPool; |
|
366 while(iRequestPool) //Find the starting position of array to delete |
|
367 { |
|
368 if(iRequestPool < pReq) |
|
369 pReq = iRequestPool; |
|
370 iRequestPool = iRequestPool->iNext; |
|
371 } |
|
372 //delete pR |
|
373 delete []pReq; |
|
374 #ifdef PRM_ENABLE_EXTENDED_VERSION |
|
375 pCL = iResourceLevelPool; |
|
376 while(iResourceLevelPool) |
|
377 { |
|
378 if(iResourceLevelPool < pCL) |
|
379 pCL = iResourceLevelPool; |
|
380 iResourceLevelPool = iResourceLevelPool->iNextInList; |
|
381 } |
|
382 //delete resource pool |
|
383 delete []pCL; |
|
384 //delete Message Queue dependency |
|
385 delete iMsgQDependency; |
|
386 #endif |
|
387 //delete Message Queue |
|
388 delete iMsgQ; |
|
389 } |
362 } |
390 |
363 |
391 /** Send notificatins to clients registered for it for the specified resource. */ |
364 /** Send notificatins to clients registered for it for the specified resource. */ |
392 void DPowerResourceController::CompleteNotifications(TInt aClientId, DStaticPowerResource* aResource, TInt aState, |
365 void DPowerResourceController::CompleteNotifications(TInt aClientId, DStaticPowerResource* aResource, TInt aState, |
393 TInt aReturnCode, TInt aLevelOwnerId, TBool aLock) |
366 TInt aReturnCode, TInt aLevelOwnerId, TBool aLock) |
401 pN = _LOFF(pNL, DPowerResourceNotification, iNotificationLink); |
374 pN = _LOFF(pNL, DPowerResourceNotification, iNotificationLink); |
402 #ifdef PRM_ENABLE_EXTENDED_VERSION |
375 #ifdef PRM_ENABLE_EXTENDED_VERSION |
403 //If dyanmic resource is deregistering, send notification to all clients requested for it |
376 //If dyanmic resource is deregistering, send notification to all clients requested for it |
404 if((pN->iCallback.iResourceId & KIdMaskDynamic) && (aClientId == KDynamicResourceDeRegistering)) |
377 if((pN->iCallback.iResourceId & KIdMaskDynamic) && (aClientId == KDynamicResourceDeRegistering)) |
405 { |
378 { |
|
379 pN->iCallback.iResult=aReturnCode; |
|
380 pN->iCallback.iMutex = iResourceMutex; |
|
381 pN->iCallback.iPendingRequestCount++; |
406 pN->iCallback.iResult = aReturnCode; |
382 pN->iCallback.iResult = aReturnCode; |
407 pN->iCallback.iLevel = aState; |
383 pN->iCallback.iLevel = aState; |
408 pN->iCallback.iClientId = aClientId; |
384 pN->iCallback.iClientId = aClientId; |
409 pN->iCallback.iLevelOwnerId = aLevelOwnerId; |
385 pN->iCallback.iLevelOwnerId = aLevelOwnerId; |
410 __KTRACE_OPT(KRESMANAGER, Kern::Printf("Notification ClientId = 0x%x, ResourceId = %d, state = %d, Result = %d", |
386 __KTRACE_OPT(KRESMANAGER, Kern::Printf("Notification ClientId = 0x%x, ResourceId = %d, state = %d, Result = %d", |
416 #endif |
392 #endif |
417 if((pN->iType==DPowerResourceNotification::EUnconditional) || |
393 if((pN->iType==DPowerResourceNotification::EUnconditional) || |
418 (pN->iDirection && ((pN->iPreviousLevel < pN->iThreshold) && (aState >= pN->iThreshold))) || |
394 (pN->iDirection && ((pN->iPreviousLevel < pN->iThreshold) && (aState >= pN->iThreshold))) || |
419 (!pN->iDirection && ((pN->iPreviousLevel > pN->iThreshold) && (aState <= pN->iThreshold)))) |
395 (!pN->iDirection && ((pN->iPreviousLevel > pN->iThreshold) && (aState <= pN->iThreshold)))) |
420 { |
396 { |
421 pN->iCallback.iResult=aReturnCode; |
397 pN->iCallback.iResult=aReturnCode; |
422 pN->iCallback.iLevel=aState; |
398 pN->iCallback.iMutex = iResourceMutex; |
423 pN->iCallback.iClientId = aClientId; |
399 pN->iCallback.iPendingRequestCount++; |
|
400 pN->iCallback.iLevel=aState; |
|
401 pN->iCallback.iClientId = aClientId; |
424 pN->iCallback.iLevelOwnerId = aLevelOwnerId; |
402 pN->iCallback.iLevelOwnerId = aLevelOwnerId; |
|
403 |
425 __KTRACE_OPT(KRESMANAGER, Kern::Printf("Notifications ClientId = 0x%x, ResourceId = %d, State = %d, Result = %d", |
404 __KTRACE_OPT(KRESMANAGER, Kern::Printf("Notifications ClientId = 0x%x, ResourceId = %d, State = %d, Result = %d", |
426 pN->iCallback.iClientId, pN->iCallback.iResourceId, aState, aReturnCode)); |
405 pN->iCallback.iClientId, pN->iCallback.iResourceId, aState, aReturnCode)); |
427 PRM_POSTNOTIFICATION_SENT_TRACE |
406 PRM_POSTNOTIFICATION_SENT_TRACE |
428 pN->iCallback.Enque(); |
407 |
|
408 pN->iCallback.Enque(); |
|
409 |
429 } |
410 } |
430 pN->iPreviousLevel = aState; //Update the state |
411 pN->iPreviousLevel = aState; //Update the state |
431 } |
412 } |
432 __KTRACE_OPT(KRESMANAGER, Kern::Printf("<DPowerResourceController::CompleteNotifications")); |
413 __KTRACE_OPT(KRESMANAGER, Kern::Printf("<DPowerResourceController::CompleteNotifications")); |
433 if(aLock) |
414 if(aLock) |
842 Finally mark resource controller as fully initialised (ready to accept state change and get request) |
835 Finally mark resource controller as fully initialised (ready to accept state change and get request) |
843 and start the message queue if exists. */ |
836 and start the message queue if exists. */ |
844 TInt DPowerResourceController::InitResources() |
837 TInt DPowerResourceController::InitResources() |
845 { |
838 { |
846 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DPowerResourceController::InitResources()")); |
839 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DPowerResourceController::InitResources()")); |
847 TUint16 count; |
840 TInt count; |
848 //Create a Kernel client object for Power Controller |
841 //Create a Kernel client object for Power Controller |
849 Lock(); |
842 Lock(); |
850 SPowerResourceClient * pC = NULL; |
843 SPowerResourceClient * pC = NULL; |
851 // By now client pool should be created |
844 // By now client pool should be created |
852 LIST_POP(iClientPool, pC, iNextInList); |
845 LIST_POP(iClientPool, pC, iNextInList); |
853 TUint16 growBy = iClientList.GrowBy(); |
846 TInt growBy = iClientList.GrowBy(); |
854 if(!pC) |
847 if(!pC) |
855 { |
848 { |
856 UnLock(); |
849 UnLock(); |
857 // coverity[alloc_fn] |
850 // coverity[alloc_fn] |
858 SPowerResourceClient *pCL = new SPowerResourceClient[growBy]; |
851 SPowerResourceClient *pCL = new SPowerResourceClient[growBy]; |
886 iClientList.Add(pC, iPowerControllerId); |
879 iClientList.Add(pC, iPowerControllerId); |
887 pC->iClientId = iPowerControllerId | CLIENT_POWER_CONTROLLER_BIT_MASK; |
880 pC->iClientId = iPowerControllerId | CLIENT_POWER_CONTROLLER_BIT_MASK; |
888 iPowerControllerId = pC->iClientId; |
881 iPowerControllerId = pC->iClientId; |
889 iClientCount++; |
882 iClientCount++; |
890 if(TPowerController::PowerController()) |
883 if(TPowerController::PowerController()) |
891 TPowerController::PowerController()->RegisterResourceController(this, iPowerControllerId); |
884 { |
|
885 if(TPowerController::PowerController()->RegisterResourceController(this, iPowerControllerId)) |
|
886 { |
|
887 #ifndef RESOURCE_MANAGER_SIMULATED_PSL |
|
888 Panic(EControllerAlreadyExists); // Panic with this error for any error returned by RegisterResourceController |
|
889 #endif |
|
890 } |
|
891 } |
|
892 |
892 iInitialised =EResConStartupCompleted; |
893 iInitialised =EResConStartupCompleted; |
893 UnLock(); |
894 UnLock(); |
894 //Check the resource for postboot level and send notifications to clients registered for it. |
895 //Check the resource for postboot level and send notifications to clients registered for it. |
895 DStaticPowerResource *pR = NULL; |
896 DStaticPowerResource *pR = NULL; |
896 TInt r; |
897 TInt r; |
897 TPowerRequest req = TPowerRequest::Get(); |
898 TPowerRequest req = TPowerRequest::Get(); |
898 //For Static resource with no dependencies |
899 //For Static resource with no dependencies |
899 for(count = 0; count< iStaticResourceArrayEntries; count++) |
900 for(count = 0; count < iStaticResourceArray.Count(); count++) |
900 { |
901 { |
901 pR = iStaticResourceArray[count]; |
902 pR = iStaticResourceArray[count]; |
902 if(pR && (pR->iFlags & SET_VALID_POST_BOOT_LEVEL)) |
903 if(pR && (pR->iFlags & SET_VALID_POST_BOOT_LEVEL)) |
903 { |
904 { |
904 //Form the request message |
905 //Form the request message |
932 req.ResourceCb() = NULL; |
933 req.ResourceCb() = NULL; |
933 req.RequiresChange() = ETrue; |
934 req.RequiresChange() = ETrue; |
934 //Form the request message |
935 //Form the request message |
935 ((DStaticPowerResourceD*)pR)->HandleChangePropagation(req, EChangeStart, req.ClientId(), KNoClient); |
936 ((DStaticPowerResourceD*)pR)->HandleChangePropagation(req, EChangeStart, req.ClientId(), KNoClient); |
936 } |
937 } |
|
938 } |
|
939 #endif |
|
940 |
|
941 // delete the temporary copy of static resource array used during initialization. |
|
942 if(StaticResourceArrayPtr) |
|
943 { |
|
944 delete StaticResourceArrayPtr; |
|
945 StaticResourceArrayPtr = NULL; |
|
946 } |
|
947 #ifdef PRM_ENABLE_EXTENDED_VERSION |
|
948 // the same applies to dependency resources array for extended version. |
|
949 if(StaticResourceDependencyArrayPtr) |
|
950 { |
|
951 delete StaticResourceDependencyArrayPtr; |
|
952 StaticResourceDependencyArrayPtr = NULL; |
937 } |
953 } |
938 #endif |
954 #endif |
939 __KTRACE_OPT(KRESMANAGER, Kern::Printf("<DPowerResourceController::InitResources()")); |
955 __KTRACE_OPT(KRESMANAGER, Kern::Printf("<DPowerResourceController::InitResources()")); |
940 return KErrNone; |
956 return KErrNone; |
941 } |
957 } |
1265 } |
1281 } |
1266 #ifdef RESOURCE_MANAGER_SIMULATED_PSL |
1282 #ifdef RESOURCE_MANAGER_SIMULATED_PSL |
1267 iCleanList.Append(pC); |
1283 iCleanList.Append(pC); |
1268 #endif |
1284 #endif |
1269 Lock(); |
1285 Lock(); |
1270 TUint16 c; |
1286 TInt c; |
1271 for(c = 0; c < iStaticResDependencyCount; c++) |
1287 for(c = 0; c < iStaticResDependencyArray.Count(); c++) |
1272 { |
1288 { |
1273 LIST_PUSH(iResourceLevelPool, &pRL[c], iNextInList); |
1289 LIST_PUSH(iResourceLevelPool, &pRL[c], iNextInList); |
1274 } |
1290 } |
1275 iResourceLevelPoolCount = iStaticResDependencyCount; |
1291 iResourceLevelPoolCount = (TUint16)iStaticResDependencyArray.Count(); |
1276 #else |
1292 #else |
1277 #ifdef RESOURCE_MANAGER_SIMULATED_PSL |
1293 #ifdef RESOURCE_MANAGER_SIMULATED_PSL |
1278 iCleanList.Append(pC); |
1294 iCleanList.Append(pC); |
1279 #endif |
1295 #endif |
1280 Lock(); |
1296 Lock(); |
1281 TUint16 c; |
1297 TUint16 c; |
1282 #endif |
1298 #endif |
1283 // Create Client pool list |
1299 // Create Client pool list |
1284 for(c = 0; c< (aKClients + aUClients); c++) |
1300 for(c = 0; c < TUint16(aKClients + aUClients); c++) |
1285 { |
1301 { |
1286 LIST_PUSH(iClientPool, &pC[c], iNextInList); |
1302 LIST_PUSH(iClientPool, &pC[c], iNextInList); |
1287 } |
1303 } |
1288 // Create client level pool list |
1304 // Create client level pool list |
1289 for(c = 0; c < aNClientLevels; c++) |
1305 for(c = 0; c < aNClientLevels; c++) |
1365 req->ReqType() = TPowerRequest::ERegisterKernelClient; |
1381 req->ReqType() = TPowerRequest::ERegisterKernelClient; |
1366 UnLock(); |
1382 UnLock(); |
1367 req->SendReceive(iMsgQ); |
1383 req->SendReceive(iMsgQ); |
1368 if(req->ReturnCode() == KErrNone) |
1384 if(req->ReturnCode() == KErrNone) |
1369 { |
1385 { |
1370 pC = iClientList[(TUint16)(req->ClientId() & ID_INDEX_BIT_MASK)]; |
1386 pC = iClientList[(req->ClientId() & ID_INDEX_BIT_MASK)]; |
1371 if(aType == EOwnerThread) |
1387 if(aType == EOwnerThread) |
1372 { |
1388 { |
1373 pC->iClientId |= CLIENT_THREAD_RELATIVE_BIT_MASK; //Set 31st bit; |
1389 pC->iClientId |= CLIENT_THREAD_RELATIVE_BIT_MASK; //Set 31st bit; |
1374 //Store the current thread Id; |
1390 //Store the current thread Id; |
1375 pC->iThreadId = thread.iId; |
1391 pC->iThreadId = thread.iId; |
1376 } |
1392 } |
1377 pC->iName = &aName; |
1393 pC->iName = &aName; |
1378 aClientId = pC->iClientId; |
1394 aClientId = pC->iClientId; |
1379 } |
1395 PRM_CLIENT_REGISTER_TRACE |
1380 PRM_CLIENT_REGISTER_TRACE |
1396 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DPowerResourceController::RegisterClient, clientId = 0x%x", aClientId)); |
1381 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DPowerResourceController::RegisterClient, clientId = 0x%x", aClientId)); |
1397 } |
1382 return(req->ReturnCode()); |
1398 return(req->ReturnCode()); |
1383 } |
1399 } |
1384 |
1400 |
1385 #ifdef PRM_ENABLE_EXTENDED_VERSION |
1401 #ifdef PRM_ENABLE_EXTENDED_VERSION |
1386 TInt DPowerResourceController::HandleResourceRegistration(TPowerRequest& aReq) |
1402 TInt DPowerResourceController::HandleResourceRegistration(TPowerRequest& aReq) |
1538 SPowerResourceClientLevel* pCLL = NULL; |
1554 SPowerResourceClientLevel* pCLL = NULL; |
1539 while(pCL != NULL) |
1555 while(pCL != NULL) |
1540 { |
1556 { |
1541 __KTRACE_OPT(KRESMANAGER, Kern::Printf("Client 0x%x has requirement on resource %d", pCL->iClientId, pCL->iResourceId)); |
1557 __KTRACE_OPT(KRESMANAGER, Kern::Printf("Client 0x%x has requirement on resource %d", pCL->iClientId, pCL->iResourceId)); |
1542 #ifdef PRM_ENABLE_EXTENDED_VERSION |
1558 #ifdef PRM_ENABLE_EXTENDED_VERSION |
1543 switch((pCL->iResourceId >>RESOURCE_BIT_IN_ID_CHECK) & 0x3) |
1559 switch((pCL->iResourceId >>RESOURCE_BIT_IN_ID_CHECK) & 0x3) |
1544 { |
1560 { |
1545 case PRM_STATIC_RESOURCE: |
1561 case PRM_STATIC_RESOURCE: |
1546 pR = iStaticResourceArray[pCL->iResourceId - 1]; |
1562 pR = iStaticResourceArray[pCL->iResourceId - 1]; |
1547 break; |
1563 break; |
1548 case PRM_DYNAMIC_RESOURCE: |
1564 case PRM_DYNAMIC_RESOURCE: |
1549 pR = (iDynamicResourceList[(TUint16)(pCL->iResourceId & ID_INDEX_BIT_MASK)]); |
1565 pR = (iDynamicResourceList[(pCL->iResourceId & ID_INDEX_BIT_MASK)]); |
1550 break; |
1566 break; |
1551 case PRM_STATIC_DEPENDENCY_RESOURCE: |
1567 case PRM_STATIC_DEPENDENCY_RESOURCE: |
1552 pR = (iStaticResDependencyArray[(TUint16)(pCL->iResourceId & ID_INDEX_BIT_MASK) - 1]); |
1568 pR = (iStaticResDependencyArray[(pCL->iResourceId & ID_INDEX_BIT_MASK) - 1]); |
1553 break; |
1569 break; |
1554 case PRM_DYNAMIC_DEPENDENCY_RESOURCE: |
1570 case PRM_DYNAMIC_DEPENDENCY_RESOURCE: |
1555 pR = (iDynamicResDependencyList[(TUint16)(pCL->iResourceId & ID_INDEX_BIT_MASK)]); |
1571 pR = (iDynamicResDependencyList[(pCL->iResourceId & ID_INDEX_BIT_MASK)]); |
1556 break; |
1572 break; |
1557 } |
1573 } |
1558 #else |
1574 #else |
1559 pR = iStaticResourceArray[pCL->iResourceId -1]; |
1575 pR = iStaticResourceArray[pCL->iResourceId - 1]; |
1560 #endif |
1576 #endif |
1561 #ifdef PRM_ENABLE_EXTENDED_VERSION |
1577 #ifdef PRM_ENABLE_EXTENDED_VERSION |
1562 if(((pR->Sense() == DStaticPowerResource::ECustom) || ((TInt)pCL->iClientId == pR->iLevelOwnerId)) && (!(pCL->iResourceId & KIdMaskDynamic) || |
1578 if(pR && (((pR->Sense() == DStaticPowerResource::ECustom) || ((TInt)pCL->iClientId == pR->iLevelOwnerId)) && (!(pCL->iResourceId & KIdMaskDynamic) || |
1563 ((pCL->iResourceId & KIdMaskDynamic) && (((DDynamicPowerResource*)pR)->LockCount() != 0)))) |
1579 ((pCL->iResourceId & KIdMaskDynamic) && (((DDynamicPowerResource*)pR)->LockCount() != 0))))) |
1564 #else |
1580 #else |
1565 if((pR->Sense() == DStaticPowerResource::ECustom) || ((TInt)pCL->iClientId == pR->iLevelOwnerId)) |
1581 if(pR && ((pR->Sense() == DStaticPowerResource::ECustom) || ((TInt)pCL->iClientId == pR->iLevelOwnerId))) |
1566 #endif |
1582 #endif |
1567 { |
1583 { |
1568 pReq->ReqType() = TPowerRequest::ESetDefaultLevel; |
1584 pReq->ReqType() = TPowerRequest::ESetDefaultLevel; |
1569 pReq->ResourceId() = pCL->iResourceId; |
1585 pReq->ResourceId() = pCL->iResourceId; |
1570 pReq->ClientId() = pCL->iClientId; |
1586 pReq->ClientId() = pCL->iClientId; |
1723 ResourceStateChangeOfClientLevels(pC); |
1739 ResourceStateChangeOfClientLevels(pC); |
1724 // Add reserved request to pool |
1740 // Add reserved request to pool |
1725 iRequestPoolCount = (TUint16)(iRequestPoolCount + (TUint16)pC->iReservedRm); |
1741 iRequestPoolCount = (TUint16)(iRequestPoolCount + (TUint16)pC->iReservedRm); |
1726 PRM_CLIENT_DEREGISTER_TRACE |
1742 PRM_CLIENT_DEREGISTER_TRACE |
1727 //Increment the free pool count for client level and request level. |
1743 //Increment the free pool count for client level and request level. |
1728 iClientList.Remove(pC, (TUint16)(pC->iClientId & ID_INDEX_BIT_MASK)); |
1744 iClientList.Remove(pC, (pC->iClientId & ID_INDEX_BIT_MASK)); |
1729 pC->iName = NULL; |
1745 pC->iName = NULL; |
1730 iClientCount--; //Decrement client count |
1746 iClientCount--; //Decrement client count |
1731 LIST_PUSH(iClientPool, pC, iNextInList); |
1747 LIST_PUSH(iClientPool, pC, iNextInList); |
1732 __KTRACE_OPT(KRESMANAGER, Kern::Printf("<DPowerResourceController::DeRegisterClient")); |
1748 __KTRACE_OPT(KRESMANAGER, Kern::Printf("<DPowerResourceController::DeRegisterClient")); |
1733 UNLOCK_RETURN(KErrNone); |
1749 UNLOCK_RETURN(KErrNone); |
1882 aResourceId = pDR->iResourceId; |
1898 aResourceId = pDR->iResourceId; |
1883 __KTRACE_OPT(KRESMANAGER, Kern::Printf("<DPowerResourceController::GetResourceId, ResourceId = 0x%x", aResourceId)); |
1899 __KTRACE_OPT(KRESMANAGER, Kern::Printf("<DPowerResourceController::GetResourceId, ResourceId = 0x%x", aResourceId)); |
1884 UNLOCK_RETURN(KErrNone); |
1900 UNLOCK_RETURN(KErrNone); |
1885 } |
1901 } |
1886 //Search in static resource with dependencies (if exists) for specified resource name |
1902 //Search in static resource with dependencies (if exists) for specified resource name |
1887 for(count = 0; count < iStaticResDependencyCount; count++) |
1903 for(count = 0; count < iStaticResDependencyArray.Count(); count++) |
1888 { |
1904 { |
1889 if(!(aResourceName.Compare(*(const TDesC8*)iStaticResDependencyArray[count]->iName))) |
1905 if(!(aResourceName.Compare(*(const TDesC8*)iStaticResDependencyArray[count]->iName))) |
1890 { |
1906 { |
1891 aResourceId = iStaticResDependencyArray[count]->iResourceId; |
1907 aResourceId = iStaticResDependencyArray[count]->iResourceId; |
1892 __KTRACE_OPT(KRESMANAGER, Kern::Printf("<DPowerResourceController::GetResourceId, ResourceId = 0x%x", aResourceId)); |
1908 __KTRACE_OPT(KRESMANAGER, Kern::Printf("<DPowerResourceController::GetResourceId, ResourceId = 0x%x", aResourceId)); |
2101 TDes8 *pInfo = (TDes8*)anInfo; |
2117 TDes8 *pInfo = (TDes8*)anInfo; |
2102 if((TUint)(pInfo->MaxLength() - pInfo->Length()) < (sizeof(TPowerResourceInfoV01) * aNumResources)) |
2118 if((TUint)(pInfo->MaxLength() - pInfo->Length()) < (sizeof(TPowerResourceInfoV01) * aNumResources)) |
2103 UNLOCK_RETURN(KErrArgument); |
2119 UNLOCK_RETURN(KErrArgument); |
2104 TPowerResourceInfoBuf01 buf; |
2120 TPowerResourceInfoBuf01 buf; |
2105 |
2121 |
2106 TUint16 count = 0; |
2122 TInt count = 0; |
2107 TInt r = KErrNone; |
2123 TInt r = KErrNone; |
2108 //Special case, if aTargetClientId is 0 fill with all the resource |
2124 //Special case, if aTargetClientId is 0 fill with all the resource |
2109 if(!aTargetClientId) |
2125 if(!aTargetClientId) |
2110 { |
2126 { |
2111 TUint numResources = aNumResources; |
2127 TInt numResources = aNumResources; |
2112 #ifndef PRM_ENABLE_EXTENDED_VERSION |
2128 #ifndef PRM_ENABLE_EXTENDED_VERSION |
2113 aNumResources = iStaticResourceCount; |
2129 aNumResources = iStaticResourceCount; |
2114 #else |
2130 #else |
2115 aNumResources = iStaticResourceCount + iDynamicResourceCount + iStaticResDependencyCount + |
2131 aNumResources = iStaticResourceCount + iDynamicResourceCount + iStaticResDependencyArray.Count() + |
2116 iDynamicResDependencyCount; |
2132 iDynamicResDependencyCount; |
2117 #endif |
2133 #endif |
2118 UnLock(); |
2134 UnLock(); |
2119 while(count < iStaticResourceArrayEntries) |
2135 while(count < iStaticResourceArray.Count()) |
2120 { |
2136 { |
2121 if(numResources <=0) |
2137 if(numResources == 0) |
2122 return KErrNone; |
2138 return KErrNone; |
2123 pR = iStaticResourceArray[count++]; |
2139 pR = iStaticResourceArray[count++]; |
2124 if(!pR) |
2140 if(!pR) |
2125 continue; |
2141 continue; |
2126 r = pR->GetInfo((TDes8*)buf.Ptr()); |
2142 r = pR->GetInfo((TDes8*)buf.Ptr()); |
2391 |
2407 |
2392 Request changing the state of a resource |
2408 Request changing the state of a resource |
2393 NOTE: If a resource callback is specified for instantaneous resource, then callback |
2409 NOTE: If a resource callback is specified for instantaneous resource, then callback |
2394 will be called after resource change and will be executed in the context of the |
2410 will be called after resource change and will be executed in the context of the |
2395 client thread. |
2411 client thread. |
2396 If a resource callback is specified for long latency reosurces, then it will be |
2412 If a resource callback is specified for long latency resources, then it will be |
2397 executed asynchronously.When the request is accepted the API returns immediately |
2413 executed asynchronously.When the request is accepted the API returns immediately |
2398 and the calling thread is unblocked: the callback (called in the client's context) |
2414 and the calling thread is unblocked: the callback (called in the client's context) |
2399 will be invoked when the resource change finally takes place. |
2415 will be invoked when the resource change finally takes place. |
2400 If aCb is not specified (NULL by default) the API executes synchronously and will |
2416 If aCb is not specified (NULL by default) the API executes synchronously and will |
2401 only return when the resource change has taken place for long latency resource. |
2417 only return when the resource change has taken place for long latency resource. |
2410 binary resource, an integer level for a multilevel resource or some |
2426 binary resource, an integer level for a multilevel resource or some |
2411 platform specific token for a multi-property resource. |
2427 platform specific token for a multi-property resource. |
2412 @param aCb For Long latency resource |
2428 @param aCb For Long latency resource |
2413 A pointer to a resource callback object which encapsulates a |
2429 A pointer to a resource callback object which encapsulates a |
2414 callback function to be called whenever the resource state change |
2430 callback function to be called whenever the resource state change |
2415 happens (if left NULL the API will execute synchrounously). |
2431 happens (if left NULL the API will execute synchronously). |
2416 For Instantaneous resource |
2432 For Instantaneous resource |
2417 A pointer to a resource callback object which encapsulates a callback |
2433 A pointer to a resource callback object which encapsulates a callback |
2418 function to be called after resource change. This executes in the |
2434 function to be called after resource change. This executes in the |
2419 context of the client thread. |
2435 context of the client thread. |
2420 |
2436 |
2465 VALIDATE_CLIENT(thread); |
2481 VALIDATE_CLIENT(thread); |
2466 #ifdef PRM_ENABLE_EXTENDED_VERSION |
2482 #ifdef PRM_ENABLE_EXTENDED_VERSION |
2467 DStaticPowerResource *pR = NULL; |
2483 DStaticPowerResource *pR = NULL; |
2468 GET_RESOURCE_FROM_LIST(aResourceId, pR) |
2484 GET_RESOURCE_FROM_LIST(aResourceId, pR) |
2469 #else |
2485 #else |
2470 if(aResourceId > iStaticResourceArrayEntries) |
2486 if(aResourceId > (TUint)iStaticResourceArray.Count()) |
2471 UNLOCK_RETURN(KErrNotFound); |
2487 UNLOCK_RETURN(KErrNotFound); |
2472 DStaticPowerResource* pR = iStaticResourceArray[aResourceId-1]; |
2488 DStaticPowerResource* pR = iStaticResourceArray[aResourceId-1]; |
2473 if(!pR) |
2489 if(!pR) |
2474 UNLOCK_RETURN(KErrNotFound); |
2490 UNLOCK_RETURN(KErrNotFound); |
2475 #endif |
2491 #endif |
2476 //Return if the resource is already in that state and client is also the same. |
2492 //Return if the resource is already in that state and client is also the same. |
2477 if((aNewState == pR->iCachedLevel) && ((TInt)aClientId == pR->iLevelOwnerId)) |
2493 if((aNewState == pR->iCachedLevel) && ((TInt)aClientId == pR->iLevelOwnerId)) |
2478 UNLOCK_RETURN(KErrNone); |
2494 { |
2479 |
2495 if(aCb) |
|
2496 { |
|
2497 //Invoke callback function |
|
2498 TUint ClientId = aClientId; |
|
2499 TUint ResourceId = aResourceId; |
|
2500 TInt Level = aNewState; |
|
2501 TInt LevelOwnerId = pR->iLevelOwnerId; |
|
2502 TInt Result = KErrNone; |
|
2503 TAny* Param = aCb->iParam; |
|
2504 aCb->iPendingRequestCount++; |
|
2505 UnLock(); |
|
2506 // Call the client specified callback function |
|
2507 aCb->iCallback(ClientId, ResourceId, Level, LevelOwnerId, Result, Param); |
|
2508 Lock(); |
|
2509 aCb->iPendingRequestCount--; |
|
2510 if(aCb->iPendingRequestCount == 0) |
|
2511 { |
|
2512 aCb->iResult = KErrCompletion; |
|
2513 } |
|
2514 } |
|
2515 UNLOCK_RETURN(KErrNone); |
|
2516 } |
2480 |
2517 |
2481 PRM_CLIENT_CHANGE_STATE_START_TRACE |
2518 PRM_CLIENT_CHANGE_STATE_START_TRACE |
2482 //If long latency resource requested synchronously from DFC thread 0 Panic |
2519 //If long latency resource requested synchronously from DFC thread 0 Panic |
2483 |
2520 |
2484 const TDesC8* pDfc0 = &KDfcThread0Name; |
2521 const TDesC8* pDfc0 = &KDfcThread0Name; |
2614 req->Level() = pR->iCachedLevel; |
2651 req->Level() = pR->iCachedLevel; |
2615 #ifdef PRM_ENABLE_EXTENDED_VERSION |
2652 #ifdef PRM_ENABLE_EXTENDED_VERSION |
2616 if(aResourceId & KIdMaskDynamic) |
2653 if(aResourceId & KIdMaskDynamic) |
2617 ((DDynamicPowerResource*)pR)->UnLock(); |
2654 ((DDynamicPowerResource*)pR)->UnLock(); |
2618 #endif |
2655 #endif |
2619 UnLock(); |
|
2620 if(aCb) |
2656 if(aCb) |
2621 { |
2657 { |
2622 //Invoke callback function |
2658 //Invoke callback function |
2623 aCb->iCallback(req->ClientId(), aResourceId, req->Level(), pR->iLevelOwnerId, r, aCb->iParam); |
2659 TUint ClientId = req->ClientId(); |
2624 //Mark the callback object to act properly during cancellation of this request. |
2660 TUint ResourceId = aResourceId; |
2625 aCb->iResult = KErrCompletion; |
2661 TInt Level = req->Level(); |
2626 } |
2662 TInt LevelOwnerId = pR->iLevelOwnerId; |
|
2663 TInt Result = r; |
|
2664 TAny* Param = aCb->iParam; |
|
2665 aCb->iPendingRequestCount++; |
|
2666 UnLock(); |
|
2667 // Call the client specified callback function |
|
2668 aCb->iCallback(ClientId, ResourceId, Level, LevelOwnerId, Result, Param); |
|
2669 Lock(); |
|
2670 aCb->iPendingRequestCount--; |
|
2671 if(aCb->iPendingRequestCount == 0) |
|
2672 { |
|
2673 aCb->iResult = KErrCompletion; |
|
2674 } |
|
2675 } |
|
2676 |
2627 PRM_CLIENT_CHANGE_STATE_END_TRACE |
2677 PRM_CLIENT_CHANGE_STATE_END_TRACE |
2628 return(r); |
2678 UNLOCK_RETURN(r); |
2629 } |
2679 } |
2630 } |
2680 } |
2631 else if(pR->iLevelOwnerId == -1) |
2681 else if(pR->iLevelOwnerId == -1) |
2632 { |
2682 { |
2633 /* Add client Level */ |
2683 /* Add client Level */ |
2682 } |
2732 } |
2683 #ifdef PRM_ENABLE_EXTENDED_VERSION |
2733 #ifdef PRM_ENABLE_EXTENDED_VERSION |
2684 if(aResourceId & KIdMaskDynamic) |
2734 if(aResourceId & KIdMaskDynamic) |
2685 ((DDynamicPowerResource*)pR)->UnLock(); |
2735 ((DDynamicPowerResource*)pR)->UnLock(); |
2686 #endif |
2736 #endif |
2687 UnLock(); |
|
2688 if(aCb) |
2737 if(aCb) |
2689 { |
2738 { |
2690 //Invoke callback function |
2739 //Invoke callback function |
2691 aCb->iCallback(req->ClientId(), aResourceId, req->Level(), pR->iLevelOwnerId, r, aCb->iParam); |
2740 TUint ClientId = req->ClientId(); |
2692 aCb->iResult = KErrCompletion; //Mark the callback object to act properly during cancellation of this request. |
2741 TUint ResourceId = aResourceId; |
|
2742 TInt Level = req->Level(); |
|
2743 TInt LevelOwnerId = pR->iLevelOwnerId; |
|
2744 TInt Result = r; |
|
2745 TAny* Param = aCb->iParam; |
|
2746 aCb->iPendingRequestCount++; |
|
2747 UnLock(); |
|
2748 // Call the client specified callback function |
|
2749 aCb->iCallback(ClientId, ResourceId, Level, LevelOwnerId, Result, Param); |
|
2750 Lock(); |
|
2751 aCb->iPendingRequestCount--; |
|
2752 if(aCb->iPendingRequestCount == 0) |
|
2753 { |
|
2754 aCb->iResult = KErrCompletion; |
|
2755 } |
2693 } |
2756 } |
2694 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DPowerResourceController::ChangeResourceState, Level = %d", req->Level())); |
2757 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DPowerResourceController::ChangeResourceState, Level = %d", req->Level())); |
2695 PRM_CLIENT_CHANGE_STATE_END_TRACE |
2758 PRM_CLIENT_CHANGE_STATE_END_TRACE |
2696 return r; |
2759 UNLOCK_RETURN(r); |
2697 } |
2760 } |
2698 |
2761 |
2699 /** |
2762 /** |
2700 @publishedPartner |
2763 @publishedPartner |
2701 @prototype 9.5 |
2764 @prototype 9.5 |
2707 @param aCached If ETrue, cached value will be updated in aState. |
2770 @param aCached If ETrue, cached value will be updated in aState. |
2708 If EFalse, aState will be updated after the resource |
2771 If EFalse, aState will be updated after the resource |
2709 state is read from resource. |
2772 state is read from resource. |
2710 @param aState Returns the resource state if operation was successful. This |
2773 @param aState Returns the resource state if operation was successful. This |
2711 could be a binary value for a binary resource, an integer level |
2774 could be a binary value for a binary resource, an integer level |
2712 for a multilevel resource or some platform specific tolen for a |
2775 for a multilevel resource or some platform specific token for a |
2713 multi-property resource. |
2776 multi-property resource. |
2714 @param aLevelOwnerId Returns the Id of the client that is currently holding the resource. |
2777 @param aLevelOwnerId Returns the Id of the client that is currently holding the resource. |
2715 -1 is returned when no client is holding the resource. |
2778 -1 is returned when no client is holding the resource. |
2716 |
2779 |
2717 @return KErrNone if operation was successful |
2780 @return KErrNone if operation was successful |
2913 aCb.iClientId = aClientId; |
2976 aCb.iClientId = aClientId; |
2914 |
2977 |
2915 PRM_RESOURCE_GET_STATE_START_TRACE |
2978 PRM_RESOURCE_GET_STATE_START_TRACE |
2916 if(aCached) //Call the callback directly |
2979 if(aCached) //Call the callback directly |
2917 { |
2980 { |
2918 UnLock(); |
2981 //Invoke callback function |
2919 aCb.iCallback(aClientId, aResourceId, pR->iCachedLevel, pR->iLevelOwnerId, KErrNone, aCb.iParam); |
2982 TUint ClientId = aClientId; |
2920 aCb.iResult = KErrCompletion; //Mark the callback object to act properly during cancellation of this request. |
2983 TUint ResourceId = aResourceId; |
|
2984 TInt Level = pR->iCachedLevel; |
|
2985 TInt LevelOwnerId = pR->iLevelOwnerId; |
|
2986 TInt Result = KErrNone; |
|
2987 TAny* Param = aCb.iParam; |
|
2988 aCb.iPendingRequestCount++; |
|
2989 UnLock(); |
|
2990 // Call the client specified callback function |
|
2991 aCb.iCallback(ClientId, ResourceId, Level, LevelOwnerId, Result, Param); |
|
2992 Lock(); |
|
2993 aCb.iPendingRequestCount--; |
|
2994 if(aCb.iPendingRequestCount == 0) |
|
2995 { |
|
2996 aCb.iResult = KErrCompletion; //Mark the callback object to act properly during cancellation of this request. |
|
2997 } |
2921 #ifdef PRM_INSTRUMENTATION_MACRO |
2998 #ifdef PRM_INSTRUMENTATION_MACRO |
2922 TInt aState = pR->iCachedLevel; |
2999 TInt aState = pR->iCachedLevel; |
2923 PRM_RESOURCE_GET_STATE_END_TRACE |
3000 PRM_RESOURCE_GET_STATE_END_TRACE |
2924 #endif |
3001 #endif |
2925 return(KErrNone); |
3002 UNLOCK_RETURN(KErrNone); |
2926 } |
3003 } |
2927 TPowerRequest* req=NULL; |
3004 TPowerRequest* req=NULL; |
2928 if(pR->LatencyGet()) |
3005 if(pR->LatencyGet()) |
2929 { |
3006 { |
2930 //Check the client quota of requests |
3007 //Check the client quota of requests |
2985 } |
3062 } |
2986 #ifdef PRM_ENABLE_EXTENDED_VERSION |
3063 #ifdef PRM_ENABLE_EXTENDED_VERSION |
2987 if(aResourceId & KIdMaskDynamic) |
3064 if(aResourceId & KIdMaskDynamic) |
2988 ((DDynamicPowerResource*)pR)->UnLock(); |
3065 ((DDynamicPowerResource*)pR)->UnLock(); |
2989 #endif |
3066 #endif |
2990 UnLock(); |
3067 |
2991 // Call the client callback function directly as it is already executing in the context of client thread. |
3068 //Invoke callback function |
2992 aCb.iCallback(aClientId, aResourceId, req->Level(), pR->iLevelOwnerId, r, aCb.iParam); |
3069 TUint ClientId = aClientId; |
2993 aCb.iResult = KErrCompletion; //Mark the callback object to act properly during cancellation of this request. |
3070 TUint ResourceId = aResourceId; |
|
3071 TInt Level = req->Level(); |
|
3072 TInt LevelOwnerId = pR->iLevelOwnerId; |
|
3073 TInt Result = r; |
|
3074 TAny* Param = aCb.iParam; |
|
3075 aCb.iPendingRequestCount++; |
|
3076 UnLock(); |
|
3077 // Call the client specified callback function |
|
3078 aCb.iCallback(ClientId, ResourceId, Level, LevelOwnerId, Result, Param); |
|
3079 Lock(); |
|
3080 aCb.iPendingRequestCount--; |
|
3081 if(aCb.iPendingRequestCount == 0) |
|
3082 { |
|
3083 aCb.iResult = KErrCompletion; //Mark the callback object to act properly during cancellation of this request. |
|
3084 } |
|
3085 UnLock(); |
2994 } |
3086 } |
2995 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DPowerResourceController::GetResourceState(asynchronous), Level = %d", req->Level())); |
3087 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DPowerResourceController::GetResourceState(asynchronous), Level = %d", req->Level())); |
2996 if(pR->LatencyGet()) |
3088 if(pR->LatencyGet()) |
2997 return r; |
3089 return r; |
2998 #ifdef PRM_INSTRUMENTATION_MACRO |
3090 #ifdef PRM_INSTRUMENTATION_MACRO |
3008 @prototype 9.5 |
3100 @prototype 9.5 |
3009 |
3101 |
3010 Cancel an asynchronous request(or its callback). |
3102 Cancel an asynchronous request(or its callback). |
3011 |
3103 |
3012 @param aClientId ID of the client which is requesting the cancellation of the request. |
3104 @param aClientId ID of the client which is requesting the cancellation of the request. |
3013 @param aResourceId ID for the resource which the request that is being cancelled operates |
3105 @param aResourceId ID for the resource which the request that is being canceled operates |
3014 upon. |
3106 upon. |
3015 @param aCb A reference to the resource callback object specified with the request |
3107 @param aCb A reference to the resource callback object specified with the request |
3016 that is being cancelled. |
3108 that is being canceled. |
3017 |
3109 |
3018 @return KErrCancel if the request was cancelled. |
3110 @return KErrCancel if the request was canceled. |
3019 KErrNotFound if this resource ID could not be found in the current list of controllable |
3111 KErrNotFound if this resource ID could not be found in the current list of controllable |
3020 resources. |
3112 resources. |
3021 KErrCompletion if request is no longer pending. |
3113 KErrCompletion if request is no longer pending. |
3022 KErrAccessDenied if the client ID could not be found in the current list of registered |
3114 KErrAccessDenied if the client ID could not be found in the current list of registered |
3023 clients or if the client was registered to be thread relative and this API is not called |
3115 clients or if the client was registered to be thread relative and this API is not called |
3024 from the same thread or if client is not the same that requested the resource state change. |
3116 from the same thread or if client is not the same that requested the resource state change. |
3025 KErrInUse if the request cannot be cancelled as processing of the request already started |
3117 KErrInUse if the request cannot be canceled as processing of the request already started |
3026 and will run to completion. |
3118 and will run to completion. |
3027 |
3119 |
3028 @pre Interrupts must be enabled |
3120 @pre Interrupts must be enabled |
3029 @pre Kernel must be unlocked |
3121 @pre Kernel must be unlocked |
3030 @pre No fast mutex can be held |
3122 @pre No fast mutex can be held |
3140 thread relative and this API is not called from the same thread. |
3232 thread relative and this API is not called from the same thread. |
3141 KErrInUse if the passed notification object is used already. |
3233 KErrInUse if the passed notification object is used already. |
3142 NOTE: This API should return immediately; however the notification will |
3234 NOTE: This API should return immediately; however the notification will |
3143 only happen when a resource change occurs.Notification request is idempotent, |
3235 only happen when a resource change occurs.Notification request is idempotent, |
3144 if the same notification has already been requested for this resource ID, |
3236 if the same notification has already been requested for this resource ID, |
3145 the API returns with no further action.Notifications remain queued until they are cancelled. |
3237 the API returns with no further action.Notifications remain queued until they are canceled. |
3146 |
3238 |
3147 @pre Interrupts must be enabled |
3239 @pre Interrupts must be enabled |
3148 @pre Kernel must be unlocked |
3240 @pre Kernel must be unlocked |
3149 @pre No fast mutex can be held |
3241 @pre No fast mutex can be held |
3150 @pre Call in a thread context but not from null thread or DFC thread1 |
3242 @pre Call in a thread context but not from null thread or DFC thread1 |
3232 |
3324 |
3233 |
3325 |
3234 |
3326 |
3235 @return KErrNone if the operation of requesting a notification was successful. |
3327 @return KErrNone if the operation of requesting a notification was successful. |
3236 KErrNotFound if this resource ID could not be found in the current list |
3328 KErrNotFound if this resource ID could not be found in the current list |
3237 of controllable reosurces. |
3329 of controllable resources. |
3238 KErrAccessDenied if the client ID could not be found in the list of |
3330 KErrAccessDenied if the client ID could not be found in the list of |
3239 registered clients or if the client was registered to be thread |
3331 registered clients or if the client was registered to be thread |
3240 relative and this API is not called from the same thread. |
3332 relative and this API is not called from the same thread. |
3241 KErrInUse if the passed notification object is used already. |
3333 KErrInUse if the passed notification object is used already. |
3242 KErrArgument if the specified threshold is out of range. |
3334 KErrArgument if the specified threshold is out of range. |
3243 NOTE: This API should return immediately; however the notification will only |
3335 NOTE: This API should return immediately; however the notification will only |
3244 happen when a resource change occurs. Notification request is idempotent, |
3336 happen when a resource change occurs. Notification request is idempotent, |
3245 if the same notification has already been requested for this resource ID, |
3337 if the same notification has already been requested for this resource ID, |
3246 the API returns with no further action. Notification remain queued until they are cancelled. |
3338 the API returns with no further action. Notification remain queued until they are canceled. |
3247 |
3339 |
3248 @pre Interrupts must be enabled |
3340 @pre Interrupts must be enabled |
3249 @pre Kernel must be unlocked |
3341 @pre Kernel must be unlocked |
3250 @pre No fast mutex can be held |
3342 @pre No fast mutex can be held |
3251 @pre Call in a thread context but not from null thread or DFC thread1 |
3343 @pre Call in a thread context but not from null thread or DFC thread1 |
3335 Cancel and remove from queue a previously issued request for notification on a |
3427 Cancel and remove from queue a previously issued request for notification on a |
3336 resource state change. |
3428 resource state change. |
3337 |
3429 |
3338 @param aClientId ID of the client which is requesting to cancel the notification |
3430 @param aClientId ID of the client which is requesting to cancel the notification |
3339 @param aResourceId for the resource whose pending notification of state changes |
3431 @param aResourceId for the resource whose pending notification of state changes |
3340 is being cancelled. |
3432 is being canceled. |
3341 @param aN A reference to the notification object that was associated with |
3433 @param aN A reference to the notification object that was associated with |
3342 the notification request that is being cancelled. This will be |
3434 the notification request that is being canceled. This will be |
3343 used to identify the notification that is being cancelled. |
3435 used to identify the notification that is being canceled. |
3344 |
3436 |
3345 @return KErrCancel if the notification request was successfully cancelled. |
3437 @return KErrCancel if the notification request was successfully canceled. |
3346 KErrNotFound if the specified notification object is |
3438 KErrNotFound if the specified notification object is |
3347 not found in the current list of notification objects for the |
3439 not found in the current list of notification objects for the |
3348 specified resource. |
3440 specified resource. |
3349 KErrAccessDenied if the client requesting the cancellation is not the same |
3441 KErrAccessDenied if the client requesting the cancellation is not the same |
3350 which registered the notification or if the resource id does not match or |
3442 which registered the notification or if the resource id does not match or |
3595 req->ReqType() = TPowerRequest::ERegisterUsersideClient; |
3687 req->ReqType() = TPowerRequest::ERegisterUsersideClient; |
3596 UnLock(); |
3688 UnLock(); |
3597 req->SendReceive(iMsgQ); |
3689 req->SendReceive(iMsgQ); |
3598 if(req->ReturnCode() == KErrNone) |
3690 if(req->ReturnCode() == KErrNone) |
3599 { |
3691 { |
3600 pC = iUserSideClientList[(TUint16)(req->ClientId() & ID_INDEX_BIT_MASK)]; |
3692 pC = iUserSideClientList[(req->ClientId() & ID_INDEX_BIT_MASK)]; |
3601 pC->iName=&aName; |
3693 pC->iName=&aName; |
3602 //Store the current thread Id; |
3694 //Store the current thread Id; |
3603 pC->iThreadId = t.iId; |
3695 pC->iThreadId = t.iId; |
3604 aClientId = pC->iClientId; |
3696 aClientId = pC->iClientId; |
3605 } |
3697 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DPowerResourceController::RegisterProxyClient, clientId = 0x%x", aClientId)); |
3606 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DPowerResourceController::RegisterProxyClient, clientId = 0x%x", aClientId)); |
3698 PRM_CLIENT_REGISTER_TRACE |
3607 PRM_CLIENT_REGISTER_TRACE |
3699 } |
3608 LOCK_AND_CRITICAL_SECTION_COUNT_CHECK |
3700 LOCK_AND_CRITICAL_SECTION_COUNT_CHECK |
3609 return KErrNone; |
3701 return KErrNone; |
3610 } |
3702 } |
3611 |
3703 |
3612 /* Deregister the specified user side client from resource controller. |
3704 /* Deregister the specified user side client from resource controller. |
3668 ResourceStateChangeOfClientLevels(pC); |
3760 ResourceStateChangeOfClientLevels(pC); |
3669 //Add reserved request to pool |
3761 //Add reserved request to pool |
3670 iRequestPoolCount = (TUint16)(iRequestPoolCount + pC->iReservedRm); |
3762 iRequestPoolCount = (TUint16)(iRequestPoolCount + pC->iReservedRm); |
3671 PRM_CLIENT_DEREGISTER_TRACE |
3763 PRM_CLIENT_DEREGISTER_TRACE |
3672 //Increment the free pool count for client level and request level. |
3764 //Increment the free pool count for client level and request level. |
3673 iUserSideClientList.Remove(pC, (TUint16)(pC->iClientId & ID_INDEX_BIT_MASK)); |
3765 iUserSideClientList.Remove(pC, (pC->iClientId & ID_INDEX_BIT_MASK)); |
3674 pC->iName = NULL; |
3766 pC->iName = NULL; |
3675 iUserSideClientCount--; //Decrement client count |
3767 iUserSideClientCount--; //Decrement client count |
3676 LIST_PUSH(iClientPool, pC, iNextInList); |
3768 LIST_PUSH(iClientPool, pC, iNextInList); |
3677 UnLock(); |
3769 UnLock(); |
3678 LOCK_AND_CRITICAL_SECTION_COUNT_CHECK |
3770 LOCK_AND_CRITICAL_SECTION_COUNT_CHECK |