diff options
Diffstat (limited to 'targets/corstone-300/retarget.c')
-rw-r--r-- | targets/corstone-300/retarget.c | 29 |
1 files changed, 22 insertions, 7 deletions
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); |