os/kernelhwsrv/kernel/eka/nkern/arm/nk_entry.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) 2008-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\nkern\arm\nk_entry.cia
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include <e32cia.h>
sl@0
    19
#include <arm.h>
sl@0
    20
#include "nk_priv.h"
sl@0
    21
sl@0
    22
#include "entry.h"
sl@0
    23
sl@0
    24
#ifndef	EKA2_ENTRY_POINT_VERSION_IDENTIFIER
sl@0
    25
#define	EKA2_ENTRY_POINT_VERSION_IDENTIFIER	\
sl@0
    26
	asm("tst pc, #%a0" : : "i" ((TInt)0) )
sl@0
    27
#endif
sl@0
    28
sl@0
    29
extern "C" {
sl@0
    30
sl@0
    31
extern void HwInit0();
sl@0
    32
extern void KernelMain();
sl@0
    33
extern TLinAddr RomHeaderAddress;
sl@0
    34
extern TLinAddr SuperPageAddress;
sl@0
    35
sl@0
    36
sl@0
    37
/*
sl@0
    38
 * The main startup program
sl@0
    39
 * aRomHeader is address of ROM header passed in by bootstrap
sl@0
    40
 * aSuperPage is address of super page passed in by bootstrap
sl@0
    41
 *
sl@0
    42
 * *** NOTE ***
sl@0
    43
 * This is written in assembler in order that nk_exe.lib can be built entirely
sl@0
    44
 * from one source file. This is necessary to ensure that the vector table above
sl@0
    45
 * appears at the very beginning of the ekern.exe code section.
sl@0
    46
 * ************
sl@0
    47
 */
sl@0
    48
#if defined(__GCC32__)
sl@0
    49
GLDEF_C __NAKED__ void _E32Startup(TLinAddr /*aRomHeader*/, TLinAddr /*aSuperPage*/)
sl@0
    50
	{
sl@0
    51
	EKA2_ENTRY_POINT_VERSION_IDENTIFIER;	// DUMMY INSTRUCTION TO INDICATE EKA2 ENTRY POINT
sl@0
    52
	asm("ldr r2, __RomHeaderAddress ");
sl@0
    53
	asm("b 1f ");				// branch over space for unique ID
sl@0
    54
sl@0
    55
	asm(".word 0 ");			// loader will replace with code seg unique ID
sl@0
    56
								// for RAM-loaded code segment
sl@0
    57
								// MUST BE AT OFFSET 12 FROM ENTRY POINT
sl@0
    58
sl@0
    59
	asm("1: ");
sl@0
    60
	asm("ldr r3, __SuperPage ");
sl@0
    61
	asm("str r0, [r2] ");
sl@0
    62
	asm("str r1, [r3] ");
sl@0
    63
sl@0
    64
	asm("bl HwInit0 ");
sl@0
    65
sl@0
    66
	asm("ldr r4, __CtorList ");
sl@0
    67
	
sl@0
    68
	asm("1: ");
sl@0
    69
	asm("ldr r0, [r4, #4]! ");
sl@0
    70
	asm("adr lr, 1b ");
sl@0
    71
	asm("cmp r0, #0 ");
sl@0
    72
	__JUMP(ne,r0);
sl@0
    73
sl@0
    74
	asm("b KernelMain ");
sl@0
    75
sl@0
    76
	asm("__RomHeaderAddress: ");
sl@0
    77
	asm(".word RomHeaderAddress ");
sl@0
    78
	asm("__SuperPage: ");
sl@0
    79
	asm(".word SuperPageAddress ");
sl@0
    80
	asm("__CtorList: ");
sl@0
    81
	asm(".word __CTOR_LIST__ ");
sl@0
    82
	}
sl@0
    83
#elif defined(__ARMCC__)
sl@0
    84
void __DLL_Export_Table__(void);
sl@0
    85
void __cpp_initialize__aeabi_();
sl@0
    86
  
sl@0
    87
// The compiler generates calls to this when it reckons a top-level construction
sl@0
    88
// needs destruction. But the kernel never will need this so, define it as a nop
sl@0
    89
void __record_needed_destruction (void * d){}
sl@0
    90
// 2.1 calls __aeabi_atexit passing __dso_handle. This can be a dummy (i.e. just a label)
sl@0
    91
sl@0
    92
__asm void __dso_handle(void) {}
sl@0
    93
void __aeabi_atexit(void *object, void (*dtor)(void *), void *handle){}
sl@0
    94
sl@0
    95
void _E32Startup_Body(TLinAddr aRomHeader, TLinAddr aSuperPage);
sl@0
    96
sl@0
    97
__NAKED__ void _E32Startup(TLinAddr aRomHeader, TLinAddr aSuperPage)
sl@0
    98
	{
sl@0
    99
	EKA2_ENTRY_POINT_VERSION_IDENTIFIER;	// DUMMY INSTRUCTION TO INDICATE EKA2 ENTRY POINT
sl@0
   100
	asm("b _E32Startup_Body ");
sl@0
   101
	asm(".word 0 ");			// padding
sl@0
   102
sl@0
   103
	asm(".word 0 ");			// loader will replace with code seg unique ID
sl@0
   104
								// for RAM-loaded code segment
sl@0
   105
								// MUST BE AT OFFSET 12 FROM ENTRY POINT
sl@0
   106
	}
sl@0
   107
sl@0
   108
GLDEF_C void _E32Startup_Body(TLinAddr aRomHeader, TLinAddr aSuperPage)
sl@0
   109
	{
sl@0
   110
	RomHeaderAddress = aRomHeader;
sl@0
   111
	SuperPageAddress = aSuperPage;
sl@0
   112
	HwInit0();
sl@0
   113
sl@0
   114
	// RVCT specific initialization
sl@0
   115
sl@0
   116
	// Make sure we get an export table
sl@0
   117
	__DLL_Export_Table__();
sl@0
   118
sl@0
   119
	// Initialise static data
sl@0
   120
	__cpp_initialize__aeabi_();
sl@0
   121
sl@0
   122
	KernelMain();
sl@0
   123
	}
sl@0
   124
#else
sl@0
   125
#error Not supported
sl@0
   126
#endif
sl@0
   127
sl@0
   128
}
sl@0
   129