kernel/eka/nkern/arm/ncmonitor.cia
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 1994-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 // e32\nkern\arm\ncmonitor.cia
       
    15 // Kernel crash debugger - NKERN ARM specific portion
       
    16 // 
       
    17 //
       
    18 
       
    19 #include <e32cia.h>
       
    20 #include <kernel/monitor.h>
       
    21 #include "nk_priv.h"
       
    22 #include <arm.h>
       
    23 
       
    24 #ifdef __CPU_HAS_MMU
       
    25 #define __USE_CP15_FAULT_INFO__
       
    26 #endif
       
    27 
       
    28 EXPORT_C __NAKED__ void Monitor::HandleException()
       
    29 //
       
    30 // Handle an exception while the monitor is running
       
    31 //
       
    32 	{
       
    33 	asm("mov r3, r1 ");				// exception type
       
    34 	asm("ldr r0, [sp, #24] ");		// code address
       
    35 #ifdef __USE_CP15_FAULT_INFO__
       
    36 #ifdef __CPU_ARM_HAS_SPLIT_FSR
       
    37 	asm("cmp r1, #%a0 " : : "i" ((TInt)EArmExceptionPrefetchAbort));
       
    38 	asm("mrceq p15, 0, r2, c5, c0, 1");		// r2=instruction fault status
       
    39 	asm("mrcne p15, 0, r2, c5, c0, 0");		// r2=data fault status
       
    40 #ifdef __CPU_ARM_HAS_CP15_IFAR
       
    41 	asm("mrceq p15, 0, r1, c6, c0, 2");		// r1= IFAR fault address
       
    42 	asm("mrcne p15, 0, r1, c6, c0, 0");		// r1= DFAR fault address
       
    43 #else 
       
    44 	asm("mrc p15, 0, r1, c6, c0");			// r1= FAR fault address
       
    45 #endif // __CPU_ARM_HAS_CP15_IFAR
       
    46 #else
       
    47 	asm("mrc p15, 0, r1, c6, c0");			// r1=fault address
       
    48 	asm("mrc p15, 0, r2, c5, c0");			// r2=fault status
       
    49 #endif // __CPU_ARM_HAS_SPLIT_FSR
       
    50 #endif // __USE_CP15_FAULT_INFO__
       
    51 	asm("add sp, sp, #28 ");		// restore mode_abt/mode_und stack balance
       
    52 	asm("mov r12, #0xd1 ");			// back into mode_fiq
       
    53 	asm("msr cpsr, r12 ");
       
    54 	asm("ldr r12, __TheMonitorPtr ");
       
    55 	asm("ldr r12, [r12] ");
       
    56 	asm("add r12, r12, #%a0" : : "i" _FOFF(Monitor,iExceptionInfo));
       
    57 	asm("stmia r12, {r0-r3} ");		// store exc info
       
    58 	asm("mov r0, #%a0" : : "i" ((TInt)KErrAbort));
       
    59 	asm("b " CSM_ZN7Monitor5LeaveEi );
       
    60 
       
    61 	asm("__TheMonitorPtr: ");
       
    62 	asm(".word TheMonitorPtr ");
       
    63 	}
       
    64