📄 lib_mem.h
字号:
/*
*********************************************************************************************************
* uC/LIB
* CUSTOM LIBRARY MODULES
*
* (c) Copyright 2004-2008; Micrium, Inc.; Weston, FL
*
* All rights reserved. Protected by international copyright laws.
*
* uC/LIB is provided in source form for FREE evaluation, for educational
* use or peaceful research. If you plan on using uC/LIB in a commercial
* product you need to contact Micrium to properly license its use in your
* product. We provide ALL the source code for your convenience and to
* help you experience uC/LIB. The fact that the source code is provided
* does NOT mean that you can use it without paying a licensing fee.
*
* Knowledge of the source code may NOT be used to develop a similar product.
*
* Please help us continue to provide the Embedded community with the finest
* software available. Your honesty is greatly appreciated.
*********************************************************************************************************
*/
/*
*********************************************************************************************************
*
* STANDARD MEMORY OPERATIONS
*
* Filename : lib_mem.h
* Version : V1.26
* Programmer(s) : ITJ
*********************************************************************************************************
* Note(s) : (1) NO compiler-supplied standard library functions are used in library or product software.
*
* (a) ALL standard library functions are implemented in the custom library modules :
*
* (1) \<Custom Library Directory>\lib*.*
*
* (2) \<Custom Library Directory>\Ports\<cpu>\<compiler>\lib*_a.*
*
* where
* <Custom Library Directory> directory path for custom library software
* <cpu> directory name for specific processor (CPU)
* <compiler> directory name for specific compiler
*
* (b) Product-specific library functions are implemented in individual products.
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* MODULE
*********************************************************************************************************
*/
#ifndef LIB_MEM_MODULE_PRESENT
#define LIB_MEM_MODULE_PRESENT
/*$PAGE*/
/*
*********************************************************************************************************
* INCLUDE FILES
*
* Note(s) : (1) The following common software files are located in the following directories :
*
* (a) \<Custom Library Directory>\lib*.*
*
* (b) (1) \<CPU-Compiler Directory>\cpu_def.h
*
* (2) \<CPU-Compiler Directory>\<cpu>\<compiler>\cpu*.*
*
* where
* <Custom Library Directory> directory path for custom library software
* <CPU-Compiler Directory> directory path for common CPU-compiler software
* <cpu> directory name for specific processor (CPU)
* <compiler> directory name for specific compiler
*
* (2) Compiler MUST be configured to include the '\<Custom Library Directory>\uC-LIB\',
* '\<CPU-Compiler Directory>\' directory, & the specific CPU-compiler directory as
* additional include path directories.
*
* (3) NO compiler-supplied standard library functions SHOULD be used.
*********************************************************************************************************
*/
#include <cpu.h>
#include <lib_def.h>
#include <app_cfg.h>
/*
*********************************************************************************************************
* EXTERNS
*********************************************************************************************************
*/
#ifdef LIB_MEM_MODULE
#define LIB_MEM_EXT
#else
#define LIB_MEM_EXT extern
#endif
/*$PAGE*/
/*
*********************************************************************************************************
* DEFAULT CONFIGURATION
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* MEMORY LIBRARY ARGUMENT CHECK CONFIGURATION
*
* Note(s) : (1) Configure LIB_MEM_CFG_ARG_CHK_EXT_EN to enable/disable the memory libray suite external
* argument check feature :
*
* (a) When ENABLED, arguments received from any port interface provided by the developer
* or application are checked/validated.
*
* (b) When DISABLED, NO arguments received from any port interface provided by the developer
* or application are checked/validated.
*********************************************************************************************************
*/
/* Configure external argument check feature (see Note #1) : */
#ifndef LIB_MEM_CFG_ARG_CHK_EXT_EN
#define LIB_MEM_CFG_ARG_CHK_EXT_EN DEF_DISABLED
/* DEF_DISABLED Argument check DISABLED */
/* DEF_ENABLED Argument check ENABLED */
#endif
/*
*********************************************************************************************************
* MEMORY ALLOCATION CONFIGURATION
*
* Note(s) : (1) Configure LIB_MEM_CFG_ALLOC_EN to enable/disable memory allocation functions.
*********************************************************************************************************
*/
/* Configure memory allocation feature (see Note #1) : */
#ifndef LIB_MEM_CFG_ALLOC_EN
#define LIB_MEM_CFG_ALLOC_EN DEF_DISABLED
/* DEF_DISABLED Memory allocation DISABLED */
/* DEF_ENABLED Memory allocation ENABLED */
#endif
/*$PAGE*/
/*
*********************************************************************************************************
* DEFINES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LIBRARY MEMORY ERROR CODES
*********************************************************************************************************
*/
#define LIB_MEM_ERR_NONE 10000
#define LIB_MEM_ERR_NULL_PTR 10001 /* Ptr arg(s) passed NULL ptr(s). */
#define LIB_MEM_ERR_INVALID_MEM_SIZE 10100 /* Invalid mem size. */
#define LIB_MEM_ERR_INVALID_SEG_SIZE 10110 /* Invalid mem seg size. */
#define LIB_MEM_ERR_INVALID_SEG_OVERLAP 10111 /* Invalid mem seg overlaps other mem seg(s). */
#define LIB_MEM_ERR_INVALID_POOL 10120 /* Invalid mem pool. */
#define LIB_MEM_ERR_INVALID_BLK_NBR 10130 /* Invalid mem pool blk nbr. */
#define LIB_MEM_ERR_INVALID_BLK_SIZE 10131 /* Invalid mem pool blk size. */
#define LIB_MEM_ERR_INVALID_BLK_IX 10132 /* Invalid mem pool ix. */
#define LIB_MEM_ERR_INVALID_BLK_ADDR 10135 /* Invalid mem pool blk addr. */
#define LIB_MEM_ERR_INVALID_BLK_ADDR_IN_POOL 10136 /* Mem pool blk addr already in mem pool. */
#define LIB_MEM_ERR_SEG_EMPTY 10200 /* Mem seg empty; i.e. NO avail mem for mem pools. */
#define LIB_MEM_ERR_POOL_FULL 10205 /* Mem pool full; i.e. All mem blks avail in mem pool. */
#define LIB_MEM_ERR_POOL_EMPTY 10206 /* Mem pool empty; i.e. NO mem blks avail in mem pool. */
#define LIB_MEM_ERR_HEAP_NOT_FOUND 10210 /* Heap seg NOT found. */
#define LIB_MEM_ERR_HEAP_EMPTY 10211 /* Heap seg empty; i.e. NO avail mem in heap. */
/*$PAGE*/
/*
*********************************************************************************************************
* MEMORY LIBRARY TYPE DEFINES
*
* Note(s) : (1) LIB_MEM_TYPE_??? #define values specifically chosen as ASCII representations of the memory
* library types. Memory displays of memory library objects will display the library TYPEs
* with their chosen ASCII names.
**********************************************************************************************************/
/* ------------------- LIB_MEM TYPES ------------------ */
#if (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_BIG)
#define LIB_MEM_TYPE_NONE 0x4E4F4E45 /* "NONE" in ASCII. */
#define LIB_MEM_TYPE_HEAP 0x48454150 /* "HEAP" in ASCII. */
#define LIB_MEM_TYPE_POOL 0x504F4F4C /* "POOL" in ASCII. */
#else
#if (CPU_CFG_DATA_SIZE == CPU_WORD_SIZE_32)
#define LIB_MEM_TYPE_NONE 0x454E4F4E /* "NONE" in ASCII. */
#define LIB_MEM_TYPE_HEAP 0x50414548 /* "HEAP" in ASCII. */
#define LIB_MEM_TYPE_POOL 0x4C4F4F50 /* "POOL" in ASCII. */
#elif (CPU_CFG_DATA_SIZE == CPU_WORD_SIZE_16)
#define LIB_MEM_TYPE_NONE 0x4F4E454E /* "NONE" in ASCII. */
#define LIB_MEM_TYPE_HEAP 0x45485041 /* "HEAP" in ASCII. */
#define LIB_MEM_TYPE_POOL 0x4F504C4F /* "POOL" in ASCII. */
#else /* Dflt CPU_WORD_SIZE_08. */
#define LIB_MEM_TYPE_NONE 0x4E4F4E45 /* "NONE" in ASCII. */
#define LIB_MEM_TYPE_HEAP 0x48454150 /* "HEAP" in ASCII. */
#define LIB_MEM_TYPE_POOL 0x504F4F4C /* "POOL" in ASCII. */
#endif
#endif
/*$PAGE*/
/*
*********************************************************************************************************
* DATA TYPES
*********************************************************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -