1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kernel/eka/euser/epoc/arm/uc_exe.cia Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,126 @@
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_exe.cia
1.18 +//
1.19 +//
1.20 +
1.21 +#include <e32cia.h>
1.22 +#include <u32std.h>
1.23 +// Include this to get imports from User (i.e. User::Invariant and User::HandleException).
1.24 +// This sets VISIBILITY to DEFAULT for BPABI builds.
1.25 +#include <e32std.h>
1.26 +
1.27 +extern "C" {
1.28 +
1.29 +void _xxxx_call_user_invariant();
1.30 +void _xxxx_call_user_handle_exception(void *);
1.31 +
1.32 +extern void RunThread(TBool aNotFirst, SThreadCreateInfo& aInfo);
1.33 +
1.34 +// NOTE: This MUST be the first function in this module
1.35 +__NAKED__ TInt _E32Startup()
1.36 + {
1.37 + // Process entry point
1.38 + // R4 = entry reason
1.39 + // SP points to information block
1.40 + EKA2_ENTRY_POINT_VERSION_IDENTIFIER; // DUMMY INSTRUCTION TO INDICATE EKA2 ENTRY POINT
1.41 + asm("cmp r4, #%a0" : : "i" ((TInt)KModuleEntryReasonThreadInit) );
1.42 + asm("b 1f "); // branch over space for unique ID
1.43 +
1.44 + asm(".word 0 "); // loader will replace with code seg unique ID
1.45 + // for RAM-loaded code segment
1.46 + // MUST BE AT OFFSET 12 FROM ENTRY POINT
1.47 +
1.48 + asm("1: ");
1.49 + asm("movls r0, r4 "); // r0 = aNotFirst
1.50 + asm("movls r1, sp "); // r1 -> parameter block
1.51 + asm("bls RunThread "); // process or thread init
1.52 + asm("cmp r4, #%a0" : : "i" ((TInt)KModuleEntryReasonException) );
1.53 +// asm("bne " CSM_ZN4User9InvariantEv ); // invalid entry reason
1.54 + asm("bne _xxxx_call_user_invariant " ); // invalid entry reason
1.55 +
1.56 + // exception entry
1.57 + // NOTE: THUMB only works on ARMv5 and above
1.58 + asm("mov r0, sp "); // r0->parameter block
1.59 + asm("ldr r4, [sp, #16]"); // r4 = saved CPSR
1.60 + asm("tst r4, #0x20 "); // test for THUMB
1.61 + asm("ldrne r1, [sp, #80] "); // r1 = saved return addr
1.62 + asm("orrne r1, r1, #1 ");
1.63 + asm("strne r1, [sp, #80] "); // if THUMB, set bit 0 of return addr
1.64 +
1.65 + asm("mov r11, sp "); // save stack pointer
1.66 +
1.67 + // The frame starts 84 bytes (up) from r11 i.e. CFA is r11 + 84
1.68 + __EH_FRAME_ADDRESS(r11, 84)
1.69 + // we can only restore callee-save values, but that's what we want if we 'leave'
1.70 + // saved link is -8 bytes from CFA (= r11 + 0x24 + 0x20 + 0x8)
1.71 + __EH_FRAME_SAVE1(lr, -8)
1.72 +
1.73 + // the other callee saves start at -48 from CFA (= r11 + 0x24)
1.74 +#if 0
1.75 + // would like to say this
1.76 + __EH_FRAME_SAVE1(r4-r11, -48)
1.77 + // but the macro expansion gives rise to odd code so we do what follows
1.78 +#endif
1.79 +#ifdef __ARMCC__
1.80 + FRAME SAVE {r4-r11}, -48
1.81 +#endif
1.82 +
1.83 + asm("bic sp, sp, #4 "); // align stack to 8 byte boundary
1.84 +// asm("bl " CSM_ZN4User15HandleExceptionEPv );
1.85 + asm("bl _xxxx_call_user_handle_exception ");
1.86 + asm("add sp, r11, #16 "); // skip exc type, exc code, FAR, FSR
1.87 + asm("ldr r4, [sp], #4 "); // r4 = saved CPSR
1.88 + asm("bic r4, r4, #0x20 "); // clear THUMB bit
1.89 + asm("msr cpsr, r4 "); // restore flags
1.90 + asm("ldmia sp, {r0-r15} "); // restore r0-r15
1.91 +
1.92 +#ifdef __ARMCC__
1.93 +#ifdef __SUPPORT_CPP_EXCEPTIONS__
1.94 +
1.95 +
1.96 + /* It is possible no functions included in the image require
1.97 + * a handler table. Therefore make only a weak reference to
1.98 + * the handler table base symbol, which may be absent.
1.99 + */
1.100 + extern |.ARM.exidx$$Base|;
1.101 + extern |.ARM.exidx$$Limit|;
1.102 + extern |.ARM.extab$$Base| [WEAK];
1.103 + extern |Image$$ER_RO$$Base|;
1.104 + extern |Image$$ER_RO$$Limit|;
1.105 + export |Symbian$$CPP$$Exception$$Descriptor|;
1.106 +
1.107 +|Symbian$$CPP$$Exception$$Descriptor|
1.108 +#ifdef __LEAVE_EQUALS_THROW__
1.109 +|Symbian$$eit_base| dcd |.ARM.exidx$$Base|; /* index table base */
1.110 +|Symbian$$eit_limit| dcd |.ARM.exidx$$Limit| ; /* index table limit */
1.111 +#endif
1.112 +#if __ARMCC_VERSION > 220000
1.113 +|Symbian$$code_seg_base| dcd |Image$$ER_RO$$Base| + 1 ; /* RO segment base + mark as ehabi v2 */
1.114 +|Symbian$$code_seg_limit| dcd |Image$$ER_RO$$Limit| ;/* RO segment limit */
1.115 +|Symbian$$reserved| dcd 0 ; /* reserved for future use */
1.116 +#else
1.117 +|Symbian$$code_seg_base| dcd |Image$$ER_RO$$Base| ; /* RO segment base */
1.118 +|Symbian$$code_seg_limit| dcd |Image$$ER_RO$$Limit| ;/* RO segment limit */
1.119 +#endif
1.120 +
1.121 +#endif
1.122 +#endif
1.123 +
1.124 + }
1.125 +void _xxxx_call_user_invariant() { User::Invariant(); }
1.126 +void _xxxx_call_user_handle_exception(void * arg) { User::HandleException(arg); }
1.127 +
1.128 +}
1.129 +