os/kernelhwsrv/kernel/eka/nkern/arm/nk_entry.cia
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/nkern/arm/nk_entry.cia	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,129 @@
     1.4 +// Copyright (c) 2008-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\nkern\arm\nk_entry.cia
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include <e32cia.h>
    1.22 +#include <arm.h>
    1.23 +#include "nk_priv.h"
    1.24 +
    1.25 +#include "entry.h"
    1.26 +
    1.27 +#ifndef	EKA2_ENTRY_POINT_VERSION_IDENTIFIER
    1.28 +#define	EKA2_ENTRY_POINT_VERSION_IDENTIFIER	\
    1.29 +	asm("tst pc, #%a0" : : "i" ((TInt)0) )
    1.30 +#endif
    1.31 +
    1.32 +extern "C" {
    1.33 +
    1.34 +extern void HwInit0();
    1.35 +extern void KernelMain();
    1.36 +extern TLinAddr RomHeaderAddress;
    1.37 +extern TLinAddr SuperPageAddress;
    1.38 +
    1.39 +
    1.40 +/*
    1.41 + * The main startup program
    1.42 + * aRomHeader is address of ROM header passed in by bootstrap
    1.43 + * aSuperPage is address of super page passed in by bootstrap
    1.44 + *
    1.45 + * *** NOTE ***
    1.46 + * This is written in assembler in order that nk_exe.lib can be built entirely
    1.47 + * from one source file. This is necessary to ensure that the vector table above
    1.48 + * appears at the very beginning of the ekern.exe code section.
    1.49 + * ************
    1.50 + */
    1.51 +#if defined(__GCC32__)
    1.52 +GLDEF_C __NAKED__ void _E32Startup(TLinAddr /*aRomHeader*/, TLinAddr /*aSuperPage*/)
    1.53 +	{
    1.54 +	EKA2_ENTRY_POINT_VERSION_IDENTIFIER;	// DUMMY INSTRUCTION TO INDICATE EKA2 ENTRY POINT
    1.55 +	asm("ldr r2, __RomHeaderAddress ");
    1.56 +	asm("b 1f ");				// branch over space for unique ID
    1.57 +
    1.58 +	asm(".word 0 ");			// loader will replace with code seg unique ID
    1.59 +								// for RAM-loaded code segment
    1.60 +								// MUST BE AT OFFSET 12 FROM ENTRY POINT
    1.61 +
    1.62 +	asm("1: ");
    1.63 +	asm("ldr r3, __SuperPage ");
    1.64 +	asm("str r0, [r2] ");
    1.65 +	asm("str r1, [r3] ");
    1.66 +
    1.67 +	asm("bl HwInit0 ");
    1.68 +
    1.69 +	asm("ldr r4, __CtorList ");
    1.70 +	
    1.71 +	asm("1: ");
    1.72 +	asm("ldr r0, [r4, #4]! ");
    1.73 +	asm("adr lr, 1b ");
    1.74 +	asm("cmp r0, #0 ");
    1.75 +	__JUMP(ne,r0);
    1.76 +
    1.77 +	asm("b KernelMain ");
    1.78 +
    1.79 +	asm("__RomHeaderAddress: ");
    1.80 +	asm(".word RomHeaderAddress ");
    1.81 +	asm("__SuperPage: ");
    1.82 +	asm(".word SuperPageAddress ");
    1.83 +	asm("__CtorList: ");
    1.84 +	asm(".word __CTOR_LIST__ ");
    1.85 +	}
    1.86 +#elif defined(__ARMCC__)
    1.87 +void __DLL_Export_Table__(void);
    1.88 +void __cpp_initialize__aeabi_();
    1.89 +  
    1.90 +// The compiler generates calls to this when it reckons a top-level construction
    1.91 +// needs destruction. But the kernel never will need this so, define it as a nop
    1.92 +void __record_needed_destruction (void * d){}
    1.93 +// 2.1 calls __aeabi_atexit passing __dso_handle. This can be a dummy (i.e. just a label)
    1.94 +
    1.95 +__asm void __dso_handle(void) {}
    1.96 +void __aeabi_atexit(void *object, void (*dtor)(void *), void *handle){}
    1.97 +
    1.98 +void _E32Startup_Body(TLinAddr aRomHeader, TLinAddr aSuperPage);
    1.99 +
   1.100 +__NAKED__ void _E32Startup(TLinAddr aRomHeader, TLinAddr aSuperPage)
   1.101 +	{
   1.102 +	EKA2_ENTRY_POINT_VERSION_IDENTIFIER;	// DUMMY INSTRUCTION TO INDICATE EKA2 ENTRY POINT
   1.103 +	asm("b _E32Startup_Body ");
   1.104 +	asm(".word 0 ");			// padding
   1.105 +
   1.106 +	asm(".word 0 ");			// loader will replace with code seg unique ID
   1.107 +								// for RAM-loaded code segment
   1.108 +								// MUST BE AT OFFSET 12 FROM ENTRY POINT
   1.109 +	}
   1.110 +
   1.111 +GLDEF_C void _E32Startup_Body(TLinAddr aRomHeader, TLinAddr aSuperPage)
   1.112 +	{
   1.113 +	RomHeaderAddress = aRomHeader;
   1.114 +	SuperPageAddress = aSuperPage;
   1.115 +	HwInit0();
   1.116 +
   1.117 +	// RVCT specific initialization
   1.118 +
   1.119 +	// Make sure we get an export table
   1.120 +	__DLL_Export_Table__();
   1.121 +
   1.122 +	// Initialise static data
   1.123 +	__cpp_initialize__aeabi_();
   1.124 +
   1.125 +	KernelMain();
   1.126 +	}
   1.127 +#else
   1.128 +#error Not supported
   1.129 +#endif
   1.130 +
   1.131 +}
   1.132 +