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