diff --git a/arch/xtensa/core/crt1-boards.S b/arch/xtensa/core/crt1-boards.S index 7b7d09b06da..c24092c80b0 100644 --- a/arch/xtensa/core/crt1-boards.S +++ b/arch/xtensa/core/crt1-boards.S @@ -18,11 +18,10 @@ /* Exports */ .global _start +.global exit /* * Imports - * __clibrary_init from C library (eg. newlib or uclibc) - * exit from C library * main from user application * board_init board-specific (uart/mingloss/tinygloss.c) * xthal_dcache_all_writeback from HAL library @@ -214,28 +213,12 @@ _start: #else /* !HALT */ .type board_init, @function - .type __clibrary_init, @function .type exit, @function /* Initialize the board (eg. UART, etc). */ CALL board_init - /* - * Call __clibrary_init to initialize the C library: - * - * void __clibrary_init(int argc, char ** argv, char ** environ, - * void(*init_func)(void), void(*fini_func)(void)); - * Pass an empty argv array, with an empty string as the program name - */ - movi ARG1, _start_argc /* argc address */ - movi ARG2, _start_argv /* argv = ["", 0] */ - movi ARG3, _start_envp /* envp = [0] */ - movi ARG4, _init /* function that calls constructors */ - movi ARG5, _fini /* function that calls destructors */ - l32i ARG1, ARG1, 0 /* argc = 1 */ - CALL __clibrary_init - /* Call: int main(int argc, char ** argv, char ** environ); */ movi ARG1, _start_argc /* argc address */ movi ARG2, _start_argv /* argv = ["", 0] */ @@ -269,3 +252,12 @@ _start_argc: .size _start, . - _start + .align 4 +exit: +#if XCHAL_HAVE_INTERRUPTS + waiti 15 +#endif + j exit + + .size exit, . - exit + diff --git a/arch/xtensa/core/crt1-sim.S b/arch/xtensa/core/crt1-sim.S index 665e24fee68..22af3708f07 100644 --- a/arch/xtensa/core/crt1-sim.S +++ b/arch/xtensa/core/crt1-sim.S @@ -17,16 +17,14 @@ /* Exports */ .global _start .global __start +.global exit /* * Imports - * __clibrary_init from C library (eg. newlib or uclibc) - * exit from C library * main from user application * __stack from linker script (see LSP Ref Manual) */ -.type __clibrary_init, @function .type _Cstart, @function .type exit, @function @@ -34,6 +32,7 @@ /* Macros to abstract away ABI differences */ #if __XTENSA_CALL0_ABI__ +# define ENTRY # define CALL call0 # define CALLX callx0 # define ARG1 a2 /* 1st outgoing call argument */ @@ -42,6 +41,7 @@ # define ARG4 a5 /* 4th outgoing call argument */ # define ARG5 a6 /* 5th outgoing call argument */ #else +# define ENTRY entry sp, 0x20 # define CALL call4 # define CALLX callx4 # define ARG1 a6 /* 1st outgoing call argument */ @@ -210,13 +210,6 @@ __start: #endif - /* - * Call __clibrary_init to initialize the C library: - * - * void __clibrary_init(int argc, char ** argv, char ** environ, - * void(*init_func)(void), void(*fini_func)(void)); - */ - /* Get argv with the arguments from the ISS */ mov a3, sp /* tell simcall where to write argv[] */ movi a2, SYS_iss_set_argv @@ -236,6 +229,14 @@ __start: .size _start, . - _start + .align 4 +exit: + ENTRY + mov a3, a2 + movi a2, SYS_exit + simcall + + .size exit, . - exit /* * Local Variables: diff --git a/scripts/Makefile.toolchain.xcc b/scripts/Makefile.toolchain.xcc index ec49be3aa32..7846f4add34 100644 --- a/scripts/Makefile.toolchain.xcc +++ b/scripts/Makefile.toolchain.xcc @@ -53,7 +53,7 @@ XTSC_INC_FILE=$(notdir ${XTSC_INC}) # Include XCC standard libraries so that users used to Xplorer IDE can port # their code easily -TOOLCHAIN_LIBS += gcc c sim hal +TOOLCHAIN_LIBS += gcc hal LIB_INCLUDE_DIR += -L${XTENSA_BUILD}/xtensa-elf/lib/xcc \ -L${XTENSA_BUILD}/xtensa-elf/lib \ -L${XTENSA_BUILD}/xtensa-elf/arch/lib