forked from Firmware/Firmwares
fixes hifive1 build
This commit is contained in:
parent
77ca8a01b4
commit
0188d404de
1
bare-metal-bsp/env/common-gcc.mk
vendored
1
bare-metal-bsp/env/common-gcc.mk
vendored
@ -45,6 +45,7 @@ else
|
||||
endif
|
||||
CFLAGS += -mabi=$(RISCV_ABI)
|
||||
CFLAGS += -mcmodel=medany
|
||||
CFLAGS += -DBOARD_$(BOARD)
|
||||
|
||||
TRIPLET?=riscv64-unknown-elf
|
||||
CXX=$(TOOL_DIR)$(TRIPLET)-c++
|
||||
|
@ -4,8 +4,14 @@
|
||||
#include "platform.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 fromhost;
|
||||
#endif
|
||||
|
||||
void write_hex(int fd, uint32_t hex);
|
||||
|
||||
void __wrap_exit(int code)
|
||||
|
@ -11,23 +11,28 @@
|
||||
|
||||
ssize_t __wrap_read(int fd, void* ptr, size_t len)
|
||||
{
|
||||
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);
|
||||
#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;
|
||||
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)) {
|
||||
for (current = (uint8_t *)ptr;
|
||||
(current < ((uint8_t *)ptr) + len) && (*uart_rx_cnt > 0);
|
||||
current ++) {
|
||||
*current = *uart_rx;
|
||||
result++;
|
||||
if (isatty(fd)) {
|
||||
for (current = (uint8_t *)ptr;
|
||||
(current < ((uint8_t *)ptr) + len) && (*uart_rx_cnt > 0);
|
||||
current ++) {
|
||||
*current = *uart_rx;
|
||||
result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
return _stub(EBADF);
|
||||
return _stub(EBADF);
|
||||
}
|
||||
weak_under_alias(read);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user