diff --git a/WORKSPACE b/WORKSPACE index 889b61b036425..dad84c89bff5a 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -174,3 +174,7 @@ git_repository( patches = ["//sw/vendor/patches/mundane:build_with_bazel.patch"], remote = "https://fuchsia.googlesource.com/mundane", ) + +load("//third_party/freertos:deps.bzl", "freertos_deps") + +freertos_deps() diff --git a/sw/device/lib/testing/test_framework/BUILD b/sw/device/lib/testing/test_framework/BUILD index d030f75a9d576..c98e69508e841 100644 --- a/sw/device/lib/testing/test_framework/BUILD +++ b/sw/device/lib/testing/test_framework/BUILD @@ -44,15 +44,10 @@ cc_library( cc_library( name = "freertos_config", - hdrs = [ - "FreeRTOSConfig.h", - ], + hdrs = ["FreeRTOSConfig.h"], # FreeRTOS sources don't follow our project's include-path standard, # and just include via the bare filename. includes = ["."], - deps = [ - "//sw/device/lib/arch:device", - ], ) cc_library( @@ -62,18 +57,21 @@ cc_library( "freertos_port.S", "freertos_port.c", ], - hdrs = [ - "ottf_macros.h", - ], + hdrs = ["ottf_macros.h"], + # FIXME: Temporary hack to allow us to #include the version in //third_party. + # To be removed once Meson is removed. + # https://github.com/lowRISC/opentitan/issues/11743 + local_defines = ["FREERTOS_IS_BAZEL"], deps = [ ":check", + ":freertos_config", "//hw/top_earlgrey/sw/autogen:top_earlgrey", "//sw/device/lib:irq", "//sw/device/lib/dif:rv_timer", "//sw/device/lib/dif:uart", "//sw/device/lib/runtime:hart", "//sw/device/lib/runtime:log", - "//sw/vendor/freertos_freertos_kernel:kernel", + "//third_party/freertos", ], ) @@ -124,9 +122,13 @@ cc_library( "-Wl,--start-group", "$(location :freertos_port)", "$(location //sw/device/lib:irq)", - "$(location //sw/vendor/freertos_freertos_kernel:kernel)", + "$(location //third_party/freertos)", "-Wl,--end-group", ], + # FIXME: Temporary hack to allow us to #include the version in //third_party. + # To be removed once Meson is removed. + # https://github.com/lowRISC/opentitan/issues/11743 + local_defines = ["FREERTOS_IS_BAZEL"], target_compatible_with = [OPENTITAN_CPU], deps = [ ":freertos_port", @@ -136,6 +138,6 @@ cc_library( "//sw/device/lib/runtime:ibex", "//sw/device/lib/runtime:log", "//sw/device/lib/runtime:print", - "//sw/vendor/freertos_freertos_kernel:kernel", + "//third_party/freertos", ], ) diff --git a/sw/device/lib/testing/test_framework/FreeRTOSConfig.h b/sw/device/lib/testing/test_framework/FreeRTOSConfig.h index 05f7dd9b51bcd..34342638527a6 100644 --- a/sw/device/lib/testing/test_framework/FreeRTOSConfig.h +++ b/sw/device/lib/testing/test_framework/FreeRTOSConfig.h @@ -5,8 +5,6 @@ #ifndef OPENTITAN_SW_DEVICE_LIB_TESTING_TEST_FRAMEWORK_FREERTOSCONFIG_H_ #define OPENTITAN_SW_DEVICE_LIB_TESTING_TEST_FRAMEWORK_FREERTOSCONFIG_H_ -#include "sw/device/lib/arch/device.h" - // These macros configure FreeRTOS. A description of each macro can be found // here: https://www.freertos.org/a00110.html diff --git a/sw/device/lib/testing/test_framework/freertos_hooks.c b/sw/device/lib/testing/test_framework/freertos_hooks.c index d99adb745b9e8..29ddb51fd8115 100644 --- a/sw/device/lib/testing/test_framework/freertos_hooks.c +++ b/sw/device/lib/testing/test_framework/freertos_hooks.c @@ -5,8 +5,14 @@ #include "sw/device/lib/irq.h" #include "sw/device/lib/runtime/hart.h" #include "sw/device/lib/runtime/log.h" + +#ifdef FREERTOS_IS_BAZEL +#include "external/freertos/include/FreeRTOS.h" +#include "external/freertos/include/task.h" +#else #include "sw/vendor/freertos_freertos_kernel/include/FreeRTOS.h" #include "sw/vendor/freertos_freertos_kernel/include/task.h" +#endif // NOTE: the function names below do NOT, and cannot, conform to the style // guide, since they are specific implementations of FreeRTOS defined functions. diff --git a/sw/device/lib/testing/test_framework/freertos_port.c b/sw/device/lib/testing/test_framework/freertos_port.c index 004e636ba52de..089cb0665ee92 100644 --- a/sw/device/lib/testing/test_framework/freertos_port.c +++ b/sw/device/lib/testing/test_framework/freertos_port.c @@ -7,13 +7,20 @@ #include "sw/device/lib/runtime/log.h" #include "sw/device/lib/testing/check.h" #include "sw/device/lib/testing/test_framework/FreeRTOSConfig.h" -#include "sw/vendor/freertos_freertos_kernel/include/FreeRTOS.h" -#include "sw/vendor/freertos_freertos_kernel/include/task.h" -#include "sw/vendor/freertos_freertos_kernel/portable/GCC/RISC-V/portmacro.h" // TODO: make this toplevel agnostic. #include "hw/top_earlgrey/sw/autogen/top_earlgrey.h" // Generated. +#ifdef FREERTOS_IS_BAZEL +#include "external/freertos/include/FreeRTOS.h" +#include "external/freertos/include/task.h" +#include "external/freertos/portable/GCC/RISC-V/portmacro.h" +#else +#include "sw/vendor/freertos_freertos_kernel/include/FreeRTOS.h" +#include "sw/vendor/freertos_freertos_kernel/include/task.h" +#include "sw/vendor/freertos_freertos_kernel/portable/GCC/RISC-V/portmacro.h" +#endif + // NOTE: some of the function names below do NOT, and cannot, conform to the // style guide, since they are specific implementations of FreeRTOS defined // functions. diff --git a/sw/device/lib/testing/test_framework/ottf.c b/sw/device/lib/testing/test_framework/ottf.c index a0bded03d8013..da9aefef57a2f 100644 --- a/sw/device/lib/testing/test_framework/ottf.c +++ b/sw/device/lib/testing/test_framework/ottf.c @@ -17,13 +17,20 @@ #include "sw/device/lib/testing/test_framework/FreeRTOSConfig.h" #include "sw/device/lib/testing/test_framework/test_coverage.h" #include "sw/device/lib/testing/test_framework/test_status.h" -#include "sw/vendor/freertos_freertos_kernel/include/FreeRTOS.h" -#include "sw/vendor/freertos_freertos_kernel/include/queue.h" -#include "sw/vendor/freertos_freertos_kernel/include/task.h" // TODO: make this toplevel agnostic. #include "hw/top_earlgrey/sw/autogen/top_earlgrey.h" +#ifdef FREERTOS_IS_BAZEL +#include "external/freertos/include/FreeRTOS.h" +#include "external/freertos/include/queue.h" +#include "external/freertos/include/task.h" +#else +#include "sw/vendor/freertos_freertos_kernel/include/FreeRTOS.h" +#include "sw/vendor/freertos_freertos_kernel/include/queue.h" +#include "sw/vendor/freertos_freertos_kernel/include/task.h" +#endif + // Check layout of test configuration struct since OTTF ISR asm code requires a // specific layout. OT_ASSERT_MEMBER_OFFSET(test_config_t, enable_concurrency, 0); diff --git a/third_party/freertos/0001-Remove-mtime-address-macros.patch b/third_party/freertos/0001-Remove-mtime-address-macros.patch new file mode 100644 index 0000000000000..d6e3458bb9674 --- /dev/null +++ b/third_party/freertos/0001-Remove-mtime-address-macros.patch @@ -0,0 +1,46 @@ +From 3d0a295ce55a3d5180e947d1b552ed91a1e63967 Mon Sep 17 00:00:00 2001 +From: Miguel Young de la Sota +Date: Mon, 28 Mar 2022 10:22:07 -0400 +Subject: [PATCH 1/3] Remove mtime address macros + +--- + portable/GCC/RISC-V/portmacro.h | 23 ----------------------- + 1 file changed, 23 deletions(-) + +diff --git a/portable/GCC/RISC-V/portmacro.h b/portable/GCC/RISC-V/portmacro.h +index fe93dc28c..5522e0bb8 100644 +--- a/portable/GCC/RISC-V/portmacro.h ++++ b/portable/GCC/RISC-V/portmacro.h +@@ -156,29 +156,6 @@ not necessary for to use this port. They are defined so the common demo files + #define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" ) + /*-----------------------------------------------------------*/ + +- +-/* configCLINT_BASE_ADDRESS is a legacy definition that was replaced by the +-configMTIME_BASE_ADDRESS and configMTIMECMP_BASE_ADDRESS definitions. For +-backward compatibility derive the newer definitions from the old if the old +-definition is found. */ +-#if defined( configCLINT_BASE_ADDRESS ) && !defined( configMTIME_BASE_ADDRESS ) && ( configCLINT_BASE_ADDRESS == 0 ) +- /* Legacy case where configCLINT_BASE_ADDRESS was defined as 0 to indicate +- there was no CLINT. Equivalent now is to set the MTIME and MTIMECMP +- addresses to 0. */ +- #define configMTIME_BASE_ADDRESS ( 0 ) +- #define configMTIMECMP_BASE_ADDRESS ( 0 ) +-#elif defined( configCLINT_BASE_ADDRESS ) && !defined( configMTIME_BASE_ADDRESS ) +- /* Legacy case where configCLINT_BASE_ADDRESS was set to the base address of +- the CLINT. Equivalent now is to derive the MTIME and MTIMECMP addresses +- from the CLINT address. */ +- #define configMTIME_BASE_ADDRESS ( ( configCLINT_BASE_ADDRESS ) + 0xBFF8UL ) +- #define configMTIMECMP_BASE_ADDRESS ( ( configCLINT_BASE_ADDRESS ) + 0x4000UL ) +-#elif !defined( configMTIME_BASE_ADDRESS ) || !defined( configMTIMECMP_BASE_ADDRESS ) +- #error configMTIME_BASE_ADDRESS and configMTIMECMP_BASE_ADDRESS must be defined in FreeRTOSConfig.h. Set them to zero if there is no MTIME (machine time) clock. See https://www.FreeRTOS.org/Using-FreeRTOS-on-RISC-V.html +-#endif +- +- +- + #ifdef __cplusplus + } + #endif +-- +2.35.1.1021.g381101b075-goog + diff --git a/third_party/freertos/0002-Remove-references-to-stdlib.h.patch b/third_party/freertos/0002-Remove-references-to-stdlib.h.patch new file mode 100644 index 0000000000000..d28427203ec81 --- /dev/null +++ b/third_party/freertos/0002-Remove-references-to-stdlib.h.patch @@ -0,0 +1,711 @@ +From b7cde8ea8e5b144ad815a65b565fcc31f9b923cf Mon Sep 17 00:00:00 2001 +From: Miguel Young de la Sota +Date: Mon, 28 Mar 2022 10:26:55 -0400 +Subject: [PATCH 2/3] Remove references to stdlib.h + +--- + event_groups.c | 2 +- + list.c | 2 +- + portable/ARMv8M/secure/heap/secure_heap.h | 2 +- + portable/BCC/16BitDOS/Flsh186/port.c | 2 +- + portable/BCC/16BitDOS/PC/port.c | 2 +- + portable/BCC/16BitDOS/common/portcomn.c | 2 +- + portable/GCC/ARM7_AT91FR40008/port.c | 2 +- + portable/GCC/ARM7_AT91SAM7S/port.c | 2 +- + portable/GCC/ARM7_LPC2000/port.c | 2 +- + portable/GCC/ARM7_LPC23xx/port.c | 2 +- + portable/GCC/ARM_CA53_64_BIT/port.c | 2 +- + portable/GCC/ARM_CA9/port.c | 2 +- + portable/GCC/ARM_CM23/secure/secure_heap.h | 2 +- + portable/GCC/ARM_CM33/secure/secure_heap.h | 2 +- + portable/GCC/ARM_CR5/port.c | 2 +- + portable/GCC/ARM_CRx_No_GIC/port.c | 2 +- + portable/GCC/ATMega323/port.c | 2 +- + portable/GCC/CORTUS_APS3/port.c | 2 +- + portable/GCC/MSP430F449/port.c | 2 +- + portable/GCC/TriCore_1782/port.c | 2 +- + portable/IAR/78K0R/port.c | 2 +- + portable/IAR/ARM_CA9/port.c | 2 +- + portable/IAR/ARM_CM23/secure/secure_heap.h | 2 +- + portable/IAR/ARM_CM33/secure/secure_heap.h | 2 +- + portable/IAR/ARM_CRx_No_GIC/port.c | 2 +- + portable/IAR/ATMega323/port.c | 2 +- + portable/IAR/AtmelSAM7S64/port.c | 2 +- + portable/IAR/AtmelSAM9XE/port.c | 2 +- + portable/IAR/LPC2000/port.c | 2 +- + portable/IAR/STR71x/port.c | 2 +- + portable/IAR/STR91x/port.c | 2 +- + portable/IAR/V850ES/port.c | 2 +- + portable/MemMang/heap_1.c | 2 +- + portable/MemMang/heap_2.c | 2 +- + portable/MemMang/heap_3.c | 2 +- + portable/MemMang/heap_4.c | 2 +- + portable/MemMang/heap_5.c | 2 +- + portable/RVDS/ARM7_LPC21xx/port.c | 2 +- + portable/RVDS/ARM_CA9/port.c | 2 +- + portable/Softune/MB91460/__STD_LIB_sbrk.c | 2 +- + portable/Softune/MB96340/__STD_LIB_sbrk.c | 2 +- + portable/ThirdParty/XCC/Xtensa/port.c | 2 +- + portable/ThirdParty/XCC/Xtensa/portclib.c | 2 +- + portable/ThirdParty/XCC/Xtensa/xtensa_intr.c | 2 +- + portable/oWatcom/16BitDOS/Flsh186/port.c | 2 +- + portable/oWatcom/16BitDOS/PC/port.c | 2 +- + portable/oWatcom/16BitDOS/common/portcomn.c | 2 +- + queue.c | 2 +- + tasks.c | 2 +- + timers.c | 2 +- + 50 files changed, 50 insertions(+), 50 deletions(-) + +diff --git a/event_groups.c b/event_groups.c +index 9abfada53..025f3d7d3 100644 +--- a/event_groups.c ++++ b/event_groups.c +@@ -27,7 +27,7 @@ + */ + + /* Standard includes. */ +-#include ++// #include + + /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining + * all the API functions to use the MPU wrappers. That should only be done when +diff --git a/list.c b/list.c +index 2dc598ce3..30e833a74 100644 +--- a/list.c ++++ b/list.c +@@ -27,7 +27,7 @@ + */ + + +-#include ++// #include + + /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining + * all the API functions to use the MPU wrappers. That should only be done when +diff --git a/portable/ARMv8M/secure/heap/secure_heap.h b/portable/ARMv8M/secure/heap/secure_heap.h +index f08c092f2..f5890d5bb 100644 +--- a/portable/ARMv8M/secure/heap/secure_heap.h ++++ b/portable/ARMv8M/secure/heap/secure_heap.h +@@ -30,7 +30,7 @@ + #define __SECURE_HEAP_H__ + + /* Standard includes. */ +-#include ++// #include + + /** + * @brief Allocates memory from heap. +diff --git a/portable/BCC/16BitDOS/Flsh186/port.c b/portable/BCC/16BitDOS/Flsh186/port.c +index 07a424c2c..a5b189556 100644 +--- a/portable/BCC/16BitDOS/Flsh186/port.c ++++ b/portable/BCC/16BitDOS/Flsh186/port.c +@@ -45,7 +45,7 @@ Changes from V2.6.1 + *----------------------------------------------------------*/ + + #include +-#include ++// #include + #include + + #include "FreeRTOS.h" +diff --git a/portable/BCC/16BitDOS/PC/port.c b/portable/BCC/16BitDOS/PC/port.c +index 302d38911..5340c4230 100644 +--- a/portable/BCC/16BitDOS/PC/port.c ++++ b/portable/BCC/16BitDOS/PC/port.c +@@ -38,7 +38,7 @@ Changes from V4.0.1 + its proper value when the scheduler exits. + */ + +-#include ++// #include + #include + #include + +diff --git a/portable/BCC/16BitDOS/common/portcomn.c b/portable/BCC/16BitDOS/common/portcomn.c +index 68f81bd47..d417070c5 100644 +--- a/portable/BCC/16BitDOS/common/portcomn.c ++++ b/portable/BCC/16BitDOS/common/portcomn.c +@@ -40,7 +40,7 @@ Changes from V2.6.1 + + + #include +-#include ++// #include + #include "FreeRTOS.h" + + /*-----------------------------------------------------------*/ +diff --git a/portable/GCC/ARM7_AT91FR40008/port.c b/portable/GCC/ARM7_AT91FR40008/port.c +index 69376d5c2..a6fc7e20c 100644 +--- a/portable/GCC/ARM7_AT91FR40008/port.c ++++ b/portable/GCC/ARM7_AT91FR40008/port.c +@@ -37,7 +37,7 @@ + *----------------------------------------------------------*/ + + /* Standard includes. */ +-#include ++// #include + + /* Scheduler includes. */ + #include "FreeRTOS.h" +diff --git a/portable/GCC/ARM7_AT91SAM7S/port.c b/portable/GCC/ARM7_AT91SAM7S/port.c +index d744d5ee4..702f74dfb 100644 +--- a/portable/GCC/ARM7_AT91SAM7S/port.c ++++ b/portable/GCC/ARM7_AT91SAM7S/port.c +@@ -36,7 +36,7 @@ + *----------------------------------------------------------*/ + + /* Standard includes. */ +-#include ++// #include + + /* Scheduler includes. */ + #include "FreeRTOS.h" +diff --git a/portable/GCC/ARM7_LPC2000/port.c b/portable/GCC/ARM7_LPC2000/port.c +index d5dc4b1de..c890689bf 100644 +--- a/portable/GCC/ARM7_LPC2000/port.c ++++ b/portable/GCC/ARM7_LPC2000/port.c +@@ -37,7 +37,7 @@ + + + /* Standard includes. */ +-#include ++// #include + + /* Scheduler includes. */ + #include "FreeRTOS.h" +diff --git a/portable/GCC/ARM7_LPC23xx/port.c b/portable/GCC/ARM7_LPC23xx/port.c +index 15d1a2199..c208f7f4a 100644 +--- a/portable/GCC/ARM7_LPC23xx/port.c ++++ b/portable/GCC/ARM7_LPC23xx/port.c +@@ -37,7 +37,7 @@ + + + /* Standard includes. */ +-#include ++// #include + + /* Scheduler includes. */ + #include "FreeRTOS.h" +diff --git a/portable/GCC/ARM_CA53_64_BIT/port.c b/portable/GCC/ARM_CA53_64_BIT/port.c +index b8722e332..0de03c777 100644 +--- a/portable/GCC/ARM_CA53_64_BIT/port.c ++++ b/portable/GCC/ARM_CA53_64_BIT/port.c +@@ -27,7 +27,7 @@ + */ + + /* Standard includes. */ +-#include ++// #include + + /* Scheduler includes. */ + #include "FreeRTOS.h" +diff --git a/portable/GCC/ARM_CA9/port.c b/portable/GCC/ARM_CA9/port.c +index a7bafb355..35601951b 100644 +--- a/portable/GCC/ARM_CA9/port.c ++++ b/portable/GCC/ARM_CA9/port.c +@@ -27,7 +27,7 @@ + */ + + /* Standard includes. */ +-#include ++// #include + + /* Scheduler includes. */ + #include "FreeRTOS.h" +diff --git a/portable/GCC/ARM_CM23/secure/secure_heap.h b/portable/GCC/ARM_CM23/secure/secure_heap.h +index f08c092f2..f5890d5bb 100644 +--- a/portable/GCC/ARM_CM23/secure/secure_heap.h ++++ b/portable/GCC/ARM_CM23/secure/secure_heap.h +@@ -30,7 +30,7 @@ + #define __SECURE_HEAP_H__ + + /* Standard includes. */ +-#include ++// #include + + /** + * @brief Allocates memory from heap. +diff --git a/portable/GCC/ARM_CM33/secure/secure_heap.h b/portable/GCC/ARM_CM33/secure/secure_heap.h +index f08c092f2..f5890d5bb 100644 +--- a/portable/GCC/ARM_CM33/secure/secure_heap.h ++++ b/portable/GCC/ARM_CM33/secure/secure_heap.h +@@ -30,7 +30,7 @@ + #define __SECURE_HEAP_H__ + + /* Standard includes. */ +-#include ++// #include + + /** + * @brief Allocates memory from heap. +diff --git a/portable/GCC/ARM_CR5/port.c b/portable/GCC/ARM_CR5/port.c +index b56e30a70..49f382367 100644 +--- a/portable/GCC/ARM_CR5/port.c ++++ b/portable/GCC/ARM_CR5/port.c +@@ -27,7 +27,7 @@ + */ + + /* Standard includes. */ +-#include ++// #include + + /* Scheduler includes. */ + #include "FreeRTOS.h" +diff --git a/portable/GCC/ARM_CRx_No_GIC/port.c b/portable/GCC/ARM_CRx_No_GIC/port.c +index 6037a10b4..b60925fe0 100644 +--- a/portable/GCC/ARM_CRx_No_GIC/port.c ++++ b/portable/GCC/ARM_CRx_No_GIC/port.c +@@ -27,7 +27,7 @@ + */ + + /* Standard includes. */ +-#include ++// #include + + /* Scheduler includes. */ + #include "FreeRTOS.h" +diff --git a/portable/GCC/ATMega323/port.c b/portable/GCC/ATMega323/port.c +index ab0a9ea10..48e0eec86 100644 +--- a/portable/GCC/ATMega323/port.c ++++ b/portable/GCC/ATMega323/port.c +@@ -35,7 +35,7 @@ Changes from V2.6.0 + WinAVR. + */ + +-#include ++// #include + #include + + #include "FreeRTOS.h" +diff --git a/portable/GCC/CORTUS_APS3/port.c b/portable/GCC/CORTUS_APS3/port.c +index 0d7110b1e..13e993e7e 100644 +--- a/portable/GCC/CORTUS_APS3/port.c ++++ b/portable/GCC/CORTUS_APS3/port.c +@@ -27,7 +27,7 @@ + */ + + /* Standard includes. */ +-#include ++// #include + + /* Kernel includes. */ + #include "FreeRTOS.h" +diff --git a/portable/GCC/MSP430F449/port.c b/portable/GCC/MSP430F449/port.c +index c8dd45af2..743c94f51 100644 +--- a/portable/GCC/MSP430F449/port.c ++++ b/portable/GCC/MSP430F449/port.c +@@ -33,7 +33,7 @@ + */ + + /* Standard includes. */ +-#include ++// #include + #include + + /* Scheduler includes. */ +diff --git a/portable/GCC/TriCore_1782/port.c b/portable/GCC/TriCore_1782/port.c +index 0dedda2e2..329624251 100644 +--- a/portable/GCC/TriCore_1782/port.c ++++ b/portable/GCC/TriCore_1782/port.c +@@ -27,7 +27,7 @@ + */ + + /* Standard includes. */ +-#include ++// #include + #include + + /* TriCore specific includes. */ +diff --git a/portable/IAR/78K0R/port.c b/portable/IAR/78K0R/port.c +index 3a5aff07e..560461e16 100644 +--- a/portable/IAR/78K0R/port.c ++++ b/portable/IAR/78K0R/port.c +@@ -27,7 +27,7 @@ + */ + + /* Standard includes. */ +-#include ++// #include + + /* Scheduler includes. */ + #include "FreeRTOS.h" +diff --git a/portable/IAR/ARM_CA9/port.c b/portable/IAR/ARM_CA9/port.c +index 1c6ffe87f..6784cd84c 100644 +--- a/portable/IAR/ARM_CA9/port.c ++++ b/portable/IAR/ARM_CA9/port.c +@@ -27,7 +27,7 @@ + */ + + /* Standard includes. */ +-#include ++// #include + + /* IAR includes. */ + #include +diff --git a/portable/IAR/ARM_CM23/secure/secure_heap.h b/portable/IAR/ARM_CM23/secure/secure_heap.h +index f08c092f2..f5890d5bb 100644 +--- a/portable/IAR/ARM_CM23/secure/secure_heap.h ++++ b/portable/IAR/ARM_CM23/secure/secure_heap.h +@@ -30,7 +30,7 @@ + #define __SECURE_HEAP_H__ + + /* Standard includes. */ +-#include ++// #include + + /** + * @brief Allocates memory from heap. +diff --git a/portable/IAR/ARM_CM33/secure/secure_heap.h b/portable/IAR/ARM_CM33/secure/secure_heap.h +index f08c092f2..f5890d5bb 100644 +--- a/portable/IAR/ARM_CM33/secure/secure_heap.h ++++ b/portable/IAR/ARM_CM33/secure/secure_heap.h +@@ -30,7 +30,7 @@ + #define __SECURE_HEAP_H__ + + /* Standard includes. */ +-#include ++// #include + + /** + * @brief Allocates memory from heap. +diff --git a/portable/IAR/ARM_CRx_No_GIC/port.c b/portable/IAR/ARM_CRx_No_GIC/port.c +index 07623cf4c..382e9a972 100644 +--- a/portable/IAR/ARM_CRx_No_GIC/port.c ++++ b/portable/IAR/ARM_CRx_No_GIC/port.c +@@ -27,7 +27,7 @@ + */ + + /* Standard includes. */ +-#include ++// #include + + /* Scheduler includes. */ + #include "FreeRTOS.h" +diff --git a/portable/IAR/ATMega323/port.c b/portable/IAR/ATMega323/port.c +index 7b7504b32..ad9bfeef7 100644 +--- a/portable/IAR/ATMega323/port.c ++++ b/portable/IAR/ATMega323/port.c +@@ -26,7 +26,7 @@ + * + */ + +-#include ++// #include + + #include "FreeRTOS.h" + #include "task.h" +diff --git a/portable/IAR/AtmelSAM7S64/port.c b/portable/IAR/AtmelSAM7S64/port.c +index 15d00fe4e..3b9fd8395 100644 +--- a/portable/IAR/AtmelSAM7S64/port.c ++++ b/portable/IAR/AtmelSAM7S64/port.c +@@ -32,7 +32,7 @@ + + + /* Standard includes. */ +-#include ++// #include + + /* Scheduler includes. */ + #include "FreeRTOS.h" +diff --git a/portable/IAR/AtmelSAM9XE/port.c b/portable/IAR/AtmelSAM9XE/port.c +index fd53a387f..c02392e35 100644 +--- a/portable/IAR/AtmelSAM9XE/port.c ++++ b/portable/IAR/AtmelSAM9XE/port.c +@@ -32,7 +32,7 @@ + + + /* Standard includes. */ +-#include ++// #include + + /* Scheduler includes. */ + #include "FreeRTOS.h" +diff --git a/portable/IAR/LPC2000/port.c b/portable/IAR/LPC2000/port.c +index 8552f5b7c..c00f007bb 100644 +--- a/portable/IAR/LPC2000/port.c ++++ b/portable/IAR/LPC2000/port.c +@@ -39,7 +39,7 @@ + */ + + /* Standard includes. */ +-#include ++// #include + #include + + /* Scheduler includes. */ +diff --git a/portable/IAR/STR71x/port.c b/portable/IAR/STR71x/port.c +index 273735334..d6a4bb29f 100644 +--- a/portable/IAR/STR71x/port.c ++++ b/portable/IAR/STR71x/port.c +@@ -36,7 +36,7 @@ + #include "eic.h" + + /* Standard includes. */ +-#include ++// #include + + /* Scheduler includes. */ + #include "FreeRTOS.h" +diff --git a/portable/IAR/STR91x/port.c b/portable/IAR/STR91x/port.c +index bc7d6c852..ad637b1c8 100644 +--- a/portable/IAR/STR91x/port.c ++++ b/portable/IAR/STR91x/port.c +@@ -35,7 +35,7 @@ + #include "91x_lib.h" + + /* Standard includes. */ +-#include ++// #include + #include + + /* Scheduler includes. */ +diff --git a/portable/IAR/V850ES/port.c b/portable/IAR/V850ES/port.c +index 871061ae9..ddd3bdce0 100644 +--- a/portable/IAR/V850ES/port.c ++++ b/portable/IAR/V850ES/port.c +@@ -27,7 +27,7 @@ + */ + + /* Standard includes. */ +-#include ++// #include + + /* Scheduler includes. */ + #include "FreeRTOS.h" +diff --git a/portable/MemMang/heap_1.c b/portable/MemMang/heap_1.c +index 68c4c5f77..01036da92 100644 +--- a/portable/MemMang/heap_1.c ++++ b/portable/MemMang/heap_1.c +@@ -34,7 +34,7 @@ + * See heap_2.c, heap_3.c and heap_4.c for alternative implementations, and the + * memory management pages of https://www.FreeRTOS.org for more information. + */ +-#include ++// #include + + /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining + * all the API functions to use the MPU wrappers. That should only be done when +diff --git a/portable/MemMang/heap_2.c b/portable/MemMang/heap_2.c +index b16b24564..54c800729 100644 +--- a/portable/MemMang/heap_2.c ++++ b/portable/MemMang/heap_2.c +@@ -35,7 +35,7 @@ + * See heap_1.c, heap_3.c and heap_4.c for alternative implementations, and the + * memory management pages of https://www.FreeRTOS.org for more information. + */ +-#include ++// #include + + /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining + * all the API functions to use the MPU wrappers. That should only be done when +diff --git a/portable/MemMang/heap_3.c b/portable/MemMang/heap_3.c +index f8ce855f3..e5e901946 100644 +--- a/portable/MemMang/heap_3.c ++++ b/portable/MemMang/heap_3.c +@@ -38,7 +38,7 @@ + * memory management pages of https://www.FreeRTOS.org for more information. + */ + +-#include ++// #include + + /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining + * all the API functions to use the MPU wrappers. That should only be done when +diff --git a/portable/MemMang/heap_4.c b/portable/MemMang/heap_4.c +index 2cd9065b8..e398a20ba 100644 +--- a/portable/MemMang/heap_4.c ++++ b/portable/MemMang/heap_4.c +@@ -34,7 +34,7 @@ + * See heap_1.c, heap_2.c and heap_3.c for alternative implementations, and the + * memory management pages of https://www.FreeRTOS.org for more information. + */ +-#include ++// #include + + /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining + * all the API functions to use the MPU wrappers. That should only be done when +diff --git a/portable/MemMang/heap_5.c b/portable/MemMang/heap_5.c +index 62c3641f5..da6d4494a 100644 +--- a/portable/MemMang/heap_5.c ++++ b/portable/MemMang/heap_5.c +@@ -68,7 +68,7 @@ + * Note 0x80000000 is the lower address so appears in the array first. + * + */ +-#include ++// #include + + /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining + * all the API functions to use the MPU wrappers. That should only be done when +diff --git a/portable/RVDS/ARM7_LPC21xx/port.c b/portable/RVDS/ARM7_LPC21xx/port.c +index 803f94682..aff6c50ca 100644 +--- a/portable/RVDS/ARM7_LPC21xx/port.c ++++ b/portable/RVDS/ARM7_LPC21xx/port.c +@@ -28,7 +28,7 @@ + + + /* Standard includes. */ +-#include ++// #include + + /* Scheduler includes. */ + #include "FreeRTOS.h" +diff --git a/portable/RVDS/ARM_CA9/port.c b/portable/RVDS/ARM_CA9/port.c +index 9f88b58a8..d04fd91d5 100644 +--- a/portable/RVDS/ARM_CA9/port.c ++++ b/portable/RVDS/ARM_CA9/port.c +@@ -27,7 +27,7 @@ + */ + + /* Standard includes. */ +-#include ++// #include + + /* Scheduler includes. */ + #include "FreeRTOS.h" +diff --git a/portable/Softune/MB91460/__STD_LIB_sbrk.c b/portable/Softune/MB91460/__STD_LIB_sbrk.c +index fe85cea01..ef35b1866 100644 +--- a/portable/Softune/MB91460/__STD_LIB_sbrk.c ++++ b/portable/Softune/MB91460/__STD_LIB_sbrk.c +@@ -37,7 +37,7 @@ + /*---------------------------------------------------------------------------*/ + + #include "FreeRTOSConfig.h" +-#include ++// #include + + static long brk_siz = 0; + typedef int _heep_t; +diff --git a/portable/Softune/MB96340/__STD_LIB_sbrk.c b/portable/Softune/MB96340/__STD_LIB_sbrk.c +index fe85cea01..ef35b1866 100644 +--- a/portable/Softune/MB96340/__STD_LIB_sbrk.c ++++ b/portable/Softune/MB96340/__STD_LIB_sbrk.c +@@ -37,7 +37,7 @@ + /*---------------------------------------------------------------------------*/ + + #include "FreeRTOSConfig.h" +-#include ++// #include + + static long brk_siz = 0; + typedef int _heep_t; +diff --git a/portable/ThirdParty/XCC/Xtensa/port.c b/portable/ThirdParty/XCC/Xtensa/port.c +index 5a6addecb..b805ed255 100644 +--- a/portable/ThirdParty/XCC/Xtensa/port.c ++++ b/portable/ThirdParty/XCC/Xtensa/port.c +@@ -27,7 +27,7 @@ + * + */ + +-#include ++// #include + #include + + #include "xtensa_rtos.h" +diff --git a/portable/ThirdParty/XCC/Xtensa/portclib.c b/portable/ThirdParty/XCC/Xtensa/portclib.c +index d64b0cad3..b0616657c 100644 +--- a/portable/ThirdParty/XCC/Xtensa/portclib.c ++++ b/portable/ThirdParty/XCC/Xtensa/portclib.c +@@ -136,7 +136,7 @@ _reclaim_reent(void * ptr) + #include + #include + #include +-#include ++// #include + #include + + #include "semphr.h" +diff --git a/portable/ThirdParty/XCC/Xtensa/xtensa_intr.c b/portable/ThirdParty/XCC/Xtensa/xtensa_intr.c +index f9ff4cbfa..ef1e3efff 100644 +--- a/portable/ThirdParty/XCC/Xtensa/xtensa_intr.c ++++ b/portable/ThirdParty/XCC/Xtensa/xtensa_intr.c +@@ -32,7 +32,7 @@ + * Also see xtensa_intr_asm.S. + */ + +-#include ++// #include + + #include + +diff --git a/portable/oWatcom/16BitDOS/Flsh186/port.c b/portable/oWatcom/16BitDOS/Flsh186/port.c +index 772db7fa1..e79d8672e 100644 +--- a/portable/oWatcom/16BitDOS/Flsh186/port.c ++++ b/portable/oWatcom/16BitDOS/Flsh186/port.c +@@ -49,7 +49,7 @@ Changes from V2.6.1 + * port. + *----------------------------------------------------------*/ + +-#include ++// #include + #include + #include + #include +diff --git a/portable/oWatcom/16BitDOS/PC/port.c b/portable/oWatcom/16BitDOS/PC/port.c +index 711bc703f..626e7b4f2 100644 +--- a/portable/oWatcom/16BitDOS/PC/port.c ++++ b/portable/oWatcom/16BitDOS/PC/port.c +@@ -49,7 +49,7 @@ Changes from V4.0.1 + its proper value when the scheduler exits. + */ + +-#include ++// #include + #include + #include + #include +diff --git a/portable/oWatcom/16BitDOS/common/portcomn.c b/portable/oWatcom/16BitDOS/common/portcomn.c +index 38e6c0e0f..b548445ac 100644 +--- a/portable/oWatcom/16BitDOS/common/portcomn.c ++++ b/portable/oWatcom/16BitDOS/common/portcomn.c +@@ -45,7 +45,7 @@ Changes from V2.6.1: + + + +-#include ++// #include + #include "FreeRTOS.h" + + /*-----------------------------------------------------------*/ +diff --git a/queue.c b/queue.c +index 08d3799da..12f81d394 100644 +--- a/queue.c ++++ b/queue.c +@@ -26,7 +26,7 @@ + * + */ + +-#include ++// #include + #include + + /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining +diff --git a/tasks.c b/tasks.c +index 91af83382..405425c60 100644 +--- a/tasks.c ++++ b/tasks.c +@@ -27,7 +27,7 @@ + */ + + /* Standard includes. */ +-#include ++// #include + #include + + /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining +diff --git a/timers.c b/timers.c +index 46e6d4851..57653dad3 100644 +--- a/timers.c ++++ b/timers.c +@@ -27,7 +27,7 @@ + */ + + /* Standard includes. */ +-#include ++// #include + + /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining + * all the API functions to use the MPU wrappers. That should only be done when +-- +2.35.1.1021.g381101b075-goog + diff --git a/third_party/freertos/0003-Replace-string.h-with-references-to-OT-memory.h.patch b/third_party/freertos/0003-Replace-string.h-with-references-to-OT-memory.h.patch new file mode 100644 index 0000000000000..2bbba94c588dd --- /dev/null +++ b/third_party/freertos/0003-Replace-string.h-with-references-to-OT-memory.h.patch @@ -0,0 +1,458 @@ +From 821187d8c24e1675dd2f00d482afff9ac4aad017 Mon Sep 17 00:00:00 2001 +From: Miguel Young de la Sota +Date: Mon, 28 Mar 2022 10:38:31 -0400 +Subject: [PATCH 3/3] Replace string.h with references to OT memory.h + +--- + include/ot_memory.h | 19 +++++++++++++++++++ + portable/GCC/MicroBlaze/port.c | 2 +- + portable/GCC/MicroBlazeV8/port.c | 2 +- + portable/GCC/MicroBlazeV9/port.c | 2 +- + portable/GCC/NiosII/port.c | 2 +- + portable/GCC/RISC-V/port.c | 2 +- + portable/GCC/RX100/port.c | 2 +- + portable/GCC/RX200/port.c | 2 +- + portable/GCC/RX600/port.c | 2 +- + portable/GCC/RX600v2/port.c | 2 +- + portable/GCC/RX700v3_DPFPU/port.c | 2 +- + portable/GCC/TriCore_1782/port.c | 2 +- + portable/IAR/RISC-V/port.c | 2 +- + portable/IAR/RX100/port.c | 2 +- + portable/IAR/RX600/port.c | 2 +- + portable/IAR/RX700v3_DPFPU/port.c | 2 +- + portable/IAR/RXv2/port.c | 2 +- + portable/MPLAB/PIC32MZ/port.c | 2 +- + portable/Renesas/RX100/port.c | 2 +- + portable/Renesas/RX200/port.c | 2 +- + portable/Renesas/RX600/port.c | 2 +- + portable/Renesas/RX600v2/port.c | 2 +- + portable/Renesas/RX700v3_DPFPU/port.c | 2 +- + portable/Renesas/SH2A_FPU/port.c | 2 +- + portable/SDCC/Cygnal/port.c | 2 +- + .../ThirdParty/GCC/ARC_EM_HS/freertos_tls.c | 2 +- + portable/ThirdParty/GCC/Posix/port.c | 2 +- + portable/ThirdParty/XCC/Xtensa/portclib.c | 2 +- + queue.c | 2 +- + stream_buffer.c | 2 +- + tasks.c | 2 +- + 31 files changed, 49 insertions(+), 30 deletions(-) + create mode 100644 include/ot_memory.h + +diff --git a/include/ot_memory.h b/include/ot_memory.h +new file mode 100644 +index 000000000..799c713e5 +--- /dev/null ++++ b/include/ot_memory.h +@@ -0,0 +1,19 @@ ++// Copyright lowRISC contributors. ++// Licensed under the Apache License, Version 2.0, see LICENSE for details. ++// SPDX-License-Identifier: Apache-2.0 ++ ++#include ++ ++// Redeclarations of the three special memory functions from memory.h ++ ++#ifdef __cplusplus ++extern "C" { ++#endif // __cplusplus ++ ++void *memcpy(void *dest, const void *src, size_t len); ++void *memset(void *dest, int value, size_t len); ++int memcmp(const void *lhs, const void *rhs, size_t len); ++ ++#ifdef __cplusplus ++} // extern "C" ++#endif // __cplusplus +diff --git a/portable/GCC/MicroBlaze/port.c b/portable/GCC/MicroBlaze/port.c +index 48d661b8d..9b06ad48d 100644 +--- a/portable/GCC/MicroBlaze/port.c ++++ b/portable/GCC/MicroBlaze/port.c +@@ -36,7 +36,7 @@ + #include "task.h" + + /* Standard includes. */ +-#include ++#include "ot_memory.h" + + /* Hardware includes. */ + #include +diff --git a/portable/GCC/MicroBlazeV8/port.c b/portable/GCC/MicroBlazeV8/port.c +index 381702fb0..ae2fc8ea7 100644 +--- a/portable/GCC/MicroBlazeV8/port.c ++++ b/portable/GCC/MicroBlazeV8/port.c +@@ -36,7 +36,7 @@ + #include "task.h" + + /* Standard includes. */ +-#include ++#include "ot_memory.h" + + /* Hardware includes. */ + #include +diff --git a/portable/GCC/MicroBlazeV9/port.c b/portable/GCC/MicroBlazeV9/port.c +index 8e70db9a2..6e202c064 100644 +--- a/portable/GCC/MicroBlazeV9/port.c ++++ b/portable/GCC/MicroBlazeV9/port.c +@@ -36,7 +36,7 @@ + #include "task.h" + + /* Standard includes. */ +-#include ++#include "ot_memory.h" + + /* Hardware includes. */ + #include +diff --git a/portable/GCC/NiosII/port.c b/portable/GCC/NiosII/port.c +index 7dc6f81f1..999e72bc6 100644 +--- a/portable/GCC/NiosII/port.c ++++ b/portable/GCC/NiosII/port.c +@@ -31,7 +31,7 @@ + *----------------------------------------------------------*/ + + /* Standard Includes. */ +-#include ++#include "ot_memory.h" + #include + + /* Altera includes. */ +diff --git a/portable/GCC/RISC-V/port.c b/portable/GCC/RISC-V/port.c +index cde63fdb1..a9e5a9704 100644 +--- a/portable/GCC/RISC-V/port.c ++++ b/portable/GCC/RISC-V/port.c +@@ -36,7 +36,7 @@ + #include "portmacro.h" + + /* Standard includes. */ +-#include "string.h" ++#include "ot_memory.h" + + #ifdef configCLINT_BASE_ADDRESS + #warning The configCLINT_BASE_ADDRESS constant has been deprecated. configMTIME_BASE_ADDRESS and configMTIMECMP_BASE_ADDRESS are currently being derived from the (possibly 0) configCLINT_BASE_ADDRESS setting. Please update to define configMTIME_BASE_ADDRESS and configMTIMECMP_BASE_ADDRESS dirctly in place of configCLINT_BASE_ADDRESS. See https://www.FreeRTOS.org/Using-FreeRTOS-on-RISC-V.html +diff --git a/portable/GCC/RX100/port.c b/portable/GCC/RX100/port.c +index a45b64661..66de1f1fc 100644 +--- a/portable/GCC/RX100/port.c ++++ b/portable/GCC/RX100/port.c +@@ -38,7 +38,7 @@ + #include "task.h" + + /* Library includes. */ +-#include "string.h" ++#include "ot_memory.h" + + /* Hardware specifics. */ + #if ( configINCLUDE_PLATFORM_H_INSTEAD_OF_IODEFINE_H == 1 ) +diff --git a/portable/GCC/RX200/port.c b/portable/GCC/RX200/port.c +index 97077743e..77cf4db7d 100644 +--- a/portable/GCC/RX200/port.c ++++ b/portable/GCC/RX200/port.c +@@ -35,7 +35,7 @@ + #include "task.h" + + /* Library includes. */ +-#include "string.h" ++#include "ot_memory.h" + + /* Hardware specifics. */ + #if ( configINCLUDE_PLATFORM_H_INSTEAD_OF_IODEFINE_H == 1 ) +diff --git a/portable/GCC/RX600/port.c b/portable/GCC/RX600/port.c +index afe1a7142..4a6c0e2f2 100644 +--- a/portable/GCC/RX600/port.c ++++ b/portable/GCC/RX600/port.c +@@ -35,7 +35,7 @@ + #include "task.h" + + /* Library includes. */ +-#include "string.h" ++#include "ot_memory.h" + + /* Hardware specifics. */ + #if ( configINCLUDE_PLATFORM_H_INSTEAD_OF_IODEFINE_H == 1 ) +diff --git a/portable/GCC/RX600v2/port.c b/portable/GCC/RX600v2/port.c +index 5527cf9a8..70a3055bb 100644 +--- a/portable/GCC/RX600v2/port.c ++++ b/portable/GCC/RX600v2/port.c +@@ -35,7 +35,7 @@ + #include "task.h" + + /* Library includes. */ +-#include "string.h" ++#include "ot_memory.h" + + /* Hardware specifics. */ + #if ( configINCLUDE_PLATFORM_H_INSTEAD_OF_IODEFINE_H == 1 ) +diff --git a/portable/GCC/RX700v3_DPFPU/port.c b/portable/GCC/RX700v3_DPFPU/port.c +index 4575c455c..fc359c9f8 100644 +--- a/portable/GCC/RX700v3_DPFPU/port.c ++++ b/portable/GCC/RX700v3_DPFPU/port.c +@@ -37,7 +37,7 @@ + #include "task.h" + + /* Library includes. */ +-#include "string.h" ++#include "ot_memory.h" + + /* Hardware specifics. */ + #if ( configINCLUDE_PLATFORM_H_INSTEAD_OF_IODEFINE_H == 1 ) +diff --git a/portable/GCC/TriCore_1782/port.c b/portable/GCC/TriCore_1782/port.c +index 329624251..c9bec08d2 100644 +--- a/portable/GCC/TriCore_1782/port.c ++++ b/portable/GCC/TriCore_1782/port.c +@@ -28,7 +28,7 @@ + + /* Standard includes. */ + // #include +-#include ++#include "ot_memory.h" + + /* TriCore specific includes. */ + #include +diff --git a/portable/IAR/RISC-V/port.c b/portable/IAR/RISC-V/port.c +index f8a49ace9..37c427e4a 100644 +--- a/portable/IAR/RISC-V/port.c ++++ b/portable/IAR/RISC-V/port.c +@@ -36,7 +36,7 @@ + #include "portmacro.h" + + /* Standard includes. */ +-#include "string.h" ++#include "ot_memory.h" + + #ifdef configCLINT_BASE_ADDRESS + #warning The configCLINT_BASE_ADDRESS constant has been deprecated. configMTIME_BASE_ADDRESS and configMTIMECMP_BASE_ADDRESS are currently being derived from the (possibly 0) configCLINT_BASE_ADDRESS setting. Please update to define configMTIME_BASE_ADDRESS and configMTIMECMP_BASE_ADDRESS dirctly in place of configCLINT_BASE_ADDRESS. See https://www.FreeRTOS.org/Using-FreeRTOS-on-RISC-V.html +diff --git a/portable/IAR/RX100/port.c b/portable/IAR/RX100/port.c +index 1a5fb3749..6727140cd 100644 +--- a/portable/IAR/RX100/port.c ++++ b/portable/IAR/RX100/port.c +@@ -38,7 +38,7 @@ + #include "task.h" + + /* Library includes. */ +-#include "string.h" ++#include "ot_memory.h" + + /* Hardware specifics. */ + #include "machine.h" +diff --git a/portable/IAR/RX600/port.c b/portable/IAR/RX600/port.c +index 8f524dd85..694c38376 100644 +--- a/portable/IAR/RX600/port.c ++++ b/portable/IAR/RX600/port.c +@@ -35,7 +35,7 @@ + #include "task.h" + + /* Library includes. */ +-#include "string.h" ++#include "ot_memory.h" + + /* Hardware specifics. */ + #include +diff --git a/portable/IAR/RX700v3_DPFPU/port.c b/portable/IAR/RX700v3_DPFPU/port.c +index 961147cec..c4dd5bec5 100644 +--- a/portable/IAR/RX700v3_DPFPU/port.c ++++ b/portable/IAR/RX700v3_DPFPU/port.c +@@ -37,7 +37,7 @@ + #include "task.h" + + /* Library includes. */ +-#include "string.h" ++#include "ot_memory.h" + + /* Hardware specifics. */ + #if ( configINCLUDE_PLATFORM_H_INSTEAD_OF_IODEFINE_H == 1 ) +diff --git a/portable/IAR/RXv2/port.c b/portable/IAR/RXv2/port.c +index aa9e79774..fc32dfef7 100644 +--- a/portable/IAR/RXv2/port.c ++++ b/portable/IAR/RXv2/port.c +@@ -35,7 +35,7 @@ + #include "task.h" + + /* Library includes. */ +-#include "string.h" ++#include "ot_memory.h" + + /* Hardware specifics. */ + #include +diff --git a/portable/MPLAB/PIC32MZ/port.c b/portable/MPLAB/PIC32MZ/port.c +index e533f9020..893dbf964 100644 +--- a/portable/MPLAB/PIC32MZ/port.c ++++ b/portable/MPLAB/PIC32MZ/port.c +@@ -34,7 +34,7 @@ + #include + + /* Standard headers. */ +-#include ++#include "ot_memory.h" + + /* Scheduler include files. */ + #include "FreeRTOS.h" +diff --git a/portable/Renesas/RX100/port.c b/portable/Renesas/RX100/port.c +index 12db4c011..5f40b0969 100644 +--- a/portable/Renesas/RX100/port.c ++++ b/portable/Renesas/RX100/port.c +@@ -38,7 +38,7 @@ + #include "task.h" + + /* Library includes. */ +-#include "string.h" ++#include "ot_memory.h" + + /* Hardware specifics. */ + #include "iodefine.h" +diff --git a/portable/Renesas/RX200/port.c b/portable/Renesas/RX200/port.c +index 2ee9d5943..1582032d7 100644 +--- a/portable/Renesas/RX200/port.c ++++ b/portable/Renesas/RX200/port.c +@@ -35,7 +35,7 @@ + #include "task.h" + + /* Library includes. */ +-#include "string.h" ++#include "ot_memory.h" + + /* Hardware specifics. */ + #include "iodefine.h" +diff --git a/portable/Renesas/RX600/port.c b/portable/Renesas/RX600/port.c +index d3315c569..1de736888 100644 +--- a/portable/Renesas/RX600/port.c ++++ b/portable/Renesas/RX600/port.c +@@ -35,7 +35,7 @@ + #include "task.h" + + /* Library includes. */ +-#include "string.h" ++#include "ot_memory.h" + + /* Hardware specifics. */ + #include "iodefine.h" +diff --git a/portable/Renesas/RX600v2/port.c b/portable/Renesas/RX600v2/port.c +index 7ee91bfa8..b207c5fe1 100644 +--- a/portable/Renesas/RX600v2/port.c ++++ b/portable/Renesas/RX600v2/port.c +@@ -35,7 +35,7 @@ + #include "task.h" + + /* Library includes. */ +-#include "string.h" ++#include "ot_memory.h" + + /* Hardware specifics. */ + #if defined( configINCLUDE_PLATFORM_H_INSTEAD_OF_IODEFINE_H ) && ( configINCLUDE_PLATFORM_H_INSTEAD_OF_IODEFINE_H == 1 ) +diff --git a/portable/Renesas/RX700v3_DPFPU/port.c b/portable/Renesas/RX700v3_DPFPU/port.c +index 26cb9f020..b91942352 100644 +--- a/portable/Renesas/RX700v3_DPFPU/port.c ++++ b/portable/Renesas/RX700v3_DPFPU/port.c +@@ -37,7 +37,7 @@ + #include "task.h" + + /* Library includes. */ +-#include "string.h" ++#include "ot_memory.h" + + /* Hardware specifics. */ + #if ( configINCLUDE_PLATFORM_H_INSTEAD_OF_IODEFINE_H == 1 ) +diff --git a/portable/Renesas/SH2A_FPU/port.c b/portable/Renesas/SH2A_FPU/port.c +index ca7c56b3d..0e9d4c655 100644 +--- a/portable/Renesas/SH2A_FPU/port.c ++++ b/portable/Renesas/SH2A_FPU/port.c +@@ -35,7 +35,7 @@ + #include "task.h" + + /* Library includes. */ +-#include "string.h" ++#include "ot_memory.h" + + /*-----------------------------------------------------------*/ + +diff --git a/portable/SDCC/Cygnal/port.c b/portable/SDCC/Cygnal/port.c +index e0a9d9488..2811b6b9a 100644 +--- a/portable/SDCC/Cygnal/port.c ++++ b/portable/SDCC/Cygnal/port.c +@@ -31,7 +31,7 @@ + *----------------------------------------------------------*/ + + /* Standard includes. */ +-#include ++#include "ot_memory.h" + + /* Scheduler includes. */ + #include "FreeRTOS.h" +diff --git a/portable/ThirdParty/GCC/ARC_EM_HS/freertos_tls.c b/portable/ThirdParty/GCC/ARC_EM_HS/freertos_tls.c +index 7d74f319e..1b4f60295 100644 +--- a/portable/ThirdParty/GCC/ARC_EM_HS/freertos_tls.c ++++ b/portable/ThirdParty/GCC/ARC_EM_HS/freertos_tls.c +@@ -30,7 +30,7 @@ + + #include + #include +- #include ++ #include "ot_memory.h" + + #include "FreeRTOS.h" + +diff --git a/portable/ThirdParty/GCC/Posix/port.c b/portable/ThirdParty/GCC/Posix/port.c +index e80f7518f..b3834ff4b 100644 +--- a/portable/ThirdParty/GCC/Posix/port.c ++++ b/portable/ThirdParty/GCC/Posix/port.c +@@ -55,7 +55,7 @@ + #include + #include + #include +-#include ++#include "ot_memory.h" + #include + #include + #include +diff --git a/portable/ThirdParty/XCC/Xtensa/portclib.c b/portable/ThirdParty/XCC/Xtensa/portclib.c +index b0616657c..720a9ecbe 100644 +--- a/portable/ThirdParty/XCC/Xtensa/portclib.c ++++ b/portable/ThirdParty/XCC/Xtensa/portclib.c +@@ -137,7 +137,7 @@ _reclaim_reent(void * ptr) + #include + #include + // #include +-#include ++#include "ot_memory.h" + + #include "semphr.h" + +diff --git a/queue.c b/queue.c +index 12f81d394..30e905ac8 100644 +--- a/queue.c ++++ b/queue.c +@@ -27,7 +27,7 @@ + */ + + // #include +-#include ++#include "ot_memory.h" + + /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining + * all the API functions to use the MPU wrappers. That should only be done when +diff --git a/stream_buffer.c b/stream_buffer.c +index 8a7a2e0d0..813e60a99 100644 +--- a/stream_buffer.c ++++ b/stream_buffer.c +@@ -28,7 +28,7 @@ + + /* Standard includes. */ + #include +-#include ++#include "ot_memory.h" + + /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining + * all the API functions to use the MPU wrappers. That should only be done when +diff --git a/tasks.c b/tasks.c +index 405425c60..48e9dc37e 100644 +--- a/tasks.c ++++ b/tasks.c +@@ -28,7 +28,7 @@ + + /* Standard includes. */ + // #include +-#include ++#include "ot_memory.h" + + /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining + * all the API functions to use the MPU wrappers. That should only be done when +-- +2.35.1.1021.g381101b075-goog + diff --git a/third_party/freertos/BUILD b/third_party/freertos/BUILD new file mode 100644 index 0000000000000..25c6317ee3581 --- /dev/null +++ b/third_party/freertos/BUILD @@ -0,0 +1,16 @@ +# Copyright lowRISC contributors. +# Licensed under the Apache License, Version 2.0, see LICENSE for details. +# SPDX-License-Identifier: Apache-2.0 + +load("//rules:opentitan.bzl", "OPENTITAN_CPU") + +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "freertos", + srcs = ["@freertos//:srcs"], + deps = [ + "//sw/device/lib/testing/test_framework:freertos_config", + "@freertos//:hdrs", + ], +) diff --git a/third_party/freertos/BUILD.freertos.bazel b/third_party/freertos/BUILD.freertos.bazel new file mode 100644 index 0000000000000..fe461caf50b1f --- /dev/null +++ b/third_party/freertos/BUILD.freertos.bazel @@ -0,0 +1,57 @@ +# Copyright lowRISC contributors. +# Licensed under the Apache License, Version 2.0, see LICENSE for details. +# SPDX-License-Identifier: Apache-2.0 + +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "portmacro", + hdrs = ["portable/GCC/RISC-V/portmacro.h"], + includes = ["portable/GCC/RISC-V"], + target_compatible_with = ["@bazel_embedded//constraints/cpu:riscv32"], +) + +cc_library( + name = "hdrs", + srcs = [ + "include/FreeRTOS.h", + "include/StackMacros.h", + "include/atomic.h", + "include/croutine.h", + "include/event_groups.h", + "include/list.h", + "include/message_buffer.h", + "include/mpu_prototypes.h", + "include/mpu_wrappers.h", + "include/ot_memory.h", + "include/portable.h", + "include/projdefs.h", + "include/queue.h", + "include/semphr.h", + "include/stack_macros.h", + "include/stream_buffer.h", + "include/task.h", + "include/timers.h", + ], + includes = ["include"], + deps = [ + ":portmacro", + ], +) + +# This needs to be a filegroup, because the actual kernel library depends on +# FreeRTOSConfig.h, which we can't make available in this repository without +# including it in the patches, which is fairly brittle. +# +# Instead, the actual kernel library is defined in the //third_party/freertos +# package. +filegroup( + name = "srcs", + srcs = [ + "include/deprecated_definitions.h", + "list.c", + "portable/MemMang/heap_1.c", + "queue.c", + "tasks.c", + ], +) diff --git a/third_party/freertos/deps.bzl b/third_party/freertos/deps.bzl new file mode 100644 index 0000000000000..4f588cb35f4bb --- /dev/null +++ b/third_party/freertos/deps.bzl @@ -0,0 +1,20 @@ +# Copyright lowRISC contributors. +# Licensed under the Apache License, Version 2.0, see LICENSE for details. +# SPDX-License-Identifier: Apache-2.0 + +load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") + +def freertos_deps(): + new_git_repository( + name = "freertos", + build_file = Label("//third_party/freertos:BUILD.freertos.bazel"), + remote = "https://github.com/FreeRTOS/FreeRTOS-Kernel.git", + commit = "0b1e9d79c82c1bf00e93142f9d5b1b7b62446995", + shallow_since = "1628817357 -0700", + patches = [ + Label("//third_party/freertos:0001-Remove-mtime-address-macros.patch"), + Label("//third_party/freertos:0002-Remove-references-to-stdlib.h.patch"), + Label("//third_party/freertos:0003-Replace-string.h-with-references-to-OT-memory.h.patch"), + ], + patch_args = ["-p1"], + )