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

25 lines
618 B
C
Raw 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-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
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);