sl@0
|
1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// e32\drivers\resourceman\resource_extend.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <drivers/resourcecontrol.h>
|
sl@0
|
19 |
|
sl@0
|
20 |
/**
|
sl@0
|
21 |
@publishedPartner
|
sl@0
|
22 |
@prototype 9.5
|
sl@0
|
23 |
Constructor for static resource with dependency
|
sl@0
|
24 |
This sets the passed resource name and default level.
|
sl@0
|
25 |
This also sets the corresponding bit to identify that it is static resource with dependencies.
|
sl@0
|
26 |
@param aName The name for the resource to be set.
|
sl@0
|
27 |
@param aDefaultLevel Default level of the resource.
|
sl@0
|
28 |
*/
|
sl@0
|
29 |
DStaticPowerResourceD::DStaticPowerResourceD(const TDesC8& aName, TInt aDefaultLevel) :
|
sl@0
|
30 |
DStaticPowerResource(aName, aDefaultLevel)
|
sl@0
|
31 |
{
|
sl@0
|
32 |
__KTRACE_OPT(KRESMANAGER, Kern::Printf(">DStaticPowerResourceD::DStaticPowerResourceD"));
|
sl@0
|
33 |
iResourceId |= KIdMaskStaticWithDependencies;
|
sl@0
|
34 |
}
|
sl@0
|
35 |
|
sl@0
|
36 |
/**
|
sl@0
|
37 |
@publishedPartner
|
sl@0
|
38 |
@prototype 9.5
|
sl@0
|
39 |
Constructor for dynamic resource
|
sl@0
|
40 |
This sets the passed resource name and default level and also sets the corresponding bit to identify
|
sl@0
|
41 |
that it is dynamic resource with no dependencies.
|
sl@0
|
42 |
@param aName The name for the resource to be set.
|
sl@0
|
43 |
@param aDefaultLevel Default level of the resource.
|
sl@0
|
44 |
*/
|
sl@0
|
45 |
EXPORT_C DDynamicPowerResource::DDynamicPowerResource(const TDesC8& aName, TInt aDefaultLevel) :
|
sl@0
|
46 |
DStaticPowerResource(aName, aDefaultLevel)
|
sl@0
|
47 |
{
|
sl@0
|
48 |
//Set the corresponding to identify that it is dynamic resource with no dependencies
|
sl@0
|
49 |
__KTRACE_OPT(KRESMANAGER, Kern::Printf(">DDynamicPowerResource::DDynamicPowerResource"));
|
sl@0
|
50 |
iResourceId |= KIdMaskDynamic;
|
sl@0
|
51 |
}
|
sl@0
|
52 |
|
sl@0
|
53 |
/**
|
sl@0
|
54 |
@publishedPartner
|
sl@0
|
55 |
@prototype 9.5
|
sl@0
|
56 |
Destructor for dynamic resource
|
sl@0
|
57 |
Panics if the resource is still registered with PRM.
|
sl@0
|
58 |
*/
|
sl@0
|
59 |
EXPORT_C DDynamicPowerResource::~DDynamicPowerResource()
|
sl@0
|
60 |
{
|
sl@0
|
61 |
__KTRACE_OPT(KRESMANAGER, Kern::Printf(">DDynamocPowerResource::~DDynamicPowerResource"));
|
sl@0
|
62 |
if(LockCount()) //Lock count is expected to be 0
|
sl@0
|
63 |
DPowerResourceController::Panic(DPowerResourceController::EDynamicResourceStillRegistered);
|
sl@0
|
64 |
}
|
sl@0
|
65 |
|
sl@0
|
66 |
/**
|
sl@0
|
67 |
@publishedPartner
|
sl@0
|
68 |
@prototype 9.5
|
sl@0
|
69 |
Constructor for dynamic resource with dependencies
|
sl@0
|
70 |
This sets the passed resource name and default level and also sets the corresponding bit to identify
|
sl@0
|
71 |
that it is dynamic resource with dependencies.
|
sl@0
|
72 |
@param aName The name for the resource to be set.
|
sl@0
|
73 |
@param aDefaultLevel Default level of the resource.
|
sl@0
|
74 |
*/
|
sl@0
|
75 |
EXPORT_C DDynamicPowerResourceD::DDynamicPowerResourceD(const TDesC8& aName, TInt aDefaultLevel) :
|
sl@0
|
76 |
DDynamicPowerResource(aName, aDefaultLevel)
|
sl@0
|
77 |
{
|
sl@0
|
78 |
//Set the corresponding to identify that it is dynamic resource with no dependencies
|
sl@0
|
79 |
__KTRACE_OPT(KRESMANAGER, Kern::Printf(">DDynamicPowerResourceD::DDynamicPowerResourceD"));
|
sl@0
|
80 |
iResourceId |= KIdMaskDynamicWithDependencies;
|
sl@0
|
81 |
}
|
sl@0
|
82 |
|
sl@0
|
83 |
/**
|
sl@0
|
84 |
@publishedPartner
|
sl@0
|
85 |
@prototype 9.5
|
sl@0
|
86 |
Destructor for dynamic resource with dependencies
|
sl@0
|
87 |
Panics if the resource is still registered with PRM.
|
sl@0
|
88 |
*/
|
sl@0
|
89 |
EXPORT_C DDynamicPowerResourceD::~DDynamicPowerResourceD()
|
sl@0
|
90 |
{
|
sl@0
|
91 |
__KTRACE_OPT(KRESMANAGER, Kern::Printf(">DDynamocPowerResource::~DDynamicPowerResource"));
|
sl@0
|
92 |
if(LockCount()) //Lock count is expected to be 0
|
sl@0
|
93 |
DPowerResourceController::Panic(DPowerResourceController::EDynamicResourceStillRegistered);
|
sl@0
|
94 |
}
|
sl@0
|
95 |
|
sl@0
|
96 |
/**
|
sl@0
|
97 |
@internalComponent
|
sl@0
|
98 |
@prototype 9.5
|
sl@0
|
99 |
This function is called in response to PowerResourceManager::ControlIO(..) with
|
sl@0
|
100 |
KResManControlIoDeregisterDynamicResource and returns ETrue if this resource has a
|
sl@0
|
101 |
'client level' from another client in its 'client level' list.
|
sl@0
|
102 |
*/
|
sl@0
|
103 |
TBool DDynamicPowerResource::InUse()
|
sl@0
|
104 |
{
|
sl@0
|
105 |
SPowerResourceClientLevel* pRCL = NULL;
|
sl@0
|
106 |
for(SDblQueLink* pRC = iClientList.First(); pRC != &iClientList.iA; pRC = pRC->iNext)
|
sl@0
|
107 |
{
|
sl@0
|
108 |
pRCL = (SPowerResourceClientLevel*)pRC;
|
sl@0
|
109 |
if(pRCL->iClientId != iOwnerId)
|
sl@0
|
110 |
return ETrue;
|
sl@0
|
111 |
}
|
sl@0
|
112 |
return EFalse;
|
sl@0
|
113 |
}
|
sl@0
|
114 |
|
sl@0
|
115 |
/**
|
sl@0
|
116 |
@publishedPartner
|
sl@0
|
117 |
@prototype 9.5
|
sl@0
|
118 |
This function is used to establish the resource's dependency list for static resource and
|
sl@0
|
119 |
will be used by PSL to establish dependency between static resources.
|
sl@0
|
120 |
Panics, if the passed priority is already in use
|
sl@0
|
121 |
*/
|
sl@0
|
122 |
TInt DStaticPowerResourceD::AddNode(SNode* aNode)
|
sl@0
|
123 |
{
|
sl@0
|
124 |
ADD_DEPENDENCY_NODE(aNode, iDependencyList)
|
sl@0
|
125 |
return KErrNone;
|
sl@0
|
126 |
}
|
sl@0
|
127 |
|
sl@0
|
128 |
/**
|
sl@0
|
129 |
@publishedPartner
|
sl@0
|
130 |
@prototype 9.5
|
sl@0
|
131 |
This function takes care of resource state change of dynamic dependency resource.
|
sl@0
|
132 |
This propagates the change to all of its dependents.
|
sl@0
|
133 |
*/
|
sl@0
|
134 |
EXPORT_C TInt DDynamicPowerResourceD::HandleChangePropagation(TPowerRequest aRequest, TPropagation aProp, TUint aOriginatorId, const TDesC8& aOriginatorName)
|
sl@0
|
135 |
{
|
sl@0
|
136 |
TInt result = KErrNone;
|
sl@0
|
137 |
static DPowerResourceController* pRC = TInterface::GetPowerResourceController();
|
sl@0
|
138 |
result = pRC->HandleResourceChange(aRequest, aProp, aOriginatorId, aOriginatorName, (DStaticPowerResourceD*)this);
|
sl@0
|
139 |
return result;
|
sl@0
|
140 |
}
|
sl@0
|
141 |
|