Firmwares/bare-metal-bsp/libwrap/sys/_exit.c

31 lines
727 B
C
Raw Permalink Normal View History

2020-06-18 12:15:52 +02:00
/* See LICENSE of license details. */
#include <unistd.h>
#include "platform.h"
2023-11-23 18:29:26 +01:00
#include "weak_under_alias.h"
2020-06-18 12:15:52 +02:00
2023-11-24 11:39:23 +01:00
#if defined(BOARD_hifive1)
static volatile uint32_t tohost;
static volatile uint32_t fromhost;
#else
2023-08-20 15:00:51 +02:00
extern volatile uint32_t tohost;
extern volatile uint32_t fromhost;
2023-11-24 11:39:23 +01:00
#endif
2023-09-30 20:31:58 +02:00
void write_hex(int fd, uint32_t hex);
2023-08-20 15:00:51 +02:00
2023-11-23 18:29:26 +01:00
void __wrap_exit(int code)
2020-06-18 12:15:52 +02:00
{
//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-08-20 15:00:51 +02:00
tohost = code+1;
write(STDERR_FILENO, "\x04", 1);
2020-06-18 12:15:52 +02:00
for (;;);
}
2023-11-23 18:29:26 +01:00
weak_under_alias(exit);