sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32\drivers\resourceman\resource_extend.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.5 sl@0: Constructor for static resource with dependency sl@0: This sets the passed resource name and default level. sl@0: This also sets the corresponding bit to identify that it is static resource with dependencies. sl@0: @param aName The name for the resource to be set. sl@0: @param aDefaultLevel Default level of the resource. sl@0: */ sl@0: DStaticPowerResourceD::DStaticPowerResourceD(const TDesC8& aName, TInt aDefaultLevel) : sl@0: DStaticPowerResource(aName, aDefaultLevel) sl@0: { sl@0: __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DStaticPowerResourceD::DStaticPowerResourceD")); sl@0: iResourceId |= KIdMaskStaticWithDependencies; sl@0: } sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.5 sl@0: Constructor for dynamic resource sl@0: This sets the passed resource name and default level and also sets the corresponding bit to identify sl@0: that it is dynamic resource with no dependencies. sl@0: @param aName The name for the resource to be set. sl@0: @param aDefaultLevel Default level of the resource. sl@0: */ sl@0: EXPORT_C DDynamicPowerResource::DDynamicPowerResource(const TDesC8& aName, TInt aDefaultLevel) : sl@0: DStaticPowerResource(aName, aDefaultLevel) sl@0: { sl@0: //Set the corresponding to identify that it is dynamic resource with no dependencies sl@0: __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DDynamicPowerResource::DDynamicPowerResource")); sl@0: iResourceId |= KIdMaskDynamic; sl@0: } sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.5 sl@0: Destructor for dynamic resource sl@0: Panics if the resource is still registered with PRM. sl@0: */ sl@0: EXPORT_C DDynamicPowerResource::~DDynamicPowerResource() sl@0: { sl@0: __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DDynamocPowerResource::~DDynamicPowerResource")); sl@0: if(LockCount()) //Lock count is expected to be 0 sl@0: DPowerResourceController::Panic(DPowerResourceController::EDynamicResourceStillRegistered); sl@0: } sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.5 sl@0: Constructor for dynamic resource with dependencies sl@0: This sets the passed resource name and default level and also sets the corresponding bit to identify sl@0: that it is dynamic resource with dependencies. sl@0: @param aName The name for the resource to be set. sl@0: @param aDefaultLevel Default level of the resource. sl@0: */ sl@0: EXPORT_C DDynamicPowerResourceD::DDynamicPowerResourceD(const TDesC8& aName, TInt aDefaultLevel) : sl@0: DDynamicPowerResource(aName, aDefaultLevel) sl@0: { sl@0: //Set the corresponding to identify that it is dynamic resource with no dependencies sl@0: __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DDynamicPowerResourceD::DDynamicPowerResourceD")); sl@0: iResourceId |= KIdMaskDynamicWithDependencies; sl@0: } sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.5 sl@0: Destructor for dynamic resource with dependencies sl@0: Panics if the resource is still registered with PRM. sl@0: */ sl@0: EXPORT_C DDynamicPowerResourceD::~DDynamicPowerResourceD() sl@0: { sl@0: __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DDynamocPowerResource::~DDynamicPowerResource")); sl@0: if(LockCount()) //Lock count is expected to be 0 sl@0: DPowerResourceController::Panic(DPowerResourceController::EDynamicResourceStillRegistered); sl@0: } sl@0: sl@0: /** sl@0: @internalComponent sl@0: @prototype 9.5 sl@0: This function is called in response to PowerResourceManager::ControlIO(..) with sl@0: KResManControlIoDeregisterDynamicResource and returns ETrue if this resource has a sl@0: 'client level' from another client in its 'client level' list. sl@0: */ sl@0: TBool DDynamicPowerResource::InUse() sl@0: { sl@0: SPowerResourceClientLevel* pRCL = NULL; sl@0: for(SDblQueLink* pRC = iClientList.First(); pRC != &iClientList.iA; pRC = pRC->iNext) sl@0: { sl@0: pRCL = (SPowerResourceClientLevel*)pRC; sl@0: if(pRCL->iClientId != iOwnerId) sl@0: return ETrue; sl@0: } sl@0: return EFalse; sl@0: } sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.5 sl@0: This function is used to establish the resource's dependency list for static resource and sl@0: will be used by PSL to establish dependency between static resources. sl@0: Panics, if the passed priority is already in use sl@0: */ sl@0: TInt DStaticPowerResourceD::AddNode(SNode* aNode) sl@0: { sl@0: ADD_DEPENDENCY_NODE(aNode, iDependencyList) sl@0: return KErrNone; sl@0: } sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype 9.5 sl@0: This function takes care of resource state change of dynamic dependency resource. sl@0: This propagates the change to all of its dependents. sl@0: */ sl@0: EXPORT_C TInt DDynamicPowerResourceD::HandleChangePropagation(TPowerRequest aRequest, TPropagation aProp, TUint aOriginatorId, const TDesC8& aOriginatorName) sl@0: { sl@0: TInt result = KErrNone; sl@0: static DPowerResourceController* pRC = TInterface::GetPowerResourceController(); sl@0: result = pRC->HandleResourceChange(aRequest, aProp, aOriginatorId, aOriginatorName, (DStaticPowerResourceD*)this); sl@0: return result; sl@0: } sl@0: