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