Skip to content

Commit

Permalink
[hal] rtos: add defaults for configENABLE_HEAP_PROTECTOR, add canary …
Browse files Browse the repository at this point in the history
…hook for gen3
  • Loading branch information
avtolstoy committed Jun 28, 2024
1 parent 29433d3 commit 6d1d9bf
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions hal/src/nRF52840/freertos/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ extern void vApplicationTaskDeleteHook(void *pvTaskToDelete, volatile long* pxPe
#define configDYNAMIC_HEAP_SIZE ( 1 )
#define configUSE_MALLOC_FAILED_HOOK ( 1 )
#define configSUPPORT_STATIC_ALLOCATION ( 1 )
#define configENABLE_HEAP_PROTECTOR (0) // TODO: enable

/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
Expand Down
7 changes: 7 additions & 0 deletions hal/src/nRF52840/rtos_hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,11 @@ void vApplicationIdleHook(void) {
}
}

#if defined(configENABLE_HEAP_PROTECTOR) && configENABLE_HEAP_PROTECTOR == 1
void vApplicationGetRandomHeapCanary( portPOINTER_SIZE_TYPE * pxHeapCanary ) {
uint32_t canary = HAL_RNG_GetRandomNumber();
*pxHeapCanary = canary;
}
#endif // defined(configENABLE_HEAP_PROTECTOR) && configENABLE_HEAP_PROTECTOR == 1

} // extern "C"
2 changes: 2 additions & 0 deletions hal/src/rtl872x/freertos/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ extern void vApplicationTaskDeleteHook(void *pvTaskToDelete, volatile long* pxPe
#define secureconfigTOTAL_SRAM_HEAP_SIZE ( ( ( size_t ) ( 6 * 1024 ) ) )
#define secureconfigTOTAL_PSRAM_HEAP_SIZE ( ( ( size_t ) ( 128 * 1024 ) ) )

#define configENABLE_HEAP_PROTECTOR (0) // TODO: enable

/* Constants that build features in or out. */
#define configUSE_MUTEXES 1
#define configMUTEX_MULTI_STEP_PRIORITY_DISINHERITANCE 1
Expand Down
1 change: 1 addition & 0 deletions hal/src/rtl872x/freertos/FreeRTOSConfig_m23.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ extern uint32_t SystemCoreClock;
#define configDYNAMIC_HEAP_SIZE ( 1 )
#define configHEAP_NO_ASSERT_OVERRIDE ( 1 )
#define configSUPPORT_STATIC_ALLOCATION ( 1 )
#define configENABLE_HEAP_PROTECTOR (0) // TODO: enable

/* Constants that build features in or out. */
#define configUSE_MUTEXES 1
Expand Down
2 changes: 2 additions & 0 deletions hal/src/rtl872x/rtos_hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,11 @@ void vApplicationIdleHook(void) {
}
}

#if defined(configENABLE_HEAP_PROTECTOR) && configENABLE_HEAP_PROTECTOR == 1
void vApplicationGetRandomHeapCanary( portPOINTER_SIZE_TYPE * pxHeapCanary ) {
uint32_t canary = HAL_RNG_GetRandomNumber();
*pxHeapCanary = canary;
}
#endif // defined(configENABLE_HEAP_PROTECTOR) && configENABLE_HEAP_PROTECTOR == 1

} // extern "C"

0 comments on commit 6d1d9bf

Please sign in to comment.