Update contrib.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32\drivers\resourceman\resource_extend.cpp
18 #include <drivers/resourcecontrol.h>
23 Constructor for static resource with dependency
24 This sets the passed resource name and default level.
25 This also sets the corresponding bit to identify that it is static resource with dependencies.
26 @param aName The name for the resource to be set.
27 @param aDefaultLevel Default level of the resource.
29 DStaticPowerResourceD::DStaticPowerResourceD(const TDesC8& aName, TInt aDefaultLevel) :
30 DStaticPowerResource(aName, aDefaultLevel)
32 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DStaticPowerResourceD::DStaticPowerResourceD"));
33 iResourceId |= KIdMaskStaticWithDependencies;
39 Constructor for dynamic resource
40 This sets the passed resource name and default level and also sets the corresponding bit to identify
41 that it is dynamic resource with no dependencies.
42 @param aName The name for the resource to be set.
43 @param aDefaultLevel Default level of the resource.
45 EXPORT_C DDynamicPowerResource::DDynamicPowerResource(const TDesC8& aName, TInt aDefaultLevel) :
46 DStaticPowerResource(aName, aDefaultLevel)
48 //Set the corresponding to identify that it is dynamic resource with no dependencies
49 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DDynamicPowerResource::DDynamicPowerResource"));
50 iResourceId |= KIdMaskDynamic;
56 Destructor for dynamic resource
57 Panics if the resource is still registered with PRM.
59 EXPORT_C DDynamicPowerResource::~DDynamicPowerResource()
61 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DDynamocPowerResource::~DDynamicPowerResource"));
62 if(LockCount()) //Lock count is expected to be 0
63 DPowerResourceController::Panic(DPowerResourceController::EDynamicResourceStillRegistered);
69 Constructor for dynamic resource with dependencies
70 This sets the passed resource name and default level and also sets the corresponding bit to identify
71 that it is dynamic resource with dependencies.
72 @param aName The name for the resource to be set.
73 @param aDefaultLevel Default level of the resource.
75 EXPORT_C DDynamicPowerResourceD::DDynamicPowerResourceD(const TDesC8& aName, TInt aDefaultLevel) :
76 DDynamicPowerResource(aName, aDefaultLevel)
78 //Set the corresponding to identify that it is dynamic resource with no dependencies
79 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DDynamicPowerResourceD::DDynamicPowerResourceD"));
80 iResourceId |= KIdMaskDynamicWithDependencies;
86 Destructor for dynamic resource with dependencies
87 Panics if the resource is still registered with PRM.
89 EXPORT_C DDynamicPowerResourceD::~DDynamicPowerResourceD()
91 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DDynamocPowerResource::~DDynamicPowerResource"));
92 if(LockCount()) //Lock count is expected to be 0
93 DPowerResourceController::Panic(DPowerResourceController::EDynamicResourceStillRegistered);
99 This function is called in response to PowerResourceManager::ControlIO(..) with
100 KResManControlIoDeregisterDynamicResource and returns ETrue if this resource has a
101 'client level' from another client in its 'client level' list.
103 TBool DDynamicPowerResource::InUse()
105 SPowerResourceClientLevel* pRCL = NULL;
106 for(SDblQueLink* pRC = iClientList.First(); pRC != &iClientList.iA; pRC = pRC->iNext)
108 pRCL = (SPowerResourceClientLevel*)pRC;
109 if(pRCL->iClientId != iOwnerId)
118 This function is used to establish the resource's dependency list for static resource and
119 will be used by PSL to establish dependency between static resources.
120 Panics, if the passed priority is already in use
122 TInt DStaticPowerResourceD::AddNode(SNode* aNode)
124 ADD_DEPENDENCY_NODE(aNode, iDependencyList)
131 This function takes care of resource state change of dynamic dependency resource.
132 This propagates the change to all of its dependents.
134 EXPORT_C TInt DDynamicPowerResourceD::HandleChangePropagation(TPowerRequest aRequest, TPropagation aProp, TUint aOriginatorId, const TDesC8& aOriginatorName)
136 TInt result = KErrNone;
137 static DPowerResourceController* pRC = TInterface::GetPowerResourceController();
138 result = pRC->HandleResourceChange(aRequest, aProp, aOriginatorId, aOriginatorName, (DStaticPowerResourceD*)this);