mirror of
				https://github.com/espressif/esp-idf.git
				synced 2025-11-04 09:01:40 +01:00 
			
		
		
		
	As the tlsf implementation is a fork from https://github.com/mattconte/tlsf, the sources are moved to a separate repository and used as a submodule in the esp-idf instead. In this commit: - Removing TLSF related files and using tlsf submodule instead. - Adding components/heap/tlsf_platform.h header gathering all IDF specifics. - The multi_heap_poisoning.c provides the declaration of the function block_absorb_post_hook() definied weak in the TLSF repository. - The tlsf_platform.h includes the tlsf_common.h file after the definition of FL_INDEX_MAX_PLATFORM macro to make sure that this macro will be available in tlsf_common.h without having to include tlaf_platform.h from IDF in the tlsf_common.h header from the TLSF repository. - Add missing include from tlsf_block_functions.h in the multi_heap.c file. Change related to the changes made in TLSF repository (tlsf_block_functions.h no longer included in tlsf.h)
		
			
				
	
	
		
			70 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			70 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
/*
 | 
						|
 * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
 | 
						|
 *
 | 
						|
 * SPDX-License-Identifier: Apache-2.0
 | 
						|
 */
 | 
						|
#pragma once
 | 
						|
 | 
						|
#include <stdlib.h>
 | 
						|
#include <stdint.h>
 | 
						|
#include <soc/soc_memory_layout.h>
 | 
						|
#include "multi_heap.h"
 | 
						|
#include "multi_heap_platform.h"
 | 
						|
#include "sys/queue.h"
 | 
						|
 | 
						|
#ifdef __cplusplus
 | 
						|
extern "C" {
 | 
						|
#endif
 | 
						|
 | 
						|
/* Some common heap registration data structures used
 | 
						|
   for heap_caps_init.c to share heap information with heap_caps.c
 | 
						|
*/
 | 
						|
 | 
						|
#define HEAP_SIZE_MAX (SOC_MAX_CONTIGUOUS_RAM_SIZE)
 | 
						|
 | 
						|
/* Type for describing each registered heap */
 | 
						|
typedef struct heap_t_ {
 | 
						|
    uint32_t caps[SOC_MEMORY_TYPE_NO_PRIOS]; ///< Capabilities for the type of memory in this heap (as a prioritised set). Copied from soc_memory_types so it's in RAM not flash.
 | 
						|
    intptr_t start;
 | 
						|
    intptr_t end;
 | 
						|
    multi_heap_lock_t heap_mux;
 | 
						|
    multi_heap_handle_t heap;
 | 
						|
    SLIST_ENTRY(heap_t_) next;
 | 
						|
} heap_t;
 | 
						|
 | 
						|
/* All registered heaps.
 | 
						|
 | 
						|
   Forms a single linked list, even though most entries are contiguous.
 | 
						|
   This means at the expense of 4 bytes per heap, new heaps can be
 | 
						|
   added at runtime in a fast & thread-safe way.
 | 
						|
*/
 | 
						|
extern SLIST_HEAD(registered_heap_ll, heap_t_) registered_heaps;
 | 
						|
 | 
						|
bool heap_caps_match(const heap_t *heap, uint32_t caps);
 | 
						|
 | 
						|
/* return all possible capabilities (across all priorities) for a given heap */
 | 
						|
inline static IRAM_ATTR uint32_t get_all_caps(const heap_t *heap)
 | 
						|
{
 | 
						|
    if (heap->heap == NULL) {
 | 
						|
        return 0;
 | 
						|
    }
 | 
						|
    uint32_t all_caps = 0;
 | 
						|
    for (int prio = 0; prio < SOC_MEMORY_TYPE_NO_PRIOS; prio++) {
 | 
						|
        all_caps |= heap->caps[prio];
 | 
						|
    }
 | 
						|
    return all_caps;
 | 
						|
}
 | 
						|
 | 
						|
/*
 | 
						|
 Because we don't want to add _another_ known allocation method to the stack of functions to trace wrt memory tracing,
 | 
						|
 these are declared private. The newlib malloc()/realloc() implementation also calls these, so they are declared
 | 
						|
 separately in newlib/syscalls.c.
 | 
						|
*/
 | 
						|
void *heap_caps_realloc_default(void *p, size_t size);
 | 
						|
void *heap_caps_malloc_default(size_t size);
 | 
						|
 | 
						|
 | 
						|
#ifdef __cplusplus
 | 
						|
}
 | 
						|
#endif
 |