Integrate the new heap implementation from InfiniTime (https://github.com/InfiniTimeOrg/InfiniTime/pull/1709).
Since FreeRTOS.h, portmacro_cmsis.h and task.h are now built in C (by lv_mem.c), I had to change some includes and declarations to make them compatible with a C compiler. Integrating the new memory management from InfiniTime in InfiniSim is not easy because InfiniSim does not include the whole FreeRTOS. Which means that, for example, pvPortMalloc() and vPortFree() are not accessible from InfiniSim. As a first step, I provided custom implementations for pvPortMalloc(), vPortFree() which are based on ... malloc(). These function keep track of the memory that is currently allocated so that xPortGetFreeHeapSize(), xPortGetMinimumEverFreeHeapSize() return something. Not that this implementation do not keep track of all the memory allocations done in InfiniTime. It can only "see" those done via pvPortMalloc(). It means that the available memory displayed by InfiniSim will probably be very optimistic.
This commit is contained in:

committed by
Reinhold Gschweicher

parent
e416f2cf74
commit
8ae5ba7c0a
15
sim/task.h
15
sim/task.h
@@ -32,7 +32,8 @@
|
||||
|
||||
#include "portmacro_cmsis.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
// copied from InfiniTime/src/FreeRTOSConfig.h
|
||||
#define configTICK_RATE_HZ 1024
|
||||
#define configSTACK_DEPTH_TYPE uint16_t
|
||||
@@ -65,11 +66,11 @@ typedef void (*TaskFunction_t)(void *instance);
|
||||
* \ingroup Tasks
|
||||
*/
|
||||
//typedef void * TaskHandle_t;
|
||||
struct TaskHandle_t {
|
||||
void *thread_handle = nullptr;
|
||||
typedef struct TaskHandle_t {
|
||||
void *thread_handle;
|
||||
TaskFunction_t task_fn;
|
||||
void *instance = nullptr;
|
||||
};
|
||||
void *instance;
|
||||
}TaskHandle_t;
|
||||
|
||||
/* Task states returned by eTaskGetState. */
|
||||
enum eTaskState
|
||||
@@ -101,7 +102,7 @@ is used in assert() statements. */
|
||||
|
||||
/* Used with the uxTaskGetSystemState() function to return the state of each task
|
||||
in the system. */
|
||||
struct TaskStatus_t {
|
||||
typedef struct TaskStatus_t {
|
||||
TaskHandle_t xHandle; /* The handle of the task to which the rest of the information in the structure relates. */
|
||||
const char *pcTaskName; /* A pointer to the task's name. This value will be invalid if the task was deleted since the structure was populated! */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
|
||||
UBaseType_t xTaskNumber; /* A number unique to the task. */
|
||||
@@ -111,7 +112,7 @@ struct TaskStatus_t {
|
||||
uint32_t ulRunTimeCounter; /* The total run time allocated to the task so far, as defined by the run time stats clock. See http://www.freertos.org/rtos-run-time-stats.html. Only valid when configGENERATE_RUN_TIME_STATS is defined as 1 in FreeRTOSConfig.h. */
|
||||
//StackType_t *pxStackBase; /* Points to the lowest address of the task's stack area. */
|
||||
uint16_t usStackHighWaterMark; /* The minimum amount of stack space that has remained for the task since the task was created. The closer this value is to zero the closer the task has come to overflowing its stack. */
|
||||
};
|
||||
}TaskStatus_t;
|
||||
|
||||
/**
|
||||
* configUSE_TRACE_FACILITY must be defined as 1 in FreeRTOSConfig.h for
|
||||
|
Reference in New Issue
Block a user