os/kernelhwsrv/kernel/eka/euser/epoc/arm/uc_exe.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\uc_exe.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 this to get imports from User (i.e. User::Invariant and User::HandleException). 
sl@0
    21
// This sets VISIBILITY to DEFAULT for BPABI builds.
sl@0
    22
#include <e32std.h>
sl@0
    23
sl@0
    24
extern "C" {
sl@0
    25
sl@0
    26
void _xxxx_call_user_invariant();
sl@0
    27
void _xxxx_call_user_handle_exception(void *);
sl@0
    28
sl@0
    29
extern void RunThread(TBool aNotFirst, SThreadCreateInfo& aInfo);
sl@0
    30
sl@0
    31
// NOTE: This MUST be the first function in this module
sl@0
    32
__NAKED__ TInt _E32Startup()
sl@0
    33
	{
sl@0
    34
	// Process entry point
sl@0
    35
	// R4 = entry reason
sl@0
    36
	// SP points to information block
sl@0
    37
	EKA2_ENTRY_POINT_VERSION_IDENTIFIER;	// DUMMY INSTRUCTION TO INDICATE EKA2 ENTRY POINT
sl@0
    38
	asm("cmp r4, #%a0" : : "i" ((TInt)KModuleEntryReasonThreadInit) );
sl@0
    39
	asm("b 1f ");				// branch over space for unique ID
sl@0
    40
sl@0
    41
	asm(".word 0 ");			// loader will replace with code seg unique ID
sl@0
    42
								// for RAM-loaded code segment
sl@0
    43
								// MUST BE AT OFFSET 12 FROM ENTRY POINT
sl@0
    44
sl@0
    45
	asm("1: ");
sl@0
    46
	asm("movls r0, r4 ");		// r0 = aNotFirst
sl@0
    47
	asm("movls r1, sp ");		// r1 -> parameter block
sl@0
    48
	asm("bls RunThread ");		// process or thread init
sl@0
    49
	asm("cmp r4, #%a0" : : "i" ((TInt)KModuleEntryReasonException) );
sl@0
    50
//  	asm("bne " CSM_ZN4User9InvariantEv );	// invalid entry reason
sl@0
    51
  	asm("bne _xxxx_call_user_invariant " );	// invalid entry reason
sl@0
    52
sl@0
    53
	// exception entry
sl@0
    54
	// NOTE: THUMB only works on ARMv5 and above
sl@0
    55
	asm("mov r0, sp ");			// r0->parameter block
sl@0
    56
	asm("ldr r4, [sp, #16]");	// r4 = saved CPSR
sl@0
    57
	asm("tst r4, #0x20 ");		// test for THUMB
sl@0
    58
	asm("ldrne r1, [sp, #80] ");	// r1 = saved return addr
sl@0
    59
	asm("orrne r1, r1, #1 ");
sl@0
    60
	asm("strne r1, [sp, #80] ");	// if THUMB, set bit 0 of return addr
sl@0
    61
sl@0
    62
	asm("mov r11, sp ");		// save stack pointer
sl@0
    63
sl@0
    64
	// The frame starts 84 bytes (up) from r11 i.e. CFA is r11 + 84
sl@0
    65
	__EH_FRAME_ADDRESS(r11, 84)
sl@0
    66
	// we can only restore callee-save values, but that's what we want if we 'leave'
sl@0
    67
	// saved link is -8 bytes from CFA (= r11 + 0x24 + 0x20 + 0x8)
sl@0
    68
	__EH_FRAME_SAVE1(lr, -8)
sl@0
    69
sl@0
    70
	// the other callee saves start at -48 from CFA (= r11 + 0x24)
sl@0
    71
#if 0
sl@0
    72
	// would like to say this 
sl@0
    73
	__EH_FRAME_SAVE1(r4-r11, -48)
sl@0
    74
	// but the macro expansion gives rise to odd code so we do what follows
sl@0
    75
#endif
sl@0
    76
#ifdef __ARMCC__
sl@0
    77
	FRAME SAVE {r4-r11}, -48
sl@0
    78
#endif
sl@0
    79
sl@0
    80
	asm("bic sp, sp, #4 ");		// align stack to 8 byte boundary
sl@0
    81
//  	asm("bl " CSM_ZN4User15HandleExceptionEPv );
sl@0
    82
  	asm("bl _xxxx_call_user_handle_exception ");
sl@0
    83
	asm("add sp, r11, #16 ");	// skip exc type, exc code, FAR, FSR
sl@0
    84
	asm("ldr r4, [sp], #4 ");	// r4 = saved CPSR
sl@0
    85
	asm("bic r4, r4, #0x20 ");	// clear THUMB bit
sl@0
    86
	asm("msr cpsr, r4 ");		// restore flags
sl@0
    87
	asm("ldmia sp, {r0-r15} ");	// restore r0-r15
sl@0
    88
sl@0
    89
#ifdef __ARMCC__
sl@0
    90
#ifdef __SUPPORT_CPP_EXCEPTIONS__
sl@0
    91
sl@0
    92
sl@0
    93
  /* It is possible no functions included in the image require
sl@0
    94
   * a handler table. Therefore make only a weak reference to
sl@0
    95
   * the handler table base symbol, which may be absent.
sl@0
    96
   */
sl@0
    97
  extern |.ARM.exidx$$Base|;
sl@0
    98
  extern |.ARM.exidx$$Limit|;
sl@0
    99
  extern |.ARM.extab$$Base| [WEAK];
sl@0
   100
  extern |Image$$ER_RO$$Base|;
sl@0
   101
  extern |Image$$ER_RO$$Limit|;
sl@0
   102
  export |Symbian$$CPP$$Exception$$Descriptor|;
sl@0
   103
sl@0
   104
|Symbian$$CPP$$Exception$$Descriptor|
sl@0
   105
#ifdef __LEAVE_EQUALS_THROW__
sl@0
   106
|Symbian$$eit_base|  		dcd |.ARM.exidx$$Base|;   /* index table base */
sl@0
   107
|Symbian$$eit_limit|  		dcd |.ARM.exidx$$Limit| ;  /* index table limit */
sl@0
   108
#endif
sl@0
   109
#if __ARMCC_VERSION > 220000
sl@0
   110
|Symbian$$code_seg_base| 	dcd |Image$$ER_RO$$Base| + 1 ; /* RO segment base + mark as ehabi v2 */
sl@0
   111
|Symbian$$code_seg_limit| 	dcd |Image$$ER_RO$$Limit| ;/* RO segment limit */
sl@0
   112
|Symbian$$reserved|		dcd 0 ; /* reserved for future use */
sl@0
   113
#else
sl@0
   114
|Symbian$$code_seg_base| 	dcd |Image$$ER_RO$$Base| ; /* RO segment base */
sl@0
   115
|Symbian$$code_seg_limit| 	dcd |Image$$ER_RO$$Limit| ;/* RO segment limit */
sl@0
   116
#endif
sl@0
   117
sl@0
   118
#endif
sl@0
   119
#endif
sl@0
   120
sl@0
   121
	}
sl@0
   122
void _xxxx_call_user_invariant() { User::Invariant(); }
sl@0
   123
void _xxxx_call_user_handle_exception(void * arg) { User::HandleException(arg); }
sl@0
   124
sl@0
   125
}
sl@0
   126