os/kernelhwsrv/kernel/eka/drivers/resourceman/resource_extend.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/drivers/resourceman/resource_extend.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,141 @@
     1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32\drivers\resourceman\resource_extend.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include <drivers/resourcecontrol.h>
    1.22 +
    1.23 +/**
    1.24 +    @publishedPartner
    1.25 +    @prototype 9.5
    1.26 +    Constructor for static resource with dependency
    1.27 +    This sets the passed resource name and default level.
    1.28 +	This also sets the corresponding bit to identify that it is static resource with dependencies.
    1.29 +    @param aName The name for the resource to be set.
    1.30 +	@param aDefaultLevel Default level of the resource. 
    1.31 +    */
    1.32 +DStaticPowerResourceD::DStaticPowerResourceD(const TDesC8& aName, TInt aDefaultLevel) :
    1.33 +                                                           DStaticPowerResource(aName, aDefaultLevel)
    1.34 +	{
    1.35 +    __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DStaticPowerResourceD::DStaticPowerResourceD"));
    1.36 +	iResourceId |= KIdMaskStaticWithDependencies;
    1.37 +	}
    1.38 +
    1.39 +/**
    1.40 +    @publishedPartner
    1.41 +    @prototype 9.5
    1.42 +    Constructor for dynamic resource
    1.43 +    This sets the passed resource name and default level and also sets the corresponding bit to identify 
    1.44 +	that it is dynamic resource with no dependencies.
    1.45 +    @param aName The name for the resource to be set.
    1.46 +	@param aDefaultLevel Default level of the resource. 
    1.47 +    */
    1.48 +EXPORT_C DDynamicPowerResource::DDynamicPowerResource(const TDesC8& aName, TInt aDefaultLevel) : 
    1.49 +	                                                       DStaticPowerResource(aName, aDefaultLevel)
    1.50 +	{
    1.51 +	//Set the corresponding to identify that it is dynamic resource with no dependencies
    1.52 +	__KTRACE_OPT(KRESMANAGER, Kern::Printf(">DDynamicPowerResource::DDynamicPowerResource"));
    1.53 +	iResourceId |= KIdMaskDynamic;
    1.54 +	}
    1.55 +
    1.56 +/**
    1.57 +    @publishedPartner
    1.58 +    @prototype 9.5
    1.59 +    Destructor for dynamic resource
    1.60 +	Panics if the resource is still registered with PRM.
    1.61 +    */
    1.62 +EXPORT_C DDynamicPowerResource::~DDynamicPowerResource()
    1.63 +	{
    1.64 +	__KTRACE_OPT(KRESMANAGER, Kern::Printf(">DDynamocPowerResource::~DDynamicPowerResource"));
    1.65 +	if(LockCount()) //Lock count is expected to be 0
    1.66 +		DPowerResourceController::Panic(DPowerResourceController::EDynamicResourceStillRegistered);	
    1.67 +	}
    1.68 +
    1.69 +/**
    1.70 +    @publishedPartner
    1.71 +    @prototype 9.5
    1.72 +    Constructor for dynamic resource with dependencies
    1.73 +    This sets the passed resource name and default level and also sets the corresponding bit to identify 
    1.74 +	that it is dynamic resource with dependencies.
    1.75 +    @param aName The name for the resource to be set.
    1.76 +	@param aDefaultLevel Default level of the resource. 
    1.77 +    */
    1.78 +EXPORT_C DDynamicPowerResourceD::DDynamicPowerResourceD(const TDesC8& aName, TInt aDefaultLevel) : 
    1.79 +	                                                   DDynamicPowerResource(aName, aDefaultLevel)
    1.80 +	{
    1.81 +	//Set the corresponding to identify that it is dynamic resource with no dependencies
    1.82 +	__KTRACE_OPT(KRESMANAGER, Kern::Printf(">DDynamicPowerResourceD::DDynamicPowerResourceD"));
    1.83 +	iResourceId |= KIdMaskDynamicWithDependencies;
    1.84 +	}
    1.85 +
    1.86 +/**
    1.87 +    @publishedPartner
    1.88 +    @prototype 9.5
    1.89 +    Destructor for dynamic resource with dependencies
    1.90 +	Panics if the resource is still registered with PRM.
    1.91 +    */
    1.92 +EXPORT_C DDynamicPowerResourceD::~DDynamicPowerResourceD()
    1.93 +	{
    1.94 +	__KTRACE_OPT(KRESMANAGER, Kern::Printf(">DDynamocPowerResource::~DDynamicPowerResource"));
    1.95 +	if(LockCount()) //Lock count is expected to be 0
    1.96 +		DPowerResourceController::Panic(DPowerResourceController::EDynamicResourceStillRegistered);	
    1.97 +	}
    1.98 +
    1.99 +/**
   1.100 +    @internalComponent
   1.101 +    @prototype 9.5
   1.102 +    This function is called in response to PowerResourceManager::ControlIO(..) with 
   1.103 +	KResManControlIoDeregisterDynamicResource and returns ETrue if this resource has a 
   1.104 +	'client level' from another client in its 'client level' list.
   1.105 +    */
   1.106 +TBool DDynamicPowerResource::InUse()
   1.107 +	{
   1.108 +	SPowerResourceClientLevel* pRCL = NULL;
   1.109 +	for(SDblQueLink* pRC = iClientList.First(); pRC != &iClientList.iA; pRC = pRC->iNext)
   1.110 +		{
   1.111 +		pRCL = (SPowerResourceClientLevel*)pRC;
   1.112 +		if(pRCL->iClientId != iOwnerId)
   1.113 +			return ETrue;
   1.114 +		}
   1.115 +	return EFalse;
   1.116 +	}
   1.117 +
   1.118 +/**
   1.119 +    @publishedPartner
   1.120 +    @prototype 9.5
   1.121 +    This function is used to establish the resource's dependency list for static resource and 
   1.122 +	will be used by PSL to establish dependency between static resources.
   1.123 +	Panics, if the passed priority is already in use
   1.124 +    */
   1.125 +TInt DStaticPowerResourceD::AddNode(SNode* aNode)
   1.126 +	{
   1.127 +	ADD_DEPENDENCY_NODE(aNode, iDependencyList)
   1.128 +	return KErrNone;
   1.129 +	}
   1.130 +
   1.131 +/**
   1.132 +	@publishedPartner
   1.133 +	@prototype 9.5
   1.134 +	This function takes care of resource state change of dynamic dependency resource.
   1.135 +	This propagates the change to all of its dependents.
   1.136 +	*/
   1.137 +EXPORT_C TInt DDynamicPowerResourceD::HandleChangePropagation(TPowerRequest aRequest, TPropagation aProp, TUint aOriginatorId, const TDesC8& aOriginatorName)
   1.138 +	{
   1.139 +	TInt result = KErrNone;
   1.140 +	static DPowerResourceController* pRC = TInterface::GetPowerResourceController();
   1.141 +	result = pRC->HandleResourceChange(aRequest, aProp, aOriginatorId, aOriginatorName, (DStaticPowerResourceD*)this);
   1.142 +	return result;
   1.143 +	}
   1.144 +