os/kernelhwsrv/kernel/eka/nkern/arm/ncmonitor.cia
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/nkern/arm/ncmonitor.cia	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,64 @@
     1.4 +// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32\nkern\arm\ncmonitor.cia
    1.18 +// Kernel crash debugger - NKERN ARM specific portion
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +#include <e32cia.h>
    1.23 +#include <kernel/monitor.h>
    1.24 +#include "nk_priv.h"
    1.25 +#include <arm.h>
    1.26 +
    1.27 +#ifdef __CPU_HAS_MMU
    1.28 +#define __USE_CP15_FAULT_INFO__
    1.29 +#endif
    1.30 +
    1.31 +EXPORT_C __NAKED__ void Monitor::HandleException()
    1.32 +//
    1.33 +// Handle an exception while the monitor is running
    1.34 +//
    1.35 +	{
    1.36 +	asm("mov r3, r1 ");				// exception type
    1.37 +	asm("ldr r0, [sp, #24] ");		// code address
    1.38 +#ifdef __USE_CP15_FAULT_INFO__
    1.39 +#ifdef __CPU_ARM_HAS_SPLIT_FSR
    1.40 +	asm("cmp r1, #%a0 " : : "i" ((TInt)EArmExceptionPrefetchAbort));
    1.41 +	asm("mrceq p15, 0, r2, c5, c0, 1");		// r2=instruction fault status
    1.42 +	asm("mrcne p15, 0, r2, c5, c0, 0");		// r2=data fault status
    1.43 +#ifdef __CPU_ARM_HAS_CP15_IFAR
    1.44 +	asm("mrceq p15, 0, r1, c6, c0, 2");		// r1= IFAR fault address
    1.45 +	asm("mrcne p15, 0, r1, c6, c0, 0");		// r1= DFAR fault address
    1.46 +#else 
    1.47 +	asm("mrc p15, 0, r1, c6, c0");			// r1= FAR fault address
    1.48 +#endif // __CPU_ARM_HAS_CP15_IFAR
    1.49 +#else
    1.50 +	asm("mrc p15, 0, r1, c6, c0");			// r1=fault address
    1.51 +	asm("mrc p15, 0, r2, c5, c0");			// r2=fault status
    1.52 +#endif // __CPU_ARM_HAS_SPLIT_FSR
    1.53 +#endif // __USE_CP15_FAULT_INFO__
    1.54 +	asm("add sp, sp, #28 ");		// restore mode_abt/mode_und stack balance
    1.55 +	asm("mov r12, #0xd1 ");			// back into mode_fiq
    1.56 +	asm("msr cpsr, r12 ");
    1.57 +	asm("ldr r12, __TheMonitorPtr ");
    1.58 +	asm("ldr r12, [r12] ");
    1.59 +	asm("add r12, r12, #%a0" : : "i" _FOFF(Monitor,iExceptionInfo));
    1.60 +	asm("stmia r12, {r0-r3} ");		// store exc info
    1.61 +	asm("mov r0, #%a0" : : "i" ((TInt)KErrAbort));
    1.62 +	asm("b " CSM_ZN7Monitor5LeaveEi );
    1.63 +
    1.64 +	asm("__TheMonitorPtr: ");
    1.65 +	asm(".word TheMonitorPtr ");
    1.66 +	}
    1.67 +