From f88b259ebacb84624f2df3cfd14db56a5dd2ca4f Mon Sep 17 00:00:00 2001 From: Mateusz Holenko Date: Mon, 24 Feb 2020 12:43:35 +0100 Subject: [PATCH] emulator: Use external hw/common.h from LiteX Remove code copied from `hw/common.h` and use the header from the LiteX repository provided using `LITEX_BASE` environment variable. Content of `common.h` is now evolving (new functions are added, some are removed) and syncing it between repos would be cumbersome. --- src/main/c/emulator/makefile | 7 ++++--- src/main/c/emulator/src/hal.c | 32 -------------------------------- 2 files changed, 4 insertions(+), 35 deletions(-) diff --git a/src/main/c/emulator/makefile b/src/main/c/emulator/makefile index 7534d08..6f3c8fc 100755 --- a/src/main/c/emulator/makefile +++ b/src/main/c/emulator/makefile @@ -18,10 +18,11 @@ sim: all qemu: CFLAGS += -DQEMU qemu: all -litex: CFLAGS += -DLITEX -I${LITEX_BASE}/software/include -litex: | check_litex_base all -check_litex_base: +litex: CFLAGS += -DLITEX -I${LITEX_GENERATED} -I${LITEX_BASE}/litex/soc/software/include +litex: | check_litex all +check_litex: @[ "${LITEX_BASE}" ] || ( echo ">> LITEX_BASE is not set"; exit 1 ) + @[ "${LITEX_GENERATED}" ] || ( echo ">> LITEX_GENERATED is not set"; exit 1 ) include ${STANDALONE}/common/riscv64-unknown-elf.mk include ${STANDALONE}/common/standalone.mk diff --git a/src/main/c/emulator/src/hal.c b/src/main/c/emulator/src/hal.c index 5a151bb..aa6745b 100644 --- a/src/main/c/emulator/src/hal.c +++ b/src/main/c/emulator/src/hal.c @@ -146,38 +146,6 @@ void halInit(){ #ifdef LITEX -// this is copied from LiteX -#define CSR_ACCESSORS_DEFINED -static inline void csr_writeb(uint8_t value, unsigned long addr) -{ - *((volatile uint8_t *)addr) = value; -} - -static inline uint8_t csr_readb(unsigned long addr) -{ - return *(volatile uint8_t *)addr; -} - -static inline void csr_writew(uint16_t value, unsigned long addr) -{ - *((volatile uint16_t *)addr) = value; -} - -static inline uint16_t csr_readw(unsigned long addr) -{ - return *(volatile uint16_t *)addr; -} - -static inline void csr_writel(uint32_t value, unsigned long addr) -{ - *((volatile uint32_t *)addr) = value; -} - -static inline uint32_t csr_readl(unsigned long addr) -{ - return *(volatile uint32_t *)addr; -} - // this is a file generated by LiteX #include