adds bsp write and read for rtl

This commit is contained in:
Eyck-Alexander Jentzsch 2025-03-24 08:28:56 +01:00
parent 7d55172d51
commit 890d4478a3
2 changed files with 37 additions and 0 deletions

19
env/testbench/rtl/bsp_read.c vendored Normal file
View File

@ -0,0 +1,19 @@
#include <stdint.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
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;
}

18
env/testbench/rtl/bsp_write.c vendored Normal file
View File

@ -0,0 +1,18 @@
/* See LICENSE of license details. */
#include <errno.h>
#include <stdint.h>
#include <sys/types.h>
#include <unistd.h>
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;
}