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