fixes hifive1 build
This commit is contained in:
parent
77ca8a01b4
commit
0188d404de
|
@ -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++
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -11,23 +11,28 @@
|
||||||
|
|
||||||
ssize_t __wrap_read(int fd, void* ptr, size_t len)
|
ssize_t __wrap_read(int fd, void* ptr, size_t len)
|
||||||
{
|
{
|
||||||
uint8_t * current = (uint8_t *)ptr;
|
#if defined(BOARD_hifive1)
|
||||||
volatile uint32_t * uart_rx = (uint32_t *)(UART0_BASE_ADDR + UART_REG_RXFIFO);
|
uint8_t * current = (uint8_t *)ptr;
|
||||||
volatile uint8_t * uart_rx_cnt = (uint8_t *)(UART0_BASE_ADDR + UART_REG_RXCTRL + 2);
|
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;
|
||||||
|
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);
|
||||||
|
#endif
|
||||||
|
|
||||||
ssize_t result = 0;
|
ssize_t result = 0;
|
||||||
|
|
||||||
if (isatty(fd)) {
|
if (isatty(fd)) {
|
||||||
for (current = (uint8_t *)ptr;
|
for (current = (uint8_t *)ptr;
|
||||||
(current < ((uint8_t *)ptr) + len) && (*uart_rx_cnt > 0);
|
(current < ((uint8_t *)ptr) + len) && (*uart_rx_cnt > 0);
|
||||||
current ++) {
|
current ++) {
|
||||||
*current = *uart_rx;
|
*current = *uart_rx;
|
||||||
result++;
|
result++;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
return result;
|
return _stub(EBADF);
|
||||||
}
|
|
||||||
|
|
||||||
return _stub(EBADF);
|
|
||||||
}
|
}
|
||||||
weak_under_alias(read);
|
weak_under_alias(read);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue