From f62c3d756917295146d415fcba7b5208c13874f7 Mon Sep 17 00:00:00 2001 From: Kristofer Jonsson Date: Thu, 21 Jan 2021 17:39:03 +0100 Subject: Build system refactoring The source tree is configured for a specific target as defined in the targets directory. The common target components are defined in targets/common. Targets for real platform should include this directory to get the default target libraries setup. Change-Id: I7fced4bfacec97432cbbd4125bd5b4cdd21122e3 --- targets/corstone-300/retarget.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'targets/corstone-300/retarget.c') diff --git a/targets/corstone-300/retarget.c b/targets/corstone-300/retarget.c index 1598427..d53431f 100644 --- a/targets/corstone-300/retarget.c +++ b/targets/corstone-300/retarget.c @@ -183,7 +183,28 @@ char *RETARGET(_command_string)(char *cmd, int len) { } void RETARGET(_exit)(int return_code) { - exit(return_code); + char exit_code_buffer[64] = {0}; + const char *p = exit_code_buffer; + + /* Print out the exit code on the uart so any reader know how we exit. */ + /* By appending 0x04, ASCII for end-of-transmission the FVP model exits, + * if the configuration parameter shutdown_on_eot on the uart is enabled. + * For some versions of FVP, the shutdown_on_eot is broken, but the same + * behaviour can be created by passing specifying a shutdown_tag= for the + * uart when starting the model so that is added last as well. + */ + + snprintf(exit_code_buffer, sizeof(exit_code_buffer), + "Application exit code: %d.\n" // Let the readers know how we exit + "\04\n" // end-of-transmission + "EXITTHESIM\n", // shutdown_tag + return_code); + + while (*p != '\0') { + uart_putc(*p++); + } + + while (1) {} } int system(const char *cmd) { @@ -231,12 +252,6 @@ int rename(const char *oldn, const char *newn) { return 0; } -void exit(int code) { - uart_putc((char)0x4); - uart_putc((char)code); - while (1) {} -} - int fputc(int ch, FILE *f) { (void)(f); return uart_putc(ch); -- cgit v1.2.1