0
|
1 |
// Copyright (c) 2005-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\debug\d_debugapi.cia
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include <arm.h>
|
|
19 |
#include "d_debugapi.h"
|
|
20 |
|
|
21 |
__NAKED__ TInt DDebugAPIChecker::ReadFromOtherProcessArmv6()
|
|
22 |
{
|
|
23 |
|
|
24 |
//Save regs.
|
|
25 |
asm("stmfd sp!,{r4-r7,lr}");
|
|
26 |
|
|
27 |
//Copy all data we need into regs. We can not access the memory of ...
|
|
28 |
//...the current process once we start changing MMU content.
|
|
29 |
asm("ldr r1, [r0, #%a0]" : : "i" _FOFF(DDebugAPIChecker, iOtherProcess_OsAsid));
|
|
30 |
asm("ldr r2, [r0, #%a0]" : : "i" _FOFF(DDebugAPIChecker, iOtherProcess_LocalPageDir));
|
|
31 |
asm("ldr r3, [r0, #%a0]" : : "i" _FOFF(DDebugAPIChecker, iCurrentProcess_OsAsid));
|
|
32 |
asm("ldr r4, [r0, #%a0]" : : "i" _FOFF(DDebugAPIChecker, iCurrentProcess_LocalPageDir));
|
|
33 |
asm("ldr r5, [r0, #%a0]" : : "i" _FOFF(DDebugAPIChecker, iAddress));
|
|
34 |
|
|
35 |
asm("mrc p15, 0, r6, c2, c0, 0 ");
|
|
36 |
asm("and r6, r6, #0x7f "); // r6 = page table cache/sharing attributes
|
|
37 |
asm("orr r2, r2, r6 "); // add in to other process page directory address
|
|
38 |
asm("orr r4, r4, r6 "); // add in to this process page directory address
|
|
39 |
asm("mov r6, #0 ");
|
|
40 |
|
|
41 |
//Disable interrupts
|
|
42 |
asm("mov r7, #0xd3 ");
|
|
43 |
asm("msr cpsr, r7 ");
|
|
44 |
|
|
45 |
//Switch MMU to the-other-process
|
|
46 |
asm("mcr p15, 0, r6, c7, c10, 4 "); // drain write buffer before changing MMU registers (see ARMv6 specs)
|
|
47 |
//! asm("orr r2, r2 #0x18"); //Uncomment this line on 1136 (r0p2) with L2 cache due to Erratum 317041.
|
|
48 |
asm("mcr p15, 0, r2, c2, c0, 0 "); // set TTBR0 - no TLB flush required due to ASID
|
|
49 |
asm("mcr p15, 0, r1, c13, c0, 1 "); // set ASID
|
|
50 |
|
|
51 |
//Read the memory from the-other-process
|
|
52 |
asm("ldr r0, [r5]");
|
|
53 |
|
|
54 |
//Switch MMU back to the-current-process
|
|
55 |
asm("mcr p15, 0, r6, c7, c10, 4 "); // drain write buffer before changing MMU registers (see ARMv6 specs)
|
|
56 |
//! asm("orr r4, r4 #0x18"); //Uncomment this line on 1136 (r0p2) with L2 cache due to Erratum 317041.
|
|
57 |
asm("mcr p15, 0, r4, c2, c0, 0 "); // set TTBR0 - no TLB flush required due to ASID
|
|
58 |
asm("mcr p15, 0, r3, c13, c0, 1 "); // set ASID
|
|
59 |
|
|
60 |
|
|
61 |
//Re-enable interrupts
|
|
62 |
asm("mov r7, #0x13 ");
|
|
63 |
asm("msr cpsr, r7 ");
|
|
64 |
|
|
65 |
//Return
|
|
66 |
asm("ldmfd sp!,{r4-r7,pc}");
|
|
67 |
}
|