From c3d9e5fa6f68acf8144677e5910c9294b9337802 Mon Sep 17 00:00:00 2001 From: Eyck-Alexander Jentzsch Date: Fri, 28 Mar 2025 23:03:53 +0100 Subject: [PATCH] adds proper device based r/w to tgc_vp --- env/moonlight/bsp_read.c | 8 +++++--- env/moonlight/bsp_write.c | 7 +++++-- libwrap/CMakeLists.txt | 1 + 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/env/moonlight/bsp_read.c b/env/moonlight/bsp_read.c index 7909286..68ba715 100644 --- a/env/moonlight/bsp_read.c +++ b/env/moonlight/bsp_read.c @@ -1,3 +1,4 @@ +#include "platform.h" #include #include #include @@ -5,14 +6,15 @@ 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); + for (current = (uint8_t *)ptr; (current < ((uint8_t *)ptr) + len) && + (get_uart_rx_tx_reg_rx_avail(uart) > 0); current++) { - *current = *uart_rx; + *current = uart_read(uart); result++; } + return result; } return EOF; diff --git a/env/moonlight/bsp_write.c b/env/moonlight/bsp_write.c index a10f78e..5e16b4e 100644 --- a/env/moonlight/bsp_write.c +++ b/env/moonlight/bsp_write.c @@ -1,5 +1,6 @@ /* See LICENSE of license details. */ +#include "platform.h" #include #include #include @@ -9,10 +10,12 @@ 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]; + uart_write(uart, current[jj]); + if (current[jj] == '\n') { + uart_write(uart, '\r'); + } } return len; } - return 1; } diff --git a/libwrap/CMakeLists.txt b/libwrap/CMakeLists.txt index aa0b488..1951e82 100644 --- a/libwrap/CMakeLists.txt +++ b/libwrap/CMakeLists.txt @@ -36,5 +36,6 @@ foreach(FILE ${LIB_SOURCES}) endforeach() add_library(wrap STATIC ${LIB_SOURCES} ../env/${BOARD_BASE}/bsp_write.c ../env/${BOARD_BASE}/bsp_read.c) +target_include_directories(wrap PUBLIC ../include) target_link_options(wrap INTERFACE ${WRAP_ARGS})