kernel/eka/euser/epoc/arm/eka1_entry_stub.cia
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     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\eka1_entry_stub.cia
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <e32cia.h>
       
    19 #include <u32std.h>
       
    20 #include <e32base.h>
       
    21 #include <e32rom.h>
       
    22 #include <e32svr.h>
       
    23 #include <u32exec.h>
       
    24 
       
    25 
       
    26 // Entry point stub to allow EKA1 binaries to be executed under EKA2
       
    27 
       
    28 extern "C" void RunV7Thread(TBool aNotFirst, SThreadCreateInfo& aInfo);
       
    29 
       
    30 extern "C" EXPORT_C __NAKED__ void Eka1ExeEntryStub()
       
    31 	{
       
    32 	// Process entry point
       
    33 	// R4 = entry reason
       
    34 	// SP points to information block
       
    35 	asm("cmp r4, #%a0" : : "i" ((TInt)KModuleEntryReasonThreadInit) );
       
    36 	asm("movls r0, r4 ");		// r0 = aNotFirst
       
    37 	asm("movls r1, sp ");		// r1 -> parameter block
       
    38 	asm("bls RunV7Thread ");	// process or thread init
       
    39 	asm("cmp r4, #%a0" : : "i" ((TInt)KModuleEntryReasonException) );
       
    40 	asm("bne " CSM_ZN4User9InvariantEv );	// invalid entry reason
       
    41 
       
    42 	// exception entry
       
    43 	// !! stack layout not same as v7 !!
       
    44 	asm("mov r0, sp ");			// r0->parameter block
       
    45 	asm("bl " CSM_ZN4User15HandleExceptionEPv );
       
    46 	asm("ldr r0, [sp, #16] ");	// r0 = saved CPSR
       
    47 	asm("add sp, sp, #20 ");	// skip exc type, exc code, FAR, FSR, CPSR
       
    48 #ifdef __SUPPORT_THUMB_INTERWORKING
       
    49 	asm("tst r0, #0x20 ");		// test for THUMB
       
    50 	asm("bic r0, r0, #0x20 ");	// clear THUMB bit
       
    51 	asm("bne 1f ");				// branch if THUMB
       
    52 #endif
       
    53 	asm("msr cpsr, r0 ");		// restore flags
       
    54 	asm("ldmia sp, {r0-r15} ");	// restore r0-r15
       
    55 #ifdef __SUPPORT_THUMB_INTERWORKING
       
    56 	asm("1: ");					// want to return in THUMB state
       
    57 	asm("msr cpsr, r0 ");		// restore flags
       
    58 	asm("ldmia sp!, {r0-r12} ");	// restore r0-r12
       
    59 	asm("ldr lr, [sp, #4]! ");	// skip saved r13, restore r14
       
    60 	asm("str r0, [sp, #0] ");	// push r0 again
       
    61 	asm("add r0, pc, #1 ");		// r0 = . + 8 + 1
       
    62 	asm("bx r0 ");				// go to next instruction in THUMB
       
    63 	asm(".code 16 ");			// get here in THUMB state
       
    64 	asm("pop {r0,pc} ");		// restore r0 and return in THUMB state
       
    65 	asm("nop ");				// pad
       
    66 	asm(".code 32 ");
       
    67 #endif
       
    68 	}
       
    69