author | mikek |
Fri, 18 Jun 2010 12:08:15 +0100 | |
branch | GCC_SURGE |
changeset 162 | a4df7686c45c |
parent 109 | b3a1d9898418 |
child 199 | 189ece41fa29 |
permissions | -rw-r--r-- |
0 | 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\include\drivers\resource.h |
|
15 |
// |
|
16 |
// WARNING: This file contains some APIs which are internal and are subject |
|
17 |
// to change without notice. Such APIs should therefore not be used |
|
18 |
// outside the Kernel and Hardware Services package. |
|
19 |
// |
|
20 |
||
21 |
#ifndef __RESOURCE_H__ |
|
22 |
#define __RESOURCE_H__ |
|
23 |
#include <kernel/kernel.h> |
|
24 |
#include <kernel/kern_priv.h> |
|
25 |
#include <drivers/resourcecontrol_trace.h> |
|
26 |
#include <drivers/resource_category.h> |
|
27 |
||
28 |
//Definition for resource flag setting. Used by PSL. |
|
29 |
static const TUint KTypeMask= 0x3; |
|
30 |
static const TUint KUsageOffset=0x1F; |
|
31 |
static const TUint KLongLatencySetOffset=0x1E; |
|
32 |
static const TUint KLongLatencyGetOffset=0x1D; |
|
33 |
static const TUint KClassOffset=0x1C; |
|
34 |
static const TUint KSenseOffset=0x1A; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
35 |
static const TUint KShared=0x1U<<KUsageOffset; |
0 | 36 |
static const TUint KLongLatencySet=0x1<<KLongLatencySetOffset; |
37 |
static const TUint KLongLatencyGet=0x1<<KLongLatencyGetOffset; |
|
38 |
static const TUint KLogical=0x1<<KClassOffset; |
|
39 |
static const TUint KSenseNegative=0x01<<KSenseOffset; |
|
40 |
static const TUint KSenseCustom=0x2<<KSenseOffset; |
|
41 |
||
42 |
struct TPowerRequest; |
|
43 |
struct SIdleResourceInfo; |
|
44 |
||
45 |
||
46 |
/** |
|
47 |
* List of operations that a Custom Function may be informed of. |
|
48 |
* |
|
49 |
* @publishedPartner |
|
50 |
* @prototype 9.5 |
|
51 |
*/ |
|
52 |
enum TCustomOperation |
|
53 |
{ |
|
54 |
/** |
|
55 |
Client has requested the given level. |
|
56 |
*/ |
|
57 |
EClientRequestLevel, |
|
58 |
||
59 |
/** |
|
60 |
Client has relinquished the given level. |
|
61 |
*/ |
|
62 |
EClientRelinquishLevel, |
|
63 |
||
64 |
/** |
|
65 |
Client is changing the level. |
|
66 |
*/ |
|
67 |
EClientChangeLevel, |
|
68 |
||
69 |
/** |
|
70 |
A dynamic resource is being deregistered. |
|
71 |
*/ |
|
72 |
EDynamicResourceDeregister |
|
73 |
}; |
|
74 |
||
75 |
||
76 |
/** |
|
77 |
* Function prototype for the Custom Function. |
|
78 |
* |
|
79 |
* @publishedPartner |
|
80 |
* @prototype 9.5 |
|
81 |
*/ |
|
82 |
typedef TBool (*TCustomFunction) (TInt& /*aClientId*/, |
|
83 |
const TDesC8& /*aClientName*/, |
|
84 |
TUint /*aResourceId*/, |
|
85 |
TCustomOperation /*aCustomOperation*/, |
|
86 |
TInt& /*aLevel*/, |
|
87 |
TAny* /*aLevelList*/, |
|
88 |
TAny* /*aReserved*/); // For future use |
|
89 |
||
90 |
/** |
|
91 |
@publishedPartner |
|
92 |
@prototype 9.5 |
|
93 |
class to represent static resources |
|
94 |
*/ |
|
95 |
class DStaticPowerResource : public DBase |
|
96 |
{ |
|
97 |
public: |
|
98 |
enum TType {EBinary = EResBinary, EMultilevel, EMultiProperty}; |
|
99 |
enum TUsage {ESingleUse = EResSingleUse, EShared}; |
|
100 |
enum TLatency {EInstantaneous = EResInstantaneous, ELongLatency}; |
|
101 |
enum TClass {EPhysical = EResPhysical, ELogical}; |
|
102 |
enum TSense {EPositive = EResPositive, ENegative, ECustom}; |
|
103 |
public: |
|
104 |
//exported to allow construction from other base port components. |
|
105 |
IMPORT_C DStaticPowerResource(const TDesC8& aName, TInt aDefaultLevel); |
|
106 |
IMPORT_C virtual TInt GetInfo(TDes8* aInfo)const; |
|
107 |
inline void SetCustomFunction(TCustomFunction aCustomFunction) |
|
108 |
{iCustomFunction=aCustomFunction;} |
|
109 |
||
110 |
//private data inlined accessors |
|
111 |
TType Type() const {return TType(iFlags&KTypeMask);} |
|
112 |
TClass Class() const {return TClass((iFlags>>KClassOffset)&0x1);} |
|
113 |
TUsage Usage() const {return TUsage((iFlags>>KUsageOffset)&0x1);} |
|
114 |
TLatency LatencyGet() const |
|
115 |
{return TLatency((iFlags>>KLongLatencyGetOffset)&0x1);} |
|
116 |
TLatency LatencySet() const |
|
117 |
{return TLatency((iFlags>>KLongLatencySetOffset)&0x1);} |
|
118 |
TSense Sense() const {return TSense((iFlags>>KSenseOffset)&0x3);} |
|
119 |
protected: |
|
120 |
//pure virtual function to be implement by PSL |
|
121 |
virtual TInt DoRequest(TPowerRequest& aRequest)=0; |
|
122 |
public: |
|
123 |
HBuf8* iName; |
|
124 |
protected: |
|
125 |
TInt iPostBootLevel; |
|
126 |
TInt iDefaultLevel; |
|
127 |
protected: |
|
128 |
TInt iCachedLevel; |
|
129 |
TUint iResourceId; |
|
130 |
SDblQue iNotificationList; |
|
131 |
SDblQue iClientList; |
|
132 |
TCustomFunction iCustomFunction; |
|
133 |
TInt iLevelOwnerId; |
|
134 |
SIdleResourceInfo* iIdleListEntry; |
|
135 |
protected: |
|
136 |
TUint iFlags; |
|
137 |
#ifdef PRM_CONTROLLER |
|
138 |
friend class DPowerResourceController; |
|
139 |
#endif |
|
140 |
}; |
|
141 |
||
142 |
typedef void (*TPowerResourceCbFn)(TUint /*aClientId*/, |
|
143 |
TUint /*aResourceId*/, |
|
144 |
TInt /*aLevel*/, |
|
145 |
TInt /*aLevelOwnerId*/, |
|
146 |
TInt /*aResult*/, |
|
147 |
TAny* /*aParam*/); |
|
148 |
||
149 |
/** |
|
150 |
@publishedPartner |
|
151 |
@prototype 9.5 |
|
152 |
An object of this type prepresents a customised Dfc |
|
153 |
used to signal completion of the resource manager's asynchronous APIs |
|
154 |
and completion of notifications |
|
155 |
@see TPowerResourceManager |
|
156 |
*/ |
|
157 |
class TPowerResourceCb : public TDfc |
|
158 |
{ |
|
159 |
public: |
|
160 |
inline TPowerResourceCb(TPowerResourceCbFn aFn, TAny* aPtr, TInt aPriority) : TDfc(DfcFunc, this, aPriority), |
|
161 |
iParam(aPtr), iCallback(aFn){ } |
|
162 |
inline TPowerResourceCb(TPowerResourceCbFn aFn, TAny* aPtr, TDfcQue* aQue, TInt aPriority): |
|
163 |
TDfc(DfcFunc, this, aQue, aPriority), iParam(aPtr), iCallback(aFn) { } |
|
164 |
private: |
|
165 |
inline static void DfcFunc(TAny* aPtr) |
|
166 |
{ |
|
167 |
TPowerResourceCb* pCb = (TPowerResourceCb*) aPtr; |
|
168 |
__KTRACE_OPT(KRESMANAGER, Kern::Printf(">TPowerResourceCb::DfcFunc ClientId = 0x%x, ResourceId = %d, Level = %d, \ |
|
169 |
LevelOwnerId = %d, Result = %d", pCb->iClientId, pCb->iResourceId, pCb->iLevel, \ |
|
170 |
pCb->iLevelOwnerId, pCb->iResult)); |
|
171 |
// Call the client specified callback function |
|
172 |
pCb->iCallback(pCb->iClientId, pCb->iResourceId, pCb->iLevel, pCb->iLevelOwnerId, pCb->iResult, pCb->iParam); |
|
173 |
pCb->iResult = KErrCompletion; //Mark the callback object to act properly during cancellation of this request. |
|
174 |
PRM_CALLBACK_COMPLETION_TRACE |
|
175 |
} |
|
176 |
private: |
|
177 |
TAny* iParam; //Stores the aPtr argument passed in the constructor, to be passed as 5th argument to the callback function |
|
178 |
TInt iResult; //Used to store the result aswell as binary usage count for the callback |
|
179 |
TInt iLevel; // Level of the resource |
|
180 |
TInt iLevelOwnerId; // Stores owner of the resource for asynchronous get operation |
|
181 |
TUint iResourceId; //Stores the ID of the resource whose state is changed/read asynchronously |
|
182 |
TUint iClientId; //Stores the ID of the client that requested the asynchronous operation |
|
183 |
TPowerResourceCbFn iCallback; //Callback function object |
|
184 |
#ifdef PRM_CONTROLLER |
|
185 |
friend class DPowerResourceController; |
|
186 |
#endif |
|
187 |
}; |
|
188 |
||
189 |
/** |
|
190 |
@publishedPartner |
|
191 |
@prototype 9.5 |
|
192 |
Notifications class. Conditional and unconditional notifications are encapsulated in this class. |
|
193 |
It uses TPowerResourceCb to perform the actual notification call. |
|
194 |
@see TPowerResourceCb |
|
195 |
*/ |
|
196 |
class DPowerResourceNotification : public DBase |
|
197 |
{ |
|
198 |
public: |
|
199 |
enum TType {EUnconditional, EConditional}; |
|
200 |
enum TResNotiPanic {ENotificationObjectStillInList = 25}; |
|
201 |
public: |
|
202 |
inline DPowerResourceNotification(TPowerResourceCbFn aFn, TAny* aPtr, TInt aPriority): |
|
203 |
iCallback(aFn, aPtr, aPriority) {} |
|
204 |
inline DPowerResourceNotification(TPowerResourceCbFn aFn, TAny* aPtr, TDfcQue* aQue, TInt aPriority) : |
|
205 |
iCallback(aFn, aPtr, aQue, aPriority) {} |
|
206 |
inline ~DPowerResourceNotification() |
|
207 |
{ |
|
208 |
if(iRegistered) |
|
209 |
Kern::Fault("Power Resource Controller", ENotificationObjectStillInList); |
|
210 |
} |
|
211 |
public: |
|
212 |
TInt iPreviousLevel; //Previous level of the resource. This is used for checking the threshold condition |
|
213 |
TUint8 iRegistered; |
|
214 |
private: |
|
215 |
TUint8 iType; // the type of notification required (conditional or unconditional). |
|
216 |
TUint16 iOwnerId; // the bottom 16 bits of the Id of the client which requested the notification |
|
217 |
TInt iThreshold; // the threshold which when crossed on a specified direction will cause a notification to be issued. |
|
218 |
TBool iDirection; // the direction of the resource change that together with the threshold to be crossed will result in the notification |
|
219 |
TPowerResourceCb iCallback; //Callback object associated with this notification |
|
220 |
SDblQueLink iNotificationLink; |
|
221 |
DPowerResourceNotification* iNextInClient; |
|
222 |
#ifdef PRM_CONTROLLER |
|
223 |
friend class DPowerResourceController; |
|
224 |
#endif |
|
225 |
}; |
|
226 |
||
227 |
/** |
|
228 |
@publishedPartner |
|
229 |
@prototype 9.5 |
|
230 |
class to represent resource properties |
|
231 |
*/ |
|
232 |
class TPowerResourceInfoV01 |
|
233 |
{ |
|
234 |
public: |
|
235 |
DStaticPowerResource::TClass iClass; |
|
236 |
DStaticPowerResource::TLatency iLatencyGet; |
|
237 |
DStaticPowerResource::TLatency iLatencySet; |
|
238 |
DStaticPowerResource::TType iType; |
|
239 |
DStaticPowerResource::TUsage iUsage; |
|
240 |
DStaticPowerResource::TSense iSense; |
|
241 |
TDesC8* iResourceName; |
|
242 |
TUint iResourceId; |
|
243 |
TInt iDefaultLevel; |
|
244 |
TInt iMinLevel; //PSL mandatory field |
|
245 |
TInt iMaxLevel; //PSL mandatory field |
|
246 |
TInt iReserved1; //Reserved for future use. |
|
247 |
TInt iReserved2; //Reserved for future use. |
|
248 |
TInt iReserved3; //Reserved for future use. |
|
249 |
TInt iPslReserved1; //PSL specific field |
|
250 |
TInt iPslReserved2; //PSL specific field |
|
251 |
TInt iPslReserved3; //PSL specific field |
|
252 |
}; |
|
253 |
||
254 |
/** |
|
255 |
@publishedPartner |
|
256 |
@prototype 9.5 |
|
257 |
*/ |
|
258 |
typedef TPckgBuf<TPowerResourceInfoV01> TPowerResourceInfoBuf01; |
|
259 |
||
260 |
/** |
|
261 |
@publishedPartner |
|
262 |
@prototype 9.5 |
|
263 |
structure to represent client properties |
|
264 |
*/ |
|
265 |
struct TPowerClientInfoV01 |
|
266 |
{ |
|
267 |
TUint iClientId; |
|
268 |
TDesC8* iClientName; |
|
269 |
}; |
|
270 |
||
271 |
#endif // __RESOURCE_H__ |