author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Thu, 02 Sep 2010 21:54:16 +0300 | |
changeset 259 | 57b9594f5772 |
parent 0 | a41df078684a |
child 257 | 3e88ff8f41d5 |
child 269 | d57b86b1867a |
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 |
// e32test\resourceman\resourceman_psl\rescontrol_psl.h |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#ifndef __RESCONTROL_PSL_H__ |
|
19 |
#define __RESCONTROL_PSL_H__ |
|
20 |
#include <drivers/resourcecontrol.h> |
|
21 |
#include <kernel/kernel.h> |
|
22 |
#include <kernel/kern_priv.h> |
|
23 |
#define E_ON 0x1 |
|
24 |
#define E_OFF 0x0 |
|
25 |
||
26 |
//Specifies the number of pre-allocate the PIL data structures. |
|
27 |
#define KERNEL_CLIENTS 0x32 |
|
28 |
#define USER_CLIENTS 0x10 |
|
29 |
#define CLIENT_LEVELS 0x32 |
|
30 |
#define REQUESTS 0x19 |
|
31 |
||
32 |
#define MAX_RESOURCE_COUNT 30 |
|
33 |
#define MAX_DEPENDENT_RESOURCE_COUNT 10 |
|
34 |
||
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
35 |
#define MAX_BLOCK_TIME 400 //Maximum block time |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
36 |
#define MIN_BLOCK_TIME 200 //Guaranteed minimum block |
0 | 37 |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
38 |
template <class T> |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
39 |
inline TBool SafeAppend(RPointerArray <T> & aStaticResourceArray, T* pR) |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
40 |
{ |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
41 |
if(pR) |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
42 |
{ |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
43 |
if(aStaticResourceArray.Append(pR) == KErrNone) |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
44 |
return ETrue; |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
45 |
else |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
46 |
delete pR; |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
47 |
} |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
48 |
return EFalse; |
0 | 49 |
} |
50 |
||
51 |
const TUint KBinary = 0x0; |
|
52 |
const TUint KMultiLevel = 0x1; |
|
53 |
||
54 |
_LIT(KResmanName, "DSimulatedResMan"); |
|
55 |
/** Simulated resource controller class */ |
|
56 |
NONSHARABLE_CLASS(DSimulatedPowerResourceController): public DPowerResourceController |
|
57 |
{ |
|
58 |
public: |
|
59 |
DSimulatedPowerResourceController(); |
|
60 |
~DSimulatedPowerResourceController(); |
|
61 |
TInt DoInitController(); |
|
62 |
TInt DoInitResources(); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
63 |
TInt DoRegisterStaticResources(RPointerArray <DStaticPowerResource> & aStaticResourceArray); |
0 | 64 |
// Function to process instantaneous resources |
65 |
TInt ProcessInstantaneousResources(TPowerRequest& req, TInt& aClientLevel, TInt aMaxLevel, TInt aMinLevel, TInt aDefaultLevel); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
66 |
// Function to process polled resources |
0 | 67 |
TInt ProcessPolledResources(TPowerRequest& req, TInt& aClientLevel, TInt aMaxLevel, TInt aMinLevel, TInt aDefaultLevel, TInt aBlockTime = 0); |
68 |
// Function to change the state of the resource |
|
69 |
TInt ChangeResource(TPowerRequest& req, TInt& aClientLevel, TInt aMaxLevel, TInt aMinLevel); |
|
70 |
// Function to process event driven resources |
|
71 |
TInt ProcessEventResources(TPowerRequest& req, TInt& aClientLevel, TInt aMaxLevel, TInt aMinLevel, TInt aDefaultLevel, TInt aBlockTime = 0); |
|
72 |
IMPORT_C static TInt CaptureIdleResourcesInfo(TUint aControllerId, TUint aNumResources, TPtr* aPtr); |
|
73 |
IMPORT_C static TInt CompleteResourceControllerInitialisation(); |
|
74 |
#ifdef PRM_ENABLE_EXTENDED_VERSION |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
75 |
TInt DoRegisterStaticResourcesDependency(RPointerArray <DStaticPowerResourceD> & aStaticResourceDArray); |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
76 |
TInt CreateResourceDependency(RPointerArray <DStaticPowerResourceD> & pResArray); |
0 | 77 |
#endif |
78 |
private: |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
79 |
static void TimerIsrFunc(TAny* ptr); //ISR Function called when specified timer expires. This is for even driven resources |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
80 |
static void EventDfcFunc(TAny* ptr); //Function to wake up the fast semaphore. This is called from timer ISR. |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
81 |
NFastSemaphore iEventFastSem; //Semaphore to block the PIL of resource controller for event driven resource operations. |
0 | 82 |
TDfc iEventDfc; //Dfc to run to signal the event semaphore when the timer expires. Queued from timer ISR |
83 |
#ifdef PRM_ENABLE_EXTENDED_VERSION |
|
84 |
SNode* iNodeArray; |
|
85 |
TUint16 iNodeCount; |
|
86 |
#endif |
|
87 |
}; |
|
88 |
||
89 |
#ifdef PRM_ENABLE_EXTENDED_VERSION |
|
90 |
DSimulatedPowerResourceController* GetControllerPtr(); |
|
91 |
#endif |
|
92 |
//class definition for Binary Single Instantaneous Positive resource |
|
93 |
NONSHARABLE_CLASS(DBSIGISPResource) : public DStaticPowerResource |
|
94 |
{ |
|
95 |
public: |
|
96 |
DBSIGISPResource(); |
|
97 |
TInt DoRequest(TPowerRequest &req); |
|
98 |
TInt GetInfo(TDes8* aInfo) const; |
|
99 |
private: |
|
100 |
TInt iMinLevel; |
|
101 |
TInt iMaxLevel; |
|
102 |
TInt iCurrentLevel; |
|
103 |
}; |
|
104 |
||
105 |
//class definition for multilevel single instantaneous positive resource |
|
106 |
NONSHARABLE_CLASS(DMLSIGISPResource) : public DStaticPowerResource |
|
107 |
{ |
|
108 |
public: |
|
109 |
DMLSIGISPResource(); |
|
110 |
TInt DoRequest(TPowerRequest &req); |
|
111 |
TInt GetInfo(TDes8* aInfo) const; |
|
112 |
private: |
|
113 |
TInt iMinLevel; |
|
114 |
TInt iMaxLevel; |
|
115 |
TInt iCurrentLevel; |
|
116 |
}; |
|
117 |
||
118 |
//class definition for binary single instantaneous negative resource |
|
119 |
NONSHARABLE_CLASS(DBSIGISNResource) : public DStaticPowerResource |
|
120 |
{ |
|
121 |
public: |
|
122 |
DBSIGISNResource(); |
|
123 |
TInt DoRequest(TPowerRequest &req); |
|
124 |
TInt GetInfo(TDes8* aInfo) const; |
|
125 |
private: |
|
126 |
TInt iMinLevel; |
|
127 |
TInt iMaxLevel; |
|
128 |
TInt iCurrentLevel; |
|
129 |
}; |
|
130 |
||
131 |
//class definition for multilevel single instantaneous negative resource |
|
132 |
NONSHARABLE_CLASS(DMLSIGISNResource) : public DStaticPowerResource |
|
133 |
{ |
|
134 |
public: |
|
135 |
DMLSIGISNResource(); |
|
136 |
TInt DoRequest(TPowerRequest &req); |
|
137 |
TInt GetInfo(TDes8* aInfo) const; |
|
138 |
private: |
|
139 |
TInt iMinLevel; |
|
140 |
TInt iMaxLevel; |
|
141 |
TInt iCurrentLevel; |
|
142 |
}; |
|
143 |
||
144 |
//class definition for binary single long latency positive resource |
|
145 |
NONSHARABLE_CLASS(DBSLGLSPResource) : public DStaticPowerResource |
|
146 |
{ |
|
147 |
public: |
|
148 |
DBSLGLSPResource(); |
|
149 |
TInt DoRequest(TPowerRequest &req); |
|
150 |
TInt GetInfo(TDes8* aInfo) const; |
|
151 |
private: |
|
152 |
TInt iMinLevel; |
|
153 |
TInt iMaxLevel; |
|
154 |
TInt iCurrentLevel; |
|
155 |
TBool iPolled; |
|
156 |
TInt iBlockTime; //Time duration the thread will be blocked. |
|
157 |
}; |
|
158 |
||
159 |
//class definition for multilevel single long latency positive resource |
|
160 |
NONSHARABLE_CLASS(DMLSLGLSPResource) : public DStaticPowerResource |
|
161 |
{ |
|
162 |
public: |
|
163 |
DMLSLGLSPResource(); |
|
164 |
TInt DoRequest(TPowerRequest &req); |
|
165 |
TInt GetInfo(TDes8* aInfo) const; |
|
166 |
private: |
|
167 |
TInt iMinLevel; |
|
168 |
TInt iMaxLevel; |
|
169 |
TInt iCurrentLevel; |
|
170 |
TBool iPolled; |
|
171 |
TInt iBlockTime; //Time duration the thread will be blocked. |
|
172 |
}; |
|
173 |
||
174 |
//class definition for binary single long latency get & instantaneous set negative resource |
|
175 |
NONSHARABLE_CLASS(DBSLGISNResource) : public DStaticPowerResource |
|
176 |
{ |
|
177 |
public: |
|
178 |
DBSLGISNResource(); |
|
179 |
TInt DoRequest(TPowerRequest &req); |
|
180 |
TInt GetInfo(TDes8* aInfo) const; |
|
181 |
private: |
|
182 |
TInt iMinLevel; |
|
183 |
TInt iMaxLevel; |
|
184 |
TInt iCurrentLevel; |
|
185 |
TBool iPolled; |
|
186 |
TInt iBlockTime; //Time duration the thread will be blocked. |
|
187 |
}; |
|
188 |
||
189 |
//class definition for multilevel single long latency get & instantaneous set negative resource |
|
190 |
NONSHARABLE_CLASS(DMLSLGISNResource) : public DStaticPowerResource |
|
191 |
{ |
|
192 |
public: |
|
193 |
DMLSLGISNResource(); |
|
194 |
TInt DoRequest(TPowerRequest &req); |
|
195 |
TInt GetInfo(TDes8* aInfo) const; |
|
196 |
private: |
|
197 |
TInt iMinLevel; |
|
198 |
TInt iMaxLevel; |
|
199 |
TInt iCurrentLevel; |
|
200 |
TBool iPolled; |
|
201 |
TInt iBlockTime; //Time duration the thread will be blocked. |
|
202 |
}; |
|
203 |
||
204 |
//class definition for binary single instantaneous get & long latency set positive resource |
|
205 |
NONSHARABLE_CLASS(DBSIGLSPResource) : public DStaticPowerResource |
|
206 |
{ |
|
207 |
public: |
|
208 |
DBSIGLSPResource(); |
|
209 |
TInt DoRequest(TPowerRequest &req); |
|
210 |
TInt GetInfo(TDes8* aInfo) const; |
|
211 |
private: |
|
212 |
TInt iMinLevel; |
|
213 |
TInt iMaxLevel; |
|
214 |
TInt iCurrentLevel; |
|
215 |
TBool iPolled; |
|
216 |
TInt iBlockTime; //Time duration the thread will be blocked. |
|
217 |
}; |
|
218 |
||
219 |
//class definition for multilevel single instantaneous get & long latency get positive resource |
|
220 |
NONSHARABLE_CLASS(DMLSIGLSPResource) : public DStaticPowerResource |
|
221 |
{ |
|
222 |
public: |
|
223 |
DMLSIGLSPResource(); |
|
224 |
TInt DoRequest(TPowerRequest &req); |
|
225 |
TInt GetInfo(TDes8* aInfo) const; |
|
226 |
private: |
|
227 |
TInt iMinLevel; |
|
228 |
TInt iMaxLevel; |
|
229 |
TInt iCurrentLevel; |
|
230 |
TBool iPolled; |
|
231 |
TInt iBlockTime; //Time duration the thread will be blocked. |
|
232 |
}; |
|
233 |
||
234 |
//class definition for Binary Shared Instantaneous Positive resource |
|
235 |
NONSHARABLE_CLASS(DBSHIGISPResource) : public DStaticPowerResource |
|
236 |
{ |
|
237 |
public: |
|
238 |
DBSHIGISPResource(); |
|
239 |
TInt DoRequest(TPowerRequest &req); |
|
240 |
TInt GetInfo(TDes8* aInfo) const; |
|
241 |
private: |
|
242 |
TInt iMinLevel; |
|
243 |
TInt iMaxLevel; |
|
244 |
TInt iCurrentLevel; |
|
245 |
}; |
|
246 |
||
247 |
//class definition for multilevel shared instantaneous positive resource |
|
248 |
NONSHARABLE_CLASS(DMLSHIGISPResource) : public DStaticPowerResource |
|
249 |
{ |
|
250 |
public: |
|
251 |
DMLSHIGISPResource(); |
|
252 |
TInt DoRequest(TPowerRequest &req); |
|
253 |
TInt GetInfo(TDes8* aInfo) const; |
|
254 |
private: |
|
255 |
TInt iMinLevel; |
|
256 |
TInt iMaxLevel; |
|
257 |
TInt iCurrentLevel; |
|
258 |
}; |
|
259 |
||
260 |
//class definition for binary shared instantaneous negative resource |
|
261 |
NONSHARABLE_CLASS(DBSHIGISNResource) : public DStaticPowerResource |
|
262 |
{ |
|
263 |
public: |
|
264 |
DBSHIGISNResource(); |
|
265 |
TInt DoRequest(TPowerRequest &req); |
|
266 |
TInt GetInfo(TDes8* aInfo) const; |
|
267 |
private: |
|
268 |
TInt iMinLevel; |
|
269 |
TInt iMaxLevel; |
|
270 |
TInt iCurrentLevel; |
|
271 |
}; |
|
272 |
||
273 |
//class definition for multilevel shared instantaneous negative resource |
|
274 |
NONSHARABLE_CLASS(DMLSHIGISNResource) : public DStaticPowerResource |
|
275 |
{ |
|
276 |
public: |
|
277 |
DMLSHIGISNResource(); |
|
278 |
TInt DoRequest(TPowerRequest &req); |
|
279 |
TInt GetInfo(TDes8* aInfo) const; |
|
280 |
private: |
|
281 |
TInt iMinLevel; |
|
282 |
TInt iMaxLevel; |
|
283 |
TInt iCurrentLevel; |
|
284 |
}; |
|
285 |
||
286 |
//class definition for binary shared long latency positive resource |
|
287 |
NONSHARABLE_CLASS(DBSHLGLSPResource) : public DStaticPowerResource |
|
288 |
{ |
|
289 |
public: |
|
290 |
DBSHLGLSPResource(); |
|
291 |
TInt DoRequest(TPowerRequest &req); |
|
292 |
TInt GetInfo(TDes8* aInfo) const; |
|
293 |
private: |
|
294 |
TInt iMinLevel; |
|
295 |
TInt iMaxLevel; |
|
296 |
TInt iCurrentLevel; |
|
297 |
TBool iPolled; //ETrue if this is a polled resource, otherwise event driven type |
|
298 |
TInt iBlockTime; //Time duration the thread will be blocked. |
|
299 |
}; |
|
300 |
||
301 |
//class definition for multilevel shared long latency positive resource |
|
302 |
NONSHARABLE_CLASS(DMLSHLGLSPResource) : public DStaticPowerResource |
|
303 |
{ |
|
304 |
public: |
|
305 |
DMLSHLGLSPResource(); |
|
306 |
TInt DoRequest(TPowerRequest &req); |
|
307 |
TInt GetInfo(TDes8* aInfo) const; |
|
308 |
private: |
|
309 |
TInt iMinLevel; |
|
310 |
TInt iMaxLevel; |
|
311 |
TInt iCurrentLevel; |
|
312 |
TBool iPolled; //ETrue if this is a polled resource, otherwise event driven type |
|
313 |
TInt iBlockTime; //Time duration the thread will be blocked. |
|
314 |
}; |
|
315 |
||
316 |
//class definition for binary shared long latency get & instantaneous set negative resource |
|
317 |
NONSHARABLE_CLASS(DBSHLGISNResource) : public DStaticPowerResource |
|
318 |
{ |
|
319 |
public: |
|
320 |
DBSHLGISNResource(); |
|
321 |
TInt DoRequest(TPowerRequest &req); |
|
322 |
TInt GetInfo(TDes8* aInfo) const; |
|
323 |
private: |
|
324 |
TInt iMinLevel; |
|
325 |
TInt iMaxLevel; |
|
326 |
TInt iCurrentLevel; |
|
327 |
TBool iPolled; //ETrue if this is a polled resource, otherwise event driven type |
|
328 |
TInt iBlockTime; //Time duration the thread will be blocked. |
|
329 |
}; |
|
330 |
||
331 |
//class definition for multilevel shared long latency get & instantaneous set negative resource |
|
332 |
NONSHARABLE_CLASS(DMLSHLGISNResource) : public DStaticPowerResource |
|
333 |
{ |
|
334 |
public: |
|
335 |
DMLSHLGISNResource(); |
|
336 |
TInt DoRequest(TPowerRequest &req); |
|
337 |
TInt GetInfo(TDes8* aInfo) const; |
|
338 |
private: |
|
339 |
TInt iMinLevel; |
|
340 |
TInt iMaxLevel; |
|
341 |
TInt iCurrentLevel; |
|
342 |
TBool iPolled; //ETrue if this is a polled resource, otherwise event driven type |
|
343 |
TInt iBlockTime; //Time duration the thread will be blocked. |
|
344 |
}; |
|
345 |
||
346 |
//class definition for binary shared instantaneous get & long latency set positive resource |
|
347 |
NONSHARABLE_CLASS(DBSHIGLSPResource) : public DStaticPowerResource |
|
348 |
{ |
|
349 |
public: |
|
350 |
DBSHIGLSPResource(); |
|
351 |
TInt DoRequest(TPowerRequest &req); |
|
352 |
TInt GetInfo(TDes8* aInfo) const; |
|
353 |
private: |
|
354 |
TInt iMinLevel; |
|
355 |
TInt iMaxLevel; |
|
356 |
TInt iCurrentLevel; |
|
357 |
TBool iPolled; //ETrue if this is a polled resource, otherwise event driven type |
|
358 |
TInt iBlockTime; //Time duration the thread will be blocked. |
|
359 |
}; |
|
360 |
||
361 |
//class definition for multilevel shared instantaneous get & long latency get positive resource |
|
362 |
NONSHARABLE_CLASS(DMLSHIGLSPResource) : public DStaticPowerResource |
|
363 |
{ |
|
364 |
public: |
|
365 |
DMLSHIGLSPResource(); |
|
366 |
TInt DoRequest(TPowerRequest &req); |
|
367 |
TInt GetInfo(TDes8* aInfo) const; |
|
368 |
private: |
|
369 |
TInt iMinLevel; |
|
370 |
TInt iMaxLevel; |
|
371 |
TInt iCurrentLevel; |
|
372 |
TBool iPolled; //ETrue if this is a polled resource, otherwise event driven type |
|
373 |
TInt iBlockTime; //Time duration the thread will be blocked. |
|
374 |
}; |
|
375 |
||
376 |
//class definition for binary shared long latency get & set custom resource |
|
377 |
NONSHARABLE_CLASS(DBSHLGLSCResource) : public DStaticPowerResource |
|
378 |
{ |
|
379 |
public: |
|
380 |
DBSHLGLSCResource(); |
|
381 |
TInt DoRequest(TPowerRequest &req); |
|
382 |
TInt GetInfo(TDes8* aInfo) const; |
|
383 |
static TBool CustomFunction(TInt &aClientId, const TDesC8& aClientName, |
|
384 |
TUint aResourceId, |
|
385 |
TCustomOperation aCustomOperation, TInt &aLevel, |
|
386 |
TAny* aLevelList, TAny* aReserved); |
|
387 |
||
388 |
private: |
|
389 |
TInt iMinLevel; |
|
390 |
TInt iMaxLevel; |
|
391 |
TInt iCurrentLevel; |
|
392 |
TBool iPolled; //ETrue if this is a polled resource, otherwise event driven type |
|
393 |
TInt iBlockTime; //Time duration the thread will be blocked. |
|
394 |
}; |
|
395 |
||
396 |
#endif //__RESCONTROL_PSL_H__ |