Software APIs
freertos_hooks.c
1 // Copyright lowRISC contributors (OpenTitan project).
2 // Licensed under the Apache License, Version 2.0, see LICENSE for details.
3 // SPDX-License-Identifier: Apache-2.0
4 
5 #include "external/freertos/include/FreeRTOS.h"
6 #include "external/freertos/include/task.h"
8 #include "sw/device/lib/runtime/irq.h"
10 
11 // NOTE: the function names below do NOT, and cannot, conform to the style
12 // guide, since they are specific implementations of FreeRTOS defined functions.
13 
14 /**
15  * This is called if configUSE_MALLOC_FAILED_HOOK is set to 1 in
16  * FreeRTOSConfig.h, and a call to pvPortMalloc() fails.
17  */
18 void vApplicationMallocFailedHook(void) {
19  LOG_INFO("%s",
20  "FreeRTOS malloc failed. Increase heap size in FreeRTOSConfig.h");
21  irq_global_ctrl(false);
22  abort();
23 }
24 
25 /**
26  * This is called if configCHECK_FOR_STACK_OVERFLOW is set to 1 or 2 in
27  * FreeRTOSConfig.h, and a task detects a stack overflow.
28  */
29 void vApplicationStackOverflowHook(TaskHandle_t xTask, char *pcTaskName) {
30  LOG_INFO("FreeRTOS stack overflow. Increase stack size of task: %s",
31  pcTaskName);
32  irq_global_ctrl(false);
33  abort();
34 }