tlsf_platform.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include <stddef.h>
  8. #include <stdbool.h>
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. #ifdef ESP_PLATFORM
  13. #include "soc/soc.h"
  14. #if !CONFIG_SPIRAM
  15. #define TLSF_MAX_POOL_SIZE (SOC_DIRAM_DRAM_HIGH - SOC_DIRAM_DRAM_LOW)
  16. #else
  17. #define TLSF_MAX_POOL_SIZE SOC_EXTRAM_DATA_SIZE
  18. #endif
  19. #endif
  20. #if (TLSF_MAX_POOL_SIZE <= (256 * 1024))
  21. #define FL_INDEX_MAX_PLATFORM 18 //Each pool can have up 256KB
  22. #elif (TLSF_MAX_POOL_SIZE <= (512 * 1024))
  23. #define FL_INDEX_MAX_PLATFORM 19 //Each pool can have up 512KB
  24. #elif (TLSF_MAX_POOL_SIZE <= (1 * 1024 * 1024))
  25. #define FL_INDEX_MAX_PLATFORM 20 //Each pool can have up 1MB
  26. #elif (TLSF_MAX_POOL_SIZE <= (2 * 1024 * 1024))
  27. #define FL_INDEX_MAX_PLATFORM 21 //Each pool can have up 2MB
  28. #elif (TLSF_MAX_POOL_SIZE <= (4 * 1024 * 1024))
  29. #define FL_INDEX_MAX_PLATFORM 22 //Each pool can have up 4MB
  30. #elif (TLSF_MAX_POOL_SIZE <= (8 * 1024 * 1024))
  31. #define FL_INDEX_MAX_PLATFORM 23 //Each pool can have up 8MB
  32. #elif (TLSF_MAX_POOL_SIZE <= (16 * 1024 * 1024))
  33. #define FL_INDEX_MAX_PLATFORM 24 //Each pool can have up 16MB
  34. #elif (TLSF_MAX_POOL_SIZE <= (32 * 1024 * 1024))
  35. #define FL_INDEX_MAX_PLATFORM 25 //Each pool can have up 32MB
  36. #else
  37. #error "Higher TLSF pool sizes should be added for this new config"
  38. #endif
  39. /* Include from the TLSF submodule to force TLSF_INDEX_MAX_PLATFORM to be defined
  40. * when the TLSF repository is compiled in the IDF environment. */
  41. #include "tlsf_common.h"
  42. #ifdef __cplusplus
  43. }
  44. #endif