2020-06-18 12:15:52 +02:00
|
|
|
/* See LICENSE of license details. */
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include "platform.h"
|
|
|
|
|
2023-08-20 15:00:51 +02:00
|
|
|
extern volatile uint32_t tohost;
|
|
|
|
extern volatile uint32_t fromhost;
|
2023-09-30 20:31:58 +02:00
|
|
|
void write_hex(int fd, uint32_t hex);
|
2023-08-20 15:00:51 +02:00
|
|
|
|
2020-06-18 12:15:52 +02:00
|
|
|
void __wrap__exit(int code)
|
|
|
|
{
|
|
|
|
//volatile uint32_t* leds = (uint32_t*) (GPIO_BASE_ADDR + GPIO_OUT_OFFSET);
|
|
|
|
const char message[] = "\nProgam has exited with code:";
|
|
|
|
//*leds = (~(code));
|
|
|
|
|
|
|
|
write(STDERR_FILENO, message, sizeof(message) - 1);
|
|
|
|
write_hex(STDERR_FILENO, code);
|
|
|
|
write(STDERR_FILENO, "\n", 1);
|
2023-10-16 13:04:11 +02:00
|
|
|
#ifdef USE_TOHOST
|
2023-08-20 15:00:51 +02:00
|
|
|
tohost = code+1;
|
2023-10-16 13:04:11 +02:00
|
|
|
#endif
|
2023-08-20 15:00:51 +02:00
|
|
|
write(STDERR_FILENO, "\x04", 1);
|
2020-06-18 12:15:52 +02:00
|
|
|
for (;;);
|
|
|
|
}
|