kernel/eka/include/drivers/resource.h
changeset 247 d8d70de2bd36
parent 109 b3a1d9898418
child 244 a77889bee936
equal deleted inserted replaced
201:43365a9b78a3 247:d8d70de2bd36
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
   166         {
   166         {
   167         TPowerResourceCb* pCb = (TPowerResourceCb*) aPtr;
   167         TPowerResourceCb* pCb = (TPowerResourceCb*) aPtr;
   168 	    __KTRACE_OPT(KRESMANAGER, Kern::Printf(">TPowerResourceCb::DfcFunc ClientId = 0x%x, ResourceId = %d, Level = %d, \
   168 	    __KTRACE_OPT(KRESMANAGER, Kern::Printf(">TPowerResourceCb::DfcFunc ClientId = 0x%x, ResourceId = %d, Level = %d, \
   169 			                    LevelOwnerId = %d, Result = %d", pCb->iClientId, pCb->iResourceId, pCb->iLevel, \
   169 			                    LevelOwnerId = %d, Result = %d", pCb->iClientId, pCb->iResourceId, pCb->iLevel, \
   170 								pCb->iLevelOwnerId, pCb->iResult));
   170 								pCb->iLevelOwnerId, pCb->iResult));
   171 	    // Call the client specified callback function
   171 
   172         pCb->iCallback(pCb->iClientId, pCb->iResourceId, pCb->iLevel, pCb->iLevelOwnerId, pCb->iResult, pCb->iParam);
   172         pCb->Lock();
   173 		pCb->iResult = KErrCompletion; //Mark the callback object to act properly during cancellation of this request.
   173         TUint ClientId = pCb->iClientId;
       
   174         TUint ResourceId = pCb->iResourceId;
       
   175         TInt Level = pCb->iLevel;
       
   176         TInt LevelOwnerId = pCb->iLevelOwnerId;
       
   177         TInt Result = pCb->iResult;
       
   178         TAny* Param = pCb->iParam;
       
   179         pCb->UnLock();
       
   180 
       
   181         // Call the client specified callback function
       
   182         pCb->iCallback(ClientId, ResourceId, Level, LevelOwnerId, Result, Param);    
       
   183 
       
   184         pCb->Lock();
       
   185         pCb->iPendingRequestCount--;
       
   186         if(pCb->iPendingRequestCount == 0)
       
   187             pCb->iResult = KErrCompletion; //Mark the callback object to act properly during cancellation of this request.
       
   188         pCb->UnLock();
   174         PRM_CALLBACK_COMPLETION_TRACE
   189         PRM_CALLBACK_COMPLETION_TRACE
   175         }
   190         }
   176 private:
   191 private:
       
   192     void Lock()
       
   193         {
       
   194         NKern::ThreadEnterCS();
       
   195         Kern::MutexWait(*iMutex);
       
   196         }
       
   197     void UnLock()
       
   198         {
       
   199         Kern::MutexSignal(*iMutex);
       
   200         NKern::ThreadLeaveCS();
       
   201         }
   177     TAny* iParam; //Stores the aPtr argument passed in the constructor, to be passed as 5th argument to the callback function
   202     TAny* iParam; //Stores the aPtr argument passed in the constructor, to be passed as 5th argument to the callback function
   178     TInt iResult; //Used to store the result aswell as binary usage count for the callback
   203     TInt iResult; //Used to store the result aswell as binary usage count for the callback
   179     TInt iLevel; // Level of the resource
   204     TInt iLevel; // Level of the resource
   180 	TInt iLevelOwnerId; // Stores owner of the resource for asynchronous get operation
   205 	TInt iLevelOwnerId; // Stores owner of the resource for asynchronous get operation
   181     TUint iResourceId; //Stores the ID of the resource whose state is changed/read asynchronously
   206     TUint iResourceId; //Stores the ID of the resource whose state is changed/read asynchronously
   182     TUint iClientId; //Stores the ID of the client that requested the asynchronous operation
   207     TUint iClientId; //Stores the ID of the client that requested the asynchronous operation
   183     TPowerResourceCbFn iCallback; //Callback function object
   208     TPowerResourceCbFn iCallback; //Callback function object
       
   209 	DMutex* iMutex;   
       
   210     TInt iPendingRequestCount;
   184 #ifdef PRM_CONTROLLER
   211 #ifdef PRM_CONTROLLER
   185     friend class DPowerResourceController;
   212     friend class DPowerResourceController;
   186 #endif
   213 #endif
   187 	};
   214 	};
   188 
   215