From 890d4478a3c05468f0cfc0b162e3e18af917ab9c Mon Sep 17 00:00:00 2001 From: Eyck-Alexander Jentzsch Date: Mon, 24 Mar 2025 08:28:56 +0100 Subject: [PATCH] adds bsp write and read for rtl --- env/testbench/rtl/bsp_read.c | 19 +++++++++++++++++++ env/testbench/rtl/bsp_write.c | 18 ++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 env/testbench/rtl/bsp_read.c create mode 100644 env/testbench/rtl/bsp_write.c 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; +}