kernel/eka/compsupp/rvct2_1/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 *
       
    18 */
       
    19 
       
    20 
       
    21 extern "C" {
       
    22 
       
    23 // This calls each of the compiler constructed functions referenced from pi_ctorvec.
       
    24 // These functions arrange to 'call' the appropriate constructor for the 'static' instance
       
    25 // (in fact the call may be inlined). If the class of the instance has a destructor then 
       
    26 // compiler records that this object needs 'destructing' at 'exit' time. It does this by 
       
    27 // calling the function __cxa_atexit. We provide our own definition of this.
       
    28 // 
       
    29 // This is the EABI compliant version - it uses .init_array rather than C$$pi_ctorvec
       
    30 // which means we need to do via assembler :-(
       
    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    |.init_array$$Base| [WEAK]
       
    40     IMPORT    |.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     ADD      r0,r0,r4
       
    61 
       
    62     BLX      r0
       
    63     ADD      r4,#4
       
    64 check
       
    65     CMP      r4,r5
       
    66     BCC      loop
       
    67     POP      {r4-r6,pc}
       
    68 
       
    69 #ifndef _NO_FP
       
    70 fpinit
       
    71     DCD    _fp_init
       
    72 #endif
       
    73 
       
    74 // cheat - saved a whole 4 bytes!!! - value is never user
       
    75 _ZSt7nothrow
       
    76 base
       
    77     DCD    |.init_array$$Base|
       
    78 limit
       
    79     DCD    |.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    |.init_array$$Base| [WEAK]
       
    91     IMPORT    |.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     ADR      r14,ret
       
   113     ADD      r0,r0,r4
       
   114     MOV      pc,r0
       
   115 ret
       
   116     ADD      r4,r4,#4
       
   117     CMP      r4,r5
       
   118     BNE      loop
       
   119     LDMFD    r13!,{r3-r5,pc}
       
   120 
       
   121 #ifndef _NO_FP
       
   122 fpinit
       
   123     DCD    _fp_init
       
   124 #endif
       
   125 
       
   126 base
       
   127     DCD    |.init_array$$Base|
       
   128 limit
       
   129     DCD    |.init_array$$Limit|
       
   130 
       
   131 // cheat - defining this here saves a whole 4 bytes!!! - value is never user
       
   132 _ZSt7nothrow
       
   133 
       
   134     }
       
   135 #endif
       
   136 
       
   137 }
       
   138