Update contrib.
1 // Copyright (c) 1995-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32\euser\epoc\arm\uc_trp.cia
24 // With -fvtable-thunks
25 const TInt KVTableTrapOffset=8;
26 const TInt KVTableLeaveOffset=16;
28 // Without -fvtable-thunks
29 // const TInt KVTableTrapOffset=12;
30 // const TInt KVTableLeaveOffset=28;
33 #ifndef __LEAVE_EQUALS_THROW__
35 EXPORT_C __NAKED__ TInt TTrap::Trap(TInt & /*aResult*/)
37 // Save the enter frame state and return 0.
41 asm("mov r2, #0 "); // aResult==KErrNone
42 asm("str r2, [r1, #0] "); // iResult=(&aResult)
43 asm("str r1, [r0, #%a0]" : : "i" _FOFF(TTrap,iResult));
44 asm("stmia r0, {r4-r11, sp, lr} "); // Save the context
45 asm("stmfd sp!, {r4,lr} ");
46 asm("bl " CSM_ZN4Exec13PushTrapFrameEP5TTrap);
47 asm("cmp r0, #0 "); // == NULL
48 asm("ldrne r3, [r0, #%a0]" : : "i" (_TTRAPHANDLER_VPTR_OFFSET_));
49 asm("beq ttrap_trap_no_trap_handler ");
50 #ifdef __SUPPORT_THUMB_INTERWORKING
51 asm("ldr r3, [r3, #%a0]" : : "i" (_TTRAPHANDLER_TRAP_OFFSET_));
52 asm("adr lr, __ttrap_trap_return "); // iHandler->Trap()
55 asm("adr lr, __ttrap_trap_return "); // iHandler->Trap()
56 asm("ldr pc, [r3, #%a0]" : : "i" (_TTRAPHANDLER_TRAP_OFFSET_));
58 asm("__ttrap_trap_return: ");
60 asm("ttrap_trap_no_trap_handler: ");
64 extern void PanicNoTrapFrame();
68 EXPORT_C __NAKED__ void User::Leave(TInt /*aReason*/)
70 Leaves the currently executing function, unwinds the call stack, and returns
71 from the most recently entered trap harness.
73 @param aReason The value returned from the most recent call to TRAP or TRAPD.
74 This is known as the reason code and, typically, it gives the
75 reason for the environment or user error causing this leave
83 asm("mov r4, r0 "); // Save aReason
84 asm("bl " CSM_ZN4Exec12PopTrapFrameEv); // Returns the current TTrap
86 asm("bleq " CSM_Z16PanicNoTrapFramev);
87 asm("ldr r1, [r0, #%a0]" : : "i" _FOFF(TTrap,iResult));
88 asm("mov r5, r0 "); // Save it for later
89 asm("ldr r0, [r0, #%a0]" : : "i" _FOFF(TTrap,iHandler));
90 asm("str r4, [r1, #0] "); // *(pT->iResult)=aReason
92 asm("ldrne r2, [r0, #%a0]" : : "i" (_TTRAPHANDLER_VPTR_OFFSET_));
93 asm("beq user_leave_no_trap_handler "); // No trap handler
94 asm("mov r1, r4 "); // Pass aReason
95 #ifdef __SUPPORT_THUMB_INTERWORKING
96 asm("ldr r3, [r2, #%a0]" : : "i" (_TTRAPHANDLER_LEAVE_OFFSET_));
97 asm("adr lr, user_leave_no_trap_handler "); // iHandler->Leave(aReason)
100 asm("adr lr, user_leave_no_trap_handler "); // iHandler->Leave(aReason)
101 asm("ldr pc, [r2, #%a0]" : : "i" (_TTRAPHANDLER_LEAVE_OFFSET_));
103 asm("user_leave_no_trap_handler: ");
104 asm("ldmia r5, {r4-r11, sp, lr} "); // Restore the context
105 asm("mov r0, #1 "); // return(1)
106 __JUMP(,lr); // return
109 #endif // !__LEAVE_EQUALS_THROW__