updates the bsp_write and exit
This commit is contained in:
parent
ada4881d33
commit
7d55172d51
13
env/iss/bsp_write.c
vendored
13
env/iss/bsp_write.c
vendored
@ -7,14 +7,17 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
extern volatile uint32_t tohost;
|
||||
extern volatile uint64_t tohost;
|
||||
|
||||
__attribute__((optimize("O0"))) ssize_t _bsp_write(int fd, const void *ptr,
|
||||
size_t len) {
|
||||
ssize_t _bsp_write(int fd, const void *ptr, size_t len) {
|
||||
|
||||
if (isatty(fd)) {
|
||||
uint64_t payload[4] = {64, 0, (uintptr_t)((uint32_t *)ptr), len};
|
||||
tohost = (uint32_t)payload;
|
||||
volatile uint64_t payload[8];
|
||||
memset((void *)payload, 0, 8 * sizeof(uint64_t));
|
||||
payload[0] = 64;
|
||||
payload[2] = (uintptr_t)ptr;
|
||||
payload[3] = len;
|
||||
tohost = (uintptr_t)payload;
|
||||
/*
|
||||
// accoring to my understading this part is used fot uart wrrite for later
|
||||
for (size_t jj = 0; jj < len; jj++) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* See LICENSE of license details. */
|
||||
|
||||
#include "weak_under_alias.h"
|
||||
//#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#if defined(SEMIHOSTING)
|
||||
#include "semihosting.h"
|
||||
@ -17,19 +18,16 @@ extern volatile uint32_t fromhost;
|
||||
void write_hex(int fd, uint32_t hex);
|
||||
|
||||
void __wrap_exit(int code) {
|
||||
/*#if defined(SEMIHOSTING)
|
||||
sh_exit();
|
||||
return;
|
||||
#endif*/
|
||||
|
||||
// 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);
|
||||
tohost = code + 1;
|
||||
tohost = (code << 1) + 1;
|
||||
write(STDERR_FILENO, "\x04", 1);
|
||||
|
||||
for (;;)
|
||||
;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user