fixes hifive1 build

This commit is contained in:
Eyck Jentzsch 2023-11-24 11:39:23 +01:00
parent 77ca8a01b4
commit 0188d404de
3 changed files with 26 additions and 14 deletions

View File

@ -45,6 +45,7 @@ else
endif endif
CFLAGS += -mabi=$(RISCV_ABI) CFLAGS += -mabi=$(RISCV_ABI)
CFLAGS += -mcmodel=medany CFLAGS += -mcmodel=medany
CFLAGS += -DBOARD_$(BOARD)
TRIPLET?=riscv64-unknown-elf TRIPLET?=riscv64-unknown-elf
CXX=$(TOOL_DIR)$(TRIPLET)-c++ CXX=$(TOOL_DIR)$(TRIPLET)-c++

View File

@ -4,8 +4,14 @@
#include "platform.h" #include "platform.h"
#include "weak_under_alias.h" #include "weak_under_alias.h"
#if defined(BOARD_hifive1)
static volatile uint32_t tohost;
static volatile uint32_t fromhost;
#else
extern volatile uint32_t tohost; extern volatile uint32_t tohost;
extern volatile uint32_t fromhost; extern volatile uint32_t fromhost;
#endif
void write_hex(int fd, uint32_t hex); void write_hex(int fd, uint32_t hex);
void __wrap_exit(int code) void __wrap_exit(int code)

View File

@ -11,9 +11,15 @@
ssize_t __wrap_read(int fd, void* ptr, size_t len) ssize_t __wrap_read(int fd, void* ptr, size_t len)
{ {
#if defined(BOARD_hifive1)
uint8_t * current = (uint8_t *)ptr;
volatile uint32_t * uart_rx = (uint32_t *)(UART0_CTRL_ADDR + UART_REG_RXFIFO);
volatile uint8_t * uart_rx_cnt = (uint8_t *)(UART0_CTRL_ADDR + UART_REG_RXCTRL + 2);
#else
uint8_t * current = (uint8_t *)ptr; uint8_t * current = (uint8_t *)ptr;
volatile uint32_t * uart_rx = (uint32_t *)(UART0_BASE_ADDR + UART_REG_RXFIFO); volatile uint32_t * uart_rx = (uint32_t *)(UART0_BASE_ADDR + UART_REG_RXFIFO);
volatile uint8_t * uart_rx_cnt = (uint8_t *)(UART0_BASE_ADDR + UART_REG_RXCTRL + 2); volatile uint8_t * uart_rx_cnt = (uint8_t *)(UART0_BASE_ADDR + UART_REG_RXCTRL + 2);
#endif
ssize_t result = 0; ssize_t result = 0;
@ -26,7 +32,6 @@ ssize_t __wrap_read(int fd, void* ptr, size_t len)
} }
return result; return result;
} }
return _stub(EBADF); return _stub(EBADF);
} }
weak_under_alias(read); weak_under_alias(read);