sl@0: // Copyright (c) 1995-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: // e32\euser\epoc\arm\uc_trp.cia sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "uc_std.h" sl@0: sl@0: // With -fvtable-thunks sl@0: const TInt KVTableTrapOffset=8; sl@0: const TInt KVTableLeaveOffset=16; sl@0: sl@0: // Without -fvtable-thunks sl@0: // const TInt KVTableTrapOffset=12; sl@0: // const TInt KVTableLeaveOffset=28; sl@0: sl@0: sl@0: #ifndef __LEAVE_EQUALS_THROW__ sl@0: sl@0: EXPORT_C __NAKED__ TInt TTrap::Trap(TInt & /*aResult*/) sl@0: // sl@0: // Save the enter frame state and return 0. sl@0: // sl@0: { sl@0: sl@0: asm("mov r2, #0 "); // aResult==KErrNone sl@0: asm("str r2, [r1, #0] "); // iResult=(&aResult) sl@0: asm("str r1, [r0, #%a0]" : : "i" _FOFF(TTrap,iResult)); sl@0: asm("stmia r0, {r4-r11, sp, lr} "); // Save the context sl@0: asm("stmfd sp!, {r4,lr} "); sl@0: asm("bl " CSM_ZN4Exec13PushTrapFrameEP5TTrap); sl@0: asm("cmp r0, #0 "); // == NULL sl@0: asm("ldrne r3, [r0, #%a0]" : : "i" (_TTRAPHANDLER_VPTR_OFFSET_)); sl@0: asm("beq ttrap_trap_no_trap_handler "); sl@0: #ifdef __SUPPORT_THUMB_INTERWORKING sl@0: asm("ldr r3, [r3, #%a0]" : : "i" (_TTRAPHANDLER_TRAP_OFFSET_)); sl@0: asm("adr lr, __ttrap_trap_return "); // iHandler->Trap() sl@0: asm("bx r3 "); sl@0: #else sl@0: asm("adr lr, __ttrap_trap_return "); // iHandler->Trap() sl@0: asm("ldr pc, [r3, #%a0]" : : "i" (_TTRAPHANDLER_TRAP_OFFSET_)); sl@0: #endif sl@0: asm("__ttrap_trap_return: "); sl@0: asm("mov r0, #0 "); sl@0: asm("ttrap_trap_no_trap_handler: "); sl@0: __POPRET("r4,"); sl@0: } sl@0: sl@0: extern void PanicNoTrapFrame(); sl@0: sl@0: sl@0: sl@0: EXPORT_C __NAKED__ void User::Leave(TInt /*aReason*/) sl@0: /** sl@0: Leaves the currently executing function, unwinds the call stack, and returns sl@0: from the most recently entered trap harness. sl@0: sl@0: @param aReason The value returned from the most recent call to TRAP or TRAPD. sl@0: This is known as the reason code and, typically, it gives the sl@0: reason for the environment or user error causing this leave sl@0: to occur. sl@0: sl@0: @see TRAP sl@0: @see TRAPD sl@0: */ sl@0: { sl@0: sl@0: asm("mov r4, r0 "); // Save aReason sl@0: asm("bl " CSM_ZN4Exec12PopTrapFrameEv); // Returns the current TTrap sl@0: asm("cmp r0, #0 "); sl@0: asm("bleq " CSM_Z16PanicNoTrapFramev); sl@0: asm("ldr r1, [r0, #%a0]" : : "i" _FOFF(TTrap,iResult)); sl@0: asm("mov r5, r0 "); // Save it for later sl@0: asm("ldr r0, [r0, #%a0]" : : "i" _FOFF(TTrap,iHandler)); sl@0: asm("str r4, [r1, #0] "); // *(pT->iResult)=aReason sl@0: asm("cmp r0, #0 "); sl@0: asm("ldrne r2, [r0, #%a0]" : : "i" (_TTRAPHANDLER_VPTR_OFFSET_)); sl@0: asm("beq user_leave_no_trap_handler "); // No trap handler sl@0: asm("mov r1, r4 "); // Pass aReason sl@0: #ifdef __SUPPORT_THUMB_INTERWORKING sl@0: asm("ldr r3, [r2, #%a0]" : : "i" (_TTRAPHANDLER_LEAVE_OFFSET_)); sl@0: asm("adr lr, user_leave_no_trap_handler "); // iHandler->Leave(aReason) sl@0: asm("bx r3 "); sl@0: #else sl@0: asm("adr lr, user_leave_no_trap_handler "); // iHandler->Leave(aReason) sl@0: asm("ldr pc, [r2, #%a0]" : : "i" (_TTRAPHANDLER_LEAVE_OFFSET_)); sl@0: #endif sl@0: asm("user_leave_no_trap_handler: "); sl@0: asm("ldmia r5, {r4-r11, sp, lr} "); // Restore the context sl@0: asm("mov r0, #1 "); // return(1) sl@0: __JUMP(,lr); // return sl@0: } sl@0: sl@0: #endif // !__LEAVE_EQUALS_THROW__