sl@0
|
1 |
// Copyright (c) 2005-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\demandpaging\d_pagestrss.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <kernel/kern_priv.h>
|
sl@0
|
19 |
#include <kernel/cache.h>
|
sl@0
|
20 |
#include "d_pagestress.h"
|
sl@0
|
21 |
|
sl@0
|
22 |
//
|
sl@0
|
23 |
// Class definitions
|
sl@0
|
24 |
//
|
sl@0
|
25 |
|
sl@0
|
26 |
class DPageStressTestFactory : public DLogicalDevice
|
sl@0
|
27 |
{
|
sl@0
|
28 |
public:
|
sl@0
|
29 |
~DPageStressTestFactory();
|
sl@0
|
30 |
virtual TInt Install();
|
sl@0
|
31 |
virtual void GetCaps(TDes8& aDes) const;
|
sl@0
|
32 |
virtual TInt Create(DLogicalChannelBase*& aChannel);
|
sl@0
|
33 |
};
|
sl@0
|
34 |
|
sl@0
|
35 |
class DPageStressTestChannel : public DLogicalChannelBase
|
sl@0
|
36 |
{
|
sl@0
|
37 |
public:
|
sl@0
|
38 |
DPageStressTestChannel();
|
sl@0
|
39 |
~DPageStressTestChannel();
|
sl@0
|
40 |
virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
|
sl@0
|
41 |
virtual TInt Request(TInt aFunction, TAny* a1, TAny* a2);
|
sl@0
|
42 |
|
sl@0
|
43 |
TInt DoConsumeRamSetup(TInt aNumPagesLeft, TInt aPagesInBlock);
|
sl@0
|
44 |
TInt DoConsumeRamFinish(void);
|
sl@0
|
45 |
TInt DoConsumeSomeRam(TInt aBlocks);
|
sl@0
|
46 |
TInt DoReleaseSomeRam(TInt aBlocks);
|
sl@0
|
47 |
TInt FreeRam();
|
sl@0
|
48 |
TInt DoSetDebugFlag(TInt aState);
|
sl@0
|
49 |
public:
|
sl@0
|
50 |
DPageStressTestFactory* iFactory;
|
sl@0
|
51 |
|
sl@0
|
52 |
private:
|
sl@0
|
53 |
TBool iRamAllocd;
|
sl@0
|
54 |
TInt iInitialFreeRam;
|
sl@0
|
55 |
TInt iTotalBlocks;
|
sl@0
|
56 |
TInt iBlockSize;
|
sl@0
|
57 |
TInt iLastBlockAllocd;
|
sl@0
|
58 |
TPhysAddr* iAddrArray;
|
sl@0
|
59 |
TInt iDebug;
|
sl@0
|
60 |
DMutex* iMutex;
|
sl@0
|
61 |
TInt iThreadCounter;
|
sl@0
|
62 |
TPhysAddr iAddrMin;
|
sl@0
|
63 |
TPhysAddr iAddrMax;
|
sl@0
|
64 |
TBool iDemandPaging;
|
sl@0
|
65 |
};
|
sl@0
|
66 |
|
sl@0
|
67 |
//
|
sl@0
|
68 |
// DPageStressTestFactory
|
sl@0
|
69 |
//
|
sl@0
|
70 |
|
sl@0
|
71 |
TInt DPageStressTestFactory::Install()
|
sl@0
|
72 |
{
|
sl@0
|
73 |
return SetName(&KPageStressTestLddName);
|
sl@0
|
74 |
}
|
sl@0
|
75 |
|
sl@0
|
76 |
DPageStressTestFactory::~DPageStressTestFactory()
|
sl@0
|
77 |
{
|
sl@0
|
78 |
}
|
sl@0
|
79 |
|
sl@0
|
80 |
void DPageStressTestFactory::GetCaps(TDes8& /*aDes*/) const
|
sl@0
|
81 |
{
|
sl@0
|
82 |
// Not used but required as DLogicalDevice::GetCaps is pure virtual
|
sl@0
|
83 |
}
|
sl@0
|
84 |
|
sl@0
|
85 |
TInt DPageStressTestFactory::Create(DLogicalChannelBase*& aChannel)
|
sl@0
|
86 |
{
|
sl@0
|
87 |
aChannel = NULL;
|
sl@0
|
88 |
DPageStressTestChannel* channel=new DPageStressTestChannel;
|
sl@0
|
89 |
if(!channel)
|
sl@0
|
90 |
return KErrNoMemory;
|
sl@0
|
91 |
channel->iFactory = this;
|
sl@0
|
92 |
aChannel = channel;
|
sl@0
|
93 |
return KErrNone;
|
sl@0
|
94 |
}
|
sl@0
|
95 |
|
sl@0
|
96 |
DECLARE_STANDARD_LDD()
|
sl@0
|
97 |
{
|
sl@0
|
98 |
return new DPageStressTestFactory;
|
sl@0
|
99 |
}
|
sl@0
|
100 |
|
sl@0
|
101 |
//
|
sl@0
|
102 |
// DPageStressTestChannel
|
sl@0
|
103 |
//
|
sl@0
|
104 |
|
sl@0
|
105 |
TInt DPageStressTestChannel::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/)
|
sl@0
|
106 |
{
|
sl@0
|
107 |
return KErrNone;
|
sl@0
|
108 |
}
|
sl@0
|
109 |
|
sl@0
|
110 |
DPageStressTestChannel::DPageStressTestChannel()
|
sl@0
|
111 |
: iRamAllocd(EFalse), iInitialFreeRam(0), iTotalBlocks(0), iBlockSize(0), iLastBlockAllocd(0),
|
sl@0
|
112 |
iAddrArray(NULL), iDebug(0), iThreadCounter(1), iAddrMin(0), iAddrMax(0), iDemandPaging(ETrue)
|
sl@0
|
113 |
{
|
sl@0
|
114 |
_LIT(KMutexName,"TPageStressMutex");
|
sl@0
|
115 |
NKern::ThreadEnterCS();
|
sl@0
|
116 |
Kern::MutexCreate(iMutex, KMutexName,KMutexOrdNone);
|
sl@0
|
117 |
NKern::ThreadLeaveCS();
|
sl@0
|
118 |
SVMCacheInfo tempPages;
|
sl@0
|
119 |
if (Kern::HalFunction(EHalGroupVM,EVMHalGetCacheSize,&tempPages,0) != KErrNone)
|
sl@0
|
120 |
{
|
sl@0
|
121 |
iDemandPaging = EFalse;
|
sl@0
|
122 |
}
|
sl@0
|
123 |
}
|
sl@0
|
124 |
|
sl@0
|
125 |
DPageStressTestChannel::~DPageStressTestChannel()
|
sl@0
|
126 |
{
|
sl@0
|
127 |
if (iRamAllocd)
|
sl@0
|
128 |
{
|
sl@0
|
129 |
DoConsumeRamFinish();
|
sl@0
|
130 |
}
|
sl@0
|
131 |
if (iMutex)
|
sl@0
|
132 |
{
|
sl@0
|
133 |
iMutex->Close(NULL);
|
sl@0
|
134 |
iMutex = NULL;
|
sl@0
|
135 |
}
|
sl@0
|
136 |
}
|
sl@0
|
137 |
|
sl@0
|
138 |
TInt DPageStressTestChannel::Request(TInt aFunction, TAny* a1, TAny* a2)
|
sl@0
|
139 |
{
|
sl@0
|
140 |
TInt threadCount = __e32_atomic_tas_ord32(&iThreadCounter, 1, 1, 0);
|
sl@0
|
141 |
if (threadCount >= 2)
|
sl@0
|
142 |
{
|
sl@0
|
143 |
Kern::Printf("DPageStressTestChannel::Request threadCount = %d\n", threadCount);
|
sl@0
|
144 |
}
|
sl@0
|
145 |
NKern::ThreadEnterCS();
|
sl@0
|
146 |
Kern::MutexWait(*iMutex);
|
sl@0
|
147 |
TInt retVal = KErrNotSupported;
|
sl@0
|
148 |
switch(aFunction)
|
sl@0
|
149 |
{
|
sl@0
|
150 |
case RPageStressTestLdd::EDoConsumeRamSetup:
|
sl@0
|
151 |
{
|
sl@0
|
152 |
retVal = DPageStressTestChannel::DoConsumeRamSetup((TInt)a1, (TInt)a2);
|
sl@0
|
153 |
}
|
sl@0
|
154 |
break;
|
sl@0
|
155 |
|
sl@0
|
156 |
case RPageStressTestLdd::EDoConsumeRamFinish:
|
sl@0
|
157 |
{
|
sl@0
|
158 |
retVal = DPageStressTestChannel::DoConsumeRamFinish();
|
sl@0
|
159 |
}
|
sl@0
|
160 |
break;
|
sl@0
|
161 |
|
sl@0
|
162 |
case RPageStressTestLdd::EDoConsumeSomeRam:
|
sl@0
|
163 |
{
|
sl@0
|
164 |
retVal = DPageStressTestChannel::DoConsumeSomeRam((TInt)a1);
|
sl@0
|
165 |
}
|
sl@0
|
166 |
break;
|
sl@0
|
167 |
|
sl@0
|
168 |
case RPageStressTestLdd::EDoReleaseSomeRam:
|
sl@0
|
169 |
{
|
sl@0
|
170 |
retVal = DPageStressTestChannel::DoReleaseSomeRam((TInt)a1);
|
sl@0
|
171 |
}
|
sl@0
|
172 |
break;
|
sl@0
|
173 |
|
sl@0
|
174 |
case RPageStressTestLdd::EDoSetDebugFlag:
|
sl@0
|
175 |
{
|
sl@0
|
176 |
retVal = DoSetDebugFlag((TInt) a1);
|
sl@0
|
177 |
}
|
sl@0
|
178 |
break;
|
sl@0
|
179 |
|
sl@0
|
180 |
default: break;
|
sl@0
|
181 |
}
|
sl@0
|
182 |
Kern::MutexSignal(*iMutex);
|
sl@0
|
183 |
NKern::ThreadLeaveCS();
|
sl@0
|
184 |
__e32_atomic_tas_ord32(&iThreadCounter, 1, -1, 0);
|
sl@0
|
185 |
return retVal;
|
sl@0
|
186 |
}
|
sl@0
|
187 |
|
sl@0
|
188 |
//
|
sl@0
|
189 |
// DPageStressTestChannel::DoConsumeRamSetup
|
sl@0
|
190 |
//
|
sl@0
|
191 |
// This test attempts to consume most of the available Contiguous Ram until we need to ask the
|
sl@0
|
192 |
// demand paging code to release memory for it.
|
sl@0
|
193 |
//
|
sl@0
|
194 |
//
|
sl@0
|
195 |
//
|
sl@0
|
196 |
#define CHECK(c) { if(!(c)) { Kern::Printf("Fail %d", __LINE__); ; retVal = __LINE__;} }
|
sl@0
|
197 |
|
sl@0
|
198 |
TInt DPageStressTestChannel::DoConsumeRamSetup(TInt aNumPagesLeft, TInt aPagesInBlock)
|
sl@0
|
199 |
{
|
sl@0
|
200 |
if (iRamAllocd)
|
sl@0
|
201 |
{
|
sl@0
|
202 |
Kern::Printf("DPageStressTestChannel trying to start again when RAM alloc'd\n");
|
sl@0
|
203 |
DoConsumeRamFinish();
|
sl@0
|
204 |
}
|
sl@0
|
205 |
|
sl@0
|
206 |
TInt retVal = KErrNone;
|
sl@0
|
207 |
|
sl@0
|
208 |
TInt pageSize = 0;
|
sl@0
|
209 |
CHECK(Kern::HalFunction(EHalGroupKernel,EKernelHalPageSizeInBytes,&pageSize,0)==KErrNone);
|
sl@0
|
210 |
|
sl@0
|
211 |
iBlockSize = aPagesInBlock * pageSize;
|
sl@0
|
212 |
iInitialFreeRam = FreeRam();
|
sl@0
|
213 |
iTotalBlocks = (iInitialFreeRam/iBlockSize) + 10;
|
sl@0
|
214 |
|
sl@0
|
215 |
iAddrArray = (TPhysAddr *)Kern::AllocZ(sizeof(TPhysAddr) * iTotalBlocks);
|
sl@0
|
216 |
|
sl@0
|
217 |
CHECK(iAddrArray);
|
sl@0
|
218 |
if(!iAddrArray)
|
sl@0
|
219 |
{
|
sl@0
|
220 |
return KErrNoMemory;
|
sl@0
|
221 |
}
|
sl@0
|
222 |
|
sl@0
|
223 |
SVMCacheInfo tempPages;
|
sl@0
|
224 |
|
sl@0
|
225 |
iRamAllocd = ETrue;
|
sl@0
|
226 |
|
sl@0
|
227 |
// get the initial free ram again as the heap may have grabbed a page during the alloc
|
sl@0
|
228 |
iInitialFreeRam = FreeRam();
|
sl@0
|
229 |
|
sl@0
|
230 |
|
sl@0
|
231 |
if (iDemandPaging)
|
sl@0
|
232 |
{
|
sl@0
|
233 |
CHECK(Kern::HalFunction(EHalGroupVM,EVMHalGetCacheSize,&tempPages,0) == KErrNone);
|
sl@0
|
234 |
if (iDebug)
|
sl@0
|
235 |
{
|
sl@0
|
236 |
Kern::Printf("Start : min %d max %d current %d maxFree %d freeRam %d",
|
sl@0
|
237 |
tempPages.iMinSize, tempPages.iMaxSize, tempPages.iCurrentSize ,tempPages.iMaxFreeSize, FreeRam());
|
sl@0
|
238 |
}
|
sl@0
|
239 |
}
|
sl@0
|
240 |
// allocate blocks to use up RAM until we fail to allocate any further...
|
sl@0
|
241 |
TInt index;
|
sl@0
|
242 |
// only alloc upto the point where we have a number of pages left.
|
sl@0
|
243 |
iLastBlockAllocd = iTotalBlocks - (aNumPagesLeft / aPagesInBlock);
|
sl@0
|
244 |
for (index = 0; index < iLastBlockAllocd; index ++)
|
sl@0
|
245 |
{
|
sl@0
|
246 |
if (iDemandPaging)
|
sl@0
|
247 |
{
|
sl@0
|
248 |
CHECK(Kern::HalFunction(EHalGroupVM,EVMHalGetCacheSize,&tempPages,0) == KErrNone);
|
sl@0
|
249 |
}
|
sl@0
|
250 |
|
sl@0
|
251 |
if (KErrNone != Epoc::AllocPhysicalRam(iBlockSize, iAddrArray[index], 0))
|
sl@0
|
252 |
{
|
sl@0
|
253 |
iAddrArray[index] = NULL;
|
sl@0
|
254 |
break;
|
sl@0
|
255 |
}
|
sl@0
|
256 |
|
sl@0
|
257 |
if ((iAddrMin == 0) || (iAddrMin > iAddrArray[index]))
|
sl@0
|
258 |
{
|
sl@0
|
259 |
iAddrMin = iAddrArray[index];
|
sl@0
|
260 |
}
|
sl@0
|
261 |
|
sl@0
|
262 |
if (iAddrMax < iAddrArray[index])
|
sl@0
|
263 |
{
|
sl@0
|
264 |
iAddrMax = iAddrArray[index];
|
sl@0
|
265 |
}
|
sl@0
|
266 |
|
sl@0
|
267 |
if (iDemandPaging)
|
sl@0
|
268 |
{
|
sl@0
|
269 |
CHECK(Kern::HalFunction(EHalGroupVM,EVMHalGetCacheSize,&tempPages,0) == KErrNone);
|
sl@0
|
270 |
}
|
sl@0
|
271 |
}
|
sl@0
|
272 |
iLastBlockAllocd = index - 1;
|
sl@0
|
273 |
|
sl@0
|
274 |
if (iDemandPaging)
|
sl@0
|
275 |
{
|
sl@0
|
276 |
CHECK(Kern::HalFunction(EHalGroupVM,EVMHalGetCacheSize,&tempPages,0) == KErrNone);
|
sl@0
|
277 |
if (iDebug)
|
sl@0
|
278 |
{
|
sl@0
|
279 |
Kern::Printf("Alloc'd : min %d max %d current %d maxFree %d freeRam %d lastIndex %d addrMin 0x%08x addrMax 0x%08x",
|
sl@0
|
280 |
tempPages.iMinSize, tempPages.iMaxSize, tempPages.iCurrentSize ,tempPages.iMaxFreeSize, FreeRam(), iLastBlockAllocd, iAddrMin, iAddrMax);
|
sl@0
|
281 |
}
|
sl@0
|
282 |
}
|
sl@0
|
283 |
return retVal;
|
sl@0
|
284 |
}
|
sl@0
|
285 |
|
sl@0
|
286 |
TInt DPageStressTestChannel::DoConsumeRamFinish(void)
|
sl@0
|
287 |
{
|
sl@0
|
288 |
TInt retVal = KErrNone;
|
sl@0
|
289 |
if (iRamAllocd)
|
sl@0
|
290 |
{
|
sl@0
|
291 |
SVMCacheInfo tempPages;
|
sl@0
|
292 |
|
sl@0
|
293 |
if (iDemandPaging)
|
sl@0
|
294 |
{
|
sl@0
|
295 |
CHECK(Kern::HalFunction(EHalGroupVM,EVMHalGetCacheSize,&tempPages,0) == KErrNone);
|
sl@0
|
296 |
if (iDebug)
|
sl@0
|
297 |
{
|
sl@0
|
298 |
Kern::Printf("Cleanup cache info: iMinSize %d iMaxSize %d iCurrentSize %d iMaxFreeSize %d",
|
sl@0
|
299 |
tempPages.iMinSize, tempPages.iMaxSize, tempPages.iCurrentSize ,tempPages.iMaxFreeSize);
|
sl@0
|
300 |
}
|
sl@0
|
301 |
}
|
sl@0
|
302 |
TInt index = iTotalBlocks - 1;
|
sl@0
|
303 |
|
sl@0
|
304 |
TBool firstTime = ETrue;
|
sl@0
|
305 |
|
sl@0
|
306 |
// free the memory we allocated...
|
sl@0
|
307 |
while(index >= 0)
|
sl@0
|
308 |
{
|
sl@0
|
309 |
if (iAddrArray[index])
|
sl@0
|
310 |
{
|
sl@0
|
311 |
if ((iAddrArray[index] < iAddrMin) || (iAddrArray[index] > iAddrMax))
|
sl@0
|
312 |
{
|
sl@0
|
313 |
Kern::Printf("ERROR: DoConsumeRamFinish : index %d addr 0x%08x min 0x%08x max 0x%08x\n : firstTime %d iLastBlockAllocd %d iTotalBlock %d", index, iAddrArray[index], iAddrMin, iAddrMax, firstTime, iLastBlockAllocd, iTotalBlocks);
|
sl@0
|
314 |
TInt tempIndex = index - 8;
|
sl@0
|
315 |
while (tempIndex < (index + 8))
|
sl@0
|
316 |
{
|
sl@0
|
317 |
Kern::Printf(" --> index %d addr 0x%08x", tempIndex, iAddrArray[tempIndex]);
|
sl@0
|
318 |
tempIndex ++;
|
sl@0
|
319 |
}
|
sl@0
|
320 |
|
sl@0
|
321 |
iAddrArray[index] = NULL;
|
sl@0
|
322 |
}
|
sl@0
|
323 |
else
|
sl@0
|
324 |
{
|
sl@0
|
325 |
TInt r = Epoc::FreePhysicalRam(iAddrArray[index], iBlockSize);
|
sl@0
|
326 |
iAddrArray[index] = NULL;
|
sl@0
|
327 |
CHECK(r==KErrNone);
|
sl@0
|
328 |
}
|
sl@0
|
329 |
}
|
sl@0
|
330 |
|
sl@0
|
331 |
firstTime = EFalse;
|
sl@0
|
332 |
--index;
|
sl@0
|
333 |
}
|
sl@0
|
334 |
|
sl@0
|
335 |
if (iDebug)
|
sl@0
|
336 |
{
|
sl@0
|
337 |
Kern::Printf("DoConsumeRamFinish : FreeRam Initial 0x%x now 0x%x",iInitialFreeRam, FreeRam());
|
sl@0
|
338 |
}
|
sl@0
|
339 |
//CHECK(FreeRam() == iInitialFreeRam)
|
sl@0
|
340 |
if (FreeRam() != iInitialFreeRam)
|
sl@0
|
341 |
{
|
sl@0
|
342 |
Kern::Printf("DoConsumeRamFinish : FreeRam Initial 0x%x now 0x%x NOT EQUAL!",iInitialFreeRam, FreeRam());
|
sl@0
|
343 |
}
|
sl@0
|
344 |
|
sl@0
|
345 |
Kern::Free(iAddrArray);
|
sl@0
|
346 |
iAddrArray = NULL;
|
sl@0
|
347 |
iAddrMin = 0;
|
sl@0
|
348 |
iAddrMax = 0;
|
sl@0
|
349 |
iLastBlockAllocd = -1;
|
sl@0
|
350 |
iTotalBlocks = 0;
|
sl@0
|
351 |
iRamAllocd = EFalse;
|
sl@0
|
352 |
|
sl@0
|
353 |
if (iDemandPaging)
|
sl@0
|
354 |
{
|
sl@0
|
355 |
CHECK(Kern::HalFunction(EHalGroupVM,EVMHalGetCacheSize,&tempPages,0) == KErrNone);
|
sl@0
|
356 |
if (iDebug)
|
sl@0
|
357 |
{
|
sl@0
|
358 |
Kern::Printf("End cache info: iMinSize %d iMaxSize %d iCurrentSize %d iMaxFreeSize %d",
|
sl@0
|
359 |
tempPages.iMinSize, tempPages.iMaxSize, tempPages.iCurrentSize ,tempPages.iMaxFreeSize);
|
sl@0
|
360 |
}
|
sl@0
|
361 |
}
|
sl@0
|
362 |
}
|
sl@0
|
363 |
return retVal;
|
sl@0
|
364 |
}
|
sl@0
|
365 |
|
sl@0
|
366 |
TInt DPageStressTestChannel::DoConsumeSomeRam(TInt aBlocks)
|
sl@0
|
367 |
{
|
sl@0
|
368 |
TInt retVal = KErrNone;
|
sl@0
|
369 |
|
sl@0
|
370 |
return retVal;
|
sl@0
|
371 |
}
|
sl@0
|
372 |
|
sl@0
|
373 |
TInt DPageStressTestChannel::DoReleaseSomeRam(TInt aBlocks)
|
sl@0
|
374 |
{
|
sl@0
|
375 |
if(iLastBlockAllocd<0)
|
sl@0
|
376 |
return KErrUnderflow;
|
sl@0
|
377 |
|
sl@0
|
378 |
TInt retVal = KErrNone;
|
sl@0
|
379 |
if (iRamAllocd)
|
sl@0
|
380 |
{
|
sl@0
|
381 |
SVMCacheInfo tempPages;
|
sl@0
|
382 |
|
sl@0
|
383 |
if (iDemandPaging)
|
sl@0
|
384 |
{
|
sl@0
|
385 |
CHECK(Kern::HalFunction(EHalGroupVM,EVMHalGetCacheSize,&tempPages,0) == KErrNone);
|
sl@0
|
386 |
if (iDebug)
|
sl@0
|
387 |
{
|
sl@0
|
388 |
Kern::Printf("Release : min %d max %d current %d maxFree %d freeRam %d lastIndex %d",
|
sl@0
|
389 |
tempPages.iMinSize, tempPages.iMaxSize, tempPages.iCurrentSize ,tempPages.iMaxFreeSize, FreeRam(), iLastBlockAllocd);
|
sl@0
|
390 |
}
|
sl@0
|
391 |
}
|
sl@0
|
392 |
|
sl@0
|
393 |
TInt index = iLastBlockAllocd;
|
sl@0
|
394 |
iLastBlockAllocd -= aBlocks;
|
sl@0
|
395 |
|
sl@0
|
396 |
TBool firstTime = ETrue;
|
sl@0
|
397 |
|
sl@0
|
398 |
// free the memory we allocated...
|
sl@0
|
399 |
while((index >= 0) && (index > iLastBlockAllocd))
|
sl@0
|
400 |
{
|
sl@0
|
401 |
if (iAddrArray[index])
|
sl@0
|
402 |
{
|
sl@0
|
403 |
//Kern::Printf("DoReleaseSomeRam : index %d addr 0x%08x size %d", index, iAddrArray[index], iBlockSize);
|
sl@0
|
404 |
if ((iAddrArray[index] < iAddrMin) || (iAddrArray[index] > iAddrMax))
|
sl@0
|
405 |
{
|
sl@0
|
406 |
Kern::Printf("ERROR: DoReleaseSomeRam : index %d addr 0x%08x min 0x%08x max 0x%08x\n : firstTime %d iLastBlockAllocd %d iTotalBlock %d", index, iAddrArray[index], iAddrMin, iAddrMax, firstTime, iLastBlockAllocd + aBlocks, iTotalBlocks);
|
sl@0
|
407 |
TInt tempIndex = index - 8;
|
sl@0
|
408 |
while (tempIndex < (index + 8))
|
sl@0
|
409 |
{
|
sl@0
|
410 |
Kern::Printf(" --> index %d addr 0x%08x", tempIndex, iAddrArray[tempIndex]);
|
sl@0
|
411 |
tempIndex ++;
|
sl@0
|
412 |
}
|
sl@0
|
413 |
|
sl@0
|
414 |
iAddrArray[index] = NULL;
|
sl@0
|
415 |
}
|
sl@0
|
416 |
else
|
sl@0
|
417 |
{
|
sl@0
|
418 |
TInt r = Epoc::FreePhysicalRam(iAddrArray[index], iBlockSize);
|
sl@0
|
419 |
iAddrArray[index] = NULL;
|
sl@0
|
420 |
CHECK(r==KErrNone);
|
sl@0
|
421 |
}
|
sl@0
|
422 |
}
|
sl@0
|
423 |
else
|
sl@0
|
424 |
{
|
sl@0
|
425 |
Kern::Printf("ERROR: DoReleaseSomeRam : trying to free NULL index %d", index, iAddrArray[index], iAddrMin, iAddrMax);
|
sl@0
|
426 |
TInt tempIndex = index - 8;
|
sl@0
|
427 |
while (tempIndex < (index + 8))
|
sl@0
|
428 |
{
|
sl@0
|
429 |
Kern::Printf(" --> index %d addr 0x%08x", tempIndex, iAddrArray[tempIndex]);
|
sl@0
|
430 |
tempIndex ++;
|
sl@0
|
431 |
}
|
sl@0
|
432 |
|
sl@0
|
433 |
}
|
sl@0
|
434 |
firstTime = EFalse;
|
sl@0
|
435 |
--index;
|
sl@0
|
436 |
}
|
sl@0
|
437 |
if (index <= 0)
|
sl@0
|
438 |
{
|
sl@0
|
439 |
Kern::Printf("WARNING : DoReleaseSomeRam : index %d !!!!!", index);
|
sl@0
|
440 |
}
|
sl@0
|
441 |
|
sl@0
|
442 |
if (iDemandPaging)
|
sl@0
|
443 |
{
|
sl@0
|
444 |
CHECK(Kern::HalFunction(EHalGroupVM,EVMHalGetCacheSize,&tempPages,0) == KErrNone);
|
sl@0
|
445 |
if (iDebug)
|
sl@0
|
446 |
{
|
sl@0
|
447 |
Kern::Printf("Released : min %d max %d current %d maxFree %d freeRam %d lastIndex %d",
|
sl@0
|
448 |
tempPages.iMinSize, tempPages.iMaxSize, tempPages.iCurrentSize ,tempPages.iMaxFreeSize, FreeRam(), iLastBlockAllocd);
|
sl@0
|
449 |
}
|
sl@0
|
450 |
}
|
sl@0
|
451 |
}
|
sl@0
|
452 |
return retVal;
|
sl@0
|
453 |
}
|
sl@0
|
454 |
|
sl@0
|
455 |
|
sl@0
|
456 |
TInt DPageStressTestChannel::FreeRam()
|
sl@0
|
457 |
{
|
sl@0
|
458 |
return Kern::FreeRamInBytes();
|
sl@0
|
459 |
}
|
sl@0
|
460 |
|
sl@0
|
461 |
TInt DPageStressTestChannel::DoSetDebugFlag(TInt aState)
|
sl@0
|
462 |
{
|
sl@0
|
463 |
iDebug = aState;
|
sl@0
|
464 |
return KErrNone;
|
sl@0
|
465 |
}
|