os/kernelhwsrv/kernel/eka/compsupp/rvct2_2/ucppinit_aeabi.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
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
// The code supports 2.2 both bpabi and non-bpabi. The values in .init_array are
sl@0
    17
// pointers in both environments, so the library is common to both.
sl@0
    18
// 
sl@0
    19
//
sl@0
    20
sl@0
    21
extern "C" {
sl@0
    22
sl@0
    23
// This calls each of the compiler constructed functions referenced from pi_ctorvec.
sl@0
    24
// These functions arrange to 'call' the appropriate constructor for the 'static' instance
sl@0
    25
// (in fact the call may be inlined). If the class of the instance has a destructor then 
sl@0
    26
// compiler records that this object needs 'destructing' at 'exit' time. It does this by 
sl@0
    27
// calling the function __cxa_atexit. We provide our own definition of this.
sl@0
    28
// 
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    |SHT$$INIT_ARRAY$$Base| [WEAK]
sl@0
    38
    IMPORT    |SHT$$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
sl@0
    59
    BLX      r0
sl@0
    60
    ADD      r4,#4
sl@0
    61
check
sl@0
    62
    CMP      r4,r5
sl@0
    63
    BCC      loop
sl@0
    64
    POP      {r4-r6,pc}
sl@0
    65
sl@0
    66
#ifndef _NO_FP
sl@0
    67
    ALIGN 4 
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 used
sl@0
    73
_ZSt7nothrow
sl@0
    74
base
sl@0
    75
    DCD    |SHT$$INIT_ARRAY$$Base|
sl@0
    76
limit
sl@0
    77
    DCD    |SHT$$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    |SHT$$INIT_ARRAY$$Base| [WEAK]
sl@0
    89
    IMPORT    |SHT$$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
#ifdef __MARM_ARMV4__
sl@0
   111
    ADR      r14,ret
sl@0
   112
    MOV      pc,r0
sl@0
   113
#else
sl@0
   114
    BLX      r0
sl@0
   115
#endif
sl@0
   116
ret
sl@0
   117
    ADD      r4,r4,#4
sl@0
   118
    CMP      r4,r5
sl@0
   119
    BNE      loop
sl@0
   120
    LDMFD    r13!,{r3-r5,pc}
sl@0
   121
sl@0
   122
#ifndef _NO_FP
sl@0
   123
fpinit
sl@0
   124
    DCD    _fp_init
sl@0
   125
#endif
sl@0
   126
sl@0
   127
base
sl@0
   128
    DCD    |SHT$$INIT_ARRAY$$Base|
sl@0
   129
limit
sl@0
   130
    DCD    |SHT$$INIT_ARRAY$$Limit|
sl@0
   131
sl@0
   132
// cheat - defining this here saves a whole 4 bytes!!! - value is never used
sl@0
   133
_ZSt7nothrow
sl@0
   134
sl@0
   135
    }
sl@0
   136
#endif
sl@0
   137
sl@0
   138
}