kernel/eka/compsupp/rvct2_2/ucppinit_aeabi.cpp
changeset 9 96e5fb8b040d
child 10 36bfc973b146
equal deleted inserted replaced
-1:000000000000 9:96e5fb8b040d
       
     1 /*
       
     2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 * toplevel initialization/destruction routines for 'user side' code compiled 
       
    16 * with the ARMCC EABI compiler. intended for static linking
       
    17 * The code supports 2.2 both bpabi and non-bpabi. The values in .init_array are
       
    18 * pointers in both environments, so the library is common to both.
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 extern "C" {
       
    24 
       
    25 // This calls each of the compiler constructed functions referenced from pi_ctorvec.
       
    26 // These functions arrange to 'call' the appropriate constructor for the 'static' instance
       
    27 // (in fact the call may be inlined). If the class of the instance has a destructor then 
       
    28 // compiler records that this object needs 'destructing' at 'exit' time. It does this by 
       
    29 // calling the function __cxa_atexit. We provide our own definition of this.
       
    30 // 
       
    31 
       
    32 #ifdef __thumb
       
    33   __asm void __cpp_initialize__aeabi_(void)
       
    34     {
       
    35     CODE16
       
    36 #ifndef _NO_FP
       
    37     IMPORT    _fp_init [WEAK]
       
    38 #endif
       
    39     IMPORT    |SHT$$INIT_ARRAY$$Base| [WEAK]
       
    40     IMPORT    |SHT$$INIT_ARRAY$$Limit| [WEAK]
       
    41 
       
    42     // export std::nothrow from here
       
    43     EXPORT    _ZSt7nothrow
       
    44 
       
    45 #ifndef _NO_FP
       
    46     LDR      r0,fpinit
       
    47 #endif
       
    48     PUSH     {r4-r6,r14}
       
    49 #ifndef _NO_FP
       
    50     CMP      r0,#0
       
    51     BEQ      skip
       
    52     BL       _fp_init  ;
       
    53 skip
       
    54 #endif
       
    55     LDR      r4,base
       
    56     LDR      r5,limit
       
    57     B        check
       
    58 loop
       
    59     LDR      r0,[r4,#0]
       
    60 
       
    61     BLX      r0
       
    62     ADD      r4,#4
       
    63 check
       
    64     CMP      r4,r5
       
    65     BCC      loop
       
    66     POP      {r4-r6,pc}
       
    67 
       
    68 #ifndef _NO_FP
       
    69     ALIGN 4 
       
    70 fpinit
       
    71     DCD    _fp_init
       
    72 #endif
       
    73 
       
    74 // cheat - saved a whole 4 bytes!!! - value is never used
       
    75 _ZSt7nothrow
       
    76 base
       
    77     DCD    |SHT$$INIT_ARRAY$$Base|
       
    78 limit
       
    79     DCD    |SHT$$INIT_ARRAY$$Limit|
       
    80 
       
    81     }
       
    82 
       
    83 #else
       
    84   __asm void __cpp_initialize__aeabi_(void)
       
    85     {
       
    86     CODE32
       
    87 #ifndef _NO_FP
       
    88     IMPORT    _fp_init [WEAK]
       
    89 #endif
       
    90     IMPORT    |SHT$$INIT_ARRAY$$Base| [WEAK]
       
    91     IMPORT    |SHT$$INIT_ARRAY$$Limit| [WEAK]
       
    92 
       
    93     // export std::nothrow from here
       
    94     EXPORT    _ZSt7nothrow
       
    95 
       
    96 #ifndef _NO_FP
       
    97     LDR	     r0, fpinit
       
    98 #endif
       
    99     STMFD    r13!,{r3-r5,r14}
       
   100 #ifndef _NO_FP
       
   101     CMP      r0, #0
       
   102     BEQ	     skip
       
   103     BL	     _fp_init
       
   104 skip
       
   105 #endif
       
   106     LDR      r4,base
       
   107     LDR      r5,limit
       
   108     CMP      r4,r5
       
   109     LDMEQFD  r13!,{r3-r5,pc}
       
   110 loop
       
   111 	LDR      r0,[r4,#0]
       
   112 #ifdef __MARM_ARMV4__
       
   113     ADR      r14,ret
       
   114     MOV      pc,r0
       
   115 #else
       
   116     BLX      r0
       
   117 #endif
       
   118 ret
       
   119     ADD      r4,r4,#4
       
   120     CMP      r4,r5
       
   121     BNE      loop
       
   122     LDMFD    r13!,{r3-r5,pc}
       
   123 
       
   124 #ifndef _NO_FP
       
   125 fpinit
       
   126     DCD    _fp_init
       
   127 #endif
       
   128 
       
   129 base
       
   130     DCD    |SHT$$INIT_ARRAY$$Base|
       
   131 limit
       
   132     DCD    |SHT$$INIT_ARRAY$$Limit|
       
   133 
       
   134 // cheat - defining this here saves a whole 4 bytes!!! - value is never used
       
   135 _ZSt7nothrow
       
   136 
       
   137     }
       
   138 #endif
       
   139 
       
   140 }