os/kernelhwsrv/kernel/eka/compsupp/rvct2_1/ucppinit_aeabi.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2003-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 "ARM EABI LICENCE.txt"
     5 // which accompanies this distribution, and is available
     6 // in kernel/eka/compsupp.
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // toplevel initialization/destruction routines for 'user side' code compiled 
    15 // with the ARMCC EABI compiler. intended for static linking
    16 // 
    17 //
    18 
    19 extern "C" {
    20 
    21 // This calls each of the compiler constructed functions referenced from pi_ctorvec.
    22 // These functions arrange to 'call' the appropriate constructor for the 'static' instance
    23 // (in fact the call may be inlined). If the class of the instance has a destructor then 
    24 // compiler records that this object needs 'destructing' at 'exit' time. It does this by 
    25 // calling the function __cxa_atexit. We provide our own definition of this.
    26 // 
    27 // This is the EABI compliant version - it uses .init_array rather than C$$pi_ctorvec
    28 // which means we need to do via assembler :-(
    29 
    30 #ifdef __thumb
    31   __asm void __cpp_initialize__aeabi_(void)
    32     {
    33     CODE16
    34 #ifndef _NO_FP
    35     IMPORT    _fp_init [WEAK]
    36 #endif
    37     IMPORT    |.init_array$$Base| [WEAK]
    38     IMPORT    |.init_array$$Limit| [WEAK]
    39 
    40     // export std::nothrow from here
    41     EXPORT    _ZSt7nothrow
    42 
    43 #ifndef _NO_FP
    44     LDR      r0,fpinit
    45 #endif
    46     PUSH     {r4-r6,r14}
    47 #ifndef _NO_FP
    48     CMP      r0,#0
    49     BEQ      skip
    50     BL       _fp_init  ;
    51 skip
    52 #endif
    53     LDR      r4,base
    54     LDR      r5,limit
    55     B        check
    56 loop
    57     LDR      r0,[r4,#0]
    58     ADD      r0,r0,r4
    59 
    60     BLX      r0
    61     ADD      r4,#4
    62 check
    63     CMP      r4,r5
    64     BCC      loop
    65     POP      {r4-r6,pc}
    66 
    67 #ifndef _NO_FP
    68 fpinit
    69     DCD    _fp_init
    70 #endif
    71 
    72 // cheat - saved a whole 4 bytes!!! - value is never user
    73 _ZSt7nothrow
    74 base
    75     DCD    |.init_array$$Base|
    76 limit
    77     DCD    |.init_array$$Limit|
    78 
    79     }
    80 
    81 #else
    82   __asm void __cpp_initialize__aeabi_(void)
    83     {
    84     CODE32
    85 #ifndef _NO_FP
    86     IMPORT    _fp_init [WEAK]
    87 #endif
    88     IMPORT    |.init_array$$Base| [WEAK]
    89     IMPORT    |.init_array$$Limit| [WEAK]
    90 
    91     // export std::nothrow from here
    92     EXPORT    _ZSt7nothrow
    93 
    94 #ifndef _NO_FP
    95     LDR	     r0, fpinit
    96 #endif
    97     STMFD    r13!,{r3-r5,r14}
    98 #ifndef _NO_FP
    99     CMP      r0, #0
   100     BEQ	     skip
   101     BL	     _fp_init
   102 skip
   103 #endif
   104     LDR      r4,base
   105     LDR      r5,limit
   106     CMP      r4,r5
   107     LDMEQFD  r13!,{r3-r5,pc}
   108 loop
   109     LDR      r0,[r4,#0]
   110     ADR      r14,ret
   111     ADD      r0,r0,r4
   112     MOV      pc,r0
   113 ret
   114     ADD      r4,r4,#4
   115     CMP      r4,r5
   116     BNE      loop
   117     LDMFD    r13!,{r3-r5,pc}
   118 
   119 #ifndef _NO_FP
   120 fpinit
   121     DCD    _fp_init
   122 #endif
   123 
   124 base
   125     DCD    |.init_array$$Base|
   126 limit
   127     DCD    |.init_array$$Limit|
   128 
   129 // cheat - defining this here saves a whole 4 bytes!!! - value is never user
   130 _ZSt7nothrow
   131 
   132     }
   133 #endif
   134 
   135 }
   136