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