From 61234a120b6f3a2513449dbb5d063137de546b64 Mon Sep 17 00:00:00 2001 From: Ching-Hsin Lee Date: Mon, 4 Sep 2023 15:41:25 +0800 Subject: [PATCH] Add port GCC_RISC_V_GENERIC and IAR_RISC_V_GENERIC * Add two rics-v generic ports to support FREERTOS_RISCV_EXTENSION config --- CMakeLists.txt | 16 +++--------- portable/CMakeLists.txt | 32 +++++++++++++++++++++++ portable/GCC/RISC-V/chip_extensions.cmake | 19 ++++++++++++++ portable/IAR/RISC-V/chip_extensions.cmake | 16 ++++++++++++ 4 files changed, 70 insertions(+), 13 deletions(-) create mode 100644 portable/GCC/RISC-V/chip_extensions.cmake create mode 100644 portable/IAR/RISC-V/chip_extensions.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 460ae96e39f..2c4e1ec80c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,7 +40,6 @@ endif() # Heap number or absolute path to custom heap implementation provided by user set(FREERTOS_HEAP "4" CACHE STRING "FreeRTOS heap model number. 1 .. 5. Or absolute path to custom heap source file") -string(FIND ${FREERTOS_PORT} "RISC_V" IS_PORT_RISCV) # FreeRTOS port option if(NOT FREERTOS_PORT) message(WARNING " FREERTOS_PORT is not set. Please specify it from top-level CMake file (example):\n" @@ -107,6 +106,8 @@ if(NOT FREERTOS_PORT) " GCC_PPC405_XILINX - Compiler: GCC Target: Xilinx PPC405\n" " GCC_PPC440_XILINX - Compiler: GCC Target: Xilinx PPC440\n" " GCC_RISC_V - Compiler: GCC Target: RISC-V\n" + " GCC_RISC_V_PULPINO_VEGA_RV32M1RM - Compiler: GCC Target: RISC-V Pulpino Vega RV32M1RM\n" + " GCC_RISC_V_GENERIC - Compiler: GCC Target: RISC-V with FREERTOS_RISCV_EXTENSION\n" " GCC_RL78 - Compiler: GCC Target: Renesas RL78\n" " GCC_RX100 - Compiler: GCC Target: Renesas RX100\n" " GCC_RX200 - Compiler: GCC Target: Renesas RX200\n" @@ -157,6 +158,7 @@ if(NOT FREERTOS_PORT) " IAR_MSP430 - Compiler: IAR Target: MSP430\n" " IAR_MSP430X - Compiler: IAR Target: MSP430X\n" " IAR_RISC_V - Compiler: IAR Target: RISC-V\n" + " IAR_RISC_V_GENERIC - Compiler: IAR Target: RISC-V with FREERTOS_RISCV_EXTENSION\n" " IAR_RL78 - Compiler: IAR Target: Renesas RL78\n" " IAR_RX100 - Compiler: IAR Target: Renesas RX100\n" " IAR_RX600 - Compiler: IAR Target: Renesas RX600\n" @@ -207,18 +209,6 @@ if(NOT FREERTOS_PORT) message(STATUS " Auto-Detected MINGW, setting FREERTOS_PORT=MSVC_MINGW") set(FREERTOS_PORT MSVC_MINGW CACHE STRING "FreeRTOS port name") endif() -elseif((IS_PORT_RISCV GREATER -1) AND (NOT FREERTOS_RISCV_EXTENSION)) - message(FATAL_ERROR " FREERTOS_RISCV_EXTENSION is not set. Please specify it from top-level CMake file (example):\n" - " set(FREERTOS_RISCV_EXTENSION RISCV_MTIME_CLINT_no_extensions CACHE STRING \"\")\n" - " or from CMake command line option:\n" - " -DFREERTOS_RISCV_EXTENSION=RISCV_MTIME_CLINT_no_extensions\n" - "\n" - " Available extension options:\n" - " Pulpino_Vega_RV32M1RM - Compiler: GCC\n" - " RISCV_MTIME_CLINT_no_extensions - Compiler: GCC\n" - " RISCV_no_extensions - Compiler: GCC\n" - " RV32I_CLINT_no_extensions - Compiler: GCC\n" - " RV32I_CLINT_no_extensions - Compiler: IAR\n") elseif((FREERTOS_PORT STREQUAL "A_CUSTOM_PORT") AND (NOT TARGET freertos_kernel_port) ) message(FATAL_ERROR " FREERTOS_PORT is set to A_CUSTOM_PORT. Please specify the custom port target with all necessary files. For example:\n" " Assuming a directory of:\n" diff --git a/portable/CMakeLists.txt b/portable/CMakeLists.txt index 2b3990ff39e..9338242ddee 100644 --- a/portable/CMakeLists.txt +++ b/portable/CMakeLists.txt @@ -1,3 +1,11 @@ +if( FREERTOS_PORT STREQUAL "GCC_RISC_V_GENERIC" ) + include( GCC/RISC-V/chip_extensions.cmake ) +endif() + +if( FREERTOS_PORT STREQUAL "IAR_RISC_V_GENERIC" ) + include( IAR/RISC-V/chip_extensions.cmake ) +endif() + # FreeRTOS internal cmake file. Do not use it in user top-level project if (FREERTOS_PORT STREQUAL "A_CUSTOM_PORT") @@ -284,6 +292,14 @@ add_library(freertos_kernel_port STATIC GCC/RISC-V/port.c GCC/RISC-V/portASM.S> + $<$: + GCC/RISC-V/port.c + GCC/RISC-V/portASM.S> + + $<$: + GCC/RISC-V/port.c + GCC/RISC-V/portASM.S> + # Renesas RL78 port for GCC $<$: GCC/RL78/port.c @@ -489,6 +505,10 @@ add_library(freertos_kernel_port STATIC IAR/RISC-V/port.c IAR/RISC-V/portASM.s> + $<$: + IAR/RISC-V/port.c + IAR/RISC-V/portASM.s> + # Renesas RL78 port for IAR EWRL78 $<$: IAR/RL78/port.c @@ -827,6 +847,14 @@ target_include_directories(freertos_kernel_port PUBLIC # RISC-V architecture ports for GCC $<$: + ${CMAKE_CURRENT_LIST_DIR}/GCC/RISC-V + ${CMAKE_CURRENT_LIST_DIR}/GCC/RISC-V/chip_specific_extensions/RISCV_MTIME_CLINT_no_extensions> + + $<$: + ${CMAKE_CURRENT_LIST_DIR}/GCC/RISC-V + ${CMAKE_CURRENT_LIST_DIR}/GCC/RISC-V/chip_specific_extensions/Pulpino_Vega_RV32M1RM> + + $<$: ${CMAKE_CURRENT_LIST_DIR}/GCC/RISC-V ${CMAKE_CURRENT_LIST_DIR}/GCC/RISC-V/chip_specific_extensions/${FREERTOS_RISCV_EXTENSION}> @@ -924,6 +952,10 @@ target_include_directories(freertos_kernel_port PUBLIC # RISC-V architecture port for IAR Embedded Workbench for RISC-V $<$: + ${CMAKE_CURRENT_LIST_DIR}/IAR/RISC-V + ${CMAKE_CURRENT_LIST_DIR}/IAR/RISC-V/chip_specific_extensions/RV32I_CLINT_no_extensions> + + $<$: ${CMAKE_CURRENT_LIST_DIR}/IAR/RISC-V ${CMAKE_CURRENT_LIST_DIR}/IAR/RISC-V/chip_specific_extensions/${FREERTOS_RISCV_EXTENSION}> diff --git a/portable/GCC/RISC-V/chip_extensions.cmake b/portable/GCC/RISC-V/chip_extensions.cmake new file mode 100644 index 00000000000..c0d2c0d86b4 --- /dev/null +++ b/portable/GCC/RISC-V/chip_extensions.cmake @@ -0,0 +1,19 @@ +if( FREERTOS_PORT STREQUAL "GCC_RISC_V_GENERIC" ) + set( VALID_CHIP_EXTENSIONS + "Pulpino_Vega_RV32M1RM" + "RISCV_MTIME_CLINT_no_extensions" + "RISCV_no_extensions" + "RV32I_CLINT_no_extensions" ) + + if( ( NOT FREERTOS_RISCV_EXTENSION ) OR ( NOT ( ${FREERTOS_RISCV_EXTENSION} IN_LIST VALID_CHIP_EXTENSIONS ) ) ) + message(FATAL_ERROR + "FREERTOS_RISCV_EXTENSION \"${FREERTOS_RISCV_EXTENSION}\" is not set or unsupported.\n" + "Please specify it from top-level CMake file (example):\n" + " set(FREERTOS_RISCV_EXTENSION RISCV_MTIME_CLINT_no_extensions CACHE STRING \"\")\n" + " or from CMake command line option:\n" + " -DFREERTOS_RISCV_EXTENSION=RISCV_MTIME_CLINT_no_extensions\n" + "\n" + " Available extension options:\n" + " ${VALID_CHIP_EXTENSIONS} \n") + endif() +endif() diff --git a/portable/IAR/RISC-V/chip_extensions.cmake b/portable/IAR/RISC-V/chip_extensions.cmake new file mode 100644 index 00000000000..110ec4a2e25 --- /dev/null +++ b/portable/IAR/RISC-V/chip_extensions.cmake @@ -0,0 +1,16 @@ +if( FREERTOS_PORT STREQUAL "IAR_RISC_V_GENERIC" ) + set( VALID_CHIP_EXTENSIONS + "RV32I_CLINT_no_extensions" ) + + if( ( NOT FREERTOS_RISCV_EXTENSION ) OR ( NOT ( ${FREERTOS_RISCV_EXTENSION} IN_LIST VALID_CHIP_EXTENSIONS ) ) ) + message(FATAL_ERROR + "FREERTOS_RISCV_EXTENSION \"${FREERTOS_RISCV_EXTENSION}\" is not set or unsupported.\n" + "Please specify it from top-level CMake file (example):\n" + " set(FREERTOS_RISCV_EXTENSION RISCV_MTIME_CLINT_no_extensions CACHE STRING \"\")\n" + " or from CMake command line option:\n" + " -DFREERTOS_RISCV_EXTENSION=RISCV_MTIME_CLINT_no_extensions\n" + "\n" + " Available extension options:\n" + " ${VALID_CHIP_EXTENSIONS} \n") + endif() +endif()