sl@0
|
1 |
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// e32test\debug\d_debugapi.cia
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <arm.h>
|
sl@0
|
19 |
#include "d_debugapi.h"
|
sl@0
|
20 |
|
sl@0
|
21 |
__NAKED__ TInt DDebugAPIChecker::ReadFromOtherProcessArmv6()
|
sl@0
|
22 |
{
|
sl@0
|
23 |
|
sl@0
|
24 |
//Save regs.
|
sl@0
|
25 |
asm("stmfd sp!,{r4-r7,lr}");
|
sl@0
|
26 |
|
sl@0
|
27 |
//Copy all data we need into regs. We can not access the memory of ...
|
sl@0
|
28 |
//...the current process once we start changing MMU content.
|
sl@0
|
29 |
asm("ldr r1, [r0, #%a0]" : : "i" _FOFF(DDebugAPIChecker, iOtherProcess_OsAsid));
|
sl@0
|
30 |
asm("ldr r2, [r0, #%a0]" : : "i" _FOFF(DDebugAPIChecker, iOtherProcess_LocalPageDir));
|
sl@0
|
31 |
asm("ldr r3, [r0, #%a0]" : : "i" _FOFF(DDebugAPIChecker, iCurrentProcess_OsAsid));
|
sl@0
|
32 |
asm("ldr r4, [r0, #%a0]" : : "i" _FOFF(DDebugAPIChecker, iCurrentProcess_LocalPageDir));
|
sl@0
|
33 |
asm("ldr r5, [r0, #%a0]" : : "i" _FOFF(DDebugAPIChecker, iAddress));
|
sl@0
|
34 |
|
sl@0
|
35 |
asm("mrc p15, 0, r6, c2, c0, 0 ");
|
sl@0
|
36 |
asm("and r6, r6, #0x7f "); // r6 = page table cache/sharing attributes
|
sl@0
|
37 |
asm("orr r2, r2, r6 "); // add in to other process page directory address
|
sl@0
|
38 |
asm("orr r4, r4, r6 "); // add in to this process page directory address
|
sl@0
|
39 |
asm("mov r6, #0 ");
|
sl@0
|
40 |
|
sl@0
|
41 |
//Disable interrupts
|
sl@0
|
42 |
asm("mov r7, #0xd3 ");
|
sl@0
|
43 |
asm("msr cpsr, r7 ");
|
sl@0
|
44 |
|
sl@0
|
45 |
//Switch MMU to the-other-process
|
sl@0
|
46 |
asm("mcr p15, 0, r6, c7, c10, 4 "); // drain write buffer before changing MMU registers (see ARMv6 specs)
|
sl@0
|
47 |
//! asm("orr r2, r2 #0x18"); //Uncomment this line on 1136 (r0p2) with L2 cache due to Erratum 317041.
|
sl@0
|
48 |
asm("mcr p15, 0, r2, c2, c0, 0 "); // set TTBR0 - no TLB flush required due to ASID
|
sl@0
|
49 |
asm("mcr p15, 0, r1, c13, c0, 1 "); // set ASID
|
sl@0
|
50 |
|
sl@0
|
51 |
//Read the memory from the-other-process
|
sl@0
|
52 |
asm("ldr r0, [r5]");
|
sl@0
|
53 |
|
sl@0
|
54 |
//Switch MMU back to the-current-process
|
sl@0
|
55 |
asm("mcr p15, 0, r6, c7, c10, 4 "); // drain write buffer before changing MMU registers (see ARMv6 specs)
|
sl@0
|
56 |
//! asm("orr r4, r4 #0x18"); //Uncomment this line on 1136 (r0p2) with L2 cache due to Erratum 317041.
|
sl@0
|
57 |
asm("mcr p15, 0, r4, c2, c0, 0 "); // set TTBR0 - no TLB flush required due to ASID
|
sl@0
|
58 |
asm("mcr p15, 0, r3, c13, c0, 1 "); // set ASID
|
sl@0
|
59 |
|
sl@0
|
60 |
|
sl@0
|
61 |
//Re-enable interrupts
|
sl@0
|
62 |
asm("mov r7, #0x13 ");
|
sl@0
|
63 |
asm("msr cpsr, r7 ");
|
sl@0
|
64 |
|
sl@0
|
65 |
//Return
|
sl@0
|
66 |
asm("ldmfd sp!,{r4-r7,pc}");
|
sl@0
|
67 |
}
|