#ifndef __HEAP_H
#define __HEAP_H

#include <stdlib.h>
#include <stdint.h>

#define HEAP_DTCM_SIZE_KB 96 //保留32k用于系统栈、Newlib堆与静态内存
#define HEAP_AXI_SIZE_KB 512 //全部用于堆
#define HEAP_APB_SIZE_KB 256 //保留32k用于elog异步输出缓冲区

typedef struct {
  uint32_t free_cnt;
  uint32_t free_size;
  uint32_t free_biggest_size;
  uint32_t used_cnt;
  uint32_t used_size;
  uint32_t used_biggest_size;
} tlsf_pool_statistics;

void *malloc_dtcm(size_t size);
void free_dtcm(void *p);
void *realloc_dtcm(void *oldmem, size_t bytes);

void *malloc_ahb(size_t size);
void free_ahb(void *p);
void *realloc_ahb(void *oldmem, size_t bytes);

tlsf_pool_statistics *get_dtcm_heap_statistics(void);
tlsf_pool_statistics *get_ahb_heap_statistics(void);
tlsf_pool_statistics *get_axi_heap_statistics(void);

void heap_init(void);

#endif
