VSF Documented
esp_heap_caps.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2026 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18/*
19 * Clean-room re-implementation of ESP-IDF public API "esp_heap_caps.h".
20 *
21 * This file is authored from the ESP-IDF v5.x public API reference only.
22 * No code is copied or derived from the ESP-IDF source tree. Flag values
23 * and function signatures are kept compatible so that unmodified ESP-IDF
24 * example applications can compile and link against this header.
25 *
26 * VSF backend: all capabilities are served from the single managed heap
27 * (service/heap/vsf_heap). The caps bitmask is therefore accepted but
28 * largely ignored -- allocations succeed whenever the underlying heap
29 * can satisfy the request. This mirrors host / single-pool IDF builds.
30 */
31
32#ifndef __VSF_ESPIDF_ESP_HEAP_CAPS_H__
33#define __VSF_ESPIDF_ESP_HEAP_CAPS_H__
34
35#include <stdint.h>
36#include <stddef.h>
37#include <stdbool.h>
38
39#include "esp_err.h"
40#include "multi_heap.h"
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46/*============================ MACROS ========================================*/
47
48/* Bit values fixed by ESP-IDF public API contract. */
49#define MALLOC_CAP_EXEC (1u << 0)
50#define MALLOC_CAP_32BIT (1u << 1)
51#define MALLOC_CAP_8BIT (1u << 2)
52#define MALLOC_CAP_DMA (1u << 3)
53#define MALLOC_CAP_PID2 (1u << 4)
54#define MALLOC_CAP_PID3 (1u << 5)
55#define MALLOC_CAP_PID4 (1u << 6)
56#define MALLOC_CAP_PID5 (1u << 7)
57#define MALLOC_CAP_PID6 (1u << 8)
58#define MALLOC_CAP_PID7 (1u << 9)
59#define MALLOC_CAP_SPIRAM (1u << 10)
60#define MALLOC_CAP_INTERNAL (1u << 11)
61#define MALLOC_CAP_DEFAULT (1u << 12)
62#define MALLOC_CAP_IRAM_8BIT (1u << 13)
63#define MALLOC_CAP_RETENTION (1u << 14)
64#define MALLOC_CAP_RTCRAM (1u << 16)
65#define MALLOC_CAP_TCM (1u << 17)
66#define MALLOC_CAP_INVALID (1u << 31)
67
68/*============================ PROTOTYPES ====================================*/
69
70/*
71 * Caveat: the VSF backend is a single flat heap, so the caps argument is
72 * accepted and validated (MALLOC_CAP_INVALID fails) but otherwise ignored.
73 * All queries report figures for the whole heap regardless of caps.
74 */
75
76extern void *heap_caps_malloc(size_t size, uint32_t caps);
77extern void heap_caps_free(void *ptr);
78extern void *heap_caps_realloc(void *ptr, size_t size, uint32_t caps);
79extern void *heap_caps_calloc(size_t n, size_t size, uint32_t caps);
80
81extern void *heap_caps_aligned_alloc(size_t alignment, size_t size, uint32_t caps);
82extern void heap_caps_aligned_free(void *ptr);
83extern void *heap_caps_aligned_calloc(size_t alignment, size_t n, size_t size, uint32_t caps);
84
85extern size_t heap_caps_get_total_size(uint32_t caps);
86extern size_t heap_caps_get_free_size(uint32_t caps);
89
90extern void heap_caps_get_info(multi_heap_info_t *info, uint32_t caps);
91
92extern bool heap_caps_check_integrity_all(bool print_errors);
93extern bool heap_caps_check_integrity(uint32_t caps, bool print_errors);
94
95#ifdef __cplusplus
96}
97#endif
98
99#endif // __VSF_ESPIDF_ESP_HEAP_CAPS_H__
void * heap_caps_calloc(size_t n, size_t size, uint32_t caps)
Definition esp_heap_caps_port.c:124
void heap_caps_get_info(multi_heap_info_t *info, uint32_t caps)
Definition esp_heap_caps_port.c:250
bool heap_caps_check_integrity_all(bool print_errors)
Definition esp_heap_caps_port.c:276
bool heap_caps_check_integrity(uint32_t caps, bool print_errors)
Definition esp_heap_caps_port.c:283
void heap_caps_aligned_free(void *ptr)
Definition esp_heap_caps_port.c:156
void * heap_caps_aligned_alloc(size_t alignment, size_t size, uint32_t caps)
Definition esp_heap_caps_port.c:144
void * heap_caps_malloc(size_t size, uint32_t caps)
Definition esp_heap_caps_port.c:87
void * heap_caps_aligned_calloc(size_t alignment, size_t n, size_t size, uint32_t caps)
Definition esp_heap_caps_port.c:165
size_t heap_caps_get_largest_free_block(uint32_t caps)
Definition esp_heap_caps_port.c:236
void * heap_caps_realloc(void *ptr, size_t size, uint32_t caps)
Definition esp_heap_caps_port.c:110
size_t heap_caps_get_minimum_free_size(uint32_t caps)
Definition esp_heap_caps_port.c:220
size_t heap_caps_get_free_size(uint32_t caps)
Definition esp_heap_caps_port.c:204
size_t heap_caps_get_total_size(uint32_t caps)
Definition esp_heap_caps_port.c:190
void heap_caps_free(void *ptr)
Definition esp_heap_caps_port.c:102
unsigned uint32_t
Definition stdint.h:9
Definition multi_heap.h:40
uint_fast32_t alignment
Definition vsf_heap.h:172
uint32_t size
Definition vsf_memfs.h:50
Generated from commit: vsfteam/vsf@c3767bf