feat: rebuild heap4 card around upstream FreeRTOS allocator

This commit is contained in:
user
2026-07-14 23:24:56 +02:00
parent 032a06fdef
commit 2b17bb4ff9
41 changed files with 1462 additions and 2138 deletions
+68
View File
@@ -0,0 +1,68 @@
#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H
#define configCPU_CLOCK_HZ ( 150000000UL )
#define configTICK_RATE_HZ ( 1000U )
#define configMTIME_BASE_ADDRESS ( 0xC0000100UL )
#define configMTIMECMP_BASE_ADDRESS ( 0xC0000108UL )
#define configUSE_PREEMPTION 1
#define configUSE_TIME_SLICING 1
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
#define configUSE_IDLE_HOOK 0
#define configUSE_PASSIVE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 0
#define configMAX_PRIORITIES 4
#define configMINIMAL_STACK_SIZE 128
#define configMAX_TASK_NAME_LEN 12
#define configTICK_TYPE_WIDTH_IN_BITS TICK_TYPE_WIDTH_32_BITS
#define configIDLE_SHOULD_YIELD 1
#define configNUMBER_OF_CORES 1
#define configTICK_CORE 0
#define configUSE_CORE_AFFINITY 0
#define configRUN_MULTIPLE_PRIORITIES 0
#define configSUPPORT_PICO_SYNC_INTEROP 0
#define configSUPPORT_DYNAMIC_ALLOCATION 1
#define configSUPPORT_STATIC_ALLOCATION 0
#define configTOTAL_HEAP_SIZE ( 4096U )
#define configAPPLICATION_ALLOCATED_HEAP 1
#define configUSE_MALLOC_FAILED_HOOK 1
#define configHEAP_CLEAR_MEMORY_ON_FREE 0
#define configENABLE_HEAP_PROTECTOR 0
#define configUSE_TIMERS 0
#define configUSE_MUTEXES 0
#define configUSE_RECURSIVE_MUTEXES 0
#define configUSE_COUNTING_SEMAPHORES 0
#define configUSE_TASK_NOTIFICATIONS 1
#define configUSE_TRACE_FACILITY 1
#define configUSE_STATS_FORMATTING_FUNCTIONS 0
#define configGENERATE_RUN_TIME_STATS 0
#define configUSE_CO_ROUTINES 0
#define configUSE_NEWLIB_REENTRANT 0
#define configUSE_POSIX_ERRNO 0
#define configCHECK_FOR_STACK_OVERFLOW 0
#define INCLUDE_vTaskDelay 0
#define INCLUDE_vTaskDelayUntil 0
#define INCLUDE_vTaskDelete 0
#define INCLUDE_vTaskSuspend 0
#define INCLUDE_xTaskGetSchedulerState 0
#define configENABLE_FPU 0
#define configENABLE_VPU 0
#if !defined(PICO_RP2350)
#define configISR_STACK_SIZE_WORDS 128
#endif
#ifndef __ASSEMBLER__
void heap4_lab_assert(const char *file, int line);
#define configASSERT(condition) \
do { if (!(condition)) heap4_lab_assert(__FILE__, __LINE__); } while (0)
#else
#define configASSERT(condition)
#endif
#endif
@@ -0,0 +1,15 @@
#ifndef FREERTOS_RISC_V_CHIP_SPECIFIC_EXTENSIONS_H
#define FREERTOS_RISC_V_CHIP_SPECIFIC_EXTENSIONS_H
/* Hazard3 adds no architectural registers to the base RV32I context. */
#define portasmHAS_MTIME 1
#define portasmHAS_SIFIVE_CLINT 0
#define portasmADDITIONAL_CONTEXT_SIZE 0
.macro portasmSAVE_ADDITIONAL_REGISTERS
.endm
.macro portasmRESTORE_ADDITIONAL_REGISTERS
.endm
#endif
+4
View File
@@ -0,0 +1,4 @@
#ifndef HEAP4_FREESTANDING_STDLIB_H
#define HEAP4_FREESTANDING_STDLIB_H
#include <stddef.h>
#endif
+7
View File
@@ -0,0 +1,7 @@
#ifndef HEAP4_FREESTANDING_STRING_H
#define HEAP4_FREESTANDING_STRING_H
#include <stddef.h>
void *memcpy(void *destination, const void *source, size_t count);
void *memset(void *destination, int value, size_t count);
size_t strlen(const char *text);
#endif
+50
View File
@@ -0,0 +1,50 @@
#ifndef HEAP4_HOST_FREERTOS_H
#define HEAP4_HOST_FREERTOS_H
#include <stddef.h>
#include <stdint.h>
typedef int BaseType_t;
typedef uintptr_t portPOINTER_SIZE_TYPE;
typedef struct xHeapStats {
size_t xAvailableHeapSpaceInBytes;
size_t xSizeOfLargestFreeBlockInBytes;
size_t xSizeOfSmallestFreeBlockInBytes;
size_t xNumberOfFreeBlocks;
size_t xMinimumEverFreeBytesRemaining;
size_t xNumberOfSuccessfulAllocations;
size_t xNumberOfSuccessfulFrees;
} HeapStats_t;
#define configSUPPORT_DYNAMIC_ALLOCATION 1
#define configTOTAL_HEAP_SIZE ((size_t)4096U)
#define configAPPLICATION_ALLOCATED_HEAP 1
#define configUSE_MALLOC_FAILED_HOOK 1
#define configHEAP_CLEAR_MEMORY_ON_FREE 0
#define configENABLE_HEAP_PROTECTOR 0
#define portBYTE_ALIGNMENT 8U
#define portBYTE_ALIGNMENT_MASK (portBYTE_ALIGNMENT - 1U)
#define portMAX_DELAY (~(size_t)0U)
#define PRIVILEGED_DATA
#define PRIVILEGED_FUNCTION
#define mtCOVERAGE_TEST_MARKER() do { } while (0)
#define traceMALLOC(pointer, size) do { (void)(pointer); (void)(size); } while (0)
#define traceFREE(pointer, size) do { (void)(pointer); (void)(size); } while (0)
#define taskENTER_CRITICAL() do { } while (0)
#define taskEXIT_CRITICAL() do { } while (0)
void heap4_lab_assert(const char *file, int line);
void vApplicationMallocFailedHook(void);
void *pvPortMalloc(size_t wanted_size);
void vPortFree(void *pointer);
size_t xPortGetFreeHeapSize(void);
size_t xPortGetMinimumEverFreeHeapSize(void);
void vPortGetHeapStats(HeapStats_t *stats);
void vPortHeapResetState(void);
#define configASSERT(condition) \
do { if (!(condition)) heap4_lab_assert(__FILE__, __LINE__); } while (0)
#endif
+9
View File
@@ -0,0 +1,9 @@
#ifndef HEAP4_HOST_TASK_H
#define HEAP4_HOST_TASK_H
#include "FreeRTOS.h"
void vTaskSuspendAll(void);
BaseType_t xTaskResumeAll(void);
#endif