-
Notifications
You must be signed in to change notification settings - Fork 827
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #416 from Jer6y/master
riscv : add riscv qemu virt support and fix fs bit error in mstatus
- Loading branch information
Showing
20 changed files
with
1,463 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Toolchain settings | ||
set(CMAKE_C_COMPILER riscv64-unknown-elf-gcc) | ||
set(CMAKE_CXX_COMPILER riscv64-unknown-elf-g++) | ||
set(AS riscv64-unknown-elf-as) | ||
set(AR riscv64-unknown-elf-ar) | ||
set(OBJCOPY riscv64-unknown-elf-objcopy) | ||
set(OBJDUMP riscv64-unknown-elf-objdump) | ||
set(SIZE riscv64-unknown-elf-size) | ||
|
||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) | ||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) | ||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) | ||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) | ||
|
||
# this makes the test compiles use static library option so that we don't need to pre-set linker flags and scripts | ||
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) | ||
|
||
set(CMAKE_C_FLAGS "${CFLAGS}" CACHE INTERNAL "c compiler flags") | ||
set(CMAKE_CXX_FLAGS "${CXXFLAGS}" CACHE INTERNAL "cxx compiler flags") | ||
set(CMAKE_ASM_FLAGS "${ASFLAGS} -D__ASSEMBLER__" CACHE INTERNAL "asm compiler flags") | ||
set(CMAKE_EXE_LINKER_FLAGS "${LDFLAGS}" CACHE INTERNAL "exe link flags") | ||
|
||
SET(CMAKE_C_FLAGS_DEBUG "-Og -g -ggdb3" CACHE INTERNAL "c debug compiler flags") | ||
SET(CMAKE_CXX_FLAGS_DEBUG "-Og -g -ggdb3" CACHE INTERNAL "cxx debug compiler flags") | ||
SET(CMAKE_ASM_FLAGS_DEBUG "-g -ggdb3" CACHE INTERNAL "asm debug compiler flags") | ||
|
||
SET(CMAKE_C_FLAGS_RELEASE "-O3" CACHE INTERNAL "c release compiler flags") | ||
SET(CMAKE_CXX_FLAGS_RELEASE "-O3" CACHE INTERNAL "cxx release compiler flags") | ||
SET(CMAKE_ASM_FLAGS_RELEASE "" CACHE INTERNAL "asm release compiler flags") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Name of the target | ||
set(CMAKE_SYSTEM_NAME Generic) | ||
set(CMAKE_SYSTEM_PROCESSOR risc-v64) | ||
|
||
set(THREADX_ARCH "risc-v64") | ||
set(THREADX_TOOLCHAIN "gnu") | ||
set(ARCH_FLAGS "-g -march=rv64gc -mabi=lp64d -mcmodel=medany") | ||
set(CFLAGS "${ARCH_FLAGS}") | ||
set(ASFLAGS "${ARCH_FLAGS}") | ||
set(LDFLAGS "${ARCH_FLAGS}") | ||
|
||
include(${CMAKE_CURRENT_LIST_DIR}/riscv64-unknown-elf.cmake) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
target_sources(${PROJECT_NAME} | ||
PRIVATE | ||
# {{BEGIN_TARGET_SOURCES}} | ||
${CMAKE_CURRENT_LIST_DIR}/src/tx_initialize_low_level.S | ||
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_context_restore.S | ||
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_context_save.S | ||
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_interrupt_control.S | ||
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_schedule.S | ||
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_stack_build.S | ||
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_system_return.S | ||
${CMAKE_CURRENT_LIST_DIR}/src/tx_timer_interrupt.c | ||
# {{END_TARGET_SOURCES}} | ||
) | ||
|
||
target_include_directories(${PROJECT_NAME} | ||
PUBLIC | ||
${CMAKE_CURRENT_LIST_DIR}/inc | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "plic.h" | ||
#include "hwtimer.h" | ||
#include "uart.h" | ||
#include <stdint.h> | ||
#include <stddef.h> | ||
|
||
void *memset(const void *des, int c,size_t n) | ||
{ | ||
if((des == NULL) || n <=0) | ||
return (void*)des; | ||
char* t = (char*)des; | ||
int i; | ||
for(i=0;i<n;i++) | ||
t[i]=c; | ||
return t; | ||
} | ||
|
||
|
||
int board_init(void) | ||
{ | ||
int ret; | ||
ret = plic_init(); | ||
if(ret) | ||
return ret; | ||
ret = uart_init(); | ||
if(ret) | ||
return ret; | ||
ret = hwtimer_init(); | ||
if(ret) | ||
return ret; | ||
return 0; | ||
} |
6 changes: 6 additions & 0 deletions
6
ports/risc-v64/gnu/example_build/qemu_virt/build_libthreadx.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
pushd ../../../../../ | ||
cmake -Bbuild -GNinja -DCMAKE_TOOLCHAIN_FILE=cmake/riscv64_gnu.cmake . | ||
cmake --build ./build/ | ||
popd |
Oops, something went wrong.