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