1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kernel/eka/euser/epoc/arm/uc_trp.cia Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,109 @@
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\arm\uc_trp.cia
1.18 +//
1.19 +//
1.20 +
1.21 +#include <e32cia.h>
1.22 +#include <u32std.h>
1.23 +#include <e32panic.h>
1.24 +#include <u32exec.h>
1.25 +#include "uc_std.h"
1.26 +
1.27 +// With -fvtable-thunks
1.28 +const TInt KVTableTrapOffset=8;
1.29 +const TInt KVTableLeaveOffset=16;
1.30 +
1.31 +// Without -fvtable-thunks
1.32 +// const TInt KVTableTrapOffset=12;
1.33 +// const TInt KVTableLeaveOffset=28;
1.34 +
1.35 +
1.36 +#ifndef __LEAVE_EQUALS_THROW__
1.37 +
1.38 +EXPORT_C __NAKED__ TInt TTrap::Trap(TInt & /*aResult*/)
1.39 +//
1.40 +// Save the enter frame state and return 0.
1.41 +//
1.42 + {
1.43 +
1.44 + asm("mov r2, #0 "); // aResult==KErrNone
1.45 + asm("str r2, [r1, #0] "); // iResult=(&aResult)
1.46 + asm("str r1, [r0, #%a0]" : : "i" _FOFF(TTrap,iResult));
1.47 + asm("stmia r0, {r4-r11, sp, lr} "); // Save the context
1.48 + asm("stmfd sp!, {r4,lr} ");
1.49 + asm("bl " CSM_ZN4Exec13PushTrapFrameEP5TTrap);
1.50 + asm("cmp r0, #0 "); // == NULL
1.51 + asm("ldrne r3, [r0, #%a0]" : : "i" (_TTRAPHANDLER_VPTR_OFFSET_));
1.52 + asm("beq ttrap_trap_no_trap_handler ");
1.53 +#ifdef __SUPPORT_THUMB_INTERWORKING
1.54 + asm("ldr r3, [r3, #%a0]" : : "i" (_TTRAPHANDLER_TRAP_OFFSET_));
1.55 + asm("adr lr, __ttrap_trap_return "); // iHandler->Trap()
1.56 + asm("bx r3 ");
1.57 +#else
1.58 + asm("adr lr, __ttrap_trap_return "); // iHandler->Trap()
1.59 + asm("ldr pc, [r3, #%a0]" : : "i" (_TTRAPHANDLER_TRAP_OFFSET_));
1.60 +#endif
1.61 + asm("__ttrap_trap_return: ");
1.62 + asm("mov r0, #0 ");
1.63 + asm("ttrap_trap_no_trap_handler: ");
1.64 + __POPRET("r4,");
1.65 + }
1.66 +
1.67 +extern void PanicNoTrapFrame();
1.68 +
1.69 +
1.70 +
1.71 +EXPORT_C __NAKED__ void User::Leave(TInt /*aReason*/)
1.72 +/**
1.73 +Leaves the currently executing function, unwinds the call stack, and returns
1.74 +from the most recently entered trap harness.
1.75 +
1.76 +@param aReason The value returned from the most recent call to TRAP or TRAPD.
1.77 + This is known as the reason code and, typically, it gives the
1.78 + reason for the environment or user error causing this leave
1.79 + to occur.
1.80 +
1.81 +@see TRAP
1.82 +@see TRAPD
1.83 +*/
1.84 + {
1.85 +
1.86 + asm("mov r4, r0 "); // Save aReason
1.87 + asm("bl " CSM_ZN4Exec12PopTrapFrameEv); // Returns the current TTrap
1.88 + asm("cmp r0, #0 ");
1.89 + asm("bleq " CSM_Z16PanicNoTrapFramev);
1.90 + asm("ldr r1, [r0, #%a0]" : : "i" _FOFF(TTrap,iResult));
1.91 + asm("mov r5, r0 "); // Save it for later
1.92 + asm("ldr r0, [r0, #%a0]" : : "i" _FOFF(TTrap,iHandler));
1.93 + asm("str r4, [r1, #0] "); // *(pT->iResult)=aReason
1.94 + asm("cmp r0, #0 ");
1.95 + asm("ldrne r2, [r0, #%a0]" : : "i" (_TTRAPHANDLER_VPTR_OFFSET_));
1.96 + asm("beq user_leave_no_trap_handler "); // No trap handler
1.97 + asm("mov r1, r4 "); // Pass aReason
1.98 +#ifdef __SUPPORT_THUMB_INTERWORKING
1.99 + asm("ldr r3, [r2, #%a0]" : : "i" (_TTRAPHANDLER_LEAVE_OFFSET_));
1.100 + asm("adr lr, user_leave_no_trap_handler "); // iHandler->Leave(aReason)
1.101 + asm("bx r3 ");
1.102 +#else
1.103 + asm("adr lr, user_leave_no_trap_handler "); // iHandler->Leave(aReason)
1.104 + asm("ldr pc, [r2, #%a0]" : : "i" (_TTRAPHANDLER_LEAVE_OFFSET_));
1.105 +#endif
1.106 + asm("user_leave_no_trap_handler: ");
1.107 + asm("ldmia r5, {r4-r11, sp, lr} "); // Restore the context
1.108 + asm("mov r0, #1 "); // return(1)
1.109 + __JUMP(,lr); // return
1.110 + }
1.111 +
1.112 +#endif // !__LEAVE_EQUALS_THROW__