res_mempool.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * Copyright (c) 2018 Actions Semiconductor Co., Ltd
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /**
  7. * @file ui memory interface
  8. */
  9. #ifndef FRAMEWORK_DISPLAY_INCLUDE_RES_MEMPOOL_H_
  10. #define FRAMEWORK_DISPLAY_INCLUDE_RES_MEMPOOL_H_
  11. /**
  12. * @defgroup view_cache_apis View Cache APIs
  13. * @ingroup system_apis
  14. * @{
  15. */
  16. #include <stdint.h>
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. /**
  21. * @brief Initialize the res manager pool memory
  22. *
  23. * @retval 0 on success else negative code.
  24. */
  25. void res_mem_init(void);
  26. /**
  27. * @brief Alloc res buffer memory
  28. *
  29. * @param type mempool type
  30. * @param size allocation size in bytes
  31. *
  32. * @retval pointer to the allocation memory.
  33. */
  34. void *res_mem_alloc_debug(uint32_t type, size_t size,const char *func);
  35. #define res_mem_alloc(type, size) res_mem_alloc_debug(type, size, __func__)
  36. /**
  37. * @brief Free res buffer memory
  38. *
  39. * @param type mempool type
  40. * @param ptr pointer to the allocated memory
  41. *
  42. * @retval N/A
  43. */
  44. void res_mem_free(uint32_t type, void *ptr);
  45. /**
  46. * @brief Dump res manger memory allocation detail.
  47. *
  48. *
  49. * @retval N/A
  50. */
  51. void res_mem_dump(void);
  52. /**
  53. * @brief Alloc fixed size res buffer memory
  54. *
  55. * @param type mem type
  56. * @param size allocation size in bytes
  57. *
  58. * @retval pointer to the allocation memory.
  59. */
  60. void* res_array_alloc_debug(int32_t type, size_t size, const char *func);
  61. #define res_array_alloc(type, size) res_array_alloc_debug(type, size,__func__)
  62. /**
  63. * @brief Free fixed size res buffer memory
  64. *
  65. * @param type mem type
  66. * @param ptr pointer to the allocated memory
  67. *
  68. * @retval 1 on success else ptr is not found
  69. */
  70. uint32_t res_array_free(void* ptr);
  71. /**
  72. * @brief check if auto searching enabled
  73. *
  74. *
  75. * @retval N/A
  76. */
  77. int res_is_auto_search_files(void);
  78. int res_debug_load_bitmap_is_on(void);
  79. int res_mem_get_max_resource_sets(void);
  80. uint32_t res_mem_get_max_compact_block_size(void);
  81. void * res_mem_aligned_alloc_debug(uint8_t type, size_t align, size_t size, const void* caller);
  82. #define res_mem_aligned_alloc(type, align, size) res_mem_aligned_alloc_debug(type, align, size, __func__)
  83. void* res_mem_alloc_block(size_t size, const char* func);
  84. void res_mem_free_block(void* ptr);
  85. int res_mem_is_block(void* ptr);
  86. size_t res_mem_get_align(void);
  87. #ifdef __cplusplus
  88. }
  89. #endif
  90. /**
  91. * @}
  92. */
  93. #endif /* FRAMEWORK_DISPLAY_INCLUDE_RES_MEMPOOL_H_ */