First public contribution.
1 // Copyright (c) 2006-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\mmu\d_cache.cia
15 // See e32test\mmu\t_cache.cpp for details
20 #ifndef __KERNEL_MODE__
27 #if defined(__CPU_ARMV7)
28 /**Returns Cache Type Register content*/
29 __NAKED__ TUint32 CacheTypeRegister()
31 asm("mrc p15, 0, r0, c0, c0, 1 ");
35 /**Returns Cache Level ID Register content*/
36 __NAKED__ TUint32 CacheLevelIDRegister()
38 asm("mrc p15, 1, r0, c0, c0, 1 ");
43 Returns Cache Size Id Register content for the given cache level/type
44 @param aType Cache type: 0=data/unified, 1=code
45 @param aLevel Cache level: 0=Level1 ... 7=Level8
47 __NAKED__ TUint32 CacheSizeIdRegister(TUint32 /*aType*/, TUint32 /*aLevel*/)
49 asm("orr r0, r1, lsl #1"); // r0 = entry for Cache Size Selection Reg.
50 asm("mcr p15, 2, r0, c0, c0, 0 "); // set Cache Size Selection Register
52 asm("mrc p15, 1, r0, c0, c0, 0 "); // read Cache Size Id Register
58 #if defined(__CPU_MEMORY_TYPE_REMAPPING)
59 /** Returns Coprocessor Control Register*/
60 __NAKED__ TUint32 CtrlRegister()
62 asm("mrc p15, 0, r0, c1, c0, 0 ");//read CR reg.
66 /** Returns PRRR Register*/
67 __NAKED__ TUint32 PRRRRegister()
69 asm("mrc p15, 0, r0, c10, c2, 0 ");
73 /** Returns NRRR Register*/
74 __NAKED__ TUint32 NRRRRegister()
76 asm("mrc p15, 0, r0, c10, c2, 1 ");
80 /** Sets PRRR Register*/
81 __NAKED__ void SetPRRR(TUint32)
83 asm("mcr p15, 0, r0, c10, c2, 0 ");
84 #if defined(__CPU_ARMV7)
93 /** Sets NRRR Register*/
94 __NAKED__ void SetNRRR(TUint32)
96 asm("mcr p15, 0, r0, c10, c2, 1 ");
103 #ifdef __CPU_HAS_CACHE_TYPE_REGISTER
104 __NAKED__ TUint32 GetCacheType()
106 asm("mrc p15, 0, r0, c0, c0, 1 ");
112 #ifdef __XSCALE_L2_CACHE__
113 /** Returns L2 Cache Type Register Content */
114 __NAKED__ TUint32 L2CacheTypeReg()
116 asm("mrc p15, 1, r0, c0, c0, 1 ");
119 #endif // __XSCALE_L2_CACHE__
151 __NAKED__ void TestCodeFunc()
153 asm("testcodestart: ");
154 NOP_512(); //512 nops * 4 bytes/nop = 2K (800h) of code
155 __JUMP(,lr); //+ 4 bytes
156 asm("testcodeend: ");
159 __NAKED__ TInt TestCodeFuncSize()
161 asm("ldr r0, = testcodeend - testcodestart"); //This should return 804h
165 #endif //#ifdef __KERNEL_MODE__
167 // It assumes that aSize and aBase are aligned to 4 bytes. Also, aSize must be > 0.
168 __NAKED__ void DataSegmetTestFunct(void* /*aBase*/, TInt /*aSize*/)
170 asm("add r1,r1,r0"); // r1 = end address (excluding)
171 asm("mov r2, #50"); // Will take 50 cycles
172 asm("mvn r12, #1"); // r12 = -2
176 asm("mov r3, r0"); // r3 = aBase
178 asm("str r12, [r3],#4");
181 asm("blo write_loop");
183 asm("mov r3, r0"); // r3 = aBase
185 asm("ldr r12, [r3],#4");
187 asm("blo read_loop");
189 asm("subs r2,r2,#1");
190 asm("bne next_cycle");