APP_MEM

Defines

SRAM_SECT_BEG
SRAM_SECT_END
PSRAM_RET_SECT_BEG
PSRAM_RET_SECT_END
PSRAM_NON_RET_SECT_BEG
PSRAM_NON_RET_SECT_END
PSRAM_RET_SECT_X_BEG
PSRAM_RET_SECT_X_END
ALIGN_4
app_mem_is_sysheap(p)

Check if p is in the sysheap.

app_mem_get_size(p)

Get mem size.

app_mem_is_in_memheap(heap, ptr)

Check if p is in the memheap(heap).

app_memcpy
app_memset
RET_ADDR

redefine ezip mem alloc/free which defined in SDK.

RET_ADDR_TRACE(p)

RET_ADDR_TRACE used for memory trace.

PSRAM_CACHE_SIZE

Enums

enum image_cache_t

Values:

enumerator CACHE_NONE

none

enumerator CACHE_SYSHEAP

Apply memory block in system heap.

enumerator CACHE_SRAM

Apply memory block in sram heap.

enumerator CACHE_PSRAM

Apply memory block in psram heap.

Functions

rt_uint32_t rt_mem_header_size(void)

Get the header size of system_heap's memory block.

rt_uint32_t rt_mem_ret_addr_offset(void)

Get the offset of system_heap's return_address.

返回值:

offset -- the relative offset of return_address in struct heap_mem

uint8_t rt_mem_is_sysheap(void *ptr)

Check if memory block is in system_heap.

参数:
  • uint8_t -- 0: not in system_heap; 1: in system_heap.

void *app_sram_alloc(rt_size_t size)

Allocate mem from sram_memheap. These memory are used for DMA or performance related scenarios.

参数:
  • size -- Size of the memory to allocate in bytes

返回值:

pointer -- to the allocated memory

void *app_sram_realloc(void *ptr, rt_size_t newsize)

Reallocate mem from sram_memheap. Reallocate a memory with a new size. The old content will be kept.

参数:
  • ptr -- pointer to an allocated memory. Its content will be copied to the new memory block and freed

  • newsize -- the desired new size in byte

返回值:

pointer -- Pointer of reallocated memory.

void *app_sram_calloc(rt_size_t count, rt_size_t size)

Allocate mem from sram_memheap. The allocated memory is filled with bytes of value zero.

参数:
  • count -- Number of objects to allocate.

  • size -- Size of the objects to allocate.

返回值:

pointer -- Pointer of reallocated memory.

void app_sram_free(void *ptr)

Aree mem from sram_memheap.

参数:
  • ptr -- the address of memory which will be released.

void *app_malloc(uint32_t size)

Allocate mem sequentially from block_mem/sys_heap/sram_memheap/psram_memheap.

参数:
  • size -- Size of the memory to allocate in bytes

返回值:

pointer -- Pointer of allocated memory.

void *app_calloc(uint32_t count, uint32_t size)

Allocate mem sequentially from block_mem/sys_heap/sram_memheap/psram_memheap. The allocated memory is filled with bytes of value zero.

参数:
  • count -- Number of objects to allocate.

  • size -- Size of the objects to allocate.

返回值:

pointer -- Pointer of allocated memory.

void *app_realloc(void *ptr, uint32_t new_size)

Reallocate mem sequentially from block_mem/sys_heap/sram_memheap/psram_memheap. Reallocate a memory with a new size. The old content will be kept.

参数:
  • ptr -- pointer to an allocated memory. Its content will be copied to the new memory block and freed

  • newsize -- the desired new size in byte

返回值:

pointer -- Pointer of allocated memory.

void app_free(void *p)

This function will release the previously allocated memory block by app_malloc/app_calloc/app_realloc. The released memory block is taken back to memheap.

参数:
  • p -- the address of memory which will be released.

void *app_cache_alloc(size_t size, uint16_t cache_type)

Allocate mem sequentially from sram_memheap/psram_memheap.

参数:
  • size -- Size of the memory to allocate in bytes

  • cache_type -- Allocted memory type, CACHE_SRAM or CACHE_PSRAM

返回值:

pointer -- Pointer of allocated memory.

void *app_cache_calloc(rt_size_t count, rt_size_t size, uint16_t cache_type)

Allocate mem sequentially from sram_memheap/psram_memheap. The allocated memory is filled with bytes of value zero.

参数:
  • size -- Size of the memory to allocate in bytes

  • cache_type -- Allocted memory type, CACHE_SRAM or CACHE_PSRAM

返回值:

pointer -- Pointer of allocated memory.

void *app_cache_realloc(void *ptr, size_t nbytes)

Reallocate mem sequentially from sram_memheap/psram_memheap. Reallocate a memory with a new size. The old content will be kept.

参数:
  • ptr -- Pointer to an allocated memory. Its content will be copied to the new memory block and freed

  • nbytes -- The desired new size in byte

返回值:

pointer -- Pointer of allocated memory.

void app_cache_free(void *p)

This function will release the previously allocated memory block by app_cache_alloc/app_cache_calloc/app_cache_realloc. The released memory block is taken back to sram_memheap/psram_memheap.

参数:
  • p -- the address of memory which will be released

lv_img_dsc_t *app_cache_copy_alloc(lv_obj_t *src_img, uint16_t cache_type)

Allocated cache copy of image in sram_memheap/psram_memheap. especially for rotating image, to accelerate rotating.

参数:
  • src_img -- Pointer to img_obj.

  • cache_type -- Allocted memory type, CACHE_SRAM or CACHE_PSRAM

返回值:

pointer -- Pointer of allocated memory, which type is lv_img_dsc_t.

void app_cache_copy_free(lv_img_dsc_t *rel_mem)

Free cache copy of image, which allocated using app_cache_copy_alloc.

参数:
  • rel_mem -- Pointer of allocated memory, which type is lv_img_dsc_t.

void *app_anim_buf_alloc(size_t nbytes, uint8_t index)

Allocate fixed_length memory for switch_animation's snapshot.

参数:
  • nbytes -- Size of snapshot memory.

  • index -- Snapshot index

void *app_anim_buf_alloc_ext(size_t nbytes, uint8_t index)

Allocate variable_length memory for switch_animation's snapshot.

参数:
  • nbytes -- Size of snapshot memory.

  • index -- Snapshot index

void *app_anim_buf_free(void *ptr)

Free snapshot memory. NOTE: not applied!!! only for check overflow.

参数:
  • ptr -- Snapshot pointer to be free, which successsful apply by app_anim_buf_alloc_ext

void app_mem_flush_cache(void *data, uint32_t size)

D-Cache Clean by address.

参数:
  • data -- Address

  • size -- Size of memory block (in number of bytes)

void app_mem_invalid_icache(void *data, uint32_t size)

I-Cache Invalid by address.

参数:
  • data -- Address

  • size -- Size of memory block (in number of bytes)

void *sifli_memcpy(void *dst, const void *src, rt_ubase_t count)

sifli_memxxx is DMA operation function.

void *sifli_memset(void *s, int c, rt_ubase_t count)

Defines

USING_BMEM_MAGIC

The following interfaces provide block memory management functionality, which can reduce memory fragmentation and improve memory allocation speed. But the disadvantage is that the block size and number of blocks need to be pre-set, which reduces memory reusability. This function can be enabled through "USING_BLOCK_MEM" in menuconfig.

BMEM_SECTION_NAME
ALIGN_SIZE_4(x)
BMEM_SIZE_WITH_HEADER(size)
BMEM_NUM(total, size)
BMEM_REGISTER_INT(bname, bsize, total_size)
BMEM_REGISTER(bsize, num)

Typedefs

typedef struct struct_bmem_t bmem_item_t

The memory item on the block memory.

typedef struct bmem_node bmem_node_t

Used to store information for each type of block memory.

Functions

void *bmem_alloc(uint32_t size)

Allocate block_mem from block_memheap, which is registered by BMEM_REGISTER. Allocation order: Find the block memory with the closest size, and if not: 1) when BMEM_ALLOC_ALWAYS configed, find the block memory of the next level 2) else,return NULL.

参数:
  • size -- Size of the memory to allocate in bytes

返回值:

pointer -- Pointer of allocated memory.

int bmem_free(void *p)

This function will release the previously allocated memory block by bmem_alloc. The released memory block is taken back to block_memheap.

参数:
  • p -- the address of memory which will be released.

int bmem_init(void)

Initialize block memory mutex and load block memheap from BMEM_REGISTER.

void *mem_is_bmem(void *p)

Check if memory block is block memory.

参数:
  • p -- the address of memory block.

struct struct_bmem_t
#include <app_bmem.h>

The memory item on the block memory.

Public Members

uint16_t magic

Magic, means freed por allocated

uint16_t size

Allocated size

struct struct_bmem_t *next

Next bmem item which had freed

struct bmem_node
#include <app_bmem.h>

Used to store information for each type of block memory.

Public Members

const char *name

The name of block memory

uint32_t size

The size of every block memory

uint32_t num

The number of block memory

uint8_t *header_ptr

The header pointer of block memory

uint8_t *tailer_ptr

The tailer pointer of block memory

bmem_item_t *free_header

The free pointer header

uint32_t act_used_num

The current acture used number

uint32_t max_used_num

The maxium used number

struct bmem_desc_t
#include <app_bmem.h>

The memory stucture of BMEM_REGISTER, used define each type of block memory.

Public Members

const char *name

The name of block memory

uint32_t size

The size of every block memory

uint32_t num

The number of block memory

uint8_t *ptr

The pointer of block memory