#ifndef _MALLOC_H #define _MALLOC_H #include "sys.h" ////////////////////////////////////////////////////////////////////////////////// //This program is for educational purposes only, without the author's permission, may not be used for any other purpose //ALIENTEK STM32F4 Explorer Board //Memory management-driver code //Hot Atomic @ALIENTEK //Forum: www.openedv.com //Date modified: 2014/5/6 //Version: V1.0 //All rights reserved pirated reserved. //Copyright(C) Guangzhou wing electronic technology limited company 2009-2019 //All rights reserved ////////////////////////////////////////////////////////////////////////////////// #ifndef NULL #define NULL 0 #endif //Define three memory pools #define SRAMCCM 0 //CCM pools (SRAM CPU can only access in this section!!! ) #define SRAMBANK 1 //Define the number of supported SRAM block //Mem3 memory parameter set, mem3 CCM to manage CCM (pay special attention to this part of the SRAM, CPU access) #define MEM3_BLOCK_SIZE 32 //Block size is 32 bytes #define MEM3_MAX_SIZE 60*1024 //Maximum memory management 60k #define MEM3_ALLOC_TABLE_SIZE MEM3_MAX_SIZE/MEM3_BLOCK_SIZE //Memory table size //Memory management controller struct _m_mallco_dev { void (*init)(u8); //Initialize u8 (*perused)(u8); //Memory usage u8 *membase[SRAMBANK]; //Memory pool management SRAMBANK a region of memory u16 *memmap[SRAMBANK]; //Memory status table u8 memrdy[SRAMBANK]; //Memory management is ready to }; extern struct _m_mallco_dev mallco_dev; //Defined in malloc.c void mymemset(void *s,u8 c,u32 count); //Setting memory void mymemcpy(void *des,void *src,u32 n);//Copy memory void mymem_init(u8 memx); //Memory initialization function (external/internal calls) u8 mem_perused(u8 memx); //For memory usage (external/internal calls) //////////////////////////////////////////////////////////////////////////////// //Users call a function void myfree(void *ptr); //Memory release (external call) void *mymalloc(u32 size); //Memory allocation (external call) void *myrealloc(void *ptr, u32 size);//Reallocating memory (external call) #endif