1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kernel/eka/euser/epoc/win32/uc_trp.cpp.orig Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,110 @@
1.4 +// Copyright (c) 1995-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\euser\epoc\win32\uc_trp.cpp
1.18 +//
1.19 +//
1.20 +
1.21 +#include <u32exec.h>
1.22 +#include <e32panic.h>
1.23 +#include "uc_std.h"
1.24 +
1.25 +GLREF_C void Panic(TCdtPanic);
1.26 +
1.27 +#ifndef __LEAVE_EQUALS_THROW__
1.28 +
1.29 +// __thiscall - parameter is expected to be removed by this function
1.30 +EXPORT_C TInt TTrap::Trap(TInt &aResult)
1.31 +//
1.32 +// Save the enter frame state and return 0.
1.33 +//
1.34 + {
1.35 + // compiler generates push ebp; mov ebp,esp here
1.36 + // hence correct action for Leave() is to restore ebp then mov esp,ebp; pop ebp; ret 4
1.37 + aResult=KErrNone;
1.38 + iResult=(&aResult);
1.39 + _asm mov eax, this
1.40 + _asm mov [eax], ebx
1.41 + _asm mov [eax+4], esi
1.42 + _asm mov [eax+8], edi
1.43 + _asm mov [eax+12], ebp
1.44 + _asm mov [eax+16], ds
1.45 + _asm mov [eax+20], es
1.46 + _asm mov [eax+24], fs
1.47 + _asm mov [eax+28], gs
1.48 + _asm mov edx, [ebp]
1.49 + _asm mov [eax+32], edx
1.50 + _asm mov edx, [ebp+4]
1.51 + _asm mov [eax+36], edx
1.52 + TTrapHandler* h = Exec::PushTrapFrame(this);
1.53 + if (h != NULL)
1.54 + h->Trap();
1.55 + return(0);
1.56 + }
1.57 +
1.58 +
1.59 +
1.60 +// __cdecl - this function will leave parameter on the stack
1.61 +// but it will return to the instruction after the call to TTrap::Trap()
1.62 +// and this expects a parameter to be popped from the stack
1.63 +// so we must return with a ret 4, rather than leaving the compiler to generate a ret 0
1.64 +EXPORT_C void User::Leave(TInt aReason)
1.65 +/**
1.66 +Leaves the currently executing function, unwinds the call stack, and returns
1.67 +from the most recently entered trap harness.
1.68 +
1.69 +@param aReason The value returned from the most recent call to TRAP or TRAPD.
1.70 + This is known as the reason code and, typically, it gives the
1.71 + reason for the environment or user error causing this leave
1.72 + to occur.
1.73 +
1.74 +@see TRAP
1.75 +@see TRAPD
1.76 +*/
1.77 + {
1.78 +
1.79 + TTrap *pT=Exec::PopTrapFrame();
1.80 + if (!pT)
1.81 + ::Panic(EUserLeaveWithoutTrap);
1.82 + TTrapHandler *pH=pT->iHandler;
1.83 + *pT->iResult=aReason;
1.84 + if (pH!=NULL)
1.85 + pH->Leave(aReason);
1.86 + _asm mov eax, pT
1.87 + _asm mov ebp, [eax+12]
1.88 + _asm mov esp, ebp
1.89 + _asm mov ebx, [eax]
1.90 + _asm mov esi, [eax+4]
1.91 + _asm mov edi, [eax+8]
1.92 + _asm mov ds, [eax+16]
1.93 + _asm mov es, [eax+20]
1.94 + _asm mov fs, [eax+24]
1.95 + _asm mov gs, [eax+28]
1.96 + _asm mov edx, [eax+32]
1.97 + _asm mov [ebp], edx
1.98 + _asm mov edx, [eax+36]
1.99 + _asm mov [ebp+4], edx
1.100 + _asm mov eax, 1
1.101 + _asm pop ebp
1.102 + _asm ret 4
1.103 + }
1.104 +
1.105 +
1.106 +
1.107 +#else // !__LEAVE_EQUALS_THROW__
1.108 +
1.109 +
1.110 +
1.111 +
1.112 +
1.113 +#endif
1.114 \ No newline at end of file