sl@0
|
1 |
// Copyright (c) 1995-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\mmu\t_mwait.cia
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <e32test.h>
|
sl@0
|
19 |
#include <u32std.h>
|
sl@0
|
20 |
#include "d_shadow.h"
|
sl@0
|
21 |
|
sl@0
|
22 |
#if defined(__CPU_ARM)
|
sl@0
|
23 |
#define INS8 asm(".word 0xe1a00000,0xe1a01001,0xe1a02002,0xe1a03003,0xe1a00000,0xe1a01001,0xe1a02002,0xe1a03003 ")
|
sl@0
|
24 |
#define INS16 INS8 ; INS8
|
sl@0
|
25 |
#define INS32 INS16 ; INS16
|
sl@0
|
26 |
#define INS64 INS32 ; INS32
|
sl@0
|
27 |
#define INS128 INS64 ; INS64
|
sl@0
|
28 |
#elif defined(__CPU_X86)
|
sl@0
|
29 |
#ifdef __GCC32__
|
sl@0
|
30 |
#define INC_EAX asm("inc eax");
|
sl@0
|
31 |
#else
|
sl@0
|
32 |
#define INC_EAX __asm inc eax
|
sl@0
|
33 |
#endif
|
sl@0
|
34 |
#define INS4 INC_EAX \
|
sl@0
|
35 |
INC_EAX \
|
sl@0
|
36 |
INC_EAX \
|
sl@0
|
37 |
INC_EAX
|
sl@0
|
38 |
#define INS8 INS4 INS4
|
sl@0
|
39 |
#define INS16 INS8 INS8
|
sl@0
|
40 |
#define INS32 INS16 INS16
|
sl@0
|
41 |
#define INS64 INS32 INS32
|
sl@0
|
42 |
#define INS128 INS64 INS64
|
sl@0
|
43 |
#define INS256 INS128 INS128
|
sl@0
|
44 |
#define INS512 INS256 INS256
|
sl@0
|
45 |
#endif
|
sl@0
|
46 |
|
sl@0
|
47 |
__NAKED__ TLinAddr MemSpeedTest(TInt /*aLoopSize*/, TInt& /*aCount*/)
|
sl@0
|
48 |
{
|
sl@0
|
49 |
#if defined(__CPU_ARM)
|
sl@0
|
50 |
asm("memspeedtest: ");
|
sl@0
|
51 |
__SWITCH_TO_ARM;
|
sl@0
|
52 |
asm("movs r0, r0 ");
|
sl@0
|
53 |
asm("beq get_function_end "); // if loopsize=0, return end address of this function
|
sl@0
|
54 |
asm("mov r3, r3 ");
|
sl@0
|
55 |
asm("mov r3, #0 "); // count of how many loops done
|
sl@0
|
56 |
asm("adr r2, loopend ");
|
sl@0
|
57 |
asm("sub r2, r2, r0 "); // r2=point to branch back to in loop
|
sl@0
|
58 |
asm("loopstart: "); // from here to loopend must be 64k bytes
|
sl@0
|
59 |
INS128;
|
sl@0
|
60 |
INS128;
|
sl@0
|
61 |
INS128;
|
sl@0
|
62 |
INS128;
|
sl@0
|
63 |
INS128;
|
sl@0
|
64 |
INS128;
|
sl@0
|
65 |
INS128;
|
sl@0
|
66 |
INS128;
|
sl@0
|
67 |
INS128;
|
sl@0
|
68 |
INS128;
|
sl@0
|
69 |
INS128;
|
sl@0
|
70 |
INS128;
|
sl@0
|
71 |
INS128;
|
sl@0
|
72 |
INS128;
|
sl@0
|
73 |
INS128;
|
sl@0
|
74 |
INS128;
|
sl@0
|
75 |
INS128;
|
sl@0
|
76 |
INS128;
|
sl@0
|
77 |
INS128;
|
sl@0
|
78 |
INS128;
|
sl@0
|
79 |
INS128;
|
sl@0
|
80 |
INS128;
|
sl@0
|
81 |
INS128;
|
sl@0
|
82 |
INS128;
|
sl@0
|
83 |
INS128;
|
sl@0
|
84 |
INS128;
|
sl@0
|
85 |
INS128;
|
sl@0
|
86 |
INS128;
|
sl@0
|
87 |
INS128;
|
sl@0
|
88 |
INS128;
|
sl@0
|
89 |
INS128;
|
sl@0
|
90 |
INS128;
|
sl@0
|
91 |
INS128;
|
sl@0
|
92 |
INS128;
|
sl@0
|
93 |
INS128;
|
sl@0
|
94 |
INS128;
|
sl@0
|
95 |
INS128;
|
sl@0
|
96 |
INS128;
|
sl@0
|
97 |
INS128;
|
sl@0
|
98 |
INS128;
|
sl@0
|
99 |
INS128;
|
sl@0
|
100 |
INS128;
|
sl@0
|
101 |
INS128;
|
sl@0
|
102 |
INS128;
|
sl@0
|
103 |
INS128;
|
sl@0
|
104 |
INS128;
|
sl@0
|
105 |
INS128;
|
sl@0
|
106 |
INS128;
|
sl@0
|
107 |
INS128;
|
sl@0
|
108 |
INS128;
|
sl@0
|
109 |
INS128;
|
sl@0
|
110 |
INS128;
|
sl@0
|
111 |
INS128;
|
sl@0
|
112 |
INS128;
|
sl@0
|
113 |
INS128;
|
sl@0
|
114 |
INS128;
|
sl@0
|
115 |
INS128;
|
sl@0
|
116 |
INS128;
|
sl@0
|
117 |
INS128;
|
sl@0
|
118 |
INS128;
|
sl@0
|
119 |
INS128;
|
sl@0
|
120 |
INS128;
|
sl@0
|
121 |
INS128;
|
sl@0
|
122 |
INS128;
|
sl@0
|
123 |
INS128;
|
sl@0
|
124 |
INS128;
|
sl@0
|
125 |
INS128;
|
sl@0
|
126 |
INS128;
|
sl@0
|
127 |
INS128;
|
sl@0
|
128 |
INS128;
|
sl@0
|
129 |
INS128;
|
sl@0
|
130 |
INS128;
|
sl@0
|
131 |
INS128;
|
sl@0
|
132 |
INS128;
|
sl@0
|
133 |
INS128;
|
sl@0
|
134 |
INS128;
|
sl@0
|
135 |
INS128;
|
sl@0
|
136 |
INS128;
|
sl@0
|
137 |
INS128;
|
sl@0
|
138 |
INS128;
|
sl@0
|
139 |
INS128;
|
sl@0
|
140 |
INS128;
|
sl@0
|
141 |
INS128;
|
sl@0
|
142 |
INS128;
|
sl@0
|
143 |
INS128;
|
sl@0
|
144 |
INS128;
|
sl@0
|
145 |
INS128;
|
sl@0
|
146 |
INS128;
|
sl@0
|
147 |
INS128;
|
sl@0
|
148 |
INS128;
|
sl@0
|
149 |
INS128;
|
sl@0
|
150 |
INS128;
|
sl@0
|
151 |
INS128;
|
sl@0
|
152 |
INS128;
|
sl@0
|
153 |
INS128;
|
sl@0
|
154 |
INS128;
|
sl@0
|
155 |
INS128;
|
sl@0
|
156 |
INS128;
|
sl@0
|
157 |
INS128;
|
sl@0
|
158 |
INS128;
|
sl@0
|
159 |
INS128;
|
sl@0
|
160 |
INS128;
|
sl@0
|
161 |
INS128;
|
sl@0
|
162 |
INS128;
|
sl@0
|
163 |
INS128;
|
sl@0
|
164 |
INS128;
|
sl@0
|
165 |
INS128;
|
sl@0
|
166 |
INS128;
|
sl@0
|
167 |
INS128;
|
sl@0
|
168 |
INS128;
|
sl@0
|
169 |
INS128;
|
sl@0
|
170 |
INS128;
|
sl@0
|
171 |
INS128;
|
sl@0
|
172 |
INS128;
|
sl@0
|
173 |
INS128;
|
sl@0
|
174 |
INS128;
|
sl@0
|
175 |
INS128;
|
sl@0
|
176 |
INS128;
|
sl@0
|
177 |
INS128;
|
sl@0
|
178 |
INS128;
|
sl@0
|
179 |
INS128;
|
sl@0
|
180 |
INS128;
|
sl@0
|
181 |
INS128;
|
sl@0
|
182 |
INS128;
|
sl@0
|
183 |
INS128;
|
sl@0
|
184 |
INS128;
|
sl@0
|
185 |
INS128;
|
sl@0
|
186 |
INS64;
|
sl@0
|
187 |
INS32;
|
sl@0
|
188 |
INS16;
|
sl@0
|
189 |
INS8;
|
sl@0
|
190 |
asm(".word 0xe1a00000,0xe1a01001,0xe1a02002 ");
|
sl@0
|
191 |
asm("add r3, r3, #1 "); // increment counter
|
sl@0
|
192 |
asm("str r3, [r1] "); // and store in aCount
|
sl@0
|
193 |
__JUMP(,r2); // branch back to start of loop
|
sl@0
|
194 |
asm("mov r0, r0 "); // two NOPs because of prefetch
|
sl@0
|
195 |
asm("mov r0, r0 ");
|
sl@0
|
196 |
asm("loopend: ");
|
sl@0
|
197 |
asm("get_function_end: ");
|
sl@0
|
198 |
asm("adr r0, memspeedtest_end ");
|
sl@0
|
199 |
__END_ARM;
|
sl@0
|
200 |
__JUMP(,lr);
|
sl@0
|
201 |
asm("memspeedtest_end: ");
|
sl@0
|
202 |
#elif defined(__CPU_X86)
|
sl@0
|
203 |
asm("mov ecx, [esp+4]"); // ecx=loop size
|
sl@0
|
204 |
asm("test ecx, ecx");
|
sl@0
|
205 |
asm("jz get_function_end"); // if zero, return function end address
|
sl@0
|
206 |
asm("mov edx, [esp+8]"); // edx=&aCount
|
sl@0
|
207 |
asm("lea ebx, loopend");
|
sl@0
|
208 |
asm("sub ebx, ecx"); // ebx=point to jump back to in loop
|
sl@0
|
209 |
asm("xor ecx, ecx"); // count of loops done
|
sl@0
|
210 |
asm("loopstart:"); // from here to loopend must be 64k bytes
|
sl@0
|
211 |
INS512;
|
sl@0
|
212 |
INS512;
|
sl@0
|
213 |
INS512;
|
sl@0
|
214 |
INS512;
|
sl@0
|
215 |
INS512;
|
sl@0
|
216 |
INS512;
|
sl@0
|
217 |
INS512;
|
sl@0
|
218 |
INS512;
|
sl@0
|
219 |
INS512;
|
sl@0
|
220 |
INS512;
|
sl@0
|
221 |
INS512;
|
sl@0
|
222 |
INS512;
|
sl@0
|
223 |
INS512;
|
sl@0
|
224 |
INS512;
|
sl@0
|
225 |
INS512;
|
sl@0
|
226 |
INS512;
|
sl@0
|
227 |
INS512;
|
sl@0
|
228 |
INS512;
|
sl@0
|
229 |
INS512;
|
sl@0
|
230 |
INS512;
|
sl@0
|
231 |
INS512;
|
sl@0
|
232 |
INS512;
|
sl@0
|
233 |
INS512;
|
sl@0
|
234 |
INS512;
|
sl@0
|
235 |
INS512;
|
sl@0
|
236 |
INS512;
|
sl@0
|
237 |
INS512;
|
sl@0
|
238 |
INS512;
|
sl@0
|
239 |
INS512;
|
sl@0
|
240 |
INS512;
|
sl@0
|
241 |
INS512;
|
sl@0
|
242 |
INS512;
|
sl@0
|
243 |
INS512;
|
sl@0
|
244 |
INS512;
|
sl@0
|
245 |
INS512;
|
sl@0
|
246 |
INS512;
|
sl@0
|
247 |
INS512;
|
sl@0
|
248 |
INS512;
|
sl@0
|
249 |
INS512;
|
sl@0
|
250 |
INS512;
|
sl@0
|
251 |
INS512;
|
sl@0
|
252 |
INS512;
|
sl@0
|
253 |
INS512;
|
sl@0
|
254 |
INS512;
|
sl@0
|
255 |
INS512;
|
sl@0
|
256 |
INS512;
|
sl@0
|
257 |
INS512;
|
sl@0
|
258 |
INS512;
|
sl@0
|
259 |
INS512;
|
sl@0
|
260 |
INS512;
|
sl@0
|
261 |
INS512;
|
sl@0
|
262 |
INS512;
|
sl@0
|
263 |
INS512;
|
sl@0
|
264 |
INS512;
|
sl@0
|
265 |
INS512;
|
sl@0
|
266 |
INS512;
|
sl@0
|
267 |
INS512;
|
sl@0
|
268 |
INS512;
|
sl@0
|
269 |
INS512;
|
sl@0
|
270 |
INS512;
|
sl@0
|
271 |
INS512;
|
sl@0
|
272 |
INS512;
|
sl@0
|
273 |
INS512;
|
sl@0
|
274 |
INS512;
|
sl@0
|
275 |
INS512;
|
sl@0
|
276 |
INS512;
|
sl@0
|
277 |
INS512;
|
sl@0
|
278 |
INS512;
|
sl@0
|
279 |
INS512;
|
sl@0
|
280 |
INS512;
|
sl@0
|
281 |
INS512;
|
sl@0
|
282 |
INS512;
|
sl@0
|
283 |
INS512;
|
sl@0
|
284 |
INS512;
|
sl@0
|
285 |
INS512;
|
sl@0
|
286 |
INS512;
|
sl@0
|
287 |
INS512;
|
sl@0
|
288 |
INS512;
|
sl@0
|
289 |
INS512;
|
sl@0
|
290 |
INS512;
|
sl@0
|
291 |
INS512;
|
sl@0
|
292 |
INS512;
|
sl@0
|
293 |
INS512;
|
sl@0
|
294 |
INS512;
|
sl@0
|
295 |
INS512;
|
sl@0
|
296 |
INS512;
|
sl@0
|
297 |
INS512;
|
sl@0
|
298 |
INS512;
|
sl@0
|
299 |
INS512;
|
sl@0
|
300 |
INS512;
|
sl@0
|
301 |
INS512;
|
sl@0
|
302 |
INS512;
|
sl@0
|
303 |
INS512;
|
sl@0
|
304 |
INS512;
|
sl@0
|
305 |
INS512;
|
sl@0
|
306 |
INS512;
|
sl@0
|
307 |
INS512;
|
sl@0
|
308 |
INS512;
|
sl@0
|
309 |
INS512;
|
sl@0
|
310 |
INS512;
|
sl@0
|
311 |
INS512;
|
sl@0
|
312 |
INS512;
|
sl@0
|
313 |
INS512;
|
sl@0
|
314 |
INS512;
|
sl@0
|
315 |
INS512;
|
sl@0
|
316 |
INS512;
|
sl@0
|
317 |
INS512;
|
sl@0
|
318 |
INS512;
|
sl@0
|
319 |
INS512;
|
sl@0
|
320 |
INS512;
|
sl@0
|
321 |
INS512;
|
sl@0
|
322 |
INS512;
|
sl@0
|
323 |
INS512;
|
sl@0
|
324 |
INS512;
|
sl@0
|
325 |
INS512;
|
sl@0
|
326 |
INS512;
|
sl@0
|
327 |
INS512;
|
sl@0
|
328 |
INS512;
|
sl@0
|
329 |
INS512;
|
sl@0
|
330 |
INS512;
|
sl@0
|
331 |
INS512;
|
sl@0
|
332 |
INS512;
|
sl@0
|
333 |
INS512;
|
sl@0
|
334 |
INS512;
|
sl@0
|
335 |
INS512;
|
sl@0
|
336 |
INS512;
|
sl@0
|
337 |
INS512;
|
sl@0
|
338 |
INS256;
|
sl@0
|
339 |
INS128;
|
sl@0
|
340 |
INS64;
|
sl@0
|
341 |
INS32;
|
sl@0
|
342 |
INS16;
|
sl@0
|
343 |
INS8;
|
sl@0
|
344 |
asm("inc ecx"); // increment loop counter
|
sl@0
|
345 |
asm("mov [edx], ecx"); // update aCount
|
sl@0
|
346 |
asm("jmp ebx"); // jump back
|
sl@0
|
347 |
asm("nop");
|
sl@0
|
348 |
asm("nop");
|
sl@0
|
349 |
asm("nop");
|
sl@0
|
350 |
asm("loopend:");
|
sl@0
|
351 |
asm("get_function_end:");
|
sl@0
|
352 |
asm("lea eax, memspeedtest_end");
|
sl@0
|
353 |
asm("ret");
|
sl@0
|
354 |
asm("memspeedtest_end:");
|
sl@0
|
355 |
#endif
|
sl@0
|
356 |
}
|
sl@0
|
357 |
|