|
1 // Copyright (c) 2004-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\mmu\d_memorytest.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 #include <kernel/kern_priv.h> |
|
19 #include <kernel/cache.h> |
|
20 #include "d_memorytest.h" |
|
21 |
|
22 // |
|
23 // Class definitions |
|
24 // |
|
25 |
|
26 class DMemoryTestFactory : public DLogicalDevice |
|
27 { |
|
28 public: |
|
29 ~DMemoryTestFactory(); |
|
30 virtual TInt Install(); |
|
31 virtual void GetCaps(TDes8& aDes) const; |
|
32 virtual TInt Create(DLogicalChannelBase*& aChannel); |
|
33 }; |
|
34 |
|
35 class DMemoryTestChannel : public DLogicalChannelBase |
|
36 { |
|
37 public: |
|
38 DMemoryTestChannel(); |
|
39 ~DMemoryTestChannel(); |
|
40 virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer); |
|
41 virtual TInt Request(TInt aFunction, TAny* a1, TAny* a2); |
|
42 private: |
|
43 TInt TestAllocZerosMemory(); |
|
44 TInt TestReAllocZerosMemory(); |
|
45 TInt AllocTest1(); |
|
46 TInt ReAllocTest1(); |
|
47 TInt ReAllocTest2(TUint8*& mem1, TUint8*& mem2, TUint8*& mem3); |
|
48 TInt AllocPhysTest(TUint32 aIters, TUint32 aSize); |
|
49 TInt AllocPhysTest1(TUint32 aIters, TUint32 aSize); |
|
50 public: |
|
51 DMemoryTestFactory* iFactory; |
|
52 TVirtualPinObject* iVirtualPinObject; |
|
53 |
|
54 struct{ |
|
55 TPhysicalPinObject* iObject; |
|
56 TPhysAddr iPhysAddr; |
|
57 TPhysAddr iPhysPageList[UCPageCount]; |
|
58 TUint iColour; |
|
59 TUint32 iActualMapAttr; |
|
60 }iPhysicalPinning; |
|
61 TUint32 iPageSize; |
|
62 }; |
|
63 |
|
64 // |
|
65 // DMemoryTestFactory |
|
66 // |
|
67 |
|
68 TInt DMemoryTestFactory::Install() |
|
69 { |
|
70 return SetName(&KMemoryTestLddName); |
|
71 } |
|
72 |
|
73 DMemoryTestFactory::~DMemoryTestFactory() |
|
74 { |
|
75 } |
|
76 |
|
77 void DMemoryTestFactory::GetCaps(TDes8& /*aDes*/) const |
|
78 { |
|
79 // Not used but required as DLogicalDevice::GetCaps is pure virtual |
|
80 } |
|
81 |
|
82 TInt DMemoryTestFactory::Create(DLogicalChannelBase*& aChannel) |
|
83 { |
|
84 aChannel = NULL; |
|
85 DMemoryTestChannel* channel=new DMemoryTestChannel; |
|
86 if(!channel) |
|
87 return KErrNoMemory; |
|
88 channel->iFactory = this; |
|
89 aChannel = channel; |
|
90 return KErrNone; |
|
91 } |
|
92 |
|
93 DECLARE_STANDARD_LDD() |
|
94 { |
|
95 return new DMemoryTestFactory; |
|
96 } |
|
97 |
|
98 // |
|
99 // DMemoryTestChannel |
|
100 // |
|
101 |
|
102 TInt DMemoryTestChannel::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/) |
|
103 { |
|
104 return KErrNone; |
|
105 } |
|
106 |
|
107 DMemoryTestChannel::DMemoryTestChannel() |
|
108 { |
|
109 iPageSize = Kern::RoundToPageSize(1); |
|
110 } |
|
111 |
|
112 DMemoryTestChannel::~DMemoryTestChannel() |
|
113 { |
|
114 Kern::DestroyVirtualPinObject(iVirtualPinObject); |
|
115 } |
|
116 |
|
117 |
|
118 TInt DMemoryTestChannel::Request(TInt aFunction, TAny* a1, TAny* a2) |
|
119 { |
|
120 TInt r=KErrNotSupported; |
|
121 |
|
122 switch(aFunction) |
|
123 { |
|
124 case RMemoryTestLdd::EReadWriteMemory: |
|
125 case RMemoryTestLdd::EReadMemory: |
|
126 case RMemoryTestLdd::EWriteMemory: |
|
127 { |
|
128 TUint32 value=(TUint32)a2; |
|
129 #ifdef _DEBUG |
|
130 TInt debugMask = Kern::CurrentThread().iDebugMask; |
|
131 Kern::CurrentThread().iDebugMask = debugMask&~(1<<KPANIC); |
|
132 #endif |
|
133 XTRAP(r, XT_DEFAULT, |
|
134 if(aFunction==RMemoryTestLdd::EReadWriteMemory) |
|
135 { |
|
136 kumemget32(&value,a1,4); |
|
137 kumemput32(a1,&value,4); |
|
138 } |
|
139 else if(aFunction==RMemoryTestLdd::EReadMemory) |
|
140 kumemget32(&value,a1,4); |
|
141 else if(aFunction==RMemoryTestLdd::EWriteMemory) |
|
142 kumemput32(a1,&value,4); |
|
143 ); |
|
144 #ifdef _DEBUG |
|
145 Kern::CurrentThread().iDebugMask = debugMask; |
|
146 #endif |
|
147 if(aFunction==RMemoryTestLdd::EReadMemory) |
|
148 kumemput32(a2,&value,sizeof(value)); |
|
149 |
|
150 return r; |
|
151 } |
|
152 |
|
153 case RMemoryTestLdd::ETestAllocZerosMemory: |
|
154 case RMemoryTestLdd::ETestReAllocZerosMemory: |
|
155 { |
|
156 NKern::ThreadEnterCS(); |
|
157 TInt r; |
|
158 if (aFunction==RMemoryTestLdd::ETestAllocZerosMemory) |
|
159 r=TestAllocZerosMemory(); |
|
160 else |
|
161 r=TestReAllocZerosMemory(); |
|
162 NKern::ThreadLeaveCS(); |
|
163 return r; |
|
164 } |
|
165 |
|
166 case RMemoryTestLdd::ETestAllocPhysTest: |
|
167 { |
|
168 NKern::ThreadEnterCS(); |
|
169 r=AllocPhysTest((TUint32)a1,(TUint32)a2); |
|
170 NKern::ThreadLeaveCS(); |
|
171 return r; |
|
172 } |
|
173 |
|
174 case RMemoryTestLdd::ETestAllocPhysTest1: |
|
175 { |
|
176 NKern::ThreadEnterCS(); |
|
177 r=AllocPhysTest1((TUint32)a1,(TUint32)a2); |
|
178 NKern::ThreadLeaveCS(); |
|
179 return r; |
|
180 } |
|
181 |
|
182 case RMemoryTestLdd::ECreateVirtualPinObject: |
|
183 { |
|
184 NKern::ThreadEnterCS(); |
|
185 r=Kern::CreateVirtualPinObject(iVirtualPinObject); |
|
186 NKern::ThreadLeaveCS(); |
|
187 return r; |
|
188 } |
|
189 |
|
190 case RMemoryTestLdd::EPinVirtualMemory: |
|
191 return Kern::PinVirtualMemory(iVirtualPinObject, (TLinAddr)a1, (TUint)a2); |
|
192 |
|
193 case RMemoryTestLdd::EUnpinVirtualMemory: |
|
194 Kern::UnpinVirtualMemory(iVirtualPinObject); |
|
195 return KErrNone; |
|
196 |
|
197 case RMemoryTestLdd::EDestroyVirtualPinObject: |
|
198 { |
|
199 NKern::ThreadEnterCS(); |
|
200 Kern::DestroyVirtualPinObject(iVirtualPinObject); |
|
201 NKern::ThreadLeaveCS(); |
|
202 return KErrNone; |
|
203 } |
|
204 |
|
205 case RMemoryTestLdd::ESetPanicTrace: |
|
206 { |
|
207 TBool old = false; |
|
208 #ifdef _DEBUG |
|
209 DThread& thread = Kern::CurrentThread(); |
|
210 TInt debugMask = thread.iDebugMask; |
|
211 if(debugMask&(1<<KPANIC)) |
|
212 old = true; |
|
213 if(a1) |
|
214 debugMask |= (1<<KPANIC); |
|
215 else |
|
216 debugMask &= ~(1<<KPANIC); |
|
217 thread.iDebugMask = debugMask; |
|
218 #endif |
|
219 return old; |
|
220 } |
|
221 |
|
222 case RMemoryTestLdd::EIsMemoryPresent: |
|
223 #ifndef __WINS__ |
|
224 return Epoc::LinearToPhysical((TLinAddr)a1) != KPhysAddrInvalid; |
|
225 #else |
|
226 Kern::PanicCurrentThread(_L("IsMemoryPresent should not be used on the emulator"), KErrNotSupported); |
|
227 return KErrNotSupported; |
|
228 #endif |
|
229 |
|
230 case RMemoryTestLdd::ECreatePhysicalPinObject: |
|
231 { |
|
232 NKern::ThreadEnterCS(); |
|
233 r=Kern::CreatePhysicalPinObject(iPhysicalPinning.iObject); |
|
234 NKern::ThreadLeaveCS(); |
|
235 return r; |
|
236 } |
|
237 |
|
238 case RMemoryTestLdd::EPinPhysicalMemory: |
|
239 return Kern::PinPhysicalMemory(iPhysicalPinning.iObject, (TLinAddr)a1, (TUint)a2, EFalse, iPhysicalPinning.iPhysAddr, |
|
240 iPhysicalPinning.iPhysPageList, iPhysicalPinning.iActualMapAttr, iPhysicalPinning.iColour, NULL); |
|
241 |
|
242 case RMemoryTestLdd::EPinPhysicalMemoryRO: |
|
243 return Kern::PinPhysicalMemory(iPhysicalPinning.iObject, (TLinAddr)a1, (TUint)a2, ETrue, iPhysicalPinning.iPhysAddr, |
|
244 iPhysicalPinning.iPhysPageList, iPhysicalPinning.iActualMapAttr, iPhysicalPinning.iColour, NULL); |
|
245 |
|
246 case RMemoryTestLdd::ECheckPageList: |
|
247 { |
|
248 #ifdef __WINS__ |
|
249 return KErrNotSupported; |
|
250 #else |
|
251 TInt i; |
|
252 for (i=0;i<UCPageCount; i++) |
|
253 { |
|
254 TPhysAddr addr = Epoc::LinearToPhysical((TLinAddr)a1 + i*iPageSize); |
|
255 if (addr==KPhysAddrInvalid) return KErrGeneral; |
|
256 if (addr!=iPhysicalPinning.iPhysPageList[i]) return KErrNotFound; |
|
257 } |
|
258 return KErrNone; |
|
259 #endif |
|
260 } |
|
261 |
|
262 case RMemoryTestLdd::ESyncPinnedPhysicalMemory: |
|
263 return Cache::SyncPhysicalMemoryBeforeDmaWrite(iPhysicalPinning.iPhysPageList, |
|
264 iPhysicalPinning.iColour, (TUint)a1, (TUint)a2, iPhysicalPinning.iActualMapAttr); |
|
265 |
|
266 case RMemoryTestLdd::EMovePinnedPhysicalMemory: |
|
267 { |
|
268 #ifdef __WINS__ |
|
269 return KErrNotSupported; |
|
270 #else |
|
271 TPhysAddr newPage; |
|
272 NKern::ThreadEnterCS(); |
|
273 r = Epoc::MovePhysicalPage(iPhysicalPinning.iPhysPageList[(TUint)a1], newPage); |
|
274 NKern::ThreadLeaveCS(); |
|
275 return r; |
|
276 #endif |
|
277 } |
|
278 |
|
279 case RMemoryTestLdd::EInvalidatePinnedPhysicalMemory: |
|
280 { |
|
281 r = Cache::SyncPhysicalMemoryBeforeDmaRead(iPhysicalPinning.iPhysPageList, |
|
282 iPhysicalPinning.iColour, (TUint)a1, (TUint)a2, iPhysicalPinning.iActualMapAttr); |
|
283 if (r==KErrNone) |
|
284 r = Cache::SyncPhysicalMemoryAfterDmaRead(iPhysicalPinning.iPhysPageList, |
|
285 iPhysicalPinning.iColour, (TUint)a1, (TUint)a2, iPhysicalPinning.iActualMapAttr); |
|
286 return r; |
|
287 } |
|
288 |
|
289 case RMemoryTestLdd::EUnpinPhysicalMemory: |
|
290 return Kern::UnpinPhysicalMemory(iPhysicalPinning.iObject); |
|
291 |
|
292 case RMemoryTestLdd::EDestroyPhysicalPinObject: |
|
293 { |
|
294 NKern::ThreadEnterCS(); |
|
295 r=Kern::DestroyPhysicalPinObject(iPhysicalPinning.iObject); |
|
296 NKern::ThreadLeaveCS(); |
|
297 return r; |
|
298 } |
|
299 |
|
300 case RMemoryTestLdd::EPinKernelPhysicalMemory: |
|
301 { |
|
302 TPhysicalPinObject* pinObject; |
|
303 TPhysAddr aAddress; |
|
304 TPhysAddr aPages[2]; |
|
305 TUint aColour=0; |
|
306 TUint32 actualMemAttr; |
|
307 NKern::ThreadEnterCS(); |
|
308 Kern::CreatePhysicalPinObject(pinObject); |
|
309 r = Kern::PinPhysicalMemory(pinObject, (TLinAddr)&aAddress, 4, EFalse, aAddress, aPages, actualMemAttr, aColour, NULL); |
|
310 Cache::SyncPhysicalMemoryBeforeDmaWrite(aPages, aColour, 10, 30, actualMemAttr); |
|
311 Kern::UnpinPhysicalMemory(pinObject); |
|
312 Kern::DestroyPhysicalPinObject(pinObject); |
|
313 NKern::ThreadLeaveCS(); |
|
314 return r; |
|
315 } |
|
316 default: |
|
317 return KErrNotSupported; |
|
318 } |
|
319 } |
|
320 |
|
321 // Fail a test by returning an error code indicating the problem |
|
322 #define FAIL_ALLOC_TEST(testIndex, byteOffset, unexepectedValue) \ |
|
323 err = ((testIndex) << 16) | ((byteOffset) << 8) | (unexepectedValue) |
|
324 |
|
325 TInt DMemoryTestChannel::TestAllocZerosMemory() |
|
326 { |
|
327 TInt count = 100; |
|
328 TInt r = KErrNotSupported; |
|
329 |
|
330 do { //re-try up to 100 times if memory conditions are not correct |
|
331 r=AllocTest1(); |
|
332 } while(((r == KErrNoMemory)||(r == KErrUnknown)) && --count); |
|
333 |
|
334 return r; |
|
335 } |
|
336 |
|
337 TInt DMemoryTestChannel::AllocTest1() |
|
338 { |
|
339 const TInt KSize = 256; |
|
340 TInt err = KErrNone; |
|
341 TUint8* mem1 = (TUint8*)Kern::Alloc(KSize); |
|
342 if (!mem1) |
|
343 return KErrNoMemory; |
|
344 memset(mem1, KSize, 0xff); |
|
345 Kern::Free(mem1); |
|
346 TUint8* mem2 = (TUint8*)Kern::Alloc(KSize); |
|
347 if (!mem2) |
|
348 return KErrNoMemory; |
|
349 if (mem1 != mem2) |
|
350 err = KErrUnknown; // Test inconclusive, can retry |
|
351 for (TInt i = 0 ; i<KSize && err==KErrNone; ++i) |
|
352 { |
|
353 if (mem2[i] != 0) |
|
354 FAIL_ALLOC_TEST(1, i, mem2[i]); |
|
355 } |
|
356 Kern::Free(mem2); |
|
357 |
|
358 return err; |
|
359 } |
|
360 |
|
361 TInt DMemoryTestChannel::TestReAllocZerosMemory() |
|
362 { |
|
363 TInt count = 100; |
|
364 TInt r = KErrNotSupported; |
|
365 |
|
366 do { //re-try up to 100 times if memory conditions are not correct |
|
367 r=ReAllocTest1(); |
|
368 } while(((r == KErrNoMemory)||(r == KErrUnknown)) && --count); |
|
369 |
|
370 if (r!=KErrNone) |
|
371 return r; |
|
372 |
|
373 count = 100; |
|
374 do { // re-try up to 100 times if memory conditions are not correct |
|
375 TUint8* mem1 = NULL; |
|
376 TUint8* mem2 = NULL; |
|
377 TUint8* mem3 = NULL; |
|
378 r=ReAllocTest2(mem1, mem2, mem3); |
|
379 if (mem1) |
|
380 Kern::Free(mem1); |
|
381 if (mem2) |
|
382 Kern::Free(mem2); |
|
383 if (mem3) |
|
384 Kern::Free(mem3); |
|
385 } while(((r == KErrNoMemory)||(r == KErrUnknown)) && --count); |
|
386 |
|
387 return r; |
|
388 } |
|
389 |
|
390 // The actual size of the block allocated given the size requested. |
|
391 #define ALIGNED_SIZE(aReqSize) (_ALIGN_UP(aReqSize + RHeap::EAllocCellSize, RHeap::ECellAlignment) - RHeap::EAllocCellSize) |
|
392 |
|
393 // We only acllocate blocks where the size we get is the size we ask for - this |
|
394 // just makes testing easier. |
|
395 const TInt KSize = ALIGNED_SIZE(200), KHalfSize = ALIGNED_SIZE(100), KSmallSize = ALIGNED_SIZE(50); |
|
396 |
|
397 TInt DMemoryTestChannel::ReAllocTest1() |
|
398 { |
|
399 // Test case where cell grows |
|
400 // |
|
401 // Expected heap layout: |
|
402 // 1: [-mem1-------] |
|
403 // 2: [-mem1-] |
|
404 // 3: [-mem1-------] |
|
405 |
|
406 TInt err = KErrNone; |
|
407 TUint8* mem1 = (TUint8*)Kern::Alloc(KSize); // 1 |
|
408 if (!mem1) |
|
409 return KErrNoMemory; |
|
410 memset(mem1, 0xff, KSize); |
|
411 TUint8* mem2 = (TUint8*)Kern::ReAlloc(mem1, KHalfSize); // 2 |
|
412 if (mem1 != mem2) |
|
413 { |
|
414 mem1 = 0; |
|
415 Kern::Free(mem2); |
|
416 return KErrUnknown; // Don't expect move on shrink |
|
417 } |
|
418 mem2 = (TUint8*)Kern::ReAlloc(mem1, KSize); // 3 |
|
419 if (mem1 != mem2) |
|
420 { |
|
421 mem1 = 0; |
|
422 Kern::Free(mem2); |
|
423 return KErrUnknown; // Expect growth into original area |
|
424 } |
|
425 |
|
426 TInt i; |
|
427 for (i = 0 ; i<KHalfSize && err==KErrNone; ++i) |
|
428 { |
|
429 if (mem1[i] != 0xff) |
|
430 FAIL_ALLOC_TEST(2, i, mem1[i]); |
|
431 } |
|
432 for (i = KHalfSize ; i<KSize && err==KErrNone; ++i) |
|
433 { |
|
434 if (mem1[i] != 0) |
|
435 FAIL_ALLOC_TEST(3, i, mem1[i]); |
|
436 } |
|
437 |
|
438 Kern::Free(mem1); |
|
439 return err; |
|
440 } |
|
441 |
|
442 TInt DMemoryTestChannel::ReAllocTest2(TUint8*& mem1, TUint8*& mem2, TUint8*& mem3) |
|
443 { |
|
444 // Test case where cell is moved |
|
445 // |
|
446 // Expected heap layout: |
|
447 // 1: [ mem1 ] |
|
448 // 2: [ mem1 ] [ mem2 ] |
|
449 // 3: [ mem1 ] [ mem2 ] [ mem3 ] |
|
450 // 4: [ mem2 ] [ mem1 ] |
|
451 |
|
452 mem1 = (TUint8*)Kern::Alloc(KSmallSize); // 1 |
|
453 if (!mem1) |
|
454 return KErrNoMemory; |
|
455 memset(mem1, 0xff, KSmallSize); |
|
456 mem2 = (TUint8*)Kern::Alloc(KSmallSize); // 2 |
|
457 if (!mem2) |
|
458 return KErrNoMemory; |
|
459 if (mem2 <= (mem1 + KSmallSize)) |
|
460 return KErrUnknown; // Expect mem2 higher than mem1 |
|
461 memset(mem2, 0xee, KSmallSize); |
|
462 mem3 = (TUint8*)Kern::Alloc(KSize); // 3 |
|
463 if (!mem3) |
|
464 return KErrNoMemory; |
|
465 if (mem3 <= (mem2 + KSmallSize)) |
|
466 return KErrUnknown; // Expect mem3 higher than mem2 |
|
467 memset(mem3, 0xdd, KSize); |
|
468 Kern::Free(mem3); |
|
469 TUint8* m3 = mem3; |
|
470 mem3 = NULL; |
|
471 TUint8* mem4 = (TUint8*)Kern::ReAlloc(mem1, KSize); // 4 |
|
472 if (!mem4) |
|
473 return KErrNoMemory; |
|
474 if (mem4 == mem1) |
|
475 return KErrUnknown; // Expect move on grow |
|
476 mem1=mem4; |
|
477 if (mem4 != m3) |
|
478 return KErrUnknown; // Expect to realloc to use old mem3 space |
|
479 |
|
480 TInt i; |
|
481 TInt err = KErrNone; |
|
482 for (i = 0 ; i<KSmallSize && err==KErrNone; ++i) |
|
483 { |
|
484 if (mem1[i] != 0xff) |
|
485 FAIL_ALLOC_TEST(4, i, mem1[i]); |
|
486 } |
|
487 for (i = KSmallSize; i<KSize && err==KErrNone; ++i) |
|
488 { |
|
489 if (mem1[i] != 0) |
|
490 FAIL_ALLOC_TEST(5, i, mem1[i]); |
|
491 } |
|
492 |
|
493 return err; |
|
494 } |
|
495 |
|
496 #ifdef __EPOC32__ |
|
497 #define CHECK(c) { if(!(c)) { Kern::Printf("Fail %d", __LINE__); ; ret = __LINE__;} } |
|
498 |
|
499 TInt DMemoryTestChannel::AllocPhysTest(TUint32 aIters, TUint32 aSize) |
|
500 { |
|
501 TInt ret = KErrNone; |
|
502 TUint32 index; |
|
503 |
|
504 TUint32 pageSize = 0; |
|
505 CHECK(Kern::HalFunction(EHalGroupKernel,EKernelHalPageSizeInBytes,&pageSize,0)==KErrNone); |
|
506 TUint32 numPages = aSize / pageSize; |
|
507 TUint32 pageIndex; |
|
508 TPhysAddr* addrArray = (TPhysAddr *)Kern::AllocZ(sizeof(TPhysAddr) * numPages); |
|
509 CHECK(addrArray); |
|
510 if(!addrArray) |
|
511 { |
|
512 return KErrNoMemory; |
|
513 } |
|
514 |
|
515 for (index = 0; index < aIters; index ++) |
|
516 { |
|
517 for (pageIndex = 0; pageIndex < numPages; pageIndex ++) |
|
518 { |
|
519 ret = Epoc::AllocPhysicalRam(pageSize, addrArray[pageIndex], 0); |
|
520 if (ret != KErrNone) |
|
521 { |
|
522 break; |
|
523 } |
|
524 } |
|
525 for (pageIndex = 0; pageIndex < numPages; pageIndex ++) |
|
526 { |
|
527 if (addrArray[pageIndex]) |
|
528 { |
|
529 Epoc::FreePhysicalRam(addrArray[pageIndex], pageSize); |
|
530 addrArray[pageIndex] = NULL; |
|
531 } |
|
532 } |
|
533 if (ret != KErrNone) |
|
534 { |
|
535 break; |
|
536 } |
|
537 } |
|
538 |
|
539 Kern::Free(addrArray); |
|
540 return ret; |
|
541 } |
|
542 |
|
543 #else |
|
544 |
|
545 TInt DMemoryTestChannel::AllocPhysTest(TUint32 , TUint32 ) |
|
546 { |
|
547 return KErrNone; |
|
548 } |
|
549 |
|
550 #endif |
|
551 |
|
552 #ifdef __EPOC32__ |
|
553 |
|
554 TInt DMemoryTestChannel::AllocPhysTest1(TUint32 aIters, TUint32 aSize) |
|
555 { |
|
556 TInt ret = KErrNone; |
|
557 TUint32 index; |
|
558 |
|
559 TUint32 pageSize = 0; |
|
560 CHECK(Kern::HalFunction(EHalGroupKernel,EKernelHalPageSizeInBytes,&pageSize,0)==KErrNone); |
|
561 TUint32 numPages = aSize / pageSize; |
|
562 TPhysAddr* addrArray = (TPhysAddr *)Kern::AllocZ(sizeof(TPhysAddr) * numPages); |
|
563 for (index = 0; index < aIters; index ++) |
|
564 { |
|
565 ret = Epoc::AllocPhysicalRam(numPages, addrArray); |
|
566 if (ret != KErrNone) |
|
567 { |
|
568 break; |
|
569 } |
|
570 Epoc::FreePhysicalRam(numPages, addrArray); |
|
571 } |
|
572 Kern::Free(addrArray); |
|
573 return ret; |
|
574 } |
|
575 #else |
|
576 |
|
577 TInt DMemoryTestChannel::AllocPhysTest1(TUint32 , TUint32 ) |
|
578 { |
|
579 return KErrNone; |
|
580 } |
|
581 |
|
582 #endif |