Merge branch 'cmake_flow' into develop

This commit is contained in:
2025-05-22 12:19:52 +02:00
93 changed files with 3507 additions and 3935 deletions

View File

@ -1,8 +1,9 @@
/* See LICENSE of license details. */
#include "platform.h"
#include "weak_under_alias.h"
//#include <stdint.h>
#include <unistd.h>
#include <stdint.h>
#if defined(SEMIHOSTING)
#include "semihosting.h"
#endif
@ -18,19 +19,17 @@ 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;
write(STDERR_FILENO, "\n", 1);
// tohost = (code << 1) + 1; // here used to stop simulation
write(STDERR_FILENO, "\x04", 1);
for (;;)
;
}

View File

@ -1,45 +1,11 @@
/* See LICENSE of license details. */
#include <errno.h>
#include <stdint.h>
#include <sys/types.h>
#include "weak_under_alias.h"
#include <string.h>
#include <unistd.h>
#include "platform.h"
#include "stub.h"
#include "weak_under_alias.h"
#if defined(SEMIHOSTING)
#include "semihosting.h"
#endif
extern ssize_t _bsp_write(int, const void *, size_t);
int __wrap_puts(const char *s) {
#if defined(SEMIHOSTING)
sh_write0(s);
return 0;
#endif
while (*s != '\0') {
#if defined(BOARD_ehrenberg) || defined(BOARD_tgc_vp)
while (get_uart_rx_tx_reg_tx_free(uart) == 0)
;
uart_write(uart, *s);
#elif defined(BOARD_iss)
*((uint32_t *)0xFFFF0000) = *s;
#elif defined(BOARD_TGCP)
// TODO: implement
#else
while (UART0_REG(UART_REG_TXFIFO) & 0x80000000)
;
UART0_REG(UART_REG_TXFIFO) = *s;
if (*s == '\n') {
while (UART0_REG(UART_REG_TXFIFO) & 0x80000000)
;
UART0_REG(UART_REG_TXFIFO) = '\r';
}
#endif
++s;
}
return 0;
int len = strlen(s);
return _bsp_write(STDOUT_FILENO, s, len);
}
weak_under_alias(puts);

View File

@ -1,62 +1,10 @@
/* See LICENSE of license details. */
#include <errno.h>
#include <stdint.h>
#include <sys/types.h>
#include "weak_under_alias.h"
#include <unistd.h>
#include "platform.h"
#include "stub.h"
#include "weak_under_alias.h"
#if defined(SEMIHOSTING)
#include "semihosting.h"
#endif
extern ssize_t _bsp_read(int fd, void *ptr, size_t len);
ssize_t __wrap_read(int fd, void *ptr, size_t len) {
uint8_t *current = (uint8_t *)ptr;
#if defined(SEMIHOSTING)
int i = sh_read(current, fd, len);
return i;
#endif
#if defined(BOARD_hifive1)
volatile uint32_t *uart_rx = (uint32_t *)(UART0_CTRL_ADDR + UART_REG_RXFIFO);
volatile uint8_t *uart_rx_cnt =
(uint8_t *)(UART0_CTRL_ADDR + UART_REG_RXCTRL + 2);
#elif defined(BOARD_iss)
volatile uint32_t *uart_rx = (uint32_t *)0xFFFF0000;
#elif defined(BOARD_TGCP)
// TODO: implement
#elif !defined(BOARD_ehrenberg) && !defined(BOARD_tgc_vp)
volatile uint32_t *uart_rx = (uint32_t *)(UART0_BASE_ADDR + UART_REG_RXFIFO);
volatile uint8_t *uart_rx_cnt =
(uint8_t *)(UART0_BASE_ADDR + UART_REG_RXCTRL + 2);
#endif
ssize_t result = 0;
if (isatty(fd)) {
#if defined(BOARD_ehrenberg) || defined(BOARD_tgc_vp)
for (current = (uint8_t *)ptr; (current < ((uint8_t *)ptr) + len) &&
(get_uart_rx_tx_reg_rx_avail(uart) > 0);
current++) {
*current = uart_read(uart);
result++;
}
#elif defined(BOARD_iss)
for (current = (uint8_t *)ptr; (current < ((uint8_t *)ptr) + len);
current++) {
*current = *uart_rx;
result++;
}
#elif defined(BOARD_TGCP)
// TODO: implement
#else
for (current = (uint8_t *)ptr;
(current < ((uint8_t *)ptr) + len) && (*uart_rx_cnt > 0); current++) {
*current = *uart_rx;
result++;
}
#endif
return result;
}
return _stub(EBADF);
return _bsp_read(fd, ptr, len);
}
weak_under_alias(read);

View File

@ -1,72 +1,9 @@
/* See LICENSE of license details. */
#include <errno.h>
#include <stdint.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdint.h>
#include "platform.h"
#include "stub.h"
#include "weak_under_alias.h"
#if defined(SEMIHOSTING)
#include "semihosting.h"
#endif
extern uint32_t tohost;
#include <stdint.h>
#include <unistd.h>
extern ssize_t _bsp_write(int, const void *, size_t);
ssize_t __wrap_write(int fd, const void *ptr, size_t len) {
const uint8_t *current = (const uint8_t *)ptr;
#if defined(SEMIHOSTING)
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;
#elif defined(BOARD_iss)
volatile uint64_t payload[4];
payload[0]= 64;
payload[1]= 0;
payload[2]= (uintptr_t)ptr;
payload[3]= len;
tohost = (uint32_t)payload;
return len;
#endif
if (isatty(fd)) {
for (size_t jj = 0; jj < len; jj++) {
#if defined(BOARD_ehrenberg) || defined(BOARD_tgc_vp)
while (get_uart_rx_tx_reg_tx_free(uart) == 0)
;
uart_write(uart, current[jj]);
if (current[jj] == '\n') {
while (get_uart_rx_tx_reg_tx_free(uart) == 0)
;
uart_write(uart, '\r');
}
#elif defined(BOARD_iss)
// *((uint32_t *)0xFFFF0000) = current[jj];
#elif defined(BOARD_TGCP)
// TODO: implement
#else
while (UART0_REG(UART_REG_TXFIFO) & 0x80000000)
;
UART0_REG(UART_REG_TXFIFO) = current[jj];
if (current[jj] == '\n') {
while (UART0_REG(UART_REG_TXFIFO) & 0x80000000)
;
UART0_REG(UART_REG_TXFIFO) = '\r';
}
#endif
}
return len;
}
return _stub(EBADF);
return _bsp_write(fd, ptr, len);
}
weak_under_alias(write);