fixes TGCP environment

This commit is contained in:
Eyck Jentzsch 2024-03-20 12:53:12 +01:00
parent e051cf180e
commit 4d25972e4d
3 changed files with 16 additions and 6 deletions

7
env/TGCP/init.c vendored
View File

@ -110,12 +110,13 @@ void _fini()
} }
int is_uart_ready(int uart_id){ int is_uart_ready(int uart_id){
return 1; return !UART0_REG(UART_REG_TXFIFO) & 0x80000000;
} }
int try_write_uart_char(int uart_id, char c){ int try_write_uart_char(int uart_id, char c){
*((char*)0x10000000) = c; if(UART0_REG(UART_REG_TXFIFO) & 0x80000000) return 0;
UART0_REG(UART_REG_TXFIFO) = c;
return 1; return 1;
} }
void write_uart_char(int uart_id, char c){ void write_uart_char(int uart_id, char c){
*((char*)0x10000000) = c; UART0_REG(UART_REG_TXFIFO) = c;
} }

13
env/TGCP/platform.h vendored
View File

@ -7,7 +7,18 @@
#define MCAUSE_INT 0x80000000 #define MCAUSE_INT 0x80000000
#define MCAUSE_CAUSE 0x7FFFFFFF #define MCAUSE_CAUSE 0x7FFFFFFF
#include "bits.h" #define UART0_BASE_ADDR 0xffff0000ULL
#define UART_REG_TXFIFO 0x00
#define UART_REG_RXFIFO 0x04
#define UART_REG_TXCTRL 0x08
#define UART_REG_RXCTRL 0x0c
#define UART_REG_IE 0x10
#define UART_REG_IP 0x14
#define UART_REG_DIV 0x18
#define UART_TXEN 0x1
#define UART0_REG(ADDR) *((volatile uint32_t*) (UART0_BASE_ADDR + ADDR))
/**************************************************************************** /****************************************************************************
* Platform definitions * Platform definitions
*****************************************************************************/ *****************************************************************************/

View File

@ -22,8 +22,6 @@ ssize_t __wrap_write(int fd, const void* ptr, size_t len)
} }
#elif defined(BOARD_iss) #elif defined(BOARD_iss)
*((uint32_t*) 0xFFFF0000) = current[jj]; *((uint32_t*) 0xFFFF0000) = current[jj];
#elif defined(BOARD_TGCP)
//TODO: implement
#else #else
while (UART0_REG(UART_REG_TXFIFO) & 0x80000000) ; while (UART0_REG(UART_REG_TXFIFO) & 0x80000000) ;
UART0_REG(UART_REG_TXFIFO) = current[jj]; UART0_REG(UART_REG_TXFIFO) = current[jj];