|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // e32\drivers\resourceman\resource_extend.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 #include <drivers/resourcecontrol.h> |
|
19 |
|
20 /** |
|
21 @publishedPartner |
|
22 @prototype 9.5 |
|
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. |
|
28 */ |
|
29 DStaticPowerResourceD::DStaticPowerResourceD(const TDesC8& aName, TInt aDefaultLevel) : |
|
30 DStaticPowerResource(aName, aDefaultLevel) |
|
31 { |
|
32 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DStaticPowerResourceD::DStaticPowerResourceD")); |
|
33 iResourceId |= KIdMaskStaticWithDependencies; |
|
34 } |
|
35 |
|
36 /** |
|
37 @publishedPartner |
|
38 @prototype 9.5 |
|
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. |
|
44 */ |
|
45 EXPORT_C DDynamicPowerResource::DDynamicPowerResource(const TDesC8& aName, TInt aDefaultLevel) : |
|
46 DStaticPowerResource(aName, aDefaultLevel) |
|
47 { |
|
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; |
|
51 } |
|
52 |
|
53 /** |
|
54 @publishedPartner |
|
55 @prototype 9.5 |
|
56 Destructor for dynamic resource |
|
57 Panics if the resource is still registered with PRM. |
|
58 */ |
|
59 EXPORT_C DDynamicPowerResource::~DDynamicPowerResource() |
|
60 { |
|
61 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DDynamocPowerResource::~DDynamicPowerResource")); |
|
62 if(LockCount()) //Lock count is expected to be 0 |
|
63 DPowerResourceController::Panic(DPowerResourceController::EDynamicResourceStillRegistered); |
|
64 } |
|
65 |
|
66 /** |
|
67 @publishedPartner |
|
68 @prototype 9.5 |
|
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. |
|
74 */ |
|
75 EXPORT_C DDynamicPowerResourceD::DDynamicPowerResourceD(const TDesC8& aName, TInt aDefaultLevel) : |
|
76 DDynamicPowerResource(aName, aDefaultLevel) |
|
77 { |
|
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; |
|
81 } |
|
82 |
|
83 /** |
|
84 @publishedPartner |
|
85 @prototype 9.5 |
|
86 Destructor for dynamic resource with dependencies |
|
87 Panics if the resource is still registered with PRM. |
|
88 */ |
|
89 EXPORT_C DDynamicPowerResourceD::~DDynamicPowerResourceD() |
|
90 { |
|
91 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DDynamocPowerResource::~DDynamicPowerResource")); |
|
92 if(LockCount()) //Lock count is expected to be 0 |
|
93 DPowerResourceController::Panic(DPowerResourceController::EDynamicResourceStillRegistered); |
|
94 } |
|
95 |
|
96 /** |
|
97 @internalComponent |
|
98 @prototype 9.5 |
|
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. |
|
102 */ |
|
103 TBool DDynamicPowerResource::InUse() |
|
104 { |
|
105 SPowerResourceClientLevel* pRCL = NULL; |
|
106 for(SDblQueLink* pRC = iClientList.First(); pRC != &iClientList.iA; pRC = pRC->iNext) |
|
107 { |
|
108 pRCL = (SPowerResourceClientLevel*)pRC; |
|
109 if(pRCL->iClientId != iOwnerId) |
|
110 return ETrue; |
|
111 } |
|
112 return EFalse; |
|
113 } |
|
114 |
|
115 /** |
|
116 @publishedPartner |
|
117 @prototype 9.5 |
|
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 |
|
121 */ |
|
122 TInt DStaticPowerResourceD::AddNode(SNode* aNode) |
|
123 { |
|
124 ADD_DEPENDENCY_NODE(aNode, iDependencyList) |
|
125 return KErrNone; |
|
126 } |
|
127 |
|
128 /** |
|
129 @publishedPartner |
|
130 @prototype 9.5 |
|
131 This function takes care of resource state change of dynamic dependency resource. |
|
132 This propagates the change to all of its dependents. |
|
133 */ |
|
134 EXPORT_C TInt DDynamicPowerResourceD::HandleChangePropagation(TPowerRequest aRequest, TPropagation aProp, TUint aOriginatorId, const TDesC8& aOriginatorName) |
|
135 { |
|
136 static TUint16 clientLevelCount = 0; |
|
137 DDynamicPowerResourceD* pDR = (DDynamicPowerResourceD*)aRequest.Resource(); |
|
138 TInt result = KErrNone; |
|
139 TInt resState = 0; |
|
140 TPowerRequest depRequest; |
|
141 depRequest.ReqType() = TPowerRequest::EChange; |
|
142 depRequest.ResourceCb() = NULL; |
|
143 depRequest.ReturnCode() = KErrNone; |
|
144 depRequest.RequiresChange() = EFalse; |
|
145 static DPowerResourceController* pRC = TInterface::GetPowerResourceController(); |
|
146 DDynamicPowerResourceD* pDepRes = NULL; |
|
147 TBool traceEnabled = EFalse; |
|
148 #ifdef PRM_INSTRUMENTATION_MACRO |
|
149 traceEnabled = ETrue; |
|
150 #endif |
|
151 HANDLE_CHANGE_PROPAGATION(pRC, DDynamicPowerResourceD*, traceEnabled, aOriginatorId, aOriginatorName) |
|
152 } |