Forked.

Fork of mbed-dev by mbed official

Committer:
bogdanm
Date:
Thu Oct 01 15:25:22 2015 +0300
Revision:
0:9b334a45a8ff
Child:
144:ef7eb2e8f9f7
Initial commit on mbed-dev

Replaces mbed-src (now inactive)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 0:9b334a45a8ff 1 /**************************************************
bogdanm 0:9b334a45a8ff 2 *
bogdanm 0:9b334a45a8ff 3 * Part two of the system initialization code, contains C-level
bogdanm 0:9b334a45a8ff 4 * initialization, thumb-2 only variant.
bogdanm 0:9b334a45a8ff 5 *
bogdanm 0:9b334a45a8ff 6 * Copyright 2006 IAR Systems. All rights reserved.
bogdanm 0:9b334a45a8ff 7 *
bogdanm 0:9b334a45a8ff 8 * $Revision: 59783 $
bogdanm 0:9b334a45a8ff 9 *
bogdanm 0:9b334a45a8ff 10 **************************************************/
bogdanm 0:9b334a45a8ff 11
bogdanm 0:9b334a45a8ff 12
bogdanm 0:9b334a45a8ff 13 ; --------------------------------------------------
bogdanm 0:9b334a45a8ff 14 ; Module ?cmain, C-level initialization.
bogdanm 0:9b334a45a8ff 15 ;
bogdanm 0:9b334a45a8ff 16
bogdanm 0:9b334a45a8ff 17
bogdanm 0:9b334a45a8ff 18 SECTION SHT$$PREINIT_ARRAY:CONST:NOROOT(2)
bogdanm 0:9b334a45a8ff 19 SECTION SHT$$INIT_ARRAY:CONST:NOROOT(2)
bogdanm 0:9b334a45a8ff 20
bogdanm 0:9b334a45a8ff 21 SECTION .text:CODE:NOROOT(2)
bogdanm 0:9b334a45a8ff 22
bogdanm 0:9b334a45a8ff 23 PUBLIC __cmain
bogdanm 0:9b334a45a8ff 24 ;; Keep ?main for legacy reasons, it is accessed in countless instances of cstartup.s around the world...
bogdanm 0:9b334a45a8ff 25 PUBLIC ?main
bogdanm 0:9b334a45a8ff 26 EXTWEAK __iar_data_init3
bogdanm 0:9b334a45a8ff 27 EXTWEAK __iar_argc_argv
bogdanm 0:9b334a45a8ff 28 EXTERN __low_level_init
bogdanm 0:9b334a45a8ff 29 EXTERN __call_ctors
bogdanm 0:9b334a45a8ff 30 EXTERN main
bogdanm 0:9b334a45a8ff 31 EXTERN exit
bogdanm 0:9b334a45a8ff 32 EXTERN __iar_dynamic_initialization
bogdanm 0:9b334a45a8ff 33 EXTERN mbed_sdk_init
bogdanm 0:9b334a45a8ff 34 EXTERN SystemInit
bogdanm 0:9b334a45a8ff 35
bogdanm 0:9b334a45a8ff 36 THUMB
bogdanm 0:9b334a45a8ff 37 __cmain:
bogdanm 0:9b334a45a8ff 38 ?main:
bogdanm 0:9b334a45a8ff 39
bogdanm 0:9b334a45a8ff 40 ; Initialize segments.
bogdanm 0:9b334a45a8ff 41 ; __segment_init and __low_level_init are assumed to use the same
bogdanm 0:9b334a45a8ff 42 ; instruction set and to be reachable by BL from the ICODE segment
bogdanm 0:9b334a45a8ff 43 ; (it is safest to link them in segment ICODE).
bogdanm 0:9b334a45a8ff 44
bogdanm 0:9b334a45a8ff 45 FUNCALL __cmain, __low_level_init
bogdanm 0:9b334a45a8ff 46 bl __low_level_init
bogdanm 0:9b334a45a8ff 47 cmp r0,#0
bogdanm 0:9b334a45a8ff 48 beq ?l1
bogdanm 0:9b334a45a8ff 49 FUNCALL __cmain, __iar_data_init3
bogdanm 0:9b334a45a8ff 50 bl __iar_data_init3
bogdanm 0:9b334a45a8ff 51 MOVS r0,#0 ; No parameters
bogdanm 0:9b334a45a8ff 52 FUNCALL __cmain, mbed_sdk_init
bogdanm 0:9b334a45a8ff 53 BL mbed_sdk_init
bogdanm 0:9b334a45a8ff 54 MOVS r0,#0 ; No parameters
bogdanm 0:9b334a45a8ff 55 FUNCALL __cmain, __iar_dynamic_initialization
bogdanm 0:9b334a45a8ff 56 BL __iar_dynamic_initialization ; C++ dynamic initialization
bogdanm 0:9b334a45a8ff 57
bogdanm 0:9b334a45a8ff 58 ?l1:
bogdanm 0:9b334a45a8ff 59 REQUIRE ?l3
bogdanm 0:9b334a45a8ff 60
bogdanm 0:9b334a45a8ff 61 SECTION .text:CODE:NOROOT(2)
bogdanm 0:9b334a45a8ff 62
bogdanm 0:9b334a45a8ff 63 PUBLIC _main
bogdanm 0:9b334a45a8ff 64 PUBLIC _call_main
bogdanm 0:9b334a45a8ff 65 THUMB
bogdanm 0:9b334a45a8ff 66
bogdanm 0:9b334a45a8ff 67 __iar_init$$done: ; Copy initialization is done
bogdanm 0:9b334a45a8ff 68
bogdanm 0:9b334a45a8ff 69 ?l3:
bogdanm 0:9b334a45a8ff 70 _call_main:
bogdanm 0:9b334a45a8ff 71 MOVS r0,#0 ; No parameters
bogdanm 0:9b334a45a8ff 72 FUNCALL __cmain, __iar_argc_argv
bogdanm 0:9b334a45a8ff 73 BL __iar_argc_argv ; Maybe setup command line
bogdanm 0:9b334a45a8ff 74
bogdanm 0:9b334a45a8ff 75 FUNCALL __cmain, main
bogdanm 0:9b334a45a8ff 76 BL main
bogdanm 0:9b334a45a8ff 77 _main:
bogdanm 0:9b334a45a8ff 78 FUNCALL __cmain, exit
bogdanm 0:9b334a45a8ff 79 BL exit
bogdanm 0:9b334a45a8ff 80
bogdanm 0:9b334a45a8ff 81 END