sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\debug\d_debugapi.cia sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include "d_debugapi.h" sl@0: sl@0: __NAKED__ TInt DDebugAPIChecker::ReadFromOtherProcessArmv6() sl@0: { sl@0: sl@0: //Save regs. sl@0: asm("stmfd sp!,{r4-r7,lr}"); sl@0: sl@0: //Copy all data we need into regs. We can not access the memory of ... sl@0: //...the current process once we start changing MMU content. sl@0: asm("ldr r1, [r0, #%a0]" : : "i" _FOFF(DDebugAPIChecker, iOtherProcess_OsAsid)); sl@0: asm("ldr r2, [r0, #%a0]" : : "i" _FOFF(DDebugAPIChecker, iOtherProcess_LocalPageDir)); sl@0: asm("ldr r3, [r0, #%a0]" : : "i" _FOFF(DDebugAPIChecker, iCurrentProcess_OsAsid)); sl@0: asm("ldr r4, [r0, #%a0]" : : "i" _FOFF(DDebugAPIChecker, iCurrentProcess_LocalPageDir)); sl@0: asm("ldr r5, [r0, #%a0]" : : "i" _FOFF(DDebugAPIChecker, iAddress)); sl@0: sl@0: asm("mrc p15, 0, r6, c2, c0, 0 "); sl@0: asm("and r6, r6, #0x7f "); // r6 = page table cache/sharing attributes sl@0: asm("orr r2, r2, r6 "); // add in to other process page directory address sl@0: asm("orr r4, r4, r6 "); // add in to this process page directory address sl@0: asm("mov r6, #0 "); sl@0: sl@0: //Disable interrupts sl@0: asm("mov r7, #0xd3 "); sl@0: asm("msr cpsr, r7 "); sl@0: sl@0: //Switch MMU to the-other-process sl@0: asm("mcr p15, 0, r6, c7, c10, 4 "); // drain write buffer before changing MMU registers (see ARMv6 specs) sl@0: //! asm("orr r2, r2 #0x18"); //Uncomment this line on 1136 (r0p2) with L2 cache due to Erratum 317041. sl@0: asm("mcr p15, 0, r2, c2, c0, 0 "); // set TTBR0 - no TLB flush required due to ASID sl@0: asm("mcr p15, 0, r1, c13, c0, 1 "); // set ASID sl@0: sl@0: //Read the memory from the-other-process sl@0: asm("ldr r0, [r5]"); sl@0: sl@0: //Switch MMU back to the-current-process sl@0: asm("mcr p15, 0, r6, c7, c10, 4 "); // drain write buffer before changing MMU registers (see ARMv6 specs) sl@0: //! asm("orr r4, r4 #0x18"); //Uncomment this line on 1136 (r0p2) with L2 cache due to Erratum 317041. sl@0: asm("mcr p15, 0, r4, c2, c0, 0 "); // set TTBR0 - no TLB flush required due to ASID sl@0: asm("mcr p15, 0, r3, c13, c0, 1 "); // set ASID sl@0: sl@0: sl@0: //Re-enable interrupts sl@0: asm("mov r7, #0x13 "); sl@0: asm("msr cpsr, r7 "); sl@0: sl@0: //Return sl@0: asm("ldmfd sp!,{r4-r7,pc}"); sl@0: }