Compare commits
No commits in common. "f419b1a3e6e9e8075d7e937ac5b1e1fb4829a976" and "5eac63d773fb3bc0b9d878e6f7c53bc72ae56ecd" have entirely different histories.
f419b1a3e6
...
5eac63d773
@ -1,11 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
project(bsp C)
|
||||
add_subdirectory(libwrap)
|
||||
add_subdirectory(env)
|
||||
message(STATUS " in bsp with ${CMAKE_CXX_FLAGS}")
|
||||
message(STATUS " SUPPORTED_BOARDS= ${SUPPORTED_BOARDS}")
|
||||
add_library(${PROJECT_NAME} INTERFACE)
|
||||
target_include_directories(${PROJECT_NAME} INTERFACE
|
||||
include/
|
||||
env/${BOARD}
|
||||
env/)
|
64
env/CMakeLists.txt
vendored
64
env/CMakeLists.txt
vendored
@ -1,64 +0,0 @@
|
||||
project(env)
|
||||
message(STATUS " here in bsp/env")
|
||||
message(STATUS " BOARD: ${BOARD}")
|
||||
# Enable ASM language
|
||||
enable_language(ASM)
|
||||
set(ASM_SOURCES
|
||||
entry.S
|
||||
start.S
|
||||
)
|
||||
add_library(asm_obj OBJECT ${ASM_SOURCES})
|
||||
set_target_properties(asm_obj PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bare-metal-bsp/${PROJECT_NAME})
|
||||
target_include_directories(asm_obj PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${BSP_BASE}/include
|
||||
#include/
|
||||
${BSP_BASE}/env
|
||||
${BSP_BASE}/env/${BOARD}
|
||||
${BSP_BASE}/drivers
|
||||
)
|
||||
|
||||
# Export variables for hello-world to use
|
||||
set(ENV_OBJECTS
|
||||
$<TARGET_OBJECTS:asm_obj>
|
||||
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
|
||||
set(BOARD_LIB_NAME ${BOARD})
|
||||
message(STATUS " BOARD_LIB_NAME: ${BOARD_LIB_NAME}")
|
||||
set(BOARD_LIB_SRC
|
||||
${BOARD}/init.c
|
||||
${BOARD}/write.c
|
||||
)
|
||||
add_library(${BOARD_LIB_NAME} STATIC ${BOARD_LIB_SRC})
|
||||
set_target_properties(${BOARD_LIB_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bare-metal-bsp/${PROJECT_NAME})
|
||||
|
||||
# Set ASM compile options
|
||||
#set(CMAKE_ASM_COMPILER riscv64-unknown-elf-as)
|
||||
#set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -march=${RISCV_ARCH}_zicsr_zifencei -mabi=${RISCV_ABI}")
|
||||
|
||||
#add_subdirectory(${BOARD})
|
||||
|
||||
|
||||
|
||||
target_include_directories(${BOARD_LIB_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${BSP_BASE}/include
|
||||
${BSP_BASE}/libwrap/sys
|
||||
${BSP_BASE}/env
|
||||
${BSP_BASE}/env/${BOARD}
|
||||
${BSP_BASE}/drivers
|
||||
)
|
||||
|
||||
# Include the ISS board configuration
|
||||
#set(ISS_SOURCE_DIR "${CMAKE_SOURCE_DIR}/bare-metal-bsp/env/iss")
|
||||
#set(ISS_BINARY_DIR "${CMAKE_BINARY_DIR}/iss_build")
|
||||
|
||||
#add_subdirectory(${ISS_SOURCE_DIR} ${ISS_BINARY_DIR})
|
||||
|
||||
|
||||
|
||||
# Export board library
|
||||
#set(BOARD_LIB board_iss PARENT_SCOPE)
|
2
env/common-gcc.mk
vendored
2
env/common-gcc.mk
vendored
@ -16,7 +16,6 @@ BOARD?=iss
|
||||
|
||||
ASM_SRCS += $(ENV_DIR)/start.S $(ENV_DIR)/entry.S
|
||||
C_SRCS += $(PLATFORM_DIR)/init.c
|
||||
C_SRCS += $(PLATFORM_DIR)/write.c
|
||||
|
||||
LINKER_SCRIPT ?= $(PLATFORM_DIR)/$(LINK_TARGET).lds
|
||||
|
||||
@ -24,7 +23,6 @@ INCLUDES += -I$(BSP_BASE)/include
|
||||
INCLUDES += -I$(BSP_BASE)/drivers/
|
||||
INCLUDES += -I$(ENV_DIR)
|
||||
INCLUDES += -I$(PLATFORM_DIR)
|
||||
INCLUDES += -I$(BSP_BASE)/libwrap/sys/
|
||||
|
||||
LDFLAGS += -march=$(RISCV_ARCH) -mabi=$(RISCV_ABI)
|
||||
LDFLAGS += -L$(ENV_DIR)
|
||||
|
30
env/iss/CMakeLists.txt
vendored
30
env/iss/CMakeLists.txt
vendored
@ -1,30 +0,0 @@
|
||||
#cmake_minimum_required(VERSION 3.12)
|
||||
project(iss)
|
||||
message(STATUS " here in iss")
|
||||
|
||||
# Create library for ISS board support
|
||||
add_library(board_iss STATIC
|
||||
init.c
|
||||
write.c
|
||||
)
|
||||
|
||||
# Include directories
|
||||
target_include_directories(board_iss PUBLIC
|
||||
${BSP_BASE}/include
|
||||
${BSP_BASE}/env
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
# Set compile options
|
||||
target_compile_options(board_iss PRIVATE
|
||||
-march=${RISCV_ARCH}_zicsr_zifencei
|
||||
-mabi=${RISCV_ABI}
|
||||
-mcmodel=medany
|
||||
-ffunction-sections
|
||||
-fdata-sections
|
||||
)
|
||||
|
||||
# Add compile definitions
|
||||
target_compile_definitions(board_iss PRIVATE
|
||||
BOARD_${BOARD}
|
||||
)
|
38
env/iss/write.c
vendored
38
env/iss/write.c
vendored
@ -1,38 +0,0 @@
|
||||
/* See LICENSE of license details. */
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "platform.h"
|
||||
#include "stub.h"
|
||||
#include "weak_under_alias.h"
|
||||
#if defined(SEMIHOSTING)
|
||||
#include "semihosting.h"
|
||||
#endif
|
||||
|
||||
ssize_t __wrap_write(int fd, const void *ptr, size_t len) {
|
||||
const uint8_t *current = (const uint8_t *)ptr;
|
||||
#if defined(SEMIHOSTING)
|
||||
if (isatty(fd)) {
|
||||
for (size_t jj = 0; jj < len; jj++) {
|
||||
sh_writec(current[jj]);
|
||||
}
|
||||
return len;
|
||||
} else {
|
||||
sh_write(current, fd);
|
||||
return len;
|
||||
}
|
||||
// return len;
|
||||
#endif
|
||||
if (isatty(fd)) {
|
||||
for (size_t jj = 0; jj < len; jj++) {
|
||||
*((uint32_t *)0xFFFF0000) = current[jj];
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
return _stub(EBADF);
|
||||
}
|
||||
weak_under_alias(write);
|
1
env/start.S
vendored
1
env/start.S
vendored
@ -1,4 +1,3 @@
|
||||
#include "encoding.h"
|
||||
// See LICENSE for license details.
|
||||
|
||||
.section .init
|
||||
|
@ -1,77 +1,55 @@
|
||||
#cmake_minimum_required(VERSION 3.12)
|
||||
project(libwrap)
|
||||
|
||||
message(STATUS " here 2 in libwrap")
|
||||
set(LIBRARY_NAME libwrap)
|
||||
set(STATIC_LIBRARY_FLAGS "rcs")
|
||||
IF(NOT DEFINED _MK_LIBWRAP)
|
||||
|
||||
# Create object library for libwrap
|
||||
set(LIB_SOURCES
|
||||
sys/_exit.c
|
||||
sys/close.c
|
||||
sys/execve.c
|
||||
sys/fork.c
|
||||
sys/fstat.c
|
||||
sys/getpid.c
|
||||
sys/isatty.c
|
||||
sys/kill.c
|
||||
sys/link.c
|
||||
sys/lseek.c
|
||||
sys/open.c
|
||||
sys/openat.c
|
||||
sys/printf.c
|
||||
sys/puts.c
|
||||
sys/read.c
|
||||
sys/sbrk.c
|
||||
sys/stat.c
|
||||
sys/times.c
|
||||
sys/unlink.c
|
||||
sys/wait.c
|
||||
# sys/write.c
|
||||
# Standard library
|
||||
stdlib/malloc.c
|
||||
# Miscellaneous
|
||||
misc/write_hex.c
|
||||
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
|
||||
${LIBWRAP_DIR}/sys/puts.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
|
||||
)
|
||||
|
||||
if(SEMIHOSTING)
|
||||
list(APPEND LIB_SOURCES
|
||||
semihosting/semihosting.c
|
||||
semihosting/trap.c )
|
||||
ADD_LIBRARY(LIBWRAP_TGC STATIC ${LIBWRAP_SRCS})
|
||||
TARGET_COMPILE_OPTIONS(LIBWRAP_TGC PRIVATE -march=${RISCV_ARCH}_zicsr_zifencei -mabi=${RISCV_ABI} "-DBOARD_${BOARD}")
|
||||
|
||||
endif()
|
||||
FOREACH(SYM ${LIBWRAP_SYMS})
|
||||
LIST(APPEND WRAP_LDFLAGS "-Wl,--wrap=${SYM}")
|
||||
ENDFOREACH()
|
||||
|
||||
#add_library(${LIBRARY_NAME} OBJECT ${LIB_SOURCES})
|
||||
add_library(${LIBRARY_NAME} STATIC ${LIB_SOURCES})
|
||||
set_target_properties(${LIBRARY_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bare-metal-bsp/${PROJECT_NAME})
|
||||
SET(LIBWRAP_TGC_LDFLAGS ${WRAP_LDFLAGS} "-Wl,--start-group" "-Wl,--end-group" "-L. -lLIBWRAP_TGC")
|
||||
|
||||
message(STATUS " CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
|
||||
|
||||
# Retrieve the output directory for the library
|
||||
get_target_property(LIBRARY_PATH ${LIBRARY_NAME} ARCHIVE_OUTPUT_DIRECTORY)
|
||||
|
||||
# Print the path to the console (for debugging purposes)
|
||||
message(STATUS "The library output path is: ${LIBRARY_PATH}")
|
||||
|
||||
# Include directories
|
||||
target_include_directories(${LIBRARY_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${BSP_BASE}/include
|
||||
include/
|
||||
${BSP_BASE}/env
|
||||
${BSP_BASE}/env/${BOARD}
|
||||
${BSP_BASE}/drivers
|
||||
)
|
||||
|
||||
|
||||
|
||||
#link global_compile_options to this libraries
|
||||
#target_link_libraries(${PROJECT_NAME} PRIVATE global_compile_options)
|
||||
|
||||
# Compile definitions
|
||||
#target_compile_definitions(libwrap_objects PRIVATE
|
||||
# BOARD_${BOARD}
|
||||
#)
|
||||
|
||||
# Export objects to parent scope
|
||||
#set(LIBWRAP_OBJECTS $<TARGET_OBJECTS:${PROJECT_NAME}> PARENT_SCOPE)
|
||||
ENDIF(NOT DEFINED _MK_LIBWRAP)
|
||||
|
@ -9,6 +9,7 @@ LIBWRAP_SRCS := \
|
||||
sys/open.c \
|
||||
sys/lseek.c \
|
||||
sys/read.c \
|
||||
sys/write.c \
|
||||
sys/fstat.c \
|
||||
sys/stat.c \
|
||||
sys/close.c \
|
||||
|
Loading…
Reference in New Issue
Block a user