author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Sat, 20 Feb 2010 00:10:51 +0200 | |
branch | RCL_3 |
changeset 19 | 4a8fed1c0ef6 |
parent 14 | 5d2844f35677 |
child 43 | c1f20ce4abcf |
permissions | -rw-r--r-- |
0 | 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; |
|
14
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
57 |
TPhysAddr iPhysPageList[KUCPageCount]; |
0 | 58 |
TUint iColour; |
59 |
TUint32 iActualMapAttr; |
|
60 |
}iPhysicalPinning; |
|
14
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
61 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
62 |
struct{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
63 |
TKernelMapObject* iObject; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
64 |
TPhysAddr iPhysPageList[KUCPageCount]; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
65 |
TLinAddr iLinAddr; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
66 |
}iKernelMapping; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
67 |
|
0 | 68 |
TUint32 iPageSize; |
69 |
}; |
|
70 |
||
71 |
// |
|
72 |
// DMemoryTestFactory |
|
73 |
// |
|
74 |
||
75 |
TInt DMemoryTestFactory::Install() |
|
76 |
{ |
|
77 |
return SetName(&KMemoryTestLddName); |
|
78 |
} |
|
79 |
||
80 |
DMemoryTestFactory::~DMemoryTestFactory() |
|
81 |
{ |
|
82 |
} |
|
83 |
||
84 |
void DMemoryTestFactory::GetCaps(TDes8& /*aDes*/) const |
|
85 |
{ |
|
86 |
// Not used but required as DLogicalDevice::GetCaps is pure virtual |
|
87 |
} |
|
88 |
||
89 |
TInt DMemoryTestFactory::Create(DLogicalChannelBase*& aChannel) |
|
90 |
{ |
|
91 |
aChannel = NULL; |
|
92 |
DMemoryTestChannel* channel=new DMemoryTestChannel; |
|
93 |
if(!channel) |
|
94 |
return KErrNoMemory; |
|
95 |
channel->iFactory = this; |
|
96 |
aChannel = channel; |
|
97 |
return KErrNone; |
|
98 |
} |
|
99 |
||
100 |
DECLARE_STANDARD_LDD() |
|
101 |
{ |
|
102 |
return new DMemoryTestFactory; |
|
103 |
} |
|
104 |
||
105 |
// |
|
106 |
// DMemoryTestChannel |
|
107 |
// |
|
108 |
||
109 |
TInt DMemoryTestChannel::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/) |
|
110 |
{ |
|
111 |
return KErrNone; |
|
112 |
} |
|
113 |
||
114 |
DMemoryTestChannel::DMemoryTestChannel() |
|
115 |
{ |
|
116 |
iPageSize = Kern::RoundToPageSize(1); |
|
117 |
} |
|
118 |
||
119 |
DMemoryTestChannel::~DMemoryTestChannel() |
|
120 |
{ |
|
121 |
Kern::DestroyVirtualPinObject(iVirtualPinObject); |
|
122 |
} |
|
123 |
||
124 |
||
125 |
TInt DMemoryTestChannel::Request(TInt aFunction, TAny* a1, TAny* a2) |
|
126 |
{ |
|
127 |
TInt r=KErrNotSupported; |
|
128 |
||
129 |
switch(aFunction) |
|
130 |
{ |
|
131 |
case RMemoryTestLdd::EReadWriteMemory: |
|
132 |
case RMemoryTestLdd::EReadMemory: |
|
133 |
case RMemoryTestLdd::EWriteMemory: |
|
134 |
{ |
|
135 |
TUint32 value=(TUint32)a2; |
|
136 |
#ifdef _DEBUG |
|
137 |
TInt debugMask = Kern::CurrentThread().iDebugMask; |
|
138 |
Kern::CurrentThread().iDebugMask = debugMask&~(1<<KPANIC); |
|
139 |
#endif |
|
140 |
XTRAP(r, XT_DEFAULT, |
|
141 |
if(aFunction==RMemoryTestLdd::EReadWriteMemory) |
|
142 |
{ |
|
143 |
kumemget32(&value,a1,4); |
|
144 |
kumemput32(a1,&value,4); |
|
145 |
} |
|
146 |
else if(aFunction==RMemoryTestLdd::EReadMemory) |
|
147 |
kumemget32(&value,a1,4); |
|
148 |
else if(aFunction==RMemoryTestLdd::EWriteMemory) |
|
149 |
kumemput32(a1,&value,4); |
|
150 |
); |
|
151 |
#ifdef _DEBUG |
|
152 |
Kern::CurrentThread().iDebugMask = debugMask; |
|
153 |
#endif |
|
154 |
if(aFunction==RMemoryTestLdd::EReadMemory) |
|
155 |
kumemput32(a2,&value,sizeof(value)); |
|
156 |
||
157 |
return r; |
|
158 |
} |
|
159 |
||
160 |
case RMemoryTestLdd::ETestAllocZerosMemory: |
|
161 |
case RMemoryTestLdd::ETestReAllocZerosMemory: |
|
162 |
{ |
|
163 |
NKern::ThreadEnterCS(); |
|
164 |
TInt r; |
|
165 |
if (aFunction==RMemoryTestLdd::ETestAllocZerosMemory) |
|
166 |
r=TestAllocZerosMemory(); |
|
167 |
else |
|
168 |
r=TestReAllocZerosMemory(); |
|
169 |
NKern::ThreadLeaveCS(); |
|
170 |
return r; |
|
171 |
} |
|
172 |
||
173 |
case RMemoryTestLdd::ETestAllocPhysTest: |
|
174 |
{ |
|
175 |
NKern::ThreadEnterCS(); |
|
176 |
r=AllocPhysTest((TUint32)a1,(TUint32)a2); |
|
177 |
NKern::ThreadLeaveCS(); |
|
178 |
return r; |
|
179 |
} |
|
180 |
||
181 |
case RMemoryTestLdd::ETestAllocPhysTest1: |
|
182 |
{ |
|
183 |
NKern::ThreadEnterCS(); |
|
184 |
r=AllocPhysTest1((TUint32)a1,(TUint32)a2); |
|
185 |
NKern::ThreadLeaveCS(); |
|
186 |
return r; |
|
187 |
} |
|
188 |
||
189 |
case RMemoryTestLdd::ECreateVirtualPinObject: |
|
190 |
{ |
|
191 |
NKern::ThreadEnterCS(); |
|
192 |
r=Kern::CreateVirtualPinObject(iVirtualPinObject); |
|
193 |
NKern::ThreadLeaveCS(); |
|
194 |
return r; |
|
195 |
} |
|
196 |
||
197 |
case RMemoryTestLdd::EPinVirtualMemory: |
|
198 |
return Kern::PinVirtualMemory(iVirtualPinObject, (TLinAddr)a1, (TUint)a2); |
|
199 |
||
200 |
case RMemoryTestLdd::EUnpinVirtualMemory: |
|
201 |
Kern::UnpinVirtualMemory(iVirtualPinObject); |
|
202 |
return KErrNone; |
|
203 |
||
204 |
case RMemoryTestLdd::EDestroyVirtualPinObject: |
|
205 |
{ |
|
206 |
NKern::ThreadEnterCS(); |
|
207 |
Kern::DestroyVirtualPinObject(iVirtualPinObject); |
|
208 |
NKern::ThreadLeaveCS(); |
|
209 |
return KErrNone; |
|
210 |
} |
|
211 |
||
212 |
case RMemoryTestLdd::ESetPanicTrace: |
|
213 |
{ |
|
214 |
TBool old = false; |
|
215 |
#ifdef _DEBUG |
|
216 |
DThread& thread = Kern::CurrentThread(); |
|
217 |
TInt debugMask = thread.iDebugMask; |
|
218 |
if(debugMask&(1<<KPANIC)) |
|
219 |
old = true; |
|
220 |
if(a1) |
|
221 |
debugMask |= (1<<KPANIC); |
|
222 |
else |
|
223 |
debugMask &= ~(1<<KPANIC); |
|
224 |
thread.iDebugMask = debugMask; |
|
225 |
#endif |
|
226 |
return old; |
|
227 |
} |
|
228 |
||
229 |
case RMemoryTestLdd::EIsMemoryPresent: |
|
230 |
#ifndef __WINS__ |
|
231 |
return Epoc::LinearToPhysical((TLinAddr)a1) != KPhysAddrInvalid; |
|
232 |
#else |
|
233 |
Kern::PanicCurrentThread(_L("IsMemoryPresent should not be used on the emulator"), KErrNotSupported); |
|
234 |
return KErrNotSupported; |
|
235 |
#endif |
|
236 |
||
237 |
case RMemoryTestLdd::ECreatePhysicalPinObject: |
|
238 |
{ |
|
239 |
NKern::ThreadEnterCS(); |
|
240 |
r=Kern::CreatePhysicalPinObject(iPhysicalPinning.iObject); |
|
241 |
NKern::ThreadLeaveCS(); |
|
242 |
return r; |
|
243 |
} |
|
244 |
||
245 |
case RMemoryTestLdd::EPinPhysicalMemory: |
|
246 |
return Kern::PinPhysicalMemory(iPhysicalPinning.iObject, (TLinAddr)a1, (TUint)a2, EFalse, iPhysicalPinning.iPhysAddr, |
|
247 |
iPhysicalPinning.iPhysPageList, iPhysicalPinning.iActualMapAttr, iPhysicalPinning.iColour, NULL); |
|
248 |
||
249 |
case RMemoryTestLdd::EPinPhysicalMemoryRO: |
|
250 |
return Kern::PinPhysicalMemory(iPhysicalPinning.iObject, (TLinAddr)a1, (TUint)a2, ETrue, iPhysicalPinning.iPhysAddr, |
|
251 |
iPhysicalPinning.iPhysPageList, iPhysicalPinning.iActualMapAttr, iPhysicalPinning.iColour, NULL); |
|
252 |
||
253 |
case RMemoryTestLdd::ECheckPageList: |
|
254 |
{ |
|
255 |
#ifdef __WINS__ |
|
256 |
return KErrNotSupported; |
|
257 |
#else |
|
258 |
TInt i; |
|
14
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
259 |
for (i=0;i<KUCPageCount; i++) |
0 | 260 |
{ |
261 |
TPhysAddr addr = Epoc::LinearToPhysical((TLinAddr)a1 + i*iPageSize); |
|
262 |
if (addr==KPhysAddrInvalid) return KErrGeneral; |
|
263 |
if (addr!=iPhysicalPinning.iPhysPageList[i]) return KErrNotFound; |
|
264 |
} |
|
265 |
return KErrNone; |
|
266 |
#endif |
|
267 |
} |
|
268 |
||
269 |
case RMemoryTestLdd::ESyncPinnedPhysicalMemory: |
|
270 |
return Cache::SyncPhysicalMemoryBeforeDmaWrite(iPhysicalPinning.iPhysPageList, |
|
271 |
iPhysicalPinning.iColour, (TUint)a1, (TUint)a2, iPhysicalPinning.iActualMapAttr); |
|
272 |
||
273 |
case RMemoryTestLdd::EMovePinnedPhysicalMemory: |
|
274 |
{ |
|
275 |
#ifdef __WINS__ |
|
276 |
return KErrNotSupported; |
|
277 |
#else |
|
278 |
TPhysAddr newPage; |
|
279 |
NKern::ThreadEnterCS(); |
|
280 |
r = Epoc::MovePhysicalPage(iPhysicalPinning.iPhysPageList[(TUint)a1], newPage); |
|
281 |
NKern::ThreadLeaveCS(); |
|
282 |
return r; |
|
283 |
#endif |
|
284 |
} |
|
285 |
||
286 |
case RMemoryTestLdd::EInvalidatePinnedPhysicalMemory: |
|
287 |
{ |
|
288 |
r = Cache::SyncPhysicalMemoryBeforeDmaRead(iPhysicalPinning.iPhysPageList, |
|
289 |
iPhysicalPinning.iColour, (TUint)a1, (TUint)a2, iPhysicalPinning.iActualMapAttr); |
|
290 |
if (r==KErrNone) |
|
291 |
r = Cache::SyncPhysicalMemoryAfterDmaRead(iPhysicalPinning.iPhysPageList, |
|
292 |
iPhysicalPinning.iColour, (TUint)a1, (TUint)a2, iPhysicalPinning.iActualMapAttr); |
|
293 |
return r; |
|
294 |
} |
|
295 |
||
296 |
case RMemoryTestLdd::EUnpinPhysicalMemory: |
|
297 |
return Kern::UnpinPhysicalMemory(iPhysicalPinning.iObject); |
|
298 |
||
299 |
case RMemoryTestLdd::EDestroyPhysicalPinObject: |
|
300 |
{ |
|
301 |
NKern::ThreadEnterCS(); |
|
302 |
r=Kern::DestroyPhysicalPinObject(iPhysicalPinning.iObject); |
|
303 |
NKern::ThreadLeaveCS(); |
|
304 |
return r; |
|
305 |
} |
|
306 |
||
307 |
case RMemoryTestLdd::EPinKernelPhysicalMemory: |
|
308 |
{ |
|
309 |
TPhysicalPinObject* pinObject; |
|
310 |
TPhysAddr aAddress; |
|
311 |
TPhysAddr aPages[2]; |
|
312 |
TUint aColour=0; |
|
313 |
TUint32 actualMemAttr; |
|
314 |
NKern::ThreadEnterCS(); |
|
315 |
Kern::CreatePhysicalPinObject(pinObject); |
|
316 |
r = Kern::PinPhysicalMemory(pinObject, (TLinAddr)&aAddress, 4, EFalse, aAddress, aPages, actualMemAttr, aColour, NULL); |
|
317 |
Cache::SyncPhysicalMemoryBeforeDmaWrite(aPages, aColour, 10, 30, actualMemAttr); |
|
318 |
Kern::UnpinPhysicalMemory(pinObject); |
|
319 |
Kern::DestroyPhysicalPinObject(pinObject); |
|
320 |
NKern::ThreadLeaveCS(); |
|
321 |
return r; |
|
322 |
} |
|
14
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
323 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
324 |
case RMemoryTestLdd::ECreateKernelMapObject: |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
325 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
326 |
NKern::ThreadEnterCS(); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
327 |
r=Kern::CreateKernelMapObject(iKernelMapping.iObject, (TUint)a1); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
328 |
NKern::ThreadLeaveCS(); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
329 |
return r; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
330 |
} |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
331 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
332 |
case RMemoryTestLdd::EKernelMapMemory: |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
333 |
return Kern::MapAndPinMemory( iKernelMapping.iObject, NULL, (TLinAddr)a1, (TUint)a2, 0, |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
334 |
iKernelMapping.iLinAddr, iKernelMapping.iPhysPageList); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
335 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
336 |
case RMemoryTestLdd::EKernelMapMemoryRO: |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
337 |
return Kern::MapAndPinMemory( iKernelMapping.iObject, NULL, (TLinAddr)a1, (TUint)a2, Kern::EKernelMap_ReadOnly, |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
338 |
iKernelMapping.iLinAddr, iKernelMapping.iPhysPageList); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
339 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
340 |
case RMemoryTestLdd::EKernelMapMemoryInvalid: |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
341 |
return Kern::MapAndPinMemory( iKernelMapping.iObject, NULL, (TLinAddr)a1, (TUint)a2, (TUint)~Kern::EKernelMap_ReadOnly, |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
342 |
iKernelMapping.iLinAddr, iKernelMapping.iPhysPageList); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
343 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
344 |
case RMemoryTestLdd::EKernelMapCheckPageList: |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
345 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
346 |
#ifdef __WINS__ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
347 |
return KErrNotSupported; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
348 |
#else |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
349 |
TUint i = 0; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
350 |
for (; i < (TUint)KUCPageCount; i++) |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
351 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
352 |
// Compare the user side address to physical addresses |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
353 |
TPhysAddr addr = Epoc::LinearToPhysical((TLinAddr)a1 + i*iPageSize); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
354 |
if (addr == KPhysAddrInvalid) |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
355 |
return KErrGeneral; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
356 |
if (addr != iKernelMapping.iPhysPageList[i]) |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
357 |
return KErrNotFound; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
358 |
// Compare the kernel side address to physical addresses |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
359 |
addr = Epoc::LinearToPhysical(iKernelMapping.iLinAddr + i*iPageSize); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
360 |
if (addr == KPhysAddrInvalid) |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
361 |
return KErrGeneral; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
362 |
if (addr != iKernelMapping.iPhysPageList[i]) |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
363 |
return KErrNotFound; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
364 |
} |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
365 |
return KErrNone; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
366 |
#endif |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
367 |
} |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
368 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
369 |
case RMemoryTestLdd::EKernelMapSyncMemory: |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
370 |
Cache::SyncMemoryBeforeDmaWrite(iKernelMapping.iLinAddr, KUCPageCount*iPageSize); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
371 |
return KErrNone; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
372 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
373 |
case RMemoryTestLdd::EKernelMapInvalidateMemory: |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
374 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
375 |
Cache::SyncMemoryBeforeDmaRead(iKernelMapping.iLinAddr, KUCPageCount*iPageSize); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
376 |
Cache::SyncMemoryAfterDmaRead(iKernelMapping.iLinAddr, KUCPageCount*iPageSize); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
377 |
return KErrNone; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
378 |
} |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
379 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
380 |
case RMemoryTestLdd::EKernelMapMoveMemory: |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
381 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
382 |
#ifdef __WINS__ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
383 |
return KErrNotSupported; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
384 |
#else |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
385 |
TPhysAddr newPage; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
386 |
NKern::ThreadEnterCS(); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
387 |
r = Epoc::MovePhysicalPage(iKernelMapping.iPhysPageList[(TUint)a1], newPage); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
388 |
NKern::ThreadLeaveCS(); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
389 |
return r; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
390 |
#endif |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
391 |
} |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
392 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
393 |
case RMemoryTestLdd::EKernelMapReadModifyMemory: |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
394 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
395 |
TUint8* p = (TUint8*)iKernelMapping.iLinAddr; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
396 |
// Verify the contents of the data when accessed via the kernel mapping. |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
397 |
TUint i = 0; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
398 |
for (i = 0; i < KUCPageCount*iPageSize; i++) |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
399 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
400 |
if (*p++ != (TUint8)i) |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
401 |
return KErrCorrupt; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
402 |
} |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
403 |
// Modify the data via the kernel mapping. |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
404 |
p = (TUint8*)iKernelMapping.iLinAddr; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
405 |
for (i = 0; i < KUCPageCount*iPageSize; i++) |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
406 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
407 |
*p++ = (TUint8)(i + 1); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
408 |
} |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
409 |
return KErrNone; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
410 |
} |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
411 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
412 |
case RMemoryTestLdd::EKernelUnmapMemory: |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
413 |
Kern::UnmapAndUnpinMemory(iKernelMapping.iObject); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
414 |
return KErrNone; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
415 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
416 |
case RMemoryTestLdd::EDestroyKernelMapObject: |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
417 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
418 |
NKern::ThreadEnterCS(); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
419 |
Kern::DestroyKernelMapObject(iKernelMapping.iObject); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
420 |
NKern::ThreadLeaveCS(); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
421 |
return KErrNone; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
422 |
} |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
423 |
|
0 | 424 |
default: |
425 |
return KErrNotSupported; |
|
426 |
} |
|
427 |
} |
|
428 |
||
429 |
// Fail a test by returning an error code indicating the problem |
|
430 |
#define FAIL_ALLOC_TEST(testIndex, byteOffset, unexepectedValue) \ |
|
431 |
err = ((testIndex) << 16) | ((byteOffset) << 8) | (unexepectedValue) |
|
432 |
||
433 |
TInt DMemoryTestChannel::TestAllocZerosMemory() |
|
434 |
{ |
|
435 |
TInt count = 100; |
|
436 |
TInt r = KErrNotSupported; |
|
437 |
||
438 |
do { //re-try up to 100 times if memory conditions are not correct |
|
439 |
r=AllocTest1(); |
|
440 |
} while(((r == KErrNoMemory)||(r == KErrUnknown)) && --count); |
|
441 |
||
442 |
return r; |
|
443 |
} |
|
444 |
||
445 |
TInt DMemoryTestChannel::AllocTest1() |
|
446 |
{ |
|
447 |
const TInt KSize = 256; |
|
448 |
TInt err = KErrNone; |
|
449 |
TUint8* mem1 = (TUint8*)Kern::Alloc(KSize); |
|
450 |
if (!mem1) |
|
451 |
return KErrNoMemory; |
|
452 |
memset(mem1, KSize, 0xff); |
|
453 |
Kern::Free(mem1); |
|
454 |
TUint8* mem2 = (TUint8*)Kern::Alloc(KSize); |
|
455 |
if (!mem2) |
|
456 |
return KErrNoMemory; |
|
457 |
if (mem1 != mem2) |
|
458 |
err = KErrUnknown; // Test inconclusive, can retry |
|
459 |
for (TInt i = 0 ; i<KSize && err==KErrNone; ++i) |
|
460 |
{ |
|
461 |
if (mem2[i] != 0) |
|
462 |
FAIL_ALLOC_TEST(1, i, mem2[i]); |
|
463 |
} |
|
464 |
Kern::Free(mem2); |
|
465 |
||
466 |
return err; |
|
467 |
} |
|
468 |
||
469 |
TInt DMemoryTestChannel::TestReAllocZerosMemory() |
|
470 |
{ |
|
471 |
TInt count = 100; |
|
472 |
TInt r = KErrNotSupported; |
|
473 |
||
474 |
do { //re-try up to 100 times if memory conditions are not correct |
|
475 |
r=ReAllocTest1(); |
|
476 |
} while(((r == KErrNoMemory)||(r == KErrUnknown)) && --count); |
|
477 |
||
478 |
if (r!=KErrNone) |
|
479 |
return r; |
|
480 |
||
481 |
count = 100; |
|
482 |
do { // re-try up to 100 times if memory conditions are not correct |
|
483 |
TUint8* mem1 = NULL; |
|
484 |
TUint8* mem2 = NULL; |
|
485 |
TUint8* mem3 = NULL; |
|
486 |
r=ReAllocTest2(mem1, mem2, mem3); |
|
487 |
if (mem1) |
|
488 |
Kern::Free(mem1); |
|
489 |
if (mem2) |
|
490 |
Kern::Free(mem2); |
|
491 |
if (mem3) |
|
492 |
Kern::Free(mem3); |
|
493 |
} while(((r == KErrNoMemory)||(r == KErrUnknown)) && --count); |
|
494 |
||
495 |
return r; |
|
496 |
} |
|
497 |
||
498 |
// The actual size of the block allocated given the size requested. |
|
499 |
#define ALIGNED_SIZE(aReqSize) (_ALIGN_UP(aReqSize + RHeap::EAllocCellSize, RHeap::ECellAlignment) - RHeap::EAllocCellSize) |
|
500 |
||
501 |
// We only acllocate blocks where the size we get is the size we ask for - this |
|
502 |
// just makes testing easier. |
|
503 |
const TInt KSize = ALIGNED_SIZE(200), KHalfSize = ALIGNED_SIZE(100), KSmallSize = ALIGNED_SIZE(50); |
|
504 |
||
505 |
TInt DMemoryTestChannel::ReAllocTest1() |
|
506 |
{ |
|
507 |
// Test case where cell grows |
|
508 |
// |
|
509 |
// Expected heap layout: |
|
510 |
// 1: [-mem1-------] |
|
511 |
// 2: [-mem1-] |
|
512 |
// 3: [-mem1-------] |
|
513 |
||
514 |
TInt err = KErrNone; |
|
515 |
TUint8* mem1 = (TUint8*)Kern::Alloc(KSize); // 1 |
|
516 |
if (!mem1) |
|
517 |
return KErrNoMemory; |
|
518 |
memset(mem1, 0xff, KSize); |
|
519 |
TUint8* mem2 = (TUint8*)Kern::ReAlloc(mem1, KHalfSize); // 2 |
|
520 |
if (mem1 != mem2) |
|
521 |
{ |
|
522 |
mem1 = 0; |
|
523 |
Kern::Free(mem2); |
|
524 |
return KErrUnknown; // Don't expect move on shrink |
|
525 |
} |
|
526 |
mem2 = (TUint8*)Kern::ReAlloc(mem1, KSize); // 3 |
|
527 |
if (mem1 != mem2) |
|
528 |
{ |
|
529 |
mem1 = 0; |
|
530 |
Kern::Free(mem2); |
|
531 |
return KErrUnknown; // Expect growth into original area |
|
532 |
} |
|
533 |
||
534 |
TInt i; |
|
535 |
for (i = 0 ; i<KHalfSize && err==KErrNone; ++i) |
|
536 |
{ |
|
537 |
if (mem1[i] != 0xff) |
|
538 |
FAIL_ALLOC_TEST(2, i, mem1[i]); |
|
539 |
} |
|
540 |
for (i = KHalfSize ; i<KSize && err==KErrNone; ++i) |
|
541 |
{ |
|
542 |
if (mem1[i] != 0) |
|
543 |
FAIL_ALLOC_TEST(3, i, mem1[i]); |
|
544 |
} |
|
545 |
||
546 |
Kern::Free(mem1); |
|
547 |
return err; |
|
548 |
} |
|
549 |
||
550 |
TInt DMemoryTestChannel::ReAllocTest2(TUint8*& mem1, TUint8*& mem2, TUint8*& mem3) |
|
551 |
{ |
|
552 |
// Test case where cell is moved |
|
553 |
// |
|
554 |
// Expected heap layout: |
|
555 |
// 1: [ mem1 ] |
|
556 |
// 2: [ mem1 ] [ mem2 ] |
|
557 |
// 3: [ mem1 ] [ mem2 ] [ mem3 ] |
|
558 |
// 4: [ mem2 ] [ mem1 ] |
|
559 |
||
560 |
mem1 = (TUint8*)Kern::Alloc(KSmallSize); // 1 |
|
561 |
if (!mem1) |
|
562 |
return KErrNoMemory; |
|
563 |
memset(mem1, 0xff, KSmallSize); |
|
564 |
mem2 = (TUint8*)Kern::Alloc(KSmallSize); // 2 |
|
565 |
if (!mem2) |
|
566 |
return KErrNoMemory; |
|
567 |
if (mem2 <= (mem1 + KSmallSize)) |
|
568 |
return KErrUnknown; // Expect mem2 higher than mem1 |
|
569 |
memset(mem2, 0xee, KSmallSize); |
|
570 |
mem3 = (TUint8*)Kern::Alloc(KSize); // 3 |
|
571 |
if (!mem3) |
|
572 |
return KErrNoMemory; |
|
573 |
if (mem3 <= (mem2 + KSmallSize)) |
|
574 |
return KErrUnknown; // Expect mem3 higher than mem2 |
|
575 |
memset(mem3, 0xdd, KSize); |
|
576 |
Kern::Free(mem3); |
|
577 |
TUint8* m3 = mem3; |
|
578 |
mem3 = NULL; |
|
579 |
TUint8* mem4 = (TUint8*)Kern::ReAlloc(mem1, KSize); // 4 |
|
580 |
if (!mem4) |
|
581 |
return KErrNoMemory; |
|
582 |
if (mem4 == mem1) |
|
583 |
return KErrUnknown; // Expect move on grow |
|
584 |
mem1=mem4; |
|
585 |
if (mem4 != m3) |
|
586 |
return KErrUnknown; // Expect to realloc to use old mem3 space |
|
587 |
||
588 |
TInt i; |
|
589 |
TInt err = KErrNone; |
|
590 |
for (i = 0 ; i<KSmallSize && err==KErrNone; ++i) |
|
591 |
{ |
|
592 |
if (mem1[i] != 0xff) |
|
593 |
FAIL_ALLOC_TEST(4, i, mem1[i]); |
|
594 |
} |
|
595 |
for (i = KSmallSize; i<KSize && err==KErrNone; ++i) |
|
596 |
{ |
|
597 |
if (mem1[i] != 0) |
|
598 |
FAIL_ALLOC_TEST(5, i, mem1[i]); |
|
599 |
} |
|
600 |
||
601 |
return err; |
|
602 |
} |
|
603 |
||
604 |
#ifdef __EPOC32__ |
|
605 |
#define CHECK(c) { if(!(c)) { Kern::Printf("Fail %d", __LINE__); ; ret = __LINE__;} } |
|
606 |
||
607 |
TInt DMemoryTestChannel::AllocPhysTest(TUint32 aIters, TUint32 aSize) |
|
608 |
{ |
|
609 |
TInt ret = KErrNone; |
|
610 |
TUint32 index; |
|
611 |
||
612 |
TUint32 pageSize = 0; |
|
613 |
CHECK(Kern::HalFunction(EHalGroupKernel,EKernelHalPageSizeInBytes,&pageSize,0)==KErrNone); |
|
614 |
TUint32 numPages = aSize / pageSize; |
|
615 |
TUint32 pageIndex; |
|
616 |
TPhysAddr* addrArray = (TPhysAddr *)Kern::AllocZ(sizeof(TPhysAddr) * numPages); |
|
617 |
CHECK(addrArray); |
|
618 |
if(!addrArray) |
|
619 |
{ |
|
620 |
return KErrNoMemory; |
|
621 |
} |
|
622 |
||
623 |
for (index = 0; index < aIters; index ++) |
|
624 |
{ |
|
625 |
for (pageIndex = 0; pageIndex < numPages; pageIndex ++) |
|
626 |
{ |
|
627 |
ret = Epoc::AllocPhysicalRam(pageSize, addrArray[pageIndex], 0); |
|
628 |
if (ret != KErrNone) |
|
629 |
{ |
|
630 |
break; |
|
631 |
} |
|
632 |
} |
|
633 |
for (pageIndex = 0; pageIndex < numPages; pageIndex ++) |
|
634 |
{ |
|
635 |
if (addrArray[pageIndex]) |
|
636 |
{ |
|
637 |
Epoc::FreePhysicalRam(addrArray[pageIndex], pageSize); |
|
638 |
addrArray[pageIndex] = NULL; |
|
639 |
} |
|
640 |
} |
|
641 |
if (ret != KErrNone) |
|
642 |
{ |
|
643 |
break; |
|
644 |
} |
|
645 |
} |
|
646 |
||
647 |
Kern::Free(addrArray); |
|
648 |
return ret; |
|
649 |
} |
|
650 |
||
651 |
#else |
|
652 |
||
653 |
TInt DMemoryTestChannel::AllocPhysTest(TUint32 , TUint32 ) |
|
654 |
{ |
|
655 |
return KErrNone; |
|
656 |
} |
|
657 |
||
658 |
#endif |
|
659 |
||
660 |
#ifdef __EPOC32__ |
|
661 |
||
662 |
TInt DMemoryTestChannel::AllocPhysTest1(TUint32 aIters, TUint32 aSize) |
|
663 |
{ |
|
664 |
TInt ret = KErrNone; |
|
665 |
TUint32 index; |
|
666 |
||
667 |
TUint32 pageSize = 0; |
|
668 |
CHECK(Kern::HalFunction(EHalGroupKernel,EKernelHalPageSizeInBytes,&pageSize,0)==KErrNone); |
|
669 |
TUint32 numPages = aSize / pageSize; |
|
670 |
TPhysAddr* addrArray = (TPhysAddr *)Kern::AllocZ(sizeof(TPhysAddr) * numPages); |
|
671 |
for (index = 0; index < aIters; index ++) |
|
672 |
{ |
|
673 |
ret = Epoc::AllocPhysicalRam(numPages, addrArray); |
|
674 |
if (ret != KErrNone) |
|
675 |
{ |
|
676 |
break; |
|
677 |
} |
|
678 |
Epoc::FreePhysicalRam(numPages, addrArray); |
|
679 |
} |
|
680 |
Kern::Free(addrArray); |
|
681 |
return ret; |
|
682 |
} |
|
683 |
#else |
|
684 |
||
685 |
TInt DMemoryTestChannel::AllocPhysTest1(TUint32 , TUint32 ) |
|
686 |
{ |
|
687 |
return KErrNone; |
|
688 |
} |
|
689 |
||
690 |
#endif |