first semihosting integration

This commit is contained in:
gabriel
2024-02-26 20:41:15 +01:00
parent 532f7e9bb8
commit 39ee91af7d
5 changed files with 219 additions and 1 deletions

54
libwrap/CMakeLists.txt Normal file
View File

@@ -0,0 +1,54 @@
IF(NOT DEFINED _MK_LIBWRAP)
SET(_MK_LIBWRAP TRUE)
SET(LIBWRAP_DIR ${CMAKE_CURRENT_LIST_DIR})
SET(LIBWRAP_SRCS
${LIBWRAP_DIR}/stdlib/malloc.c
${LIBWRAP_DIR}/sys/open.c
${LIBWRAP_DIR}/sys/lseek.c
${LIBWRAP_DIR}/sys/read.c
${LIBWRAP_DIR}/sys/write.c
${LIBWRAP_DIR}/sys/fstat.c
${LIBWRAP_DIR}/sys/stat.c
${LIBWRAP_DIR}/sys/close.c
${LIBWRAP_DIR}/sys/link.c
${LIBWRAP_DIR}/sys/unlink.c
${LIBWRAP_DIR}/sys/execve.c
${LIBWRAP_DIR}/sys/fork.c
${LIBWRAP_DIR}/sys/getpid.c
${LIBWRAP_DIR}/sys/kill.c
${LIBWRAP_DIR}/sys/wait.c
${LIBWRAP_DIR}/sys/isatty.c
${LIBWRAP_DIR}/sys/times.c
${LIBWRAP_DIR}/sys/sbrk.c
${LIBWRAP_DIR}/sys/_exit.c
${LIBWRAP_DIR}/misc/write_hex.c
${LIBWRAP_DIR}/sys/printf.c
)
IF(${SEMIHOSTING})
SET(LIBWRAP_SRCS ${LIBWRAP_SRCS} ${LIBWRAP_DIR}/semihosting/semihosting.c ${LIBWRAP_DIR}/semihosting/trap.c)
ENDIF()
SET(LIBWRAP_SYMS malloc free open lseek read write fstat stat close link unlink execve fork getpid jukk wait isatty times sbrk _exit printf puts)
# Includes
INCLUDE_DIRECTORIES(
${LIBWRAP_DIR}
${LIBWRAP_DIR}/../include
${LIBWRAP_DIR}/../drivers
${LIBWRAP_DIR}/../env
${LIBWRAP_DIR}/../env/iss
)
ADD_LIBRARY(LIBWRAP_TGC STATIC ${LIBWRAP_SRCS})
TARGET_COMPILE_OPTIONS(LIBWRAP_TGC PRIVATE -march=${RISCV_ARCH}_zicsr_zifencei -mabi=${RISCV_ABI} "-DBOARD_${BOARD}")
FOREACH(SYM ${LIBWRAP_SYMS})
LIST(APPEND WRAP_LDFLAGS "-Wl,--wrap=${SYM}")
ENDFOREACH()
SET(LIBWRAP_TGC_LDFLAGS ${WRAP_LDFLAGS} "-Wl,--start-group" "-Wl,--end-group")
ENDIF(NOT DEFINED _MK_LIBWRAP)