sl@0
|
1 |
// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// e32\euser\epoc\win32\uc_trp.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <u32exec.h>
|
sl@0
|
19 |
#include <e32panic.h>
|
sl@0
|
20 |
#include "uc_std.h"
|
sl@0
|
21 |
|
sl@0
|
22 |
GLREF_C void Panic(TCdtPanic);
|
sl@0
|
23 |
|
sl@0
|
24 |
#ifndef __LEAVE_EQUALS_THROW__
|
sl@0
|
25 |
|
sl@0
|
26 |
// __thiscall - parameter is expected to be removed by this function
|
sl@0
|
27 |
EXPORT_C TInt TTrap::Trap(TInt &aResult)
|
sl@0
|
28 |
//
|
sl@0
|
29 |
// Save the enter frame state and return 0.
|
sl@0
|
30 |
//
|
sl@0
|
31 |
{
|
sl@0
|
32 |
// compiler generates push ebp; mov ebp,esp here
|
sl@0
|
33 |
// hence correct action for Leave() is to restore ebp then mov esp,ebp; pop ebp; ret 4
|
sl@0
|
34 |
aResult=KErrNone;
|
sl@0
|
35 |
iResult=(&aResult);
|
sl@0
|
36 |
_asm mov eax, this
|
sl@0
|
37 |
_asm mov [eax], ebx
|
sl@0
|
38 |
_asm mov [eax+4], esi
|
sl@0
|
39 |
_asm mov [eax+8], edi
|
sl@0
|
40 |
_asm mov [eax+12], ebp
|
sl@0
|
41 |
_asm mov [eax+16], ds
|
sl@0
|
42 |
_asm mov [eax+20], es
|
sl@0
|
43 |
_asm mov [eax+24], fs
|
sl@0
|
44 |
_asm mov [eax+28], gs
|
sl@0
|
45 |
_asm mov edx, [ebp]
|
sl@0
|
46 |
_asm mov [eax+32], edx
|
sl@0
|
47 |
_asm mov edx, [ebp+4]
|
sl@0
|
48 |
_asm mov [eax+36], edx
|
sl@0
|
49 |
TTrapHandler* h = Exec::PushTrapFrame(this);
|
sl@0
|
50 |
if (h != NULL)
|
sl@0
|
51 |
h->Trap();
|
sl@0
|
52 |
return(0);
|
sl@0
|
53 |
}
|
sl@0
|
54 |
|
sl@0
|
55 |
|
sl@0
|
56 |
|
sl@0
|
57 |
// __cdecl - this function will leave parameter on the stack
|
sl@0
|
58 |
// but it will return to the instruction after the call to TTrap::Trap()
|
sl@0
|
59 |
// and this expects a parameter to be popped from the stack
|
sl@0
|
60 |
// so we must return with a ret 4, rather than leaving the compiler to generate a ret 0
|
sl@0
|
61 |
EXPORT_C void User::Leave(TInt aReason)
|
sl@0
|
62 |
/**
|
sl@0
|
63 |
Leaves the currently executing function, unwinds the call stack, and returns
|
sl@0
|
64 |
from the most recently entered trap harness.
|
sl@0
|
65 |
|
sl@0
|
66 |
@param aReason The value returned from the most recent call to TRAP or TRAPD.
|
sl@0
|
67 |
This is known as the reason code and, typically, it gives the
|
sl@0
|
68 |
reason for the environment or user error causing this leave
|
sl@0
|
69 |
to occur.
|
sl@0
|
70 |
|
sl@0
|
71 |
@see TRAP
|
sl@0
|
72 |
@see TRAPD
|
sl@0
|
73 |
*/
|
sl@0
|
74 |
{
|
sl@0
|
75 |
|
sl@0
|
76 |
TTrap *pT=Exec::PopTrapFrame();
|
sl@0
|
77 |
if (!pT)
|
sl@0
|
78 |
::Panic(EUserLeaveWithoutTrap);
|
sl@0
|
79 |
TTrapHandler *pH=pT->iHandler;
|
sl@0
|
80 |
*pT->iResult=aReason;
|
sl@0
|
81 |
if (pH!=NULL)
|
sl@0
|
82 |
pH->Leave(aReason);
|
sl@0
|
83 |
_asm mov eax, pT
|
sl@0
|
84 |
_asm mov ebp, [eax+12]
|
sl@0
|
85 |
_asm mov esp, ebp
|
sl@0
|
86 |
_asm mov ebx, [eax]
|
sl@0
|
87 |
_asm mov esi, [eax+4]
|
sl@0
|
88 |
_asm mov edi, [eax+8]
|
sl@0
|
89 |
_asm mov ds, [eax+16]
|
sl@0
|
90 |
_asm mov es, [eax+20]
|
sl@0
|
91 |
_asm mov fs, [eax+24]
|
sl@0
|
92 |
_asm mov gs, [eax+28]
|
sl@0
|
93 |
_asm mov edx, [eax+32]
|
sl@0
|
94 |
_asm mov [ebp], edx
|
sl@0
|
95 |
_asm mov edx, [eax+36]
|
sl@0
|
96 |
_asm mov [ebp+4], edx
|
sl@0
|
97 |
_asm mov eax, 1
|
sl@0
|
98 |
_asm pop ebp
|
sl@0
|
99 |
_asm ret 4
|
sl@0
|
100 |
}
|
sl@0
|
101 |
|
sl@0
|
102 |
#endif // !__LEAVE_EQUALS_THROW__
|