--- a/kernel/eka/include/drivers/resource.h Thu Aug 19 11:14:22 2010 +0300
+++ b/kernel/eka/include/drivers/resource.h Tue Aug 31 16:34:26 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the License "Eclipse Public License v1.0"
@@ -12,7 +12,7 @@
//
// Description:
// e32\include\drivers\resource.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.
@@ -26,18 +26,18 @@
#include <drivers/resource_category.h>
//Definition for resource flag setting. Used by PSL.
-static const TUint KTypeMask= 0x3;
-static const TUint KUsageOffset=0x1F;
-static const TUint KLongLatencySetOffset=0x1E;
-static const TUint KLongLatencyGetOffset=0x1D;
-static const TUint KClassOffset=0x1C;
-static const TUint KSenseOffset=0x1A;
-static const TUint KShared=0x1<<KUsageOffset;
-static const TUint KLongLatencySet=0x1<<KLongLatencySetOffset;
-static const TUint KLongLatencyGet=0x1<<KLongLatencyGetOffset;
-static const TUint KLogical=0x1<<KClassOffset;
-static const TUint KSenseNegative=0x01<<KSenseOffset;
-static const TUint KSenseCustom=0x2<<KSenseOffset;
+const TUint KTypeMask = 0x3;
+const TUint KUsageOffset = 0x1F;
+const TUint KLongLatencySetOffset = 0x1E;
+const TUint KLongLatencyGetOffset = 0x1D;
+const TUint KClassOffset = 0x1C;
+const TUint KSenseOffset = 0x1A;
+const TUint KShared = 0x1u << KUsageOffset;
+const TUint KLongLatencySet = 0x1u << KLongLatencySetOffset;
+const TUint KLongLatencyGet = 0x1u << KLongLatencyGetOffset;
+const TUint KLogical = 0x1u << KClassOffset;
+const TUint KSenseNegative = 0x1u << KSenseOffset;
+const TUint KSenseCustom = 0x2u << KSenseOffset;
struct TPowerRequest;
struct SIdleResourceInfo;
@@ -149,7 +149,7 @@
/**
@publishedPartner
@prototype 9.5
-An object of this type prepresents a customised Dfc
+An object of this type represents a customized Dfc
used to signal completion of the resource manager's asynchronous APIs
and completion of notifications
@see TPowerResourceManager
@@ -168,19 +168,48 @@
__KTRACE_OPT(KRESMANAGER, Kern::Printf(">TPowerResourceCb::DfcFunc ClientId = 0x%x, ResourceId = %d, Level = %d, \
LevelOwnerId = %d, Result = %d", pCb->iClientId, pCb->iResourceId, pCb->iLevel, \
pCb->iLevelOwnerId, pCb->iResult));
- // Call the client specified callback function
- pCb->iCallback(pCb->iClientId, pCb->iResourceId, pCb->iLevel, pCb->iLevelOwnerId, pCb->iResult, pCb->iParam);
- pCb->iResult = KErrCompletion; //Mark the callback object to act properly during cancellation of this request.
+
+ pCb->Lock();
+ TUint ClientId = pCb->iClientId;
+ TUint ResourceId = pCb->iResourceId;
+ TInt Level = pCb->iLevel;
+ TInt LevelOwnerId = pCb->iLevelOwnerId;
+ TInt Result = pCb->iResult;
+ TAny* Param = pCb->iParam;
+ pCb->UnLock();
+
+ // Call the client specified callback function
+ pCb->iCallback(ClientId, ResourceId, Level, LevelOwnerId, Result, Param);
+
+ pCb->Lock();
+ pCb->iPendingRequestCount--;
+ if(pCb->iPendingRequestCount == 0)
+ pCb->iResult = KErrCompletion; //Mark the callback object to act properly during cancellation of this request.
+ pCb->UnLock();
PRM_CALLBACK_COMPLETION_TRACE
}
private:
+ void Lock()
+ {
+ __ASSERT_DEBUG(iMutex, Kern::Fault("TPowerResourceCb::Lock", __LINE__));
+ NKern::ThreadEnterCS();
+ Kern::MutexWait(*iMutex);
+ }
+ void UnLock()
+ {
+ __ASSERT_DEBUG(iMutex, Kern::Fault("TPowerResourceCb::UnLock", __LINE__));
+ Kern::MutexSignal(*iMutex);
+ NKern::ThreadLeaveCS();
+ }
TAny* iParam; //Stores the aPtr argument passed in the constructor, to be passed as 5th argument to the callback function
- TInt iResult; //Used to store the result aswell as binary usage count for the callback
+ TInt iResult; //Used to store the result as well as binary usage count for the callback
TInt iLevel; // Level of the resource
TInt iLevelOwnerId; // Stores owner of the resource for asynchronous get operation
TUint iResourceId; //Stores the ID of the resource whose state is changed/read asynchronously
TUint iClientId; //Stores the ID of the client that requested the asynchronous operation
TPowerResourceCbFn iCallback; //Callback function object
+ DMutex* iMutex;
+ TInt iPendingRequestCount;
#ifdef PRM_CONTROLLER
friend class DPowerResourceController;
#endif