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