further semihosting support

This commit is contained in:
gabriel
2024-04-30 08:48:44 +02:00
parent e83f7996bc
commit 9aaf428620
9 changed files with 57 additions and 32 deletions

View File

@ -17,10 +17,10 @@ void write_hex(int fd, uint32_t hex);
void __wrap_exit(int code)
{
#if defined(SEMIHOSTING)
/*#if defined(SEMIHOSTING)
sh_exit();
return;
#endif
#endif*/
//volatile uint32_t* leds = (uint32_t*) (GPIO_BASE_ADDR + GPIO_OUT_OFFSET);
const char message[] = "\nProgam has exited with code:";
//*leds = (~(code));

View File

@ -1,11 +1,10 @@
/* See LICENSE of license details. */
#include <unistd.h>
#include "weak_under_alias.h"
#include "semihosting.h"
#include "weak_under_alias.h"
#include <unistd.h>
int __wrap_isatty(int fd)
{
int __wrap_isatty(int fd) {
#if defined(SEMIHOSTING)
int i = sh_istty(fd);
return i;

View File

@ -12,7 +12,7 @@ off_t __wrap_lseek(int fd, off_t ptr, int dir)
#if defined(SEMIHOSTING)
if(sh_istty(fd))
return 0;
sh_seek();
sh_seek(fd, ptr);
return ptr;
#endif
if (isatty(fd))

View File

@ -7,7 +7,7 @@
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include "semihosting.h"
//#include "semihosting.h"
#undef putchar
int putchar(int ch)
@ -115,11 +115,7 @@ static void vprintfmt(void (*putch)(int, void**), void **putdat, const char *fmt
if (ch == '\0')
return;
fmt++;
#if defined(SEMIHOSTING)
sh_writec(ch);
#else
putch(ch, putdat);
#endif
}
fmt++;

View File

@ -5,6 +5,8 @@
#include <unistd.h>
#include <sys/types.h>
#include "../../include/tgc-vp/devices/uart.h"
#include "../../env/tgc-vp/platform.h"
#include "platform.h"
#include "stub.h"
#include "weak_under_alias.h"
@ -15,7 +17,7 @@ int __wrap_puts(const char *s)
#if defined(SEMIHOSTING)
sh_write0(s);
return 0;
#endif
#endif
while (*s != '\0') {
#if defined(BOARD_ehrenberg)
while (uart_get_tx_free(uart)==0) ;

View File

@ -7,6 +7,8 @@
#if defined(BOARD_ehrenberg)
#include "platform.h"
#endif
#include "../../include/tgc-vp/devices/uart.h"
#include "/scratch/gabriel/repos/Firmwares/bare-metal-bsp/env/tgc-vp/platform.h"
#include "platform.h"
#include "stub.h"
#include "weak_under_alias.h"

View File

@ -5,6 +5,8 @@
#include <unistd.h>
#include <sys/types.h>
#include "../../include/tgc-vp/devices/uart.h"
#include "../../env/tgc-vp/platform.h"
#include "platform.h"
#include "stub.h"
#include "weak_under_alias.h"
@ -12,11 +14,19 @@
ssize_t __wrap_write(int fd, const void* ptr, size_t len)
{
const uint8_t * current = (const uint8_t *)ptr;
const uint8_t * current = (const uint8_t *)ptr;
#if defined(SEMIHOSTING)
sh_write(current, fd);
return len;
#endif
if(isatty(fd)) {
for (size_t jj = 0; jj < len; jj++) {
sh_writec(current[jj]);
}
return len;
} else {
sh_write(current, fd);
return len;
}
//return len;
#endif
if (isatty(fd)) {
for (size_t jj = 0; jj < len; jj++) {
#if defined(BOARD_ehrenberg)