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 |
// e32test\resourceman\d_rescontrol_cli.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <kernel/kern_priv.h>
|
sl@0
|
19 |
#include <drivers/resource_extend.h>
|
sl@0
|
20 |
#include <drivers/resourceman.h>
|
sl@0
|
21 |
#include "d_rescontrolcli.h"
|
sl@0
|
22 |
#ifdef PRM_ENABLE_EXTENDED_VERSION
|
sl@0
|
23 |
#include "dynamicresource.h"
|
sl@0
|
24 |
#endif
|
sl@0
|
25 |
#include "./resourceman_psl/rescontrol_psl.h"
|
sl@0
|
26 |
|
sl@0
|
27 |
#ifndef PRM_ENABLE_EXTENDED_VERSION
|
sl@0
|
28 |
_LIT(KTestPowerRCName, "D_RESCONTROLCLI.LDD");
|
sl@0
|
29 |
#else
|
sl@0
|
30 |
_LIT(KTestPowerRCName, "D_EXTENDEDRESCONTROLCLI.LDD");
|
sl@0
|
31 |
#endif
|
sl@0
|
32 |
|
sl@0
|
33 |
const TInt KTestResManLddThreadPriority = 0x5;
|
sl@0
|
34 |
_LIT(KTestResManLddThread, "TestResManLddThread");
|
sl@0
|
35 |
|
sl@0
|
36 |
#ifdef PRM_ENABLE_EXTENDED_VERSION
|
sl@0
|
37 |
#define EXPECTED_POST_NOTI_COUNT 6 //Expected number of notifications as a result of post boot level setting.
|
sl@0
|
38 |
#else
|
sl@0
|
39 |
#define EXPECTED_POST_NOTI_COUNT 5
|
sl@0
|
40 |
#endif
|
sl@0
|
41 |
#define MAX_DYNAMIC_RES_NUM 5
|
sl@0
|
42 |
/**
|
sl@0
|
43 |
Structure for holding resource information
|
sl@0
|
44 |
*/
|
sl@0
|
45 |
struct SClientInfo
|
sl@0
|
46 |
{
|
sl@0
|
47 |
HBuf8* pName;
|
sl@0
|
48 |
TUint iClientId;
|
sl@0
|
49 |
};
|
sl@0
|
50 |
/**
|
sl@0
|
51 |
The logical device (factory class) for the resource manager client side test.
|
sl@0
|
52 |
*/
|
sl@0
|
53 |
class DTestResManLddFactory : public DLogicalDevice
|
sl@0
|
54 |
{
|
sl@0
|
55 |
public:
|
sl@0
|
56 |
DTestResManLddFactory();
|
sl@0
|
57 |
~DTestResManLddFactory();
|
sl@0
|
58 |
virtual TInt Install();
|
sl@0
|
59 |
virtual void GetCaps(TDes8 &aDes) const;
|
sl@0
|
60 |
virtual TInt Create(DLogicalChannelBase*& aChannel);
|
sl@0
|
61 |
static void PostBootNotificationFunc(TUint aClientId, TUint aResId, TInt aLevel, TInt aLevelOwnerId, TInt aResult, TAny* aParam);
|
sl@0
|
62 |
void SetPostBootLevelAndRequestNotification(TUint aClientId, TUint aResId, TInt aPostBootLevel);
|
sl@0
|
63 |
TDynamicDfcQue* iDfcQ;
|
sl@0
|
64 |
DStaticPowerResource *iStaticRes;
|
sl@0
|
65 |
DStaticPowerResource *iStaticResArray[3];
|
sl@0
|
66 |
static SClientInfo iClient; //Need to be static to access them in PostBootNotificationFunc (callback function).
|
sl@0
|
67 |
static TUint iPostBootNotiCount;
|
sl@0
|
68 |
};
|
sl@0
|
69 |
|
sl@0
|
70 |
/** Logical channel class for Resource manager test LDD */
|
sl@0
|
71 |
class DTestResManLdd : public DLogicalChannel
|
sl@0
|
72 |
{
|
sl@0
|
73 |
public:
|
sl@0
|
74 |
DTestResManLdd();
|
sl@0
|
75 |
virtual ~DTestResManLdd();
|
sl@0
|
76 |
// Inherited from DLogicalChannel
|
sl@0
|
77 |
virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
|
sl@0
|
78 |
virtual void HandleMsg(TMessageBase* aMsg);
|
sl@0
|
79 |
private:
|
sl@0
|
80 |
TInt DoControl(TInt aFunction, TAny* a1, TAny* a2);
|
sl@0
|
81 |
TInt DoRequest(TInt aFunction, TRequestStatus* aStatus, TAny* a1, TAny* a2);
|
sl@0
|
82 |
TInt DoCancel(TUint aMask);
|
sl@0
|
83 |
static void CallbackFunc(TUint aClientId, TUint aResId, TInt aLevel, TInt aLevelOwnerId, TInt aResult, TAny* aParam);
|
sl@0
|
84 |
static void CondNotificationFunc(TUint aClientId, TUint aResId, TInt aLevel, TInt aLevelOwnerId, TInt aResult, TAny* aParam);
|
sl@0
|
85 |
static void UnCondNotificationFunc(TUint aClientId, TUint aResId, TInt aLevel, TInt aLevelOwnerId, TInt aResult, TAny* aParam);
|
sl@0
|
86 |
private:
|
sl@0
|
87 |
DThread* iClientThreadPtr;
|
sl@0
|
88 |
TPowerResourceCb iAsyncResourceCallback; //Callback object for handling long latency resources.
|
sl@0
|
89 |
//Structure for storing the notification information
|
sl@0
|
90 |
struct SNotificationList
|
sl@0
|
91 |
{
|
sl@0
|
92 |
TUint iClientId;
|
sl@0
|
93 |
TUint iResourceId;
|
sl@0
|
94 |
TUint iCount;
|
sl@0
|
95 |
DPowerResourceNotification *iNoti;
|
sl@0
|
96 |
SNotificationList *iNext;
|
sl@0
|
97 |
};
|
sl@0
|
98 |
SNotificationList *iCondList; //List for maintaining conditional notification
|
sl@0
|
99 |
SNotificationList *iUnCondList; //List for maintaining unconditional notification
|
sl@0
|
100 |
TRequestStatus *iStatus; //Store the status and complete on callback function.
|
sl@0
|
101 |
TBool iCallbackCancel;
|
sl@0
|
102 |
TInt iClientId; //ID of the client that requested long latency operation, to compare in callback and notifications.
|
sl@0
|
103 |
TUint iResourceId; //Id of the resource of long latency operation, to compare in callback and notifications.
|
sl@0
|
104 |
//Below 2 variables are used only for asynchronous get resource state operation
|
sl@0
|
105 |
TInt *iStatePtr; //Pointer to hold the address of state variable, where state is updated in callback function.
|
sl@0
|
106 |
TInt *iLevelOwnerIdPtr; //Pointer to hold the address of level owner Id variable, where owner Id is updated in callback function.
|
sl@0
|
107 |
HBuf *pBuf; //Buffer for testing caching of resource information for Idle power management
|
sl@0
|
108 |
SClientInfo clientInfo[MAX_CLIENTS];
|
sl@0
|
109 |
#ifdef PRM_ENABLE_EXTENDED_VERSION
|
sl@0
|
110 |
TUint iTestParallelResourceId; //Variable to hold the long latency resource id, this is used only in test parallel execution of DFC's
|
sl@0
|
111 |
static void TestParallelExecutionCallback(TUint aClientId, TUint aResId, TInt aLevel, TInt aLevelOwnerId, TInt aResult, TAny* aParam);
|
sl@0
|
112 |
TBool iCallbackReceived;
|
sl@0
|
113 |
TBool iValidateCallbackReceived;
|
sl@0
|
114 |
TPowerResourceCb iAsyncTestParallelCallback; //Callback object for handling long latency resources change state while deregistering non-dependency resource.
|
sl@0
|
115 |
RArray <DDynamicPowerResource*> iDynamicArray; //Array to hold dynamic resources. This includes dynamic dependent resource
|
sl@0
|
116 |
#endif
|
sl@0
|
117 |
};
|
sl@0
|
118 |
|
sl@0
|
119 |
//class definition for multilevel single instantaneous positive resource
|
sl@0
|
120 |
class DLaterRegisterStaticResource : public DStaticPowerResource
|
sl@0
|
121 |
{
|
sl@0
|
122 |
public:
|
sl@0
|
123 |
DLaterRegisterStaticResource();
|
sl@0
|
124 |
TInt DoRequest(TPowerRequest &req);
|
sl@0
|
125 |
TInt GetInfo(TDes8* aInfo) const;
|
sl@0
|
126 |
private:
|
sl@0
|
127 |
TInt iMinLevel;
|
sl@0
|
128 |
TInt iMaxLevel;
|
sl@0
|
129 |
TInt iCurrentLevel;
|
sl@0
|
130 |
};
|
sl@0
|
131 |
|
sl@0
|
132 |
//Constructors of the resource
|
sl@0
|
133 |
_LIT(KLaterRegisterStaticResource, "LaterRegisterStaticResource");
|
sl@0
|
134 |
DLaterRegisterStaticResource::DLaterRegisterStaticResource() : DStaticPowerResource(KLaterRegisterStaticResource, E_OFF), iMinLevel(0), iMaxLevel(1), iCurrentLevel(0)
|
sl@0
|
135 |
{
|
sl@0
|
136 |
iFlags = KBinary;
|
sl@0
|
137 |
}
|
sl@0
|
138 |
|
sl@0
|
139 |
TInt DLaterRegisterStaticResource::DoRequest(TPowerRequest& req)
|
sl@0
|
140 |
{
|
sl@0
|
141 |
Kern::Printf("DLaterRegisterStaticResource::DoRequest\n");
|
sl@0
|
142 |
if(req.ReqType() == TPowerRequest::EGet)
|
sl@0
|
143 |
{
|
sl@0
|
144 |
req.Level() = iCurrentLevel;
|
sl@0
|
145 |
}
|
sl@0
|
146 |
else if(req.ReqType() == TPowerRequest::EChange)
|
sl@0
|
147 |
{
|
sl@0
|
148 |
iCurrentLevel = req.Level();
|
sl@0
|
149 |
}
|
sl@0
|
150 |
else if(req.ReqType() == TPowerRequest::ESetDefaultLevel)
|
sl@0
|
151 |
{
|
sl@0
|
152 |
req.Level() = iDefaultLevel;
|
sl@0
|
153 |
iCurrentLevel = iDefaultLevel;
|
sl@0
|
154 |
}
|
sl@0
|
155 |
else
|
sl@0
|
156 |
return KErrNotSupported;
|
sl@0
|
157 |
return KErrNone;
|
sl@0
|
158 |
}
|
sl@0
|
159 |
|
sl@0
|
160 |
TInt DLaterRegisterStaticResource::GetInfo(TDes8* info) const
|
sl@0
|
161 |
{
|
sl@0
|
162 |
DStaticPowerResource::GetInfo((TDes8*)info);
|
sl@0
|
163 |
TPowerResourceInfoV01 *buf1 = (TPowerResourceInfoV01*)info;
|
sl@0
|
164 |
buf1->iDefaultLevel = iDefaultLevel;
|
sl@0
|
165 |
buf1->iMinLevel = iMinLevel;
|
sl@0
|
166 |
buf1->iMaxLevel = iMaxLevel;
|
sl@0
|
167 |
return KErrNone;
|
sl@0
|
168 |
}
|
sl@0
|
169 |
|
sl@0
|
170 |
//class definition for multilevel single instantaneous positive resource
|
sl@0
|
171 |
class DLaterRegisterStaticResource1 : public DStaticPowerResource
|
sl@0
|
172 |
{
|
sl@0
|
173 |
public:
|
sl@0
|
174 |
DLaterRegisterStaticResource1();
|
sl@0
|
175 |
TInt DoRequest(TPowerRequest &req);
|
sl@0
|
176 |
TInt GetInfo(TDes8* aInfo) const;
|
sl@0
|
177 |
private:
|
sl@0
|
178 |
TInt iMinLevel;
|
sl@0
|
179 |
TInt iMaxLevel;
|
sl@0
|
180 |
TInt iCurrentLevel;
|
sl@0
|
181 |
};
|
sl@0
|
182 |
|
sl@0
|
183 |
//Constructors of the resource
|
sl@0
|
184 |
_LIT(KLaterRegisterStaticResource1, "LaterRegisterStaticResource1");
|
sl@0
|
185 |
DLaterRegisterStaticResource1::DLaterRegisterStaticResource1() : DStaticPowerResource(KLaterRegisterStaticResource1, E_OFF), iMinLevel(0), iMaxLevel(1), iCurrentLevel(0)
|
sl@0
|
186 |
{
|
sl@0
|
187 |
iFlags = KBinary;
|
sl@0
|
188 |
}
|
sl@0
|
189 |
|
sl@0
|
190 |
TInt DLaterRegisterStaticResource1::DoRequest(TPowerRequest& req)
|
sl@0
|
191 |
{
|
sl@0
|
192 |
Kern::Printf("DLaterRegisterStaticResource1::DoRequest\n");
|
sl@0
|
193 |
if(req.ReqType() == TPowerRequest::EGet)
|
sl@0
|
194 |
{
|
sl@0
|
195 |
req.Level() = iCurrentLevel;
|
sl@0
|
196 |
}
|
sl@0
|
197 |
else if(req.ReqType() == TPowerRequest::EChange)
|
sl@0
|
198 |
{
|
sl@0
|
199 |
iCurrentLevel = req.Level();
|
sl@0
|
200 |
}
|
sl@0
|
201 |
else if(req.ReqType() == TPowerRequest::ESetDefaultLevel)
|
sl@0
|
202 |
{
|
sl@0
|
203 |
req.Level() = iDefaultLevel;
|
sl@0
|
204 |
iCurrentLevel = iDefaultLevel;
|
sl@0
|
205 |
}
|
sl@0
|
206 |
else
|
sl@0
|
207 |
return KErrNotSupported;
|
sl@0
|
208 |
return KErrNone;
|
sl@0
|
209 |
}
|
sl@0
|
210 |
|
sl@0
|
211 |
TInt DLaterRegisterStaticResource1::GetInfo(TDes8* info) const
|
sl@0
|
212 |
{
|
sl@0
|
213 |
DStaticPowerResource::GetInfo((TDes8*)info);
|
sl@0
|
214 |
TPowerResourceInfoV01 *buf1 = (TPowerResourceInfoV01*)info;
|
sl@0
|
215 |
buf1->iDefaultLevel = iDefaultLevel;
|
sl@0
|
216 |
buf1->iMinLevel = iMinLevel;
|
sl@0
|
217 |
buf1->iMaxLevel = iMaxLevel;
|
sl@0
|
218 |
return KErrNone;
|
sl@0
|
219 |
}
|
sl@0
|
220 |
|
sl@0
|
221 |
//class definition for multilevel single instantaneous positive resource
|
sl@0
|
222 |
class DLaterRegisterStaticResource2 : public DStaticPowerResource
|
sl@0
|
223 |
{
|
sl@0
|
224 |
public:
|
sl@0
|
225 |
DLaterRegisterStaticResource2();
|
sl@0
|
226 |
TInt DoRequest(TPowerRequest &req);
|
sl@0
|
227 |
TInt GetInfo(TDes8* aInfo) const;
|
sl@0
|
228 |
private:
|
sl@0
|
229 |
TInt iMinLevel;
|
sl@0
|
230 |
TInt iMaxLevel;
|
sl@0
|
231 |
TInt iCurrentLevel;
|
sl@0
|
232 |
};
|
sl@0
|
233 |
|
sl@0
|
234 |
//Constructors of the resource
|
sl@0
|
235 |
_LIT(KLaterRegisterStaticResource2, "LaterRegisterStaticResource2");
|
sl@0
|
236 |
DLaterRegisterStaticResource2::DLaterRegisterStaticResource2() : DStaticPowerResource(KLaterRegisterStaticResource2, E_OFF), iMinLevel(0), iMaxLevel(1), iCurrentLevel(0)
|
sl@0
|
237 |
{
|
sl@0
|
238 |
iFlags = KBinary;
|
sl@0
|
239 |
}
|
sl@0
|
240 |
|
sl@0
|
241 |
TInt DLaterRegisterStaticResource2::DoRequest(TPowerRequest& req)
|
sl@0
|
242 |
{
|
sl@0
|
243 |
Kern::Printf("DLaterRegisterStaticResource2::DoRequest\n");
|
sl@0
|
244 |
if(req.ReqType() == TPowerRequest::EGet)
|
sl@0
|
245 |
{
|
sl@0
|
246 |
req.Level() = iCurrentLevel;
|
sl@0
|
247 |
}
|
sl@0
|
248 |
else if(req.ReqType() == TPowerRequest::EChange)
|
sl@0
|
249 |
{
|
sl@0
|
250 |
iCurrentLevel = req.Level();
|
sl@0
|
251 |
}
|
sl@0
|
252 |
else if(req.ReqType() == TPowerRequest::ESetDefaultLevel)
|
sl@0
|
253 |
{
|
sl@0
|
254 |
req.Level() = iDefaultLevel;
|
sl@0
|
255 |
iCurrentLevel = iDefaultLevel;
|
sl@0
|
256 |
}
|
sl@0
|
257 |
else
|
sl@0
|
258 |
return KErrNotSupported;
|
sl@0
|
259 |
return KErrNone;
|
sl@0
|
260 |
}
|
sl@0
|
261 |
|
sl@0
|
262 |
TInt DLaterRegisterStaticResource2::GetInfo(TDes8* info) const
|
sl@0
|
263 |
{
|
sl@0
|
264 |
DStaticPowerResource::GetInfo((TDes8*)info);
|
sl@0
|
265 |
TPowerResourceInfoV01 *buf1 = (TPowerResourceInfoV01*)info;
|
sl@0
|
266 |
buf1->iDefaultLevel = iDefaultLevel;
|
sl@0
|
267 |
buf1->iMinLevel = iMinLevel;
|
sl@0
|
268 |
buf1->iMaxLevel = iMaxLevel;
|
sl@0
|
269 |
return KErrNone;
|
sl@0
|
270 |
}
|
sl@0
|
271 |
|
sl@0
|
272 |
TUint DTestResManLddFactory::iPostBootNotiCount = 0;
|
sl@0
|
273 |
SClientInfo DTestResManLddFactory::iClient = {NULL, 0};
|
sl@0
|
274 |
DTestResManLddFactory::DTestResManLddFactory()
|
sl@0
|
275 |
{
|
sl@0
|
276 |
iParseMask=0; // Allow info and pdd, but not units
|
sl@0
|
277 |
iUnitsMask=0;
|
sl@0
|
278 |
// Set version number for this device
|
sl@0
|
279 |
iVersion=RTestResMan::VersionRequired();
|
sl@0
|
280 |
}
|
sl@0
|
281 |
|
sl@0
|
282 |
DTestResManLddFactory::~DTestResManLddFactory()
|
sl@0
|
283 |
{
|
sl@0
|
284 |
if(iDfcQ)
|
sl@0
|
285 |
iDfcQ->Destroy();
|
sl@0
|
286 |
if(iStaticRes)
|
sl@0
|
287 |
delete iStaticRes;
|
sl@0
|
288 |
if(iStaticResArray[0])
|
sl@0
|
289 |
delete iStaticResArray[0];
|
sl@0
|
290 |
if(iStaticResArray[2])
|
sl@0
|
291 |
delete iStaticResArray[2];
|
sl@0
|
292 |
}
|
sl@0
|
293 |
|
sl@0
|
294 |
/** Entry point for this driver */
|
sl@0
|
295 |
DECLARE_STANDARD_LDD()
|
sl@0
|
296 |
{
|
sl@0
|
297 |
DTestResManLddFactory* p = new DTestResManLddFactory;
|
sl@0
|
298 |
if(!p)
|
sl@0
|
299 |
return NULL;
|
sl@0
|
300 |
TInt r = Kern::DynamicDfcQCreate(p->iDfcQ, KTestResManLddThreadPriority, KTestResManLddThread);
|
sl@0
|
301 |
if(r != KErrNone)
|
sl@0
|
302 |
{
|
sl@0
|
303 |
Kern::Printf("Memory not allocated");
|
sl@0
|
304 |
p->AsyncDelete();
|
sl@0
|
305 |
return NULL;
|
sl@0
|
306 |
}
|
sl@0
|
307 |
|
sl@0
|
308 |
#ifdef CPU_AFFINITY_ANY
|
sl@0
|
309 |
NKern::ThreadSetCpuAffinity((NThread*)(p->iDfcQ->iThread), KCpuAffinityAny);
|
sl@0
|
310 |
#endif
|
sl@0
|
311 |
|
sl@0
|
312 |
//Register client with Resource Controller
|
sl@0
|
313 |
TBuf8<32> ClientName(_L8("Client"));
|
sl@0
|
314 |
p->iClient.pName = HBuf::New((const TDesC&)ClientName);
|
sl@0
|
315 |
if(!p->iClient.pName)
|
sl@0
|
316 |
{
|
sl@0
|
317 |
p->iDfcQ->Destroy();
|
sl@0
|
318 |
p->AsyncDelete();
|
sl@0
|
319 |
return NULL;
|
sl@0
|
320 |
}
|
sl@0
|
321 |
//Allocating memory earlier so that during failure conditions can cleanup easily
|
sl@0
|
322 |
p->iStaticRes = new DLaterRegisterStaticResource();
|
sl@0
|
323 |
if(!p->iStaticRes)
|
sl@0
|
324 |
{
|
sl@0
|
325 |
delete p->iClient.pName;
|
sl@0
|
326 |
p->iDfcQ->Destroy();
|
sl@0
|
327 |
p->AsyncDelete();
|
sl@0
|
328 |
return NULL;
|
sl@0
|
329 |
}
|
sl@0
|
330 |
p->iStaticResArray[0] = new DLaterRegisterStaticResource1();
|
sl@0
|
331 |
if(!p->iStaticResArray[0])
|
sl@0
|
332 |
{
|
sl@0
|
333 |
delete p->iStaticRes;
|
sl@0
|
334 |
delete p->iClient.pName;
|
sl@0
|
335 |
p->iDfcQ->Destroy();
|
sl@0
|
336 |
p->AsyncDelete();
|
sl@0
|
337 |
return NULL;
|
sl@0
|
338 |
}
|
sl@0
|
339 |
p->iStaticResArray[2] = new DLaterRegisterStaticResource2();
|
sl@0
|
340 |
if(!p->iStaticResArray[2])
|
sl@0
|
341 |
{
|
sl@0
|
342 |
delete p->iStaticRes;
|
sl@0
|
343 |
delete p->iStaticResArray[0];
|
sl@0
|
344 |
delete p->iClient.pName;
|
sl@0
|
345 |
p->iDfcQ->Destroy();
|
sl@0
|
346 |
p->AsyncDelete();
|
sl@0
|
347 |
return NULL;
|
sl@0
|
348 |
}
|
sl@0
|
349 |
r = PowerResourceManager::RegisterClient(DTestResManLddFactory::iClient.iClientId, (const TDesC&)*DTestResManLddFactory::iClient.pName);
|
sl@0
|
350 |
if(r != KErrNone)
|
sl@0
|
351 |
{
|
sl@0
|
352 |
Kern::Printf("RegisterClient Failed\n");
|
sl@0
|
353 |
Kern::Fault("PRM REGISTER CLIENT FAILED", __LINE__);
|
sl@0
|
354 |
}
|
sl@0
|
355 |
//Set postbootlevel for these resources.
|
sl@0
|
356 |
p->SetPostBootLevelAndRequestNotification(DTestResManLddFactory::iClient.iClientId, 1, 0);
|
sl@0
|
357 |
p->SetPostBootLevelAndRequestNotification(DTestResManLddFactory::iClient.iClientId, 6, 12);
|
sl@0
|
358 |
p->SetPostBootLevelAndRequestNotification(DTestResManLddFactory::iClient.iClientId, 7, 1);
|
sl@0
|
359 |
p->SetPostBootLevelAndRequestNotification(DTestResManLddFactory::iClient.iClientId, 12, 10);
|
sl@0
|
360 |
p->SetPostBootLevelAndRequestNotification(DTestResManLddFactory::iClient.iClientId, 15, 0);
|
sl@0
|
361 |
#ifdef PRM_ENABLE_EXTENDED_VERSION
|
sl@0
|
362 |
p->SetPostBootLevelAndRequestNotification(DTestResManLddFactory::iClient.iClientId, 65537, -50);
|
sl@0
|
363 |
#endif
|
sl@0
|
364 |
//Test the later registration of static resources.
|
sl@0
|
365 |
r = DPowerResourceController::RegisterStaticResource(DTestResManLddFactory::iClient.iClientId, p->iStaticRes);
|
sl@0
|
366 |
if(r != KErrNone)
|
sl@0
|
367 |
Kern::Fault("PRM REGISTER STATIC RESOURCE FAILED", __LINE__);
|
sl@0
|
368 |
DStaticPowerResource **resPtr = &p->iStaticResArray[0];
|
sl@0
|
369 |
r = DPowerResourceController::RegisterArrayOfStaticResources(DTestResManLddFactory::iClient.iClientId, resPtr, 3);
|
sl@0
|
370 |
if(r != KErrNone)
|
sl@0
|
371 |
Kern::Fault("PRM REGISTER STATIC RESOURCE FAILED", __LINE__);
|
sl@0
|
372 |
r = DSimulatedPowerResourceController::CompleteResourceControllerInitialisation();
|
sl@0
|
373 |
if(r != KErrNone)
|
sl@0
|
374 |
Kern::Fault("PRM INIT FAILED", __LINE__);
|
sl@0
|
375 |
return p;
|
sl@0
|
376 |
}
|
sl@0
|
377 |
|
sl@0
|
378 |
void DTestResManLddFactory::SetPostBootLevelAndRequestNotification(TUint aClientId, TUint aResId, TInt aPostBootLevel)
|
sl@0
|
379 |
{
|
sl@0
|
380 |
DPowerResourceController::PostBootLevel(aResId, aPostBootLevel);
|
sl@0
|
381 |
DPowerResourceNotification* iNoti = new DPowerResourceNotification(PostBootNotificationFunc, (TAny*)NULL, Kern::DfcQue0(), 3);
|
sl@0
|
382 |
if(!iNoti)
|
sl@0
|
383 |
{
|
sl@0
|
384 |
Kern::Fault("PRM NOTI FAILED", __LINE__);
|
sl@0
|
385 |
}
|
sl@0
|
386 |
//Passing the address of the object so that it could be deleted in callback function
|
sl@0
|
387 |
new (iNoti) DPowerResourceNotification(PostBootNotificationFunc, iNoti, Kern::DfcQue0(), 3);
|
sl@0
|
388 |
TInt r = PowerResourceManager::RequestNotification(aClientId, aResId, *iNoti);
|
sl@0
|
389 |
if(r != KErrNone)
|
sl@0
|
390 |
Kern::Fault("PRM REQ NOTI FAILED", __LINE__);
|
sl@0
|
391 |
}
|
sl@0
|
392 |
|
sl@0
|
393 |
|
sl@0
|
394 |
/** Second stage constuctor */
|
sl@0
|
395 |
TInt DTestResManLddFactory::Install()
|
sl@0
|
396 |
{
|
sl@0
|
397 |
return(SetName(&KTestPowerRCName));
|
sl@0
|
398 |
}
|
sl@0
|
399 |
|
sl@0
|
400 |
/** Device capabilities */
|
sl@0
|
401 |
void DTestResManLddFactory::GetCaps(TDes8& aDes)const
|
sl@0
|
402 |
{
|
sl@0
|
403 |
// Create a capabilities object
|
sl@0
|
404 |
RTestResMan::TCaps caps;
|
sl@0
|
405 |
caps.iVersion = iVersion;
|
sl@0
|
406 |
// Write it back to user memory
|
sl@0
|
407 |
Kern::InfoCopy(aDes,(TUint8*)&caps,sizeof(caps));
|
sl@0
|
408 |
}
|
sl@0
|
409 |
|
sl@0
|
410 |
/** Create logical channel, only open of one channel is allowed */
|
sl@0
|
411 |
TInt DTestResManLddFactory::Create(DLogicalChannelBase*& aChannel)
|
sl@0
|
412 |
{
|
sl@0
|
413 |
if (iOpenChannels != 0) //A Channel is already open
|
sl@0
|
414 |
return KErrInUse;
|
sl@0
|
415 |
//Deregister the client registered in ldd init.
|
sl@0
|
416 |
TInt r = PowerResourceManager::DeRegisterClient(DTestResManLddFactory::iClient.iClientId);
|
sl@0
|
417 |
if(r != KErrNone)
|
sl@0
|
418 |
Kern::Fault("PRM CLIENT DEREGISTER FAILED", __LINE__);
|
sl@0
|
419 |
delete DTestResManLddFactory::iClient.pName;
|
sl@0
|
420 |
DTestResManLddFactory::iClient.pName = NULL;
|
sl@0
|
421 |
DTestResManLddFactory::iClient.iClientId = 0;
|
sl@0
|
422 |
aChannel = new DTestResManLdd;
|
sl@0
|
423 |
if(!aChannel)
|
sl@0
|
424 |
return KErrNoMemory;
|
sl@0
|
425 |
return KErrNone;
|
sl@0
|
426 |
}
|
sl@0
|
427 |
|
sl@0
|
428 |
/** Constructor */
|
sl@0
|
429 |
DTestResManLdd::DTestResManLdd(): iAsyncResourceCallback(CallbackFunc, this, 3)
|
sl@0
|
430 |
#ifdef PRM_ENABLE_EXTENDED_VERSION
|
sl@0
|
431 |
, iAsyncTestParallelCallback(TestParallelExecutionCallback, this, 3)
|
sl@0
|
432 |
#endif
|
sl@0
|
433 |
{
|
sl@0
|
434 |
iCondList = NULL;
|
sl@0
|
435 |
iUnCondList = NULL;
|
sl@0
|
436 |
iCallbackCancel = EFalse;
|
sl@0
|
437 |
iClientId = 0;
|
sl@0
|
438 |
iResourceId = 0;
|
sl@0
|
439 |
iStatePtr = NULL;
|
sl@0
|
440 |
iLevelOwnerIdPtr = NULL;
|
sl@0
|
441 |
for(TUint c = 0; c < MAX_CLIENTS; c++)
|
sl@0
|
442 |
{
|
sl@0
|
443 |
clientInfo[c].iClientId = 0;
|
sl@0
|
444 |
clientInfo[c].pName = NULL;
|
sl@0
|
445 |
}
|
sl@0
|
446 |
iClientThreadPtr=&Kern::CurrentThread();
|
sl@0
|
447 |
// Increase the DThread's ref count so that it does not close without us
|
sl@0
|
448 |
((DObject*)iClientThreadPtr)->Open();;
|
sl@0
|
449 |
}
|
sl@0
|
450 |
|
sl@0
|
451 |
/** Destructor */
|
sl@0
|
452 |
DTestResManLdd::~DTestResManLdd()
|
sl@0
|
453 |
{
|
sl@0
|
454 |
if(pBuf) //Buffer created for storing idle resource information
|
sl@0
|
455 |
delete pBuf;
|
sl@0
|
456 |
#ifdef PRM_ENABLE_EXTENDED_VERSION
|
sl@0
|
457 |
for(TInt c = 0; c < iDynamicArray.Count(); c++)
|
sl@0
|
458 |
{
|
sl@0
|
459 |
delete iDynamicArray[c]; //Delete the dynamic array. This includes dynamic dependent resource.
|
sl@0
|
460 |
}
|
sl@0
|
461 |
iDynamicArray.Close();
|
sl@0
|
462 |
#endif
|
sl@0
|
463 |
// Close our reference on the client thread
|
sl@0
|
464 |
Kern::SafeClose((DObject*&)iClientThreadPtr,NULL);
|
sl@0
|
465 |
}
|
sl@0
|
466 |
|
sl@0
|
467 |
/** Second stage constructor. */
|
sl@0
|
468 |
TInt DTestResManLdd::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& aVer)
|
sl@0
|
469 |
{
|
sl@0
|
470 |
// Check version
|
sl@0
|
471 |
if (!Kern::QueryVersionSupported(RTestResMan::VersionRequired(),aVer))
|
sl@0
|
472 |
return KErrNotSupported;
|
sl@0
|
473 |
SetDfcQ(((DTestResManLddFactory*)iDevice)->iDfcQ);
|
sl@0
|
474 |
iAsyncResourceCallback.SetDfcQ(iDfcQ);
|
sl@0
|
475 |
#ifdef PRM_ENABLE_EXTENDED_VERSION
|
sl@0
|
476 |
iAsyncTestParallelCallback.SetDfcQ(iDfcQ);
|
sl@0
|
477 |
#endif
|
sl@0
|
478 |
iMsgQ.Receive();
|
sl@0
|
479 |
return KErrNone;
|
sl@0
|
480 |
}
|
sl@0
|
481 |
|
sl@0
|
482 |
/** Process a message for this logical channel */
|
sl@0
|
483 |
void DTestResManLdd::HandleMsg(TMessageBase* aMsg)
|
sl@0
|
484 |
{
|
sl@0
|
485 |
TThreadMessage& m=*(TThreadMessage*)aMsg;
|
sl@0
|
486 |
TInt id=m.iValue;
|
sl@0
|
487 |
|
sl@0
|
488 |
if (id==(TInt)ECloseMsg)
|
sl@0
|
489 |
{
|
sl@0
|
490 |
// Channel close.
|
sl@0
|
491 |
m.Complete(KErrNone,EFalse);
|
sl@0
|
492 |
return;
|
sl@0
|
493 |
}
|
sl@0
|
494 |
else if (id==KMaxTInt)
|
sl@0
|
495 |
{
|
sl@0
|
496 |
// DoCancel
|
sl@0
|
497 |
m.Complete(KErrNone,ETrue);
|
sl@0
|
498 |
return;
|
sl@0
|
499 |
}
|
sl@0
|
500 |
else if (id<0)
|
sl@0
|
501 |
{
|
sl@0
|
502 |
// DoRequest
|
sl@0
|
503 |
TRequestStatus* pS=(TRequestStatus*)m.Ptr0();
|
sl@0
|
504 |
TInt r=DoRequest(~id,pS,m.Ptr1(),m.Ptr2());
|
sl@0
|
505 |
if (r!=KErrNone)
|
sl@0
|
506 |
Kern::RequestComplete(iClientThreadPtr,pS,r);
|
sl@0
|
507 |
m.Complete(KErrNone,ETrue);
|
sl@0
|
508 |
}
|
sl@0
|
509 |
else
|
sl@0
|
510 |
{
|
sl@0
|
511 |
// DoControl
|
sl@0
|
512 |
TInt r=DoControl(id,m.Ptr0(),m.Ptr1());
|
sl@0
|
513 |
m.Complete(r,ETrue);
|
sl@0
|
514 |
}
|
sl@0
|
515 |
}
|
sl@0
|
516 |
|
sl@0
|
517 |
|
sl@0
|
518 |
/**
|
sl@0
|
519 |
Process synchronous 'control' requests
|
sl@0
|
520 |
*/
|
sl@0
|
521 |
TInt DTestResManLdd::DoControl(TInt aFunction, TAny* a1, TAny* a2)
|
sl@0
|
522 |
{
|
sl@0
|
523 |
TInt r = KErrNone;
|
sl@0
|
524 |
TParameterListInfo ptr = {0, 0, 0, 0, 0};
|
sl@0
|
525 |
//Copy parameter structure from user space.
|
sl@0
|
526 |
if((aFunction != RTestResMan::EDeRegisterClient)
|
sl@0
|
527 |
&& (aFunction != RTestResMan::ERequestNotificationUncond)
|
sl@0
|
528 |
&& (aFunction != RTestResMan::EGetIdleResourcesInfo)
|
sl@0
|
529 |
&& (aFunction != RTestResMan::EDeRegisterClientLevelFromResource)
|
sl@0
|
530 |
&& (aFunction != RTestResMan::ECheckPostBootLevelNotifications)
|
sl@0
|
531 |
&& (aFunction != RTestResMan::EGetControllerVersion)
|
sl@0
|
532 |
#ifdef PRM_ENABLE_EXTENDED_VERSION
|
sl@0
|
533 |
&& (aFunction != RTestResMan::ERegisterDynamicResource))
|
sl@0
|
534 |
#else
|
sl@0
|
535 |
)
|
sl@0
|
536 |
#endif
|
sl@0
|
537 |
{
|
sl@0
|
538 |
r = Kern::ThreadRawRead(iClientThreadPtr, (TParameterListInfo*)a1, &ptr, sizeof(TParameterListInfo));
|
sl@0
|
539 |
if(r != KErrNone)
|
sl@0
|
540 |
return r;
|
sl@0
|
541 |
}
|
sl@0
|
542 |
switch(aFunction)
|
sl@0
|
543 |
{
|
sl@0
|
544 |
case RTestResMan::ERegisterClient:
|
sl@0
|
545 |
{
|
sl@0
|
546 |
TBuf8<256> aName;
|
sl@0
|
547 |
TUint c;
|
sl@0
|
548 |
//Copy name from user address space
|
sl@0
|
549 |
r = Kern::ThreadDesRead(iClientThreadPtr, (const TDesC*)ptr.iPtr2, (TDes8&)aName, 0);
|
sl@0
|
550 |
if(r != KErrNone)
|
sl@0
|
551 |
{
|
sl@0
|
552 |
Kern::Printf("RTestResMan::ERegisterClient ThreadDesRead failed with %d", r);
|
sl@0
|
553 |
break;
|
sl@0
|
554 |
}
|
sl@0
|
555 |
for(c = 0; c < MAX_CLIENTS; c++)
|
sl@0
|
556 |
{
|
sl@0
|
557 |
if(clientInfo[c].pName == NULL)
|
sl@0
|
558 |
break;
|
sl@0
|
559 |
if(!clientInfo[c].pName->Compare(aName))
|
sl@0
|
560 |
return KErrAlreadyExists;
|
sl@0
|
561 |
}
|
sl@0
|
562 |
if(c == MAX_CLIENTS)
|
sl@0
|
563 |
return KErrOverflow;
|
sl@0
|
564 |
clientInfo[c].pName = HBuf::New((const TDesC8&)aName);
|
sl@0
|
565 |
if(!clientInfo[c].pName)
|
sl@0
|
566 |
return KErrNoMemory;
|
sl@0
|
567 |
r = PowerResourceManager::RegisterClient(clientInfo[c].iClientId, (const TDesC&)*clientInfo[c].pName, (TOwnerType)(TInt)ptr.iPtr3);
|
sl@0
|
568 |
if(r != KErrNone)
|
sl@0
|
569 |
{
|
sl@0
|
570 |
delete clientInfo[c].pName;
|
sl@0
|
571 |
clientInfo[c].pName = NULL;
|
sl@0
|
572 |
clientInfo[c].iClientId = 0;
|
sl@0
|
573 |
}
|
sl@0
|
574 |
if(r == KErrNone)
|
sl@0
|
575 |
{
|
sl@0
|
576 |
r = Kern::ThreadRawWrite(iClientThreadPtr, ptr.iPtr1, &clientInfo[c].iClientId, sizeof(TUint));
|
sl@0
|
577 |
if(r != KErrNone)
|
sl@0
|
578 |
Kern::Printf("RTestResMan::ERegisterClient ThreadRawWrite failed with %d", r);
|
sl@0
|
579 |
}
|
sl@0
|
580 |
break;
|
sl@0
|
581 |
}
|
sl@0
|
582 |
case RTestResMan::EDeRegisterClient: //Deregister client from RM
|
sl@0
|
583 |
{
|
sl@0
|
584 |
//Cancel all notification pending for this client
|
sl@0
|
585 |
SNotificationList *pL;
|
sl@0
|
586 |
SNotificationList* pN = iCondList;
|
sl@0
|
587 |
while(pN != NULL)
|
sl@0
|
588 |
{
|
sl@0
|
589 |
if(pN->iClientId == (TUint)a1)
|
sl@0
|
590 |
{
|
sl@0
|
591 |
PowerResourceManager::CancelNotification(pN->iClientId, pN->iResourceId, *pN->iNoti);
|
sl@0
|
592 |
pL = pN;
|
sl@0
|
593 |
pN = pN->iNext;
|
sl@0
|
594 |
LIST_REMOVE(iCondList, pL, iNext, SNotificationList);
|
sl@0
|
595 |
delete pL->iNoti;
|
sl@0
|
596 |
delete pL;
|
sl@0
|
597 |
}
|
sl@0
|
598 |
else
|
sl@0
|
599 |
pN = pN->iNext;
|
sl@0
|
600 |
}
|
sl@0
|
601 |
pN = iUnCondList;
|
sl@0
|
602 |
while(pN != NULL)
|
sl@0
|
603 |
{
|
sl@0
|
604 |
if(pN->iClientId == (TUint)a1)
|
sl@0
|
605 |
{
|
sl@0
|
606 |
PowerResourceManager::CancelNotification(pN->iClientId, pN->iResourceId, *pN->iNoti);
|
sl@0
|
607 |
pL = pN;
|
sl@0
|
608 |
pN = pN->iNext;
|
sl@0
|
609 |
LIST_REMOVE(iUnCondList, pL, iNext, SNotificationList);
|
sl@0
|
610 |
delete pL->iNoti;
|
sl@0
|
611 |
delete pL;
|
sl@0
|
612 |
}
|
sl@0
|
613 |
else
|
sl@0
|
614 |
pN = pN->iNext;
|
sl@0
|
615 |
}
|
sl@0
|
616 |
iClientId = -1;
|
sl@0
|
617 |
r = PowerResourceManager::DeRegisterClient((TUint)a1);
|
sl@0
|
618 |
if(r != KErrNone)
|
sl@0
|
619 |
break;
|
sl@0
|
620 |
r = KErrNotFound;
|
sl@0
|
621 |
for(TUint c = 0; c < MAX_CLIENTS; c++)
|
sl@0
|
622 |
{
|
sl@0
|
623 |
if(clientInfo[c].iClientId == (TUint)a1)
|
sl@0
|
624 |
{
|
sl@0
|
625 |
delete clientInfo[c].pName;
|
sl@0
|
626 |
clientInfo[c].pName = 0;
|
sl@0
|
627 |
clientInfo[c].iClientId = 0;
|
sl@0
|
628 |
r = KErrNone;
|
sl@0
|
629 |
break;
|
sl@0
|
630 |
}
|
sl@0
|
631 |
}
|
sl@0
|
632 |
|
sl@0
|
633 |
break;
|
sl@0
|
634 |
}
|
sl@0
|
635 |
case RTestResMan::EGetClientName: //Get Client Name
|
sl@0
|
636 |
{
|
sl@0
|
637 |
TBuf8<32> aName;
|
sl@0
|
638 |
r = PowerResourceManager::GetClientName((TUint)ptr.iClientId, (TUint)ptr.iPtr1, (TDes &)aName);
|
sl@0
|
639 |
if(r== KErrNone)
|
sl@0
|
640 |
{
|
sl@0
|
641 |
r = Kern::ThreadDesWrite(iClientThreadPtr, ptr.iPtr2, (const TDesC8&)aName, 0);
|
sl@0
|
642 |
if(r != KErrNone)
|
sl@0
|
643 |
Kern::Printf("RTestResMan::EGetClientName ThreadDesWrite failed with %d", r);
|
sl@0
|
644 |
}
|
sl@0
|
645 |
break;
|
sl@0
|
646 |
}
|
sl@0
|
647 |
case RTestResMan::EGetClientId: //Get Client Id
|
sl@0
|
648 |
{
|
sl@0
|
649 |
TBuf8<256> aName;
|
sl@0
|
650 |
TUint aClientId;
|
sl@0
|
651 |
r = Kern::ThreadDesRead(iClientThreadPtr, (const TDesC*)ptr.iPtr1, (TDes8&)aName, 0,KChunkShiftBy0);
|
sl@0
|
652 |
if(r != KErrNone)
|
sl@0
|
653 |
{
|
sl@0
|
654 |
Kern::Printf("RTestResMan::EGetClientId ThreadDesRead failed with %d", r);
|
sl@0
|
655 |
break;
|
sl@0
|
656 |
}
|
sl@0
|
657 |
r = PowerResourceManager::GetClientId(ptr.iClientId, (TDesC&)aName, aClientId);
|
sl@0
|
658 |
if(r == KErrNone)
|
sl@0
|
659 |
{
|
sl@0
|
660 |
r = Kern::ThreadRawWrite(iClientThreadPtr, ptr.iPtr2, &aClientId, sizeof(TUint));
|
sl@0
|
661 |
if(r != KErrNone)
|
sl@0
|
662 |
Kern::Printf("RTestResMan::EGetClientId ThreadRawWrite failed with %d", r);
|
sl@0
|
663 |
}
|
sl@0
|
664 |
break;
|
sl@0
|
665 |
}
|
sl@0
|
666 |
case RTestResMan::EGetResourceId: //Get Resource Id
|
sl@0
|
667 |
{
|
sl@0
|
668 |
TBuf8<256> aName;
|
sl@0
|
669 |
TUint aResourceId;
|
sl@0
|
670 |
r = Kern::ThreadDesRead(iClientThreadPtr, (const TDesC*)ptr.iPtr1, (TDes8&)aName, 0,KChunkShiftBy0);
|
sl@0
|
671 |
if(r != KErrNone)
|
sl@0
|
672 |
{
|
sl@0
|
673 |
Kern::Printf("RTestResMan::EGetResourceId ThreadDesRead failed with %d", r);
|
sl@0
|
674 |
break;
|
sl@0
|
675 |
}
|
sl@0
|
676 |
r = PowerResourceManager::GetResourceId(ptr.iClientId, (TDesC&)aName, aResourceId);
|
sl@0
|
677 |
if(r == KErrNone)
|
sl@0
|
678 |
{
|
sl@0
|
679 |
r = Kern::ThreadRawWrite(iClientThreadPtr, ptr.iPtr2, &aResourceId, sizeof(TUint));
|
sl@0
|
680 |
if(r != KErrNone)
|
sl@0
|
681 |
Kern::Printf("RTestResMan::EGetResourceId ThreadRawWrite failed with %d", r);
|
sl@0
|
682 |
}
|
sl@0
|
683 |
break;
|
sl@0
|
684 |
}
|
sl@0
|
685 |
case RTestResMan::EGetResourceInfo: //Get resource information
|
sl@0
|
686 |
{
|
sl@0
|
687 |
NKern::ThreadEnterCS();
|
sl@0
|
688 |
HBuf *info = HBuf::New(sizeof(TPowerResourceInfoV01));
|
sl@0
|
689 |
NKern::ThreadLeaveCS();
|
sl@0
|
690 |
r = PowerResourceManager::GetResourceInfo(ptr.iClientId, (TUint)ptr.iPtr1, (TAny*)info);
|
sl@0
|
691 |
if(r == KErrNone)
|
sl@0
|
692 |
{
|
sl@0
|
693 |
r = Kern::ThreadDesWrite(iClientThreadPtr, ptr.iPtr2, (const TDesC8&)*info, 0);
|
sl@0
|
694 |
if(r != KErrNone)
|
sl@0
|
695 |
Kern::Printf("RTestResMan::EGetResourceInfo ThreadRawWrite failed with %d", r);
|
sl@0
|
696 |
}
|
sl@0
|
697 |
Kern::Free(info);
|
sl@0
|
698 |
break;
|
sl@0
|
699 |
}
|
sl@0
|
700 |
case RTestResMan::EGetNumResourcesInUseByClient:
|
sl@0
|
701 |
{
|
sl@0
|
702 |
TUint numResource;
|
sl@0
|
703 |
r = PowerResourceManager::GetNumResourcesInUseByClient(ptr.iClientId, (TUint)ptr.iPtr1, numResource);
|
sl@0
|
704 |
if(r == KErrNone)
|
sl@0
|
705 |
{
|
sl@0
|
706 |
r = Kern::ThreadRawWrite(iClientThreadPtr, ptr.iPtr2, &numResource, sizeof(TUint));
|
sl@0
|
707 |
if(r != KErrNone)
|
sl@0
|
708 |
Kern::Printf("RTestResMan::EGetNumResourcesInUseByClient ThreadRawWrite failed with %d", r);
|
sl@0
|
709 |
}
|
sl@0
|
710 |
break;
|
sl@0
|
711 |
}
|
sl@0
|
712 |
case RTestResMan::EGetInfoOnResourcesInUseByClient:
|
sl@0
|
713 |
{
|
sl@0
|
714 |
TUint numResource;
|
sl@0
|
715 |
HBuf* info = NULL;
|
sl@0
|
716 |
r = Kern::ThreadRawRead(iClientThreadPtr, ptr.iPtr2, &numResource, sizeof(TUint));
|
sl@0
|
717 |
if(r != KErrNone)
|
sl@0
|
718 |
{
|
sl@0
|
719 |
Kern::Printf("RTestResMan::GetInfoOnResourceInUseByClient ThreadRawRead failed with %d", r);
|
sl@0
|
720 |
break;
|
sl@0
|
721 |
}
|
sl@0
|
722 |
if(ptr.iPtr3 != NULL)
|
sl@0
|
723 |
{
|
sl@0
|
724 |
NKern::ThreadEnterCS();
|
sl@0
|
725 |
info = HBuf::New(numResource * sizeof(TPowerResourceInfoV01));
|
sl@0
|
726 |
NKern::ThreadLeaveCS();
|
sl@0
|
727 |
}
|
sl@0
|
728 |
r = PowerResourceManager::GetInfoOnResourcesInUseByClient(ptr.iClientId, (TUint)ptr.iPtr1, numResource, (TAny*)info);
|
sl@0
|
729 |
if(r == KErrNone)
|
sl@0
|
730 |
{
|
sl@0
|
731 |
r = Kern::ThreadRawWrite(iClientThreadPtr, ptr.iPtr2, &numResource, sizeof(TUint));
|
sl@0
|
732 |
if(r !=KErrNone)
|
sl@0
|
733 |
{
|
sl@0
|
734 |
Kern::Printf("RTestResMan::GetInfoOnResourceInUseByClient ThreadRawWrite failed with %d", r);
|
sl@0
|
735 |
Kern::Free(info);
|
sl@0
|
736 |
break;
|
sl@0
|
737 |
}
|
sl@0
|
738 |
if(ptr.iPtr3)
|
sl@0
|
739 |
r = Kern::ThreadDesWrite(iClientThreadPtr, ptr.iPtr3, (const TDesC8&)*info, 0);
|
sl@0
|
740 |
}
|
sl@0
|
741 |
Kern::Free(info);
|
sl@0
|
742 |
break;
|
sl@0
|
743 |
}
|
sl@0
|
744 |
case RTestResMan::EGetNumClientsUsingResource:
|
sl@0
|
745 |
{
|
sl@0
|
746 |
TUint numClient;
|
sl@0
|
747 |
r = PowerResourceManager::GetNumClientsUsingResource(ptr.iClientId, (TUint)ptr.iPtr1, numClient);
|
sl@0
|
748 |
if(r == KErrNone)
|
sl@0
|
749 |
{
|
sl@0
|
750 |
r = Kern::ThreadRawWrite(iClientThreadPtr, ptr.iPtr2, &numClient, sizeof(TUint));
|
sl@0
|
751 |
if(r != KErrNone)
|
sl@0
|
752 |
Kern::Printf("RTestResMan::EGetNumResourcesInUseByClient ThreadRawWrite failed with %d", r);
|
sl@0
|
753 |
}
|
sl@0
|
754 |
break;
|
sl@0
|
755 |
}
|
sl@0
|
756 |
case RTestResMan::EGetInfoOnClientsUsingResource:
|
sl@0
|
757 |
{
|
sl@0
|
758 |
TUint numClient;
|
sl@0
|
759 |
HBuf* info = NULL;
|
sl@0
|
760 |
r = Kern::ThreadRawRead(iClientThreadPtr, ptr.iPtr2, &numClient, sizeof(TUint));
|
sl@0
|
761 |
if(r != KErrNone)
|
sl@0
|
762 |
{
|
sl@0
|
763 |
Kern::Printf("RTestResMan::GetInfoOnResourceInUseByClient ThreadRawRead failed with %d", r);
|
sl@0
|
764 |
break;
|
sl@0
|
765 |
}
|
sl@0
|
766 |
if(ptr.iPtr3 != NULL)
|
sl@0
|
767 |
{
|
sl@0
|
768 |
NKern::ThreadEnterCS();
|
sl@0
|
769 |
info = HBuf::New(numClient * sizeof(TPowerClientInfoV01));
|
sl@0
|
770 |
NKern::ThreadLeaveCS();
|
sl@0
|
771 |
}
|
sl@0
|
772 |
r = PowerResourceManager::GetInfoOnClientsUsingResource(ptr.iClientId, (TUint)ptr.iPtr1, numClient, (TAny*)info);
|
sl@0
|
773 |
if(r == KErrNone)
|
sl@0
|
774 |
{
|
sl@0
|
775 |
r = Kern::ThreadRawWrite(iClientThreadPtr, ptr.iPtr2, &numClient, sizeof(TUint));
|
sl@0
|
776 |
if(r !=KErrNone)
|
sl@0
|
777 |
{
|
sl@0
|
778 |
Kern::Printf("RTestResMan::GetInfoOnResourceInUseByClient ThreadRawWrite failed with %d", r);
|
sl@0
|
779 |
Kern::Free(info);
|
sl@0
|
780 |
break;
|
sl@0
|
781 |
}
|
sl@0
|
782 |
if(ptr.iPtr3)
|
sl@0
|
783 |
r = Kern::ThreadDesWrite(iClientThreadPtr, ptr.iPtr3, (const TDesC8&)*info, 0);
|
sl@0
|
784 |
}
|
sl@0
|
785 |
Kern::Free(info);
|
sl@0
|
786 |
break;
|
sl@0
|
787 |
}
|
sl@0
|
788 |
case RTestResMan::EAllocReserve:
|
sl@0
|
789 |
{
|
sl@0
|
790 |
r = PowerResourceManager::AllocReserve(ptr.iClientId, (TUint8)(TUint)ptr.iPtr1, (TUint8)(TUint)ptr.iPtr2);
|
sl@0
|
791 |
break;
|
sl@0
|
792 |
}
|
sl@0
|
793 |
case RTestResMan::EChangeResourceStateSync:
|
sl@0
|
794 |
{
|
sl@0
|
795 |
SNotificationList* pN;
|
sl@0
|
796 |
//Zero the conditional notification count for the resource id.
|
sl@0
|
797 |
for(pN=iCondList; pN != NULL; pN=pN->iNext)
|
sl@0
|
798 |
{
|
sl@0
|
799 |
if(pN->iResourceId == (TUint)ptr.iPtr1)
|
sl@0
|
800 |
{
|
sl@0
|
801 |
pN->iCount = 0;
|
sl@0
|
802 |
break;
|
sl@0
|
803 |
}
|
sl@0
|
804 |
}
|
sl@0
|
805 |
//Zero the unconditional notification count for the resource id.
|
sl@0
|
806 |
for(pN=iUnCondList; pN != NULL; pN=pN->iNext)
|
sl@0
|
807 |
{
|
sl@0
|
808 |
if(pN->iResourceId == (TUint)ptr.iPtr1)
|
sl@0
|
809 |
{
|
sl@0
|
810 |
pN->iCount = 0;
|
sl@0
|
811 |
break;
|
sl@0
|
812 |
}
|
sl@0
|
813 |
}
|
sl@0
|
814 |
iClientId = ptr.iClientId;
|
sl@0
|
815 |
iResourceId = (TUint)ptr.iPtr1;
|
sl@0
|
816 |
r = PowerResourceManager::ChangeResourceState(ptr.iClientId, (TUint)ptr.iPtr1, (TInt)ptr.iPtr2);
|
sl@0
|
817 |
break;
|
sl@0
|
818 |
}
|
sl@0
|
819 |
case RTestResMan::EGetResourceStateSync:
|
sl@0
|
820 |
{
|
sl@0
|
821 |
TInt newState, levelOwnerId;
|
sl@0
|
822 |
r = PowerResourceManager::GetResourceState(ptr.iClientId, (TUint)ptr.iPtr1, (TBool)ptr.iPtr2, newState, levelOwnerId);
|
sl@0
|
823 |
if(r == KErrNone)
|
sl@0
|
824 |
{
|
sl@0
|
825 |
r = Kern::ThreadRawWrite(iClientThreadPtr, ptr.iPtr3, (TAny*)&newState, sizeof(TInt));
|
sl@0
|
826 |
if(r != KErrNone)
|
sl@0
|
827 |
{
|
sl@0
|
828 |
Kern::Printf("RTestResMan::GetResourceStateSync ThreadRawWrite failed with %d", r);
|
sl@0
|
829 |
break;
|
sl@0
|
830 |
}
|
sl@0
|
831 |
r = Kern::ThreadRawWrite(iClientThreadPtr, ptr.iPtr4, (TAny*)&levelOwnerId, sizeof(TInt));
|
sl@0
|
832 |
if(r != KErrNone)
|
sl@0
|
833 |
Kern::Printf("RTestResMan::GetResourceStateSync ThreadRawWrite failed with %d", r);
|
sl@0
|
834 |
}
|
sl@0
|
835 |
break;
|
sl@0
|
836 |
}
|
sl@0
|
837 |
case RTestResMan::ERequestNotificationUncond:
|
sl@0
|
838 |
{
|
sl@0
|
839 |
SNotificationList *notiList;
|
sl@0
|
840 |
notiList = new SNotificationList; //Create new notification list
|
sl@0
|
841 |
if(!notiList)
|
sl@0
|
842 |
{
|
sl@0
|
843 |
r = KErrNoMemory;
|
sl@0
|
844 |
break;
|
sl@0
|
845 |
}
|
sl@0
|
846 |
//Create notification object to pass to RM
|
sl@0
|
847 |
notiList->iNoti = new DPowerResourceNotification(UnCondNotificationFunc, this, ((DTestResManLddFactory*)iDevice)->iDfcQ, 3);
|
sl@0
|
848 |
if(!notiList->iNoti)
|
sl@0
|
849 |
{
|
sl@0
|
850 |
delete notiList;
|
sl@0
|
851 |
r = KErrNoMemory;
|
sl@0
|
852 |
break;
|
sl@0
|
853 |
}
|
sl@0
|
854 |
notiList->iClientId = (TUint)a1;
|
sl@0
|
855 |
notiList->iResourceId = (TUint)a2;
|
sl@0
|
856 |
notiList->iCount = 0;
|
sl@0
|
857 |
LIST_PUSH(iUnCondList, notiList, iNext); //Add to unconditional list.
|
sl@0
|
858 |
r = PowerResourceManager::RequestNotification((TUint)a1, (TUint)a2, *notiList->iNoti);
|
sl@0
|
859 |
break;
|
sl@0
|
860 |
}
|
sl@0
|
861 |
case RTestResMan::ERequestNotificationCond:
|
sl@0
|
862 |
{
|
sl@0
|
863 |
SNotificationList *notiList;
|
sl@0
|
864 |
notiList = new SNotificationList; // Create new notification list
|
sl@0
|
865 |
if(!notiList)
|
sl@0
|
866 |
{
|
sl@0
|
867 |
r = KErrNoMemory;
|
sl@0
|
868 |
break;
|
sl@0
|
869 |
}
|
sl@0
|
870 |
//Create notification object to pass to RM
|
sl@0
|
871 |
notiList->iNoti = new DPowerResourceNotification(CondNotificationFunc, this, ((DTestResManLddFactory*)iDevice)->iDfcQ, 3);
|
sl@0
|
872 |
if(!notiList->iNoti)
|
sl@0
|
873 |
{
|
sl@0
|
874 |
delete notiList;
|
sl@0
|
875 |
r = KErrNoMemory;
|
sl@0
|
876 |
break;
|
sl@0
|
877 |
}
|
sl@0
|
878 |
notiList->iClientId = ptr.iClientId;
|
sl@0
|
879 |
notiList->iResourceId = (TUint)ptr.iPtr1;
|
sl@0
|
880 |
notiList->iCount = 0;
|
sl@0
|
881 |
LIST_PUSH(iCondList, notiList, iNext); //Add to conditional list.
|
sl@0
|
882 |
r = PowerResourceManager::RequestNotification((TUint)ptr.iClientId, (TUint)ptr.iPtr1, *notiList->iNoti, (TInt)ptr.iPtr2, (TBool)ptr.iPtr3);
|
sl@0
|
883 |
break;
|
sl@0
|
884 |
}
|
sl@0
|
885 |
case RTestResMan::EDeRegisterClientLevelFromResource:
|
sl@0
|
886 |
{
|
sl@0
|
887 |
r = PowerResourceManager::DeRegisterClientLevelFromResource((TUint)a1, (TUint)a2);
|
sl@0
|
888 |
break;
|
sl@0
|
889 |
}
|
sl@0
|
890 |
case RTestResMan::ECancelNotification:
|
sl@0
|
891 |
{
|
sl@0
|
892 |
r = KErrNotFound;
|
sl@0
|
893 |
if(ptr.iPtr2) //Check for notification in conditional list if it is true.
|
sl@0
|
894 |
{
|
sl@0
|
895 |
for(SNotificationList* pN=iCondList; pN != NULL; pN=pN->iNext)
|
sl@0
|
896 |
{
|
sl@0
|
897 |
if((pN->iClientId == ptr.iClientId) && (pN->iResourceId == (TUint)ptr.iPtr1))
|
sl@0
|
898 |
{
|
sl@0
|
899 |
r = PowerResourceManager::CancelNotification(pN->iClientId, pN->iResourceId, *pN->iNoti);
|
sl@0
|
900 |
LIST_REMOVE(iCondList, pN, iNext, SNotificationList);
|
sl@0
|
901 |
delete pN->iNoti;
|
sl@0
|
902 |
delete pN;
|
sl@0
|
903 |
break;
|
sl@0
|
904 |
}
|
sl@0
|
905 |
}
|
sl@0
|
906 |
}
|
sl@0
|
907 |
else //Check for notification in unconditional list.
|
sl@0
|
908 |
{
|
sl@0
|
909 |
for(SNotificationList* pN=iUnCondList; pN != NULL; pN=pN->iNext)
|
sl@0
|
910 |
{
|
sl@0
|
911 |
if((pN->iClientId == ptr.iClientId) && (pN->iResourceId == (TUint)ptr.iPtr1))
|
sl@0
|
912 |
{
|
sl@0
|
913 |
r = PowerResourceManager::CancelNotification(pN->iClientId, pN->iResourceId, *pN->iNoti);
|
sl@0
|
914 |
LIST_REMOVE(iUnCondList, pN, iNext, SNotificationList);
|
sl@0
|
915 |
delete pN->iNoti;
|
sl@0
|
916 |
delete pN;
|
sl@0
|
917 |
break;
|
sl@0
|
918 |
}
|
sl@0
|
919 |
}
|
sl@0
|
920 |
}
|
sl@0
|
921 |
break;
|
sl@0
|
922 |
}
|
sl@0
|
923 |
case RTestResMan::ECheckNotifications:
|
sl@0
|
924 |
{
|
sl@0
|
925 |
NKern::Sleep(NKern::TimerTicks(300)); //This is required as sometimes check is done before callback is called.
|
sl@0
|
926 |
TUint countCond = 0, countUncond = 0;
|
sl@0
|
927 |
SNotificationList* pN;
|
sl@0
|
928 |
//Get the conditional notification callback functions called for the resource id.
|
sl@0
|
929 |
for(pN=iCondList; pN != NULL; pN=pN->iNext)
|
sl@0
|
930 |
{
|
sl@0
|
931 |
if(pN->iResourceId == (TUint)ptr.iPtr1)
|
sl@0
|
932 |
{
|
sl@0
|
933 |
countCond = pN->iCount;
|
sl@0
|
934 |
pN->iCount = 0;
|
sl@0
|
935 |
break;
|
sl@0
|
936 |
}
|
sl@0
|
937 |
}
|
sl@0
|
938 |
//Get the unconditional notification callback functions called for the resource id.
|
sl@0
|
939 |
for(pN=iUnCondList; pN != NULL; pN=pN->iNext)
|
sl@0
|
940 |
{
|
sl@0
|
941 |
if(pN->iResourceId == (TUint)ptr.iPtr1)
|
sl@0
|
942 |
{
|
sl@0
|
943 |
countUncond = pN->iCount;
|
sl@0
|
944 |
pN->iCount = 0;
|
sl@0
|
945 |
break;
|
sl@0
|
946 |
}
|
sl@0
|
947 |
}
|
sl@0
|
948 |
//If the notifications count is not as expected return error.
|
sl@0
|
949 |
if((countCond != (TUint)ptr.iPtr3) || (countUncond != (TUint)ptr.iPtr2))
|
sl@0
|
950 |
r = KErrUnderflow;
|
sl@0
|
951 |
break;
|
sl@0
|
952 |
}
|
sl@0
|
953 |
case RTestResMan::ERegisterForIdleResourcesInfo:
|
sl@0
|
954 |
{
|
sl@0
|
955 |
if(pBuf)
|
sl@0
|
956 |
{
|
sl@0
|
957 |
r = KErrAlreadyExists;
|
sl@0
|
958 |
break;
|
sl@0
|
959 |
}
|
sl@0
|
960 |
NKern::ThreadEnterCS();
|
sl@0
|
961 |
pBuf = HBuf::New((TUint)ptr.iPtr1 * sizeof(SIdleResourceInfo)); //Allocate buffer for requested resources
|
sl@0
|
962 |
NKern::ThreadLeaveCS();
|
sl@0
|
963 |
if(!pBuf)
|
sl@0
|
964 |
return KErrNoMemory;
|
sl@0
|
965 |
r = Kern::ThreadRawRead(iClientThreadPtr, ptr.iPtr2, (TAny*)pBuf->Ptr(), (TUint)ptr.iPtr1 * sizeof(SIdleResourceInfo));
|
sl@0
|
966 |
if(r != KErrNone)
|
sl@0
|
967 |
{
|
sl@0
|
968 |
Kern::Printf("RTestResMan::ERegisterForIdleResourceInfo threadRawRead failed with %d\n", r);
|
sl@0
|
969 |
break;
|
sl@0
|
970 |
}
|
sl@0
|
971 |
//Below function calls RegisterForResourceIdle resource controller virtual function,
|
sl@0
|
972 |
//This is for testing purposes only.
|
sl@0
|
973 |
|
sl@0
|
974 |
r =DSimulatedPowerResourceController::CaptureIdleResourcesInfo((TUint)ptr.iClientId, (TUint)ptr.iPtr1, (TPtr*)pBuf);
|
sl@0
|
975 |
if( r == KErrInUse)
|
sl@0
|
976 |
delete pBuf;
|
sl@0
|
977 |
break;
|
sl@0
|
978 |
}
|
sl@0
|
979 |
case RTestResMan::EGetIdleResourcesInfo:
|
sl@0
|
980 |
{
|
sl@0
|
981 |
//Pass the buffer for comparision
|
sl@0
|
982 |
if(!pBuf)
|
sl@0
|
983 |
{
|
sl@0
|
984 |
r = KErrNotFound;
|
sl@0
|
985 |
break;
|
sl@0
|
986 |
}
|
sl@0
|
987 |
pBuf->SetLength(sizeof(SIdleResourceInfo) * (TUint)a1);
|
sl@0
|
988 |
r = Kern::ThreadDesWrite(iClientThreadPtr, a2, (const TDesC8&)*pBuf, 0);
|
sl@0
|
989 |
break;
|
sl@0
|
990 |
}
|
sl@0
|
991 |
case RTestResMan::ECheckPostBootLevelNotifications:
|
sl@0
|
992 |
{
|
sl@0
|
993 |
if(DTestResManLddFactory::iPostBootNotiCount != EXPECTED_POST_NOTI_COUNT)
|
sl@0
|
994 |
{
|
sl@0
|
995 |
r = KErrUnderflow;
|
sl@0
|
996 |
break;
|
sl@0
|
997 |
}
|
sl@0
|
998 |
r = KErrNone;
|
sl@0
|
999 |
break;
|
sl@0
|
1000 |
}
|
sl@0
|
1001 |
case RTestResMan::EGetControllerVersion:
|
sl@0
|
1002 |
{
|
sl@0
|
1003 |
TUint Version;
|
sl@0
|
1004 |
r = PowerResourceManager::GetResourceControllerVersion((TUint)a1, Version);
|
sl@0
|
1005 |
if(r == KErrNone)
|
sl@0
|
1006 |
{
|
sl@0
|
1007 |
r = Kern::ThreadRawWrite(iClientThreadPtr, a2, &Version, sizeof(TUint));
|
sl@0
|
1008 |
if(r != KErrNone)
|
sl@0
|
1009 |
Kern::Printf("RTestResMan::EGetControllerVersion ThreadRawWrite failed with %d", r);
|
sl@0
|
1010 |
}
|
sl@0
|
1011 |
break;
|
sl@0
|
1012 |
}
|
sl@0
|
1013 |
#ifdef PRM_ENABLE_EXTENDED_VERSION
|
sl@0
|
1014 |
case RTestResMan::ERegisterDynamicResource:
|
sl@0
|
1015 |
{
|
sl@0
|
1016 |
TUint resId;
|
sl@0
|
1017 |
r = Kern::ThreadRawRead(iClientThreadPtr, a2, (TAny*)&resId, sizeof(TUint));
|
sl@0
|
1018 |
if(r != KErrNone)
|
sl@0
|
1019 |
{
|
sl@0
|
1020 |
Kern::Printf("RTestResMan::RegisterDynamicResource ThreadRawRead failed with %d", r);
|
sl@0
|
1021 |
break;
|
sl@0
|
1022 |
}
|
sl@0
|
1023 |
DDynamicPowerResource* pDR = NULL;
|
sl@0
|
1024 |
switch(resId) //Create the dynamic resource
|
sl@0
|
1025 |
{
|
sl@0
|
1026 |
case 1:
|
sl@0
|
1027 |
pDR = new (DBIGISSPDynamicResource);
|
sl@0
|
1028 |
break;
|
sl@0
|
1029 |
case 2:
|
sl@0
|
1030 |
pDR = new (DMLIGLSSHNDynamicResource);
|
sl@0
|
1031 |
break;
|
sl@0
|
1032 |
case 3:
|
sl@0
|
1033 |
pDR = new (DBLGLSSHNDynamicResource);
|
sl@0
|
1034 |
break;
|
sl@0
|
1035 |
case 4:
|
sl@0
|
1036 |
pDR = new (DMLLGLSSHPDynamicResource);
|
sl@0
|
1037 |
break;
|
sl@0
|
1038 |
case 5:
|
sl@0
|
1039 |
pDR = (DDynamicPowerResource*) new (DDynamicResourceD01);
|
sl@0
|
1040 |
break;
|
sl@0
|
1041 |
case 6:
|
sl@0
|
1042 |
pDR = (DDynamicPowerResource*) new (DDynamicResourceD02);
|
sl@0
|
1043 |
break;
|
sl@0
|
1044 |
case 7:
|
sl@0
|
1045 |
pDR = (DDynamicPowerResource*) new (DDynamicResourceD03);
|
sl@0
|
1046 |
break;
|
sl@0
|
1047 |
case 8:
|
sl@0
|
1048 |
pDR = (DDynamicPowerResource*) new (DDynamicResourceD04);
|
sl@0
|
1049 |
break;
|
sl@0
|
1050 |
}
|
sl@0
|
1051 |
if(!pDR)
|
sl@0
|
1052 |
return KErrNoMemory;
|
sl@0
|
1053 |
iDynamicArray.Append(pDR);
|
sl@0
|
1054 |
r = PowerResourceManager::RegisterDynamicResource((TUint)a1, pDR, resId);
|
sl@0
|
1055 |
if(r == KErrNone)
|
sl@0
|
1056 |
{
|
sl@0
|
1057 |
r = Kern::ThreadRawWrite(iClientThreadPtr, a2, (TAny*)&resId, sizeof(TUint));
|
sl@0
|
1058 |
if(r != KErrNone)
|
sl@0
|
1059 |
Kern::Printf("RTestResMan::RegisterDynamicResource ThreadRawWrite failed with %d", r);
|
sl@0
|
1060 |
}
|
sl@0
|
1061 |
break;
|
sl@0
|
1062 |
}
|
sl@0
|
1063 |
case RTestResMan::EDeRegisterDynamicResource: //Deregister dynamic resource
|
sl@0
|
1064 |
{
|
sl@0
|
1065 |
if(ptr.iPtr2)
|
sl@0
|
1066 |
{
|
sl@0
|
1067 |
TInt level;
|
sl@0
|
1068 |
r = Kern::ThreadRawRead(iClientThreadPtr, ptr.iPtr2, &level, sizeof(TInt));
|
sl@0
|
1069 |
if(r != KErrNone)
|
sl@0
|
1070 |
{
|
sl@0
|
1071 |
Kern::Printf("RTestResMan::DeRegisterDynamicResource ThreadRawRead failed with %d", r);
|
sl@0
|
1072 |
break;
|
sl@0
|
1073 |
}
|
sl@0
|
1074 |
r = PowerResourceManager::DeRegisterDynamicResource(ptr.iClientId, (TUint)ptr.iPtr1, &level);
|
sl@0
|
1075 |
}
|
sl@0
|
1076 |
else
|
sl@0
|
1077 |
r = PowerResourceManager::DeRegisterDynamicResource(ptr.iClientId, (TUint)ptr.iPtr1, NULL);
|
sl@0
|
1078 |
break;
|
sl@0
|
1079 |
}
|
sl@0
|
1080 |
case RTestResMan::ERegisterResourceDependency: //Register resource dependency
|
sl@0
|
1081 |
{
|
sl@0
|
1082 |
SResourceDependencyInfo info1, info2;
|
sl@0
|
1083 |
r = Kern::ThreadRawRead(iClientThreadPtr, ptr.iPtr1, &info1, sizeof(SResourceDependencyInfo));
|
sl@0
|
1084 |
if(r != KErrNone)
|
sl@0
|
1085 |
{
|
sl@0
|
1086 |
Kern::Printf("RTestResMan::RegisterResourceDependency ThreadRawRead failed with %d", r);
|
sl@0
|
1087 |
break;
|
sl@0
|
1088 |
}
|
sl@0
|
1089 |
r = Kern::ThreadRawRead(iClientThreadPtr, ptr.iPtr2, &info2, sizeof(SResourceDependencyInfo));
|
sl@0
|
1090 |
if(r != KErrNone)
|
sl@0
|
1091 |
{
|
sl@0
|
1092 |
Kern::Printf("RTestResMan::RegisterResourceDependency ThreadRawRead failed with %d", r);
|
sl@0
|
1093 |
break;
|
sl@0
|
1094 |
}
|
sl@0
|
1095 |
r = PowerResourceManager::RegisterResourceDependency(ptr.iClientId, &info1, &info2);
|
sl@0
|
1096 |
break;
|
sl@0
|
1097 |
}
|
sl@0
|
1098 |
case RTestResMan::EDeRegisterResourceDependency: //Deregister resource dependency
|
sl@0
|
1099 |
{
|
sl@0
|
1100 |
r = PowerResourceManager::DeRegisterResourceDependency(ptr.iClientId, (TUint)ptr.iPtr1, (TUint)ptr.iPtr2);
|
sl@0
|
1101 |
break;
|
sl@0
|
1102 |
}
|
sl@0
|
1103 |
case RTestResMan::EGetNumDependentsForResource:
|
sl@0
|
1104 |
{
|
sl@0
|
1105 |
TUint numDepResources;
|
sl@0
|
1106 |
r = PowerResourceManager::GetNumDependentsForResource(ptr.iClientId, (TUint)ptr.iPtr1, numDepResources);
|
sl@0
|
1107 |
if(r == KErrNone)
|
sl@0
|
1108 |
{
|
sl@0
|
1109 |
r = Kern::ThreadRawWrite(iClientThreadPtr, ptr.iPtr2, (TAny*)&numDepResources, sizeof(TUint));
|
sl@0
|
1110 |
if(r != KErrNone)
|
sl@0
|
1111 |
Kern::Printf("RTestResMan::RegisterDynamicResource ThreadRawWrite failed with %d", r);
|
sl@0
|
1112 |
}
|
sl@0
|
1113 |
break;
|
sl@0
|
1114 |
}
|
sl@0
|
1115 |
case RTestResMan::EGetDependentsIdForResource:
|
sl@0
|
1116 |
{
|
sl@0
|
1117 |
TUint numDepResources;
|
sl@0
|
1118 |
HBuf* sResDepInfo = NULL;
|
sl@0
|
1119 |
r = Kern::ThreadRawRead(iClientThreadPtr, ptr.iPtr3, (TAny*)&numDepResources, sizeof(TUint));
|
sl@0
|
1120 |
if(r != KErrNone)
|
sl@0
|
1121 |
{
|
sl@0
|
1122 |
Kern::Printf("RTestResMan::GetDependentsIdForResource ThreadRawRead failed with %d", r);
|
sl@0
|
1123 |
break;
|
sl@0
|
1124 |
}
|
sl@0
|
1125 |
if(ptr.iPtr2 != NULL)
|
sl@0
|
1126 |
{
|
sl@0
|
1127 |
NKern::ThreadEnterCS();
|
sl@0
|
1128 |
sResDepInfo = HBuf::New(numDepResources * sizeof(SResourceDependencyInfo));
|
sl@0
|
1129 |
NKern::ThreadLeaveCS();
|
sl@0
|
1130 |
if(!sResDepInfo)
|
sl@0
|
1131 |
return KErrNoMemory;
|
sl@0
|
1132 |
}
|
sl@0
|
1133 |
|
sl@0
|
1134 |
r = PowerResourceManager::GetDependentsIdForResource(ptr.iClientId, (TUint)ptr.iPtr1, (TAny*)sResDepInfo, numDepResources);
|
sl@0
|
1135 |
if(r == KErrNone)
|
sl@0
|
1136 |
{
|
sl@0
|
1137 |
if(ptr.iPtr2)
|
sl@0
|
1138 |
r = Kern::ThreadDesWrite(iClientThreadPtr, ptr.iPtr2, (const TDesC8&)*sResDepInfo, 0);
|
sl@0
|
1139 |
if(r != KErrNone)
|
sl@0
|
1140 |
{
|
sl@0
|
1141 |
Kern::Printf("RTestResMan::GetDepedentsIdForResource ThreadDesWrite failed with %d", r);
|
sl@0
|
1142 |
Kern::Free(sResDepInfo);
|
sl@0
|
1143 |
break;
|
sl@0
|
1144 |
}
|
sl@0
|
1145 |
r = Kern::ThreadRawWrite(iClientThreadPtr, ptr.iPtr3, (TAny*)&numDepResources, sizeof(TUint));
|
sl@0
|
1146 |
if(r != KErrNone)
|
sl@0
|
1147 |
{
|
sl@0
|
1148 |
Kern::Printf("RTestResMan::GetDependentsIdForResource ThreadRawWrite failed with %d", r);
|
sl@0
|
1149 |
Kern::Free(sResDepInfo);
|
sl@0
|
1150 |
break;
|
sl@0
|
1151 |
}
|
sl@0
|
1152 |
}
|
sl@0
|
1153 |
Kern::Free(sResDepInfo);
|
sl@0
|
1154 |
break;
|
sl@0
|
1155 |
}
|
sl@0
|
1156 |
|
sl@0
|
1157 |
#endif
|
sl@0
|
1158 |
default:
|
sl@0
|
1159 |
r = KErrNotSupported;
|
sl@0
|
1160 |
break;
|
sl@0
|
1161 |
}
|
sl@0
|
1162 |
return r;
|
sl@0
|
1163 |
}
|
sl@0
|
1164 |
|
sl@0
|
1165 |
TInt DTestResManLdd::DoRequest(TInt aReqNo, TRequestStatus* aStatus, TAny* a1, TAny* /*a2*/)
|
sl@0
|
1166 |
{
|
sl@0
|
1167 |
TInt r = KErrNone;
|
sl@0
|
1168 |
TParameterListInfo ptr;
|
sl@0
|
1169 |
r = Kern::ThreadRawRead(iClientThreadPtr, (TParameterListInfo*)a1, &ptr, sizeof(TParameterListInfo));
|
sl@0
|
1170 |
if(r != KErrNone)
|
sl@0
|
1171 |
Kern::RequestComplete(iClientThreadPtr, aStatus, r);
|
sl@0
|
1172 |
switch(aReqNo)
|
sl@0
|
1173 |
{
|
sl@0
|
1174 |
case RTestResMan::EChangeResourceStateAsync:
|
sl@0
|
1175 |
#ifdef PRM_ENABLE_EXTENDED_VERSION
|
sl@0
|
1176 |
case RTestResMan::EChangeResStateAndDeregisterDynamicRes:
|
sl@0
|
1177 |
case RTestResMan::ECheckParallelExecutionForChangeResState:
|
sl@0
|
1178 |
#endif
|
sl@0
|
1179 |
SNotificationList* pN;
|
sl@0
|
1180 |
//Zero the conditional notification count for the resource id.
|
sl@0
|
1181 |
for(pN=iCondList; pN != NULL; pN=pN->iNext)
|
sl@0
|
1182 |
{
|
sl@0
|
1183 |
if(pN->iResourceId == (TUint)ptr.iPtr1)
|
sl@0
|
1184 |
{
|
sl@0
|
1185 |
pN->iCount = 0;
|
sl@0
|
1186 |
break;
|
sl@0
|
1187 |
}
|
sl@0
|
1188 |
}
|
sl@0
|
1189 |
//Zero the unconditional notification count for the resource id.
|
sl@0
|
1190 |
for(pN=iUnCondList; pN != NULL; pN=pN->iNext)
|
sl@0
|
1191 |
{
|
sl@0
|
1192 |
if(pN->iResourceId == (TUint)ptr.iPtr1)
|
sl@0
|
1193 |
{
|
sl@0
|
1194 |
pN->iCount = 0;
|
sl@0
|
1195 |
break;
|
sl@0
|
1196 |
}
|
sl@0
|
1197 |
}
|
sl@0
|
1198 |
iLevelOwnerIdPtr = NULL;
|
sl@0
|
1199 |
iStatePtr = (TInt*)ptr.iPtr2;
|
sl@0
|
1200 |
TInt state;
|
sl@0
|
1201 |
r = Kern::ThreadRawRead(iClientThreadPtr, iStatePtr, &state, sizeof(TInt));
|
sl@0
|
1202 |
if(r != KErrNone)
|
sl@0
|
1203 |
Kern::RequestComplete(iClientThreadPtr, aStatus, r);
|
sl@0
|
1204 |
iStatus = aStatus;
|
sl@0
|
1205 |
iClientId = ptr.iClientId;
|
sl@0
|
1206 |
iResourceId = (TUint)ptr.iPtr1;
|
sl@0
|
1207 |
iCallbackCancel = EFalse;
|
sl@0
|
1208 |
r = PowerResourceManager::ChangeResourceState(ptr.iClientId, (TUint)ptr.iPtr1, state, &iAsyncResourceCallback);
|
sl@0
|
1209 |
#ifdef PRM_ENABLE_EXTENDED_VERSION
|
sl@0
|
1210 |
if(aReqNo == RTestResMan::EChangeResStateAndDeregisterDynamicRes) //Try to delete the dynamic while resource change
|
sl@0
|
1211 |
{
|
sl@0
|
1212 |
r = PowerResourceManager::DeRegisterDynamicResource(ptr.iClientId, (TUint)ptr.iPtr1, NULL);
|
sl@0
|
1213 |
if(r == KErrInUse) //Wait for the request to complete
|
sl@0
|
1214 |
r = KErrNone;
|
sl@0
|
1215 |
break;
|
sl@0
|
1216 |
}
|
sl@0
|
1217 |
if(aReqNo == RTestResMan::ECheckParallelExecutionForChangeResState)
|
sl@0
|
1218 |
{
|
sl@0
|
1219 |
r = PowerResourceManager::ChangeResourceState(ptr.iClientId, (TUint)ptr.iPtr3, (TInt)ptr.iPtr4, &iAsyncTestParallelCallback);
|
sl@0
|
1220 |
iTestParallelResourceId = (TUint)ptr.iPtr3;
|
sl@0
|
1221 |
iValidateCallbackReceived = ETrue;
|
sl@0
|
1222 |
break;
|
sl@0
|
1223 |
}
|
sl@0
|
1224 |
#endif
|
sl@0
|
1225 |
if(ptr.iPtr3) //Cancel the asynchronous operation if true.
|
sl@0
|
1226 |
{
|
sl@0
|
1227 |
r = PowerResourceManager::CancelAsyncRequestCallBack(ptr.iClientId, (TUint)ptr.iPtr1, iAsyncResourceCallback);
|
sl@0
|
1228 |
if(r == KErrInUse) //Wait for the request to complete
|
sl@0
|
1229 |
r = KErrNone;
|
sl@0
|
1230 |
else
|
sl@0
|
1231 |
iCallbackCancel = ETrue;
|
sl@0
|
1232 |
}
|
sl@0
|
1233 |
break;
|
sl@0
|
1234 |
case RTestResMan::EGetResourceStateAsync:
|
sl@0
|
1235 |
iStatus = aStatus;
|
sl@0
|
1236 |
iCallbackCancel = EFalse;
|
sl@0
|
1237 |
iClientId = ptr.iClientId;
|
sl@0
|
1238 |
iResourceId = (TUint)ptr.iPtr1;
|
sl@0
|
1239 |
iStatePtr = (TInt*)ptr.iPtr4;
|
sl@0
|
1240 |
iLevelOwnerIdPtr = (TInt*)ptr.iPtr5;
|
sl@0
|
1241 |
r = PowerResourceManager::GetResourceState(ptr.iClientId, (TUint)ptr.iPtr1, (TBool)ptr.iPtr2, iAsyncResourceCallback);
|
sl@0
|
1242 |
if(ptr.iPtr3) //Cancel the asynchronous operation if true.
|
sl@0
|
1243 |
{
|
sl@0
|
1244 |
r = PowerResourceManager::CancelAsyncRequestCallBack(ptr.iClientId, (TUint)ptr.iPtr1, iAsyncResourceCallback);
|
sl@0
|
1245 |
if(r == KErrInUse)
|
sl@0
|
1246 |
r = KErrNone;
|
sl@0
|
1247 |
else
|
sl@0
|
1248 |
iCallbackCancel = ETrue;
|
sl@0
|
1249 |
}
|
sl@0
|
1250 |
break;
|
sl@0
|
1251 |
}
|
sl@0
|
1252 |
return r;
|
sl@0
|
1253 |
}
|
sl@0
|
1254 |
|
sl@0
|
1255 |
//Function called on Asynchronous operation
|
sl@0
|
1256 |
void DTestResManLdd::CallbackFunc(TUint aClientId, TUint aResId, TInt aLevel, TInt aLevelOwnerId, TInt aResult, TAny* aParam)
|
sl@0
|
1257 |
{
|
sl@0
|
1258 |
TInt r;
|
sl@0
|
1259 |
DTestResManLdd *pC = (DTestResManLdd*)aParam;
|
sl@0
|
1260 |
//Check for correctnes of clientId and resourceId
|
sl@0
|
1261 |
if((TUint)pC->iClientId != aClientId || pC->iResourceId != aResId)
|
sl@0
|
1262 |
Kern::RequestComplete(pC->iClientThreadPtr, pC->iStatus, KErrCorrupt);
|
sl@0
|
1263 |
if(!pC->iCallbackCancel)
|
sl@0
|
1264 |
{
|
sl@0
|
1265 |
if(pC->iStatePtr)
|
sl@0
|
1266 |
{
|
sl@0
|
1267 |
r = Kern::ThreadRawWrite(pC->iClientThreadPtr, pC->iStatePtr, (TAny*)&aLevel, sizeof(TInt));
|
sl@0
|
1268 |
if(r != KErrNone)
|
sl@0
|
1269 |
Kern::Printf("RTestResManLdd::CallbackFunc ThreadRawWrite failed with %d", r);
|
sl@0
|
1270 |
}
|
sl@0
|
1271 |
if(pC->iLevelOwnerIdPtr)
|
sl@0
|
1272 |
{
|
sl@0
|
1273 |
r = Kern::ThreadRawWrite(pC->iClientThreadPtr, pC->iLevelOwnerIdPtr, (TAny*)&aLevelOwnerId, sizeof(TInt));
|
sl@0
|
1274 |
if(r != KErrNone)
|
sl@0
|
1275 |
Kern::Printf("RTestResManLdd::CallbackFunc ThreadRawWrite failed with %d", r);
|
sl@0
|
1276 |
}
|
sl@0
|
1277 |
#ifdef PRM_ENABLE_EXTENDED_VERSION
|
sl@0
|
1278 |
if(pC->iValidateCallbackReceived)
|
sl@0
|
1279 |
{
|
sl@0
|
1280 |
if(!pC->iCallbackReceived)
|
sl@0
|
1281 |
aResult = KErrCompletion;
|
sl@0
|
1282 |
}
|
sl@0
|
1283 |
#endif
|
sl@0
|
1284 |
Kern::RequestComplete(pC->iClientThreadPtr, pC->iStatus, aResult);
|
sl@0
|
1285 |
}
|
sl@0
|
1286 |
pC->iCallbackCancel = EFalse;
|
sl@0
|
1287 |
pC->iStatus = NULL;
|
sl@0
|
1288 |
}
|
sl@0
|
1289 |
|
sl@0
|
1290 |
#ifdef PRM_ENABLE_EXTENDED_VERSION
|
sl@0
|
1291 |
//Function called on completion of asynchronous long latency resource, used only to check parallel execution of DFC's
|
sl@0
|
1292 |
void DTestResManLdd::TestParallelExecutionCallback(TUint aClientId, TUint aResId, TInt /*aLevel*/, TInt /*aLevelOwnerId*/, TInt /*aResult*/, TAny* aParam)
|
sl@0
|
1293 |
{
|
sl@0
|
1294 |
Kern::Printf("DTestResManLdd::TestParallelExecutionCallback:: called");
|
sl@0
|
1295 |
DTestResManLdd *pC = (DTestResManLdd*)aParam;
|
sl@0
|
1296 |
//Check for correctness of clientId and resourceId
|
sl@0
|
1297 |
if((TUint)pC->iClientId == aClientId && pC->iTestParallelResourceId == aResId)
|
sl@0
|
1298 |
{
|
sl@0
|
1299 |
pC->iCallbackReceived = ETrue;
|
sl@0
|
1300 |
}
|
sl@0
|
1301 |
}
|
sl@0
|
1302 |
#endif
|
sl@0
|
1303 |
|
sl@0
|
1304 |
//Function called on Conditional notification
|
sl@0
|
1305 |
void DTestResManLdd::CondNotificationFunc(TUint /*aClientId*/, TUint aResId, TInt /*aLevel*/, TInt /*aLevelOwnerId*/, TInt /*aResult*/, TAny* aParam)
|
sl@0
|
1306 |
{
|
sl@0
|
1307 |
DTestResManLdd *pC = (DTestResManLdd*)aParam;
|
sl@0
|
1308 |
for(SNotificationList *pN = pC->iCondList; pN!= NULL; pN=pN->iNext)
|
sl@0
|
1309 |
{
|
sl@0
|
1310 |
if((pN->iResourceId == aResId))
|
sl@0
|
1311 |
{
|
sl@0
|
1312 |
pN->iCount++; //Increment the count, as same callback function for all conditioanl notifications.
|
sl@0
|
1313 |
break;
|
sl@0
|
1314 |
}
|
sl@0
|
1315 |
}
|
sl@0
|
1316 |
}
|
sl@0
|
1317 |
|
sl@0
|
1318 |
//Function called on UnConditional notification
|
sl@0
|
1319 |
void DTestResManLdd::UnCondNotificationFunc(TUint /*aClientId*/, TUint aResId, TInt /*aLevel*/, TInt /*aLevelOwnerId*/, TInt /*aResult*/, TAny* aParam)
|
sl@0
|
1320 |
{
|
sl@0
|
1321 |
DTestResManLdd *pC = (DTestResManLdd*)aParam;
|
sl@0
|
1322 |
for(SNotificationList *pN = pC->iUnCondList; pN!= NULL; pN=pN->iNext)
|
sl@0
|
1323 |
{
|
sl@0
|
1324 |
if((pN->iResourceId == aResId) && (pC->iCallbackCancel == EFalse))
|
sl@0
|
1325 |
{
|
sl@0
|
1326 |
pN->iCount++; //Increment the count as same callback function for all unconditioanl notifications.
|
sl@0
|
1327 |
break;
|
sl@0
|
1328 |
}
|
sl@0
|
1329 |
}
|
sl@0
|
1330 |
}
|
sl@0
|
1331 |
|
sl@0
|
1332 |
//Function called on postbootvalueset.
|
sl@0
|
1333 |
void DTestResManLddFactory::PostBootNotificationFunc(TUint /*aClientId*/, TUint aResId, TInt /*aLevel*/, TInt /*aLevelOwnerId*/, TInt /*aResult*/, TAny* aParam)
|
sl@0
|
1334 |
{
|
sl@0
|
1335 |
iPostBootNotiCount++;
|
sl@0
|
1336 |
DPowerResourceNotification *ptr = (DPowerResourceNotification*)aParam;
|
sl@0
|
1337 |
TInt r = PowerResourceManager::CancelNotification(iClient.iClientId, aResId, *ptr);
|
sl@0
|
1338 |
if(r == KErrNone)
|
sl@0
|
1339 |
delete ptr;
|
sl@0
|
1340 |
}
|