diff --git a/env/testbench/rtl/bsp_read.c b/env/testbench/rtl/bsp_read.c new file mode 100644 index 0000000..7909286 --- /dev/null +++ b/env/testbench/rtl/bsp_read.c @@ -0,0 +1,19 @@ +#include +#include +#include +#include + +ssize_t _bsp_read(int fd, void *ptr, size_t len) { + uint8_t *current = (uint8_t *)ptr; + volatile uint32_t *uart_rx = (uint32_t *)0xFFFF0000; + ssize_t result = 0; + if (isatty(fd)) { + for (current = (uint8_t *)ptr; (current < ((uint8_t *)ptr) + len); + current++) { + *current = *uart_rx; + result++; + } + return result; + } + return EOF; +} diff --git a/env/testbench/rtl/bsp_write.c b/env/testbench/rtl/bsp_write.c new file mode 100644 index 0000000..a10f78e --- /dev/null +++ b/env/testbench/rtl/bsp_write.c @@ -0,0 +1,18 @@ +/* See LICENSE of license details. */ + +#include +#include +#include +#include + +ssize_t _bsp_write(int fd, const void *ptr, size_t len) { + const uint8_t *current = (const uint8_t *)ptr; + if (isatty(fd)) { + for (size_t jj = 0; jj < len; jj++) { + *((uint32_t *)0xFFFF0000) = current[jj]; + } + return len; + } + + return 1; +}