mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-24 11:10:23 +00:00
dynamic control block per heap
This commit is contained in:
@@ -37,23 +37,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
|
||||
#include "soc/soc.h"
|
||||
|
||||
#if !CONFIG_SPIRAM
|
||||
#define TLSF_MAX_POOL_SIZE (SOC_DIRAM_DRAM_HIGH - SOC_DIRAM_DRAM_LOW)
|
||||
#else
|
||||
#define TLSF_MAX_POOL_SIZE SOC_EXTRAM_DATA_SIZE
|
||||
#endif
|
||||
|
||||
enum tlsf_config
|
||||
{
|
||||
/* log2 of number of linear subdivisions of block sizes. Larger
|
||||
** values require more memory in the control structure. Values of
|
||||
** 4 or 5 are typical.
|
||||
** 4 or 5 are typical, 3 is for very small pools.
|
||||
*/
|
||||
SL_INDEX_COUNT_LOG2 = 5,
|
||||
SL_INDEX_COUNT_LOG2_MIN = 3,
|
||||
|
||||
/* All allocation sizes and addresses are aligned to 4 bytes. */
|
||||
ALIGN_SIZE_LOG2 = 2,
|
||||
@@ -68,59 +58,9 @@ enum tlsf_config
|
||||
** trying to split size ranges into more slots than we have available.
|
||||
** Instead, we calculate the minimum threshold size, and place all
|
||||
** blocks below that size into the 0th first-level list.
|
||||
** Values below are the absolute minimum to accept a pool addition
|
||||
*/
|
||||
|
||||
/* Tunning the first level, we can reduce TLSF pool overhead
|
||||
* in exchange of manage a pool smaller than 4GB
|
||||
*/
|
||||
#if (TLSF_MAX_POOL_SIZE <= (256 * 1024))
|
||||
FL_INDEX_MAX = 18, //Each pool can have up 256KB
|
||||
#elif (TLSF_MAX_POOL_SIZE <= (512 * 1024))
|
||||
FL_INDEX_MAX = 19, //Each pool can have up 512KB
|
||||
#elif (TLSF_MAX_POOL_SIZE <= (1 * 1024 * 1024))
|
||||
FL_INDEX_MAX = 20, //Each pool can have up 1MB
|
||||
#elif (TLSF_MAX_POOL_SIZE <= (2 * 1024 * 1024))
|
||||
FL_INDEX_MAX = 21, //Each pool can have up 2MB
|
||||
#elif (TLSF_MAX_POOL_SIZE <= (4 * 1024 * 1024))
|
||||
FL_INDEX_MAX = 22, //Each pool can have up 4MB
|
||||
#elif (TLSF_MAX_POOL_SIZE <= (8 * 1024 * 1024))
|
||||
FL_INDEX_MAX = 23, //Each pool can have up 8MB
|
||||
#elif (TLSF_MAX_POOL_SIZE <= (16 * 1024 * 1024))
|
||||
FL_INDEX_MAX = 24, //Each pool can have up 16MB
|
||||
#else
|
||||
#error "Higher TLSF pool sizes should be added for this new config"
|
||||
#endif
|
||||
|
||||
SL_INDEX_COUNT = (1 << SL_INDEX_COUNT_LOG2),
|
||||
FL_INDEX_SHIFT = (SL_INDEX_COUNT_LOG2 + ALIGN_SIZE_LOG2),
|
||||
FL_INDEX_COUNT = (FL_INDEX_MAX - FL_INDEX_SHIFT + 1),
|
||||
|
||||
SMALL_BLOCK_SIZE = (1 << FL_INDEX_SHIFT),
|
||||
FL_INDEX_MAX_MIN = 14, // For a less than 16kB pool
|
||||
SL_INDEX_COUNT_MIN = (1 << SL_INDEX_COUNT_LOG2_MIN),
|
||||
FL_INDEX_COUNT_MIN = (FL_INDEX_MAX_MIN - (SL_INDEX_COUNT_LOG2_MIN + ALIGN_SIZE_LOG2) + 1),
|
||||
};
|
||||
#else
|
||||
enum tlsf_config
|
||||
{
|
||||
//Specific configuration for host test.
|
||||
|
||||
/* log2 of number of linear subdivisions of block sizes. Larger
|
||||
** values require more memory in the control structure. Values of
|
||||
** 4 or 5 are typical.
|
||||
*/
|
||||
SL_INDEX_COUNT_LOG2 = 5,
|
||||
|
||||
/* All allocation sizes and addresses are aligned to 4 bytes. */
|
||||
ALIGN_SIZE_LOG2 = 2,
|
||||
ALIGN_SIZE = (1 << ALIGN_SIZE_LOG2),
|
||||
|
||||
/* Tunning the first level, we can reduce TLSF pool overhead
|
||||
* in exchange of manage a pool smaller than 4GB
|
||||
*/
|
||||
FL_INDEX_MAX = 30,
|
||||
|
||||
SL_INDEX_COUNT = (1 << SL_INDEX_COUNT_LOG2),
|
||||
FL_INDEX_SHIFT = (SL_INDEX_COUNT_LOG2 + ALIGN_SIZE_LOG2),
|
||||
FL_INDEX_COUNT = (FL_INDEX_MAX - FL_INDEX_SHIFT + 1),
|
||||
|
||||
SMALL_BLOCK_SIZE = (1 << FL_INDEX_SHIFT),
|
||||
};
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user