1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/mmu/t_mwait.cia Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,357 @@
1.4 +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// e32test\mmu\t_mwait.cia
1.18 +//
1.19 +//
1.20 +
1.21 +#include <e32test.h>
1.22 +#include <u32std.h>
1.23 +#include "d_shadow.h"
1.24 +
1.25 +#if defined(__CPU_ARM)
1.26 +#define INS8 asm(".word 0xe1a00000,0xe1a01001,0xe1a02002,0xe1a03003,0xe1a00000,0xe1a01001,0xe1a02002,0xe1a03003 ")
1.27 +#define INS16 INS8 ; INS8
1.28 +#define INS32 INS16 ; INS16
1.29 +#define INS64 INS32 ; INS32
1.30 +#define INS128 INS64 ; INS64
1.31 +#elif defined(__CPU_X86)
1.32 +#ifdef __GCC32__
1.33 +#define INC_EAX asm("inc eax");
1.34 +#else
1.35 +#define INC_EAX __asm inc eax
1.36 +#endif
1.37 +#define INS4 INC_EAX \
1.38 + INC_EAX \
1.39 + INC_EAX \
1.40 + INC_EAX
1.41 +#define INS8 INS4 INS4
1.42 +#define INS16 INS8 INS8
1.43 +#define INS32 INS16 INS16
1.44 +#define INS64 INS32 INS32
1.45 +#define INS128 INS64 INS64
1.46 +#define INS256 INS128 INS128
1.47 +#define INS512 INS256 INS256
1.48 +#endif
1.49 +
1.50 +__NAKED__ TLinAddr MemSpeedTest(TInt /*aLoopSize*/, TInt& /*aCount*/)
1.51 + {
1.52 +#if defined(__CPU_ARM)
1.53 + asm("memspeedtest: ");
1.54 + __SWITCH_TO_ARM;
1.55 + asm("movs r0, r0 ");
1.56 + asm("beq get_function_end "); // if loopsize=0, return end address of this function
1.57 + asm("mov r3, r3 ");
1.58 + asm("mov r3, #0 "); // count of how many loops done
1.59 + asm("adr r2, loopend ");
1.60 + asm("sub r2, r2, r0 "); // r2=point to branch back to in loop
1.61 + asm("loopstart: "); // from here to loopend must be 64k bytes
1.62 + INS128;
1.63 + INS128;
1.64 + INS128;
1.65 + INS128;
1.66 + INS128;
1.67 + INS128;
1.68 + INS128;
1.69 + INS128;
1.70 + INS128;
1.71 + INS128;
1.72 + INS128;
1.73 + INS128;
1.74 + INS128;
1.75 + INS128;
1.76 + INS128;
1.77 + INS128;
1.78 + INS128;
1.79 + INS128;
1.80 + INS128;
1.81 + INS128;
1.82 + INS128;
1.83 + INS128;
1.84 + INS128;
1.85 + INS128;
1.86 + INS128;
1.87 + INS128;
1.88 + INS128;
1.89 + INS128;
1.90 + INS128;
1.91 + INS128;
1.92 + INS128;
1.93 + INS128;
1.94 + INS128;
1.95 + INS128;
1.96 + INS128;
1.97 + INS128;
1.98 + INS128;
1.99 + INS128;
1.100 + INS128;
1.101 + INS128;
1.102 + INS128;
1.103 + INS128;
1.104 + INS128;
1.105 + INS128;
1.106 + INS128;
1.107 + INS128;
1.108 + INS128;
1.109 + INS128;
1.110 + INS128;
1.111 + INS128;
1.112 + INS128;
1.113 + INS128;
1.114 + INS128;
1.115 + INS128;
1.116 + INS128;
1.117 + INS128;
1.118 + INS128;
1.119 + INS128;
1.120 + INS128;
1.121 + INS128;
1.122 + INS128;
1.123 + INS128;
1.124 + INS128;
1.125 + INS128;
1.126 + INS128;
1.127 + INS128;
1.128 + INS128;
1.129 + INS128;
1.130 + INS128;
1.131 + INS128;
1.132 + INS128;
1.133 + INS128;
1.134 + INS128;
1.135 + INS128;
1.136 + INS128;
1.137 + INS128;
1.138 + INS128;
1.139 + INS128;
1.140 + INS128;
1.141 + INS128;
1.142 + INS128;
1.143 + INS128;
1.144 + INS128;
1.145 + INS128;
1.146 + INS128;
1.147 + INS128;
1.148 + INS128;
1.149 + INS128;
1.150 + INS128;
1.151 + INS128;
1.152 + INS128;
1.153 + INS128;
1.154 + INS128;
1.155 + INS128;
1.156 + INS128;
1.157 + INS128;
1.158 + INS128;
1.159 + INS128;
1.160 + INS128;
1.161 + INS128;
1.162 + INS128;
1.163 + INS128;
1.164 + INS128;
1.165 + INS128;
1.166 + INS128;
1.167 + INS128;
1.168 + INS128;
1.169 + INS128;
1.170 + INS128;
1.171 + INS128;
1.172 + INS128;
1.173 + INS128;
1.174 + INS128;
1.175 + INS128;
1.176 + INS128;
1.177 + INS128;
1.178 + INS128;
1.179 + INS128;
1.180 + INS128;
1.181 + INS128;
1.182 + INS128;
1.183 + INS128;
1.184 + INS128;
1.185 + INS128;
1.186 + INS128;
1.187 + INS128;
1.188 + INS128;
1.189 + INS64;
1.190 + INS32;
1.191 + INS16;
1.192 + INS8;
1.193 + asm(".word 0xe1a00000,0xe1a01001,0xe1a02002 ");
1.194 + asm("add r3, r3, #1 "); // increment counter
1.195 + asm("str r3, [r1] "); // and store in aCount
1.196 + __JUMP(,r2); // branch back to start of loop
1.197 + asm("mov r0, r0 "); // two NOPs because of prefetch
1.198 + asm("mov r0, r0 ");
1.199 + asm("loopend: ");
1.200 + asm("get_function_end: ");
1.201 + asm("adr r0, memspeedtest_end ");
1.202 + __END_ARM;
1.203 + __JUMP(,lr);
1.204 + asm("memspeedtest_end: ");
1.205 +#elif defined(__CPU_X86)
1.206 + asm("mov ecx, [esp+4]"); // ecx=loop size
1.207 + asm("test ecx, ecx");
1.208 + asm("jz get_function_end"); // if zero, return function end address
1.209 + asm("mov edx, [esp+8]"); // edx=&aCount
1.210 + asm("lea ebx, loopend");
1.211 + asm("sub ebx, ecx"); // ebx=point to jump back to in loop
1.212 + asm("xor ecx, ecx"); // count of loops done
1.213 + asm("loopstart:"); // from here to loopend must be 64k bytes
1.214 + INS512;
1.215 + INS512;
1.216 + INS512;
1.217 + INS512;
1.218 + INS512;
1.219 + INS512;
1.220 + INS512;
1.221 + INS512;
1.222 + INS512;
1.223 + INS512;
1.224 + INS512;
1.225 + INS512;
1.226 + INS512;
1.227 + INS512;
1.228 + INS512;
1.229 + INS512;
1.230 + INS512;
1.231 + INS512;
1.232 + INS512;
1.233 + INS512;
1.234 + INS512;
1.235 + INS512;
1.236 + INS512;
1.237 + INS512;
1.238 + INS512;
1.239 + INS512;
1.240 + INS512;
1.241 + INS512;
1.242 + INS512;
1.243 + INS512;
1.244 + INS512;
1.245 + INS512;
1.246 + INS512;
1.247 + INS512;
1.248 + INS512;
1.249 + INS512;
1.250 + INS512;
1.251 + INS512;
1.252 + INS512;
1.253 + INS512;
1.254 + INS512;
1.255 + INS512;
1.256 + INS512;
1.257 + INS512;
1.258 + INS512;
1.259 + INS512;
1.260 + INS512;
1.261 + INS512;
1.262 + INS512;
1.263 + INS512;
1.264 + INS512;
1.265 + INS512;
1.266 + INS512;
1.267 + INS512;
1.268 + INS512;
1.269 + INS512;
1.270 + INS512;
1.271 + INS512;
1.272 + INS512;
1.273 + INS512;
1.274 + INS512;
1.275 + INS512;
1.276 + INS512;
1.277 + INS512;
1.278 + INS512;
1.279 + INS512;
1.280 + INS512;
1.281 + INS512;
1.282 + INS512;
1.283 + INS512;
1.284 + INS512;
1.285 + INS512;
1.286 + INS512;
1.287 + INS512;
1.288 + INS512;
1.289 + INS512;
1.290 + INS512;
1.291 + INS512;
1.292 + INS512;
1.293 + INS512;
1.294 + INS512;
1.295 + INS512;
1.296 + INS512;
1.297 + INS512;
1.298 + INS512;
1.299 + INS512;
1.300 + INS512;
1.301 + INS512;
1.302 + INS512;
1.303 + INS512;
1.304 + INS512;
1.305 + INS512;
1.306 + INS512;
1.307 + INS512;
1.308 + INS512;
1.309 + INS512;
1.310 + INS512;
1.311 + INS512;
1.312 + INS512;
1.313 + INS512;
1.314 + INS512;
1.315 + INS512;
1.316 + INS512;
1.317 + INS512;
1.318 + INS512;
1.319 + INS512;
1.320 + INS512;
1.321 + INS512;
1.322 + INS512;
1.323 + INS512;
1.324 + INS512;
1.325 + INS512;
1.326 + INS512;
1.327 + INS512;
1.328 + INS512;
1.329 + INS512;
1.330 + INS512;
1.331 + INS512;
1.332 + INS512;
1.333 + INS512;
1.334 + INS512;
1.335 + INS512;
1.336 + INS512;
1.337 + INS512;
1.338 + INS512;
1.339 + INS512;
1.340 + INS512;
1.341 + INS256;
1.342 + INS128;
1.343 + INS64;
1.344 + INS32;
1.345 + INS16;
1.346 + INS8;
1.347 + asm("inc ecx"); // increment loop counter
1.348 + asm("mov [edx], ecx"); // update aCount
1.349 + asm("jmp ebx"); // jump back
1.350 + asm("nop");
1.351 + asm("nop");
1.352 + asm("nop");
1.353 + asm("loopend:");
1.354 + asm("get_function_end:");
1.355 + asm("lea eax, memspeedtest_end");
1.356 + asm("ret");
1.357 + asm("memspeedtest_end:");
1.358 +#endif
1.359 + }
1.360 +