1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/misc/cpumeter.cia Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,256 @@
1.4 +// Copyright (c) 1996-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\misc\cpumeter.cia
1.18 +//
1.19 +//
1.20 +
1.21 +#include <e32test.h>
1.22 +#include <e32hal.h>
1.23 +#include <u32std.h>
1.24 +
1.25 +extern TUint32 NopCount;
1.26 +extern TUint MaxCycles;
1.27 +
1.28 +#if defined(__CPU_ARM)
1.29 +__NAKED__ TInt CountNops(TAny*)
1.30 + {
1.31 + __SWITCH_TO_ARM;
1.32 + asm("ldr r0, __NopCount ");
1.33 + asm("mov r1, #0 ");
1.34 +
1.35 + asm("loop: ");
1.36 + asm("mov r0, r0 ");
1.37 + asm("mov r0, r0 ");
1.38 + asm("mov r0, r0 ");
1.39 + asm("mov r0, r0 ");
1.40 + asm("mov r0, r0 ");
1.41 + asm("mov r0, r0 ");
1.42 + asm("mov r0, r0 ");
1.43 + asm("mov r0, r0 ");
1.44 + asm("mov r0, r0 ");
1.45 + asm("mov r0, r0 ");
1.46 + asm("mov r0, r0 ");
1.47 + asm("mov r0, r0 ");
1.48 + asm("mov r0, r0 ");
1.49 + asm("mov r0, r0 ");
1.50 + asm("mov r0, r0 ");
1.51 + asm("mov r0, r0 ");
1.52 + asm("mov r0, r0 ");
1.53 + asm("mov r0, r0 ");
1.54 + asm("mov r0, r0 ");
1.55 + asm("mov r0, r0 ");
1.56 + asm("mov r0, r0 ");
1.57 + asm("mov r0, r0 ");
1.58 + asm("mov r0, r0 ");
1.59 + asm("mov r0, r0 ");
1.60 + asm("mov r0, r0 ");
1.61 + asm("mov r0, r0 ");
1.62 + asm("mov r0, r0 ");
1.63 + asm("mov r0, r0 ");
1.64 + asm("mov r0, r0 ");
1.65 + asm("mov r0, r0 ");
1.66 + asm("mov r0, r0 ");
1.67 + asm("mov r0, r0 ");
1.68 + asm("mov r0, r0 ");
1.69 + asm("mov r0, r0 ");
1.70 + asm("mov r0, r0 ");
1.71 + asm("mov r0, r0 ");
1.72 + asm("mov r0, r0 ");
1.73 + asm("mov r0, r0 ");
1.74 + asm("mov r0, r0 ");
1.75 + asm("mov r0, r0 ");
1.76 + asm("mov r0, r0 ");
1.77 + asm("mov r0, r0 ");
1.78 + asm("mov r0, r0 ");
1.79 + asm("mov r0, r0 ");
1.80 + asm("mov r0, r0 ");
1.81 + asm("mov r0, r0 ");
1.82 + asm("mov r0, r0 ");
1.83 + asm("mov r0, r0 ");
1.84 + asm("mov r0, r0 ");
1.85 + asm("mov r0, r0 ");
1.86 + asm("mov r0, r0 ");
1.87 + asm("mov r0, r0 ");
1.88 + asm("mov r0, r0 ");
1.89 + asm("mov r0, r0 ");
1.90 + asm("mov r0, r0 ");
1.91 + asm("mov r0, r0 ");
1.92 + asm("mov r0, r0 ");
1.93 + asm("mov r0, r0 ");
1.94 + asm("mov r0, r0 ");
1.95 + asm("mov r0, r0 ");
1.96 + asm("mov r0, r0 ");
1.97 + asm("mov r0, r0 ");
1.98 + asm("mov r0, r0 ");
1.99 + asm("mov r0, r0 ");
1.100 + asm("add r1, r1, #71 ");
1.101 + asm("str r1, [r0] ");
1.102 + asm("b loop ");
1.103 +
1.104 + asm("mov r0, #0 ");
1.105 + __JUMP(,lr);
1.106 +
1.107 + asm("__NopCount: ");
1.108 + asm(".word NopCount ");
1.109 + __END_ARM;
1.110 + }
1.111 +#elif defined(__CPU_X86)
1.112 +__NAKED__ TInt CountNops(TAny*)
1.113 + {
1.114 +#ifdef __WINS__
1.115 + __asm lea edx, NopCount
1.116 + __asm mov eax, 0
1.117 +noploop:
1.118 + __asm inc eax
1.119 + __asm inc eax
1.120 + __asm inc eax
1.121 + __asm inc eax
1.122 + __asm inc eax
1.123 + __asm inc eax
1.124 + __asm inc eax
1.125 + __asm inc eax
1.126 + __asm inc eax
1.127 + __asm inc eax
1.128 + __asm inc eax
1.129 + __asm inc eax
1.130 + __asm inc eax
1.131 + __asm inc eax
1.132 + __asm inc eax
1.133 + __asm inc eax
1.134 + __asm inc eax
1.135 + __asm inc eax
1.136 + __asm inc eax
1.137 + __asm inc eax
1.138 + __asm inc eax
1.139 + __asm inc eax
1.140 + __asm inc eax
1.141 + __asm inc eax
1.142 + __asm inc eax
1.143 + __asm inc eax
1.144 + __asm inc eax
1.145 + __asm inc eax
1.146 + __asm inc eax
1.147 + __asm inc eax
1.148 + __asm inc eax
1.149 + __asm inc eax
1.150 + __asm inc eax
1.151 + __asm inc eax
1.152 + __asm inc eax
1.153 + __asm inc eax
1.154 + __asm inc eax
1.155 + __asm inc eax
1.156 + __asm inc eax
1.157 + __asm inc eax
1.158 + __asm inc eax
1.159 + __asm inc eax
1.160 + __asm inc eax
1.161 + __asm inc eax
1.162 + __asm inc eax
1.163 + __asm inc eax
1.164 + __asm inc eax
1.165 + __asm inc eax
1.166 + __asm inc eax
1.167 + __asm inc eax
1.168 + __asm inc eax
1.169 + __asm inc eax
1.170 + __asm inc eax
1.171 + __asm inc eax
1.172 + __asm inc eax
1.173 + __asm inc eax
1.174 + __asm inc eax
1.175 + __asm inc eax
1.176 + __asm inc eax
1.177 + __asm inc eax
1.178 + __asm inc eax
1.179 + __asm inc eax
1.180 + __asm inc eax
1.181 + __asm inc eax
1.182 + __asm add eax, 3
1.183 + __asm mov [edx], eax
1.184 + __asm jmp noploop
1.185 +#else
1.186 + asm("mov edx, %a0": : "i"(&NopCount));
1.187 + asm("mov eax, 0");
1.188 + asm("noploop:");
1.189 + asm("inc eax");
1.190 + asm("inc eax");
1.191 + asm("inc eax");
1.192 + asm("inc eax");
1.193 + asm("inc eax");
1.194 + asm("inc eax");
1.195 + asm("inc eax");
1.196 + asm("inc eax");
1.197 + asm("inc eax");
1.198 + asm("inc eax");
1.199 + asm("inc eax");
1.200 + asm("inc eax");
1.201 + asm("inc eax");
1.202 + asm("inc eax");
1.203 + asm("inc eax");
1.204 + asm("inc eax");
1.205 + asm("inc eax");
1.206 + asm("inc eax");
1.207 + asm("inc eax");
1.208 + asm("inc eax");
1.209 + asm("inc eax");
1.210 + asm("inc eax");
1.211 + asm("inc eax");
1.212 + asm("inc eax");
1.213 + asm("inc eax");
1.214 + asm("inc eax");
1.215 + asm("inc eax");
1.216 + asm("inc eax");
1.217 + asm("inc eax");
1.218 + asm("inc eax");
1.219 + asm("inc eax");
1.220 + asm("inc eax");
1.221 + asm("inc eax");
1.222 + asm("inc eax");
1.223 + asm("inc eax");
1.224 + asm("inc eax");
1.225 + asm("inc eax");
1.226 + asm("inc eax");
1.227 + asm("inc eax");
1.228 + asm("inc eax");
1.229 + asm("inc eax");
1.230 + asm("inc eax");
1.231 + asm("inc eax");
1.232 + asm("inc eax");
1.233 + asm("inc eax");
1.234 + asm("inc eax");
1.235 + asm("inc eax");
1.236 + asm("inc eax");
1.237 + asm("inc eax");
1.238 + asm("inc eax");
1.239 + asm("inc eax");
1.240 + asm("inc eax");
1.241 + asm("inc eax");
1.242 + asm("inc eax");
1.243 + asm("inc eax");
1.244 + asm("inc eax");
1.245 + asm("inc eax");
1.246 + asm("inc eax");
1.247 + asm("inc eax");
1.248 + asm("inc eax");
1.249 + asm("inc eax");
1.250 + asm("inc eax");
1.251 + asm("inc eax");
1.252 + asm("inc eax");
1.253 + asm("add eax, 3");
1.254 + asm("mov [edx], eax");
1.255 + asm("jmp noploop");
1.256 +#endif
1.257 + }
1.258 +#endif
1.259 +