|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // e32\euser\epoc\arm\uc_trp.cia |
|
15 // |
|
16 // |
|
17 |
|
18 #include <e32cia.h> |
|
19 #include <u32std.h> |
|
20 #include <e32panic.h> |
|
21 #include <u32exec.h> |
|
22 #include "uc_std.h" |
|
23 |
|
24 // With -fvtable-thunks |
|
25 const TInt KVTableTrapOffset=8; |
|
26 const TInt KVTableLeaveOffset=16; |
|
27 |
|
28 // Without -fvtable-thunks |
|
29 // const TInt KVTableTrapOffset=12; |
|
30 // const TInt KVTableLeaveOffset=28; |
|
31 |
|
32 |
|
33 #ifndef __LEAVE_EQUALS_THROW__ |
|
34 |
|
35 EXPORT_C __NAKED__ TInt TTrap::Trap(TInt & /*aResult*/) |
|
36 // |
|
37 // Save the enter frame state and return 0. |
|
38 // |
|
39 { |
|
40 |
|
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() |
|
53 asm("bx r3 "); |
|
54 #else |
|
55 asm("adr lr, __ttrap_trap_return "); // iHandler->Trap() |
|
56 asm("ldr pc, [r3, #%a0]" : : "i" (_TTRAPHANDLER_TRAP_OFFSET_)); |
|
57 #endif |
|
58 asm("__ttrap_trap_return: "); |
|
59 asm("mov r0, #0 "); |
|
60 asm("ttrap_trap_no_trap_handler: "); |
|
61 __POPRET("r4,"); |
|
62 } |
|
63 |
|
64 extern void PanicNoTrapFrame(); |
|
65 |
|
66 |
|
67 |
|
68 EXPORT_C __NAKED__ void User::Leave(TInt /*aReason*/) |
|
69 /** |
|
70 Leaves the currently executing function, unwinds the call stack, and returns |
|
71 from the most recently entered trap harness. |
|
72 |
|
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 |
|
76 to occur. |
|
77 |
|
78 @see TRAP |
|
79 @see TRAPD |
|
80 */ |
|
81 { |
|
82 |
|
83 asm("mov r4, r0 "); // Save aReason |
|
84 asm("bl " CSM_ZN4Exec12PopTrapFrameEv); // Returns the current TTrap |
|
85 asm("cmp r0, #0 "); |
|
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 |
|
91 asm("cmp r0, #0 "); |
|
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) |
|
98 asm("bx r3 "); |
|
99 #else |
|
100 asm("adr lr, user_leave_no_trap_handler "); // iHandler->Leave(aReason) |
|
101 asm("ldr pc, [r2, #%a0]" : : "i" (_TTRAPHANDLER_LEAVE_OFFSET_)); |
|
102 #endif |
|
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 |
|
107 } |
|
108 |
|
109 #endif // !__LEAVE_EQUALS_THROW__ |