lib_mem.h
上传用户:yj_qqy
上传日期:2017-01-28
资源大小:2911k
文件大小:51k
源码类别:

uCOS

开发平台:

C/C++

  1. /*
  2. *********************************************************************************************************
  3. *                                               uC/LIB
  4. *                                       CUSTOM LIBRARY MODULES
  5. *
  6. *                          (c) Copyright 2004-2008; Micrium, Inc.; Weston, FL
  7. *
  8. *               All rights reserved.  Protected by international copyright laws.
  9. *
  10. *               uC/LIB is provided in source form for FREE evaluation, for educational
  11. *               use or peaceful research.  If you plan on using uC/LIB in a commercial
  12. *               product you need to contact Micrium to properly license its use in your
  13. *               product.  We provide ALL the source code for your convenience and to
  14. *               help you experience uC/LIB.  The fact that the source code is provided
  15. *               does NOT mean that you can use it without paying a licensing fee.
  16. *
  17. *               Knowledge of the source code may NOT be used to develop a similar product.
  18. *
  19. *               Please help us continue to provide the Embedded community with the finest
  20. *               software available.  Your honesty is greatly appreciated.
  21. *********************************************************************************************************
  22. */
  23. /*
  24. *********************************************************************************************************
  25. *
  26. *                                     STANDARD MEMORY OPERATIONS
  27. *
  28. * Filename      : lib_mem.h
  29. * Version       : V1.25
  30. * Programmer(s) : ITJ
  31. *********************************************************************************************************
  32. * Note(s)       : (1) NO compiler-supplied standard library functions are used in library or product software.
  33. *
  34. *                     (a) ALL standard library functions are implemented in the custom library modules :
  35. *
  36. *                         (1) <Custom Library Directory>lib*.*
  37. *
  38. *                         (2) <Custom Library Directory>Ports<cpu><compiler>lib*_a.*
  39. *
  40. *                               where
  41. *                                       <Custom Library Directory>      directory path for custom library software
  42. *                                       <cpu>                           directory name for specific processor (CPU)
  43. *                                       <compiler>                      directory name for specific compiler
  44. *
  45. *                     (b) Product-specific library functions are implemented in individual products.
  46. *********************************************************************************************************
  47. */
  48. /*
  49. *********************************************************************************************************
  50. *                                               MODULE
  51. *********************************************************************************************************
  52. */
  53. #ifndef  LIB_MEM_MODULE_PRESENT
  54. #define  LIB_MEM_MODULE_PRESENT
  55. /*$PAGE*/
  56. /*
  57. *********************************************************************************************************
  58. *                                            INCLUDE FILES
  59. *
  60. * Note(s) : (1) The following common software files are located in the following directories :
  61. *
  62. *               (a) <Custom Library Directory>lib*.*
  63. *
  64. *               (b) (1) <CPU-Compiler Directory>cpu_def.h
  65. *
  66. *                   (2) <CPU-Compiler Directory><cpu><compiler>cpu*.*
  67. *
  68. *                           where
  69. *                                   <Custom Library Directory>      directory path for custom   library      software
  70. *                                   <CPU-Compiler Directory>        directory path for common   CPU-compiler software
  71. *                                   <cpu>                           directory name for specific processor (CPU)
  72. *                                   <compiler>                      directory name for specific compiler
  73. *
  74. *           (2) Compiler MUST be configured to include the '<Custom Library Directory>uC-LIB',
  75. *               '<CPU-Compiler Directory>' directory, & the specific CPU-compiler directory as
  76. *               additional include path directories.
  77. *
  78. *           (3) NO compiler-supplied standard library functions SHOULD be used.
  79. *********************************************************************************************************
  80. */
  81. #include  <cpu.h>
  82. #include  <lib_def.h>
  83. #include  <app_cfg.h>
  84. /*
  85. *********************************************************************************************************
  86. *                                               EXTERNS
  87. *********************************************************************************************************
  88. */
  89. #ifdef   LIB_MEM_MODULE
  90. #define  LIB_MEM_EXT
  91. #else
  92. #define  LIB_MEM_EXT  extern
  93. #endif
  94. /*$PAGE*/
  95. /*
  96. *********************************************************************************************************
  97. *                                        DEFAULT CONFIGURATION
  98. *********************************************************************************************************
  99. */
  100. /*
  101. *********************************************************************************************************
  102. *                             MEMORY LIBRARY ARGUMENT CHECK CONFIGURATION
  103. *
  104. * Note(s) : (1) Configure LIB_MEM_CFG_ARG_CHK_EXT_EN to enable/disable the memory libray suite external
  105. *               argument check feature :
  106. *
  107. *               (a) When ENABLED,      arguments received from any port interface provided by the developer
  108. *                   or application are checked/validated.
  109. *
  110. *               (b) When DISABLED, NO  arguments received from any port interface provided by the developer
  111. *                   or application are checked/validated.
  112. *********************************************************************************************************
  113. */
  114.                                                         /* Configure external argument check feature (see Note #1) :    */
  115. #ifndef  LIB_MEM_CFG_ARG_CHK_EXT_EN
  116. #define  LIB_MEM_CFG_ARG_CHK_EXT_EN     DEF_DISABLED
  117.                                                         /*   DEF_DISABLED     Argument check DISABLED                   */
  118.                                                         /*   DEF_ENABLED      Argument check ENABLED                    */
  119. #endif
  120. /*
  121. *********************************************************************************************************
  122. *                                      MEMORY POOL CONFIGURATION
  123. *
  124. * Note(s) : (1) Configure LIB_MEM_CFG_POOL_EN to enable/disable memory pool functions.
  125. *********************************************************************************************************
  126. */
  127.                                                         /* Configure memory pool feature (see Note #1) :                */
  128. #ifndef  LIB_MEM_CFG_POOL_EN
  129. #define  LIB_MEM_CFG_POOL_EN            DEF_DISABLED
  130.                                                         /*   DEF_DISABLED     Memory pool(s) DISABLED                   */
  131.                                                         /*   DEF_ENABLED      Memory pool(s) ENABLED                    */
  132. #endif
  133. /*$PAGE*/
  134. /*
  135. *********************************************************************************************************
  136. *                                               DEFINES
  137. *********************************************************************************************************
  138. */
  139. /*
  140. *********************************************************************************************************
  141. *                                      LIBRARY MEMORY ERROR CODES
  142. *********************************************************************************************************
  143. */
  144. #define  LIB_MEM_ERR_NONE                              10000
  145. #define  LIB_MEM_ERR_NULL_PTR                          10001    /* Ptr arg(s) passed NULL ptr(s).                       */
  146. #define  LIB_MEM_ERR_NONE_AVAIL                        10010    /* NO avail mem rsrc's.                                 */
  147. #define  LIB_MEM_ERR_INVALID_SEG_SIZE                  10100    /* Invalid mem seg size.                                */
  148. #define  LIB_MEM_ERR_INVALID_SEG_OVERLAP               10101    /* Invalid mem seg overlaps other mem seg(s).           */
  149. #define  LIB_MEM_ERR_INVALID_POOL                      10102    /* Invalid mem pool.                                    */
  150. #define  LIB_MEM_ERR_INVALID_ADDR                      10103    /* Invalid mem pool addr.                               */
  151. #define  LIB_MEM_ERR_INVALID_BLK_NBR                   10104    /* Invalid mem pool blk nbr.                            */
  152. #define  LIB_MEM_ERR_INVALID_BLK_SIZE                  10105    /* Invalid mem pool blk size.                           */
  153. #define  LIB_MEM_ERR_INVALID_BLK_IX                    10106    /* Invalid mem pool ix.                                 */
  154. #define  LIB_MEM_ERR_SEG_EMPTY                         10110    /* Mem seg  empty; i.e. NO avail mem for mem pools.     */
  155. #define  LIB_MEM_ERR_POOL_FULL                         10111    /* Mem pool full;  i.e. All mem blks avail in mem pool. */
  156. #define  LIB_MEM_ERR_HEAP_NOT_FOUND                    10115    /* Heap seg NOT found.                                  */
  157. #define  LIB_MEM_ERR_HEAP_EMPTY                        10116    /* Heap seg empty; i.e. NO avail mem in heap.           */
  158. /*$PAGE*/
  159. /*
  160. *********************************************************************************************************
  161. *                                     MEMORY LIBRARY TYPE DEFINES
  162. *
  163. * Note(s) : (1) LIB_MEM_TYPE_??? #define values specifically chosen as ASCII representations of the memory
  164. *               library types.  Memory displays of memory library objects will display the library TYPEs
  165. *               with their chosen ASCII names.
  166. **********************************************************************************************************/
  167.                                                                 /* ------------------- LIB_MEM TYPES ------------------ */
  168. #if     (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_BIG)
  169. #define  LIB_MEM_TYPE_NONE                        0x4E4F4E45    /* "NONE" in ASCII.                                     */
  170. #define  LIB_MEM_TYPE_HEAP                        0x48454150    /* "HEAP" in ASCII.                                     */
  171. #define  LIB_MEM_TYPE_POOL                        0x504F4F4C    /* "POOL" in ASCII.                                     */
  172. #else
  173. #if     (CPU_CFG_DATA_SIZE   == CPU_WORD_SIZE_32)
  174. #define  LIB_MEM_TYPE_NONE                        0x454E4F4E    /* "NONE" in ASCII.                                     */
  175. #define  LIB_MEM_TYPE_HEAP                        0x50414548    /* "HEAP" in ASCII.                                     */
  176. #define  LIB_MEM_TYPE_POOL                        0x4C4F4F50    /* "POOL" in ASCII.                                     */
  177. #elif   (CPU_CFG_DATA_SIZE   == CPU_WORD_SIZE_16)
  178. #define  LIB_MEM_TYPE_NONE                        0x4F4E454E    /* "NONE" in ASCII.                                     */
  179. #define  LIB_MEM_TYPE_HEAP                        0x45485041    /* "HEAP" in ASCII.                                     */
  180. #define  LIB_MEM_TYPE_POOL                        0x4F504C4F    /* "POOL" in ASCII.                                     */
  181. #else                                                           /* Dflt CPU_WORD_SIZE_08.                               */
  182. #define  LIB_MEM_TYPE_NONE                        0x4E4F4E45    /* "NONE" in ASCII.                                     */
  183. #define  LIB_MEM_TYPE_HEAP                        0x48454150    /* "HEAP" in ASCII.                                     */
  184. #define  LIB_MEM_TYPE_POOL                        0x504F4F4C    /* "POOL" in ASCII.                                     */
  185. #endif
  186. #endif
  187. /*$PAGE*/
  188. /*
  189. *********************************************************************************************************
  190. *                                             DATA TYPES
  191. *********************************************************************************************************
  192. */
  193. /*
  194. *********************************************************************************************************
  195. *                                            LIB MEM TYPE
  196. *
  197. * Note(s) : (1) 'LIB_MEM_TYPE' declared as 'CPU_INT32U' & all 'LIB_MEM_TYPE's #define'd with large, non-trivial
  198. *               values to trap & discard invalid/corrupted library memory objects based on 'LIB_MEM_TYPE'.
  199. *********************************************************************************************************
  200. */
  201. typedef  CPU_INT32U  LIB_MEM_TYPE;
  202. /*
  203. *********************************************************************************************************
  204. *                                      MEMORY POOL TABLE IX TYPE
  205. *
  206. * Note(s) : (1) MEM_POOL_IX_NONE  SHOULD be #define'd based on 'MEM_POOL_IX' data type declared.
  207. *********************************************************************************************************
  208. */
  209. typedef  CPU_INT16U   MEM_POOL_IX;
  210. #define  MEM_POOL_IX_NONE                DEF_INT_16U_MAX_VAL    /* Define as max unsigned val (see Note #1).            */
  211. #define  MEM_POOL_IX_MIN                                   1
  212. #define  MEM_POOL_IX_MAX               (MEM_POOL_IX_NONE - 1)
  213. /*$PAGE*/
  214. /*
  215. *********************************************************************************************************
  216. *                                        MEMORY POOL DATA TYPES
  217. *
  218. *                                                                      MEMORY SEGMENT
  219. *                                                                     ----------------
  220. *                                            MEMORY POOL'S            |              | <----
  221. *                                             POINTERS TO             |    MEMORY    |     |
  222. *                    MEM_POOL                MEMORY BLOCKS            |    BLOCKS    |     |
  223. *               |----------------|            |---------|             |   --------   |     |
  224. *               |        O------------------> |    O--------------------> |      |   |     |
  225. *               |----------------|            |---------|             |   |      |   |     |
  226. *               | Pool Addr Ptrs |            |    O-------------     |   --------   |     |
  227. *               | Pool Size      |            |---------|       |     |              |     |
  228. *               |----------------|            |         |       |     |   --------   |     |
  229. *               |    Blk Size    |            |         |       --------> |      |   |     |
  230. *               |    Blk Nbr     |            |         |             |   |      |   |     |
  231. *               |    Blk Ix      |            |    .    |             |   --------   |     |
  232. *               |----------------|            |    .    |             |              |     |
  233. *               |----------------|            |    .    |             |      .       |     |
  234. *               |        O-----------------   |         |             |      .       |     |
  235. *               |----------------|        |   |         |             |      .       |     |
  236. *               |        O------------    |   |         |             |              |     |
  237. *               |----------------|   |    |   |---------|             |   --------   |     |
  238. *               |  Seg Size Tot  |   |    |   |    O--------------------> |      |   |     |
  239. *               |  Seg Size Rem  |   |    |   |---------|             |   |      |   |     |
  240. *               |----------------|   |    |   |         |             |   --------   |     |
  241. *               | Seg List Ptrs  |   |    |   |---------|             |              |     |
  242. *               |----------------|   |    |                           | ------------ |     |
  243. *                                    |    |                           |              | <--------
  244. *                                    |    |                           |              |     |   |
  245. *                                    |    |                           |              |     |   |
  246. *                                    |    |                           |              |     |   |
  247. *                                    |    |                           |              |     |   |
  248. *                                    |    |                           |              |     |   |
  249. *                                    |    |                           ----------------     |   |
  250. *                                    |    |                                                |   |
  251. *                                    |    --------------------------------------------------   |
  252. *                                    |                                                         |
  253. *                                    -----------------------------------------------------------
  254. *
  255. *********************************************************************************************************
  256. */
  257. typedef  struct  mem_pool  MEM_POOL;
  258.                                                                 /* --------------------- MEM POOL --------------------- */
  259. struct  mem_pool {
  260.     LIB_MEM_TYPE    Type;                                       /* Pool type : LIB_TYPE_POOL or LIB_TYPE_HEAP.          */
  261.     MEM_POOL       *SegPrevPtr;                                 /* Ptr to PREV mem seg.                                 */
  262.     MEM_POOL       *SegNextPtr;                                 /* Ptr to NEXT mem seg.                                 */
  263.     MEM_POOL       *PoolPrevPtr;                                /* Ptr to PREV mem pool.                                */
  264.     MEM_POOL       *PoolNextPtr;                                /* Ptr to NEXT mem pool.                                */
  265.     void           *PoolAddrStart;                              /* Ptr   to start of mem seg for mem pool blks.         */
  266.     void           *PoolAddrEnd;                                /* Ptr   to end   of mem seg for mem pool blks.         */
  267.     void          **PoolPtrs;                                   /* Ptr   to mem pool's array of blk ptrs.               */
  268.     MEM_POOL_IX     BlkIx;                                      /* Ix  into mem pool's array of blk ptrs.               */
  269.     CPU_SIZE_T      PoolSize;                                   /* Size  of mem pool        (in octets).                */
  270.     CPU_SIZE_T      BlkNbr;                                     /* Nbr   of mem pool   blks.                            */
  271.     CPU_SIZE_T      BlkSize;                                    /* Size  of mem pool   blks (in octets).                */
  272.     CPU_SIZE_T      BlkAlign;                                   /* Align of mem pool   blks (in octets).                */
  273.                                                                 /* --------------------- MEM SEG ---------------------- */
  274.     void           *SegAddr;                                    /* Ptr      to mem seg's base/start addr.               */
  275.     void           *SegAddrNextAvail;                           /* Ptr      to mem seg's next avail addr.               */
  276.     CPU_SIZE_T      SegSizeTot;                                 /* Tot size of mem seg (in octets).                     */
  277.     CPU_SIZE_T      SegSizeRem;                                 /* Rem size of mem seg (in octets).                     */
  278. };
  279. /*$PAGE*/
  280. /*
  281. *********************************************************************************************************
  282. *                                          GLOBAL VARIABLES
  283. *********************************************************************************************************
  284. */
  285. /*$PAGE*/
  286. /*
  287. *********************************************************************************************************
  288. *                                              MACRO'S
  289. *********************************************************************************************************
  290. */
  291. /*
  292. *********************************************************************************************************
  293. *                                      MEMORY DATA VALUE MACRO'S
  294. *
  295. * Note(s) : (1) (a) Some variables & variable buffers to pass & receive data values MUST start on appropriate
  296. *                   CPU word-aligned addresses.  This is required because most word-aligned processors are more
  297. *                   efficient & may even REQUIRE that multi-octet words start on CPU word-aligned addresses.
  298. *
  299. *                   (1) For 16-bit word-aligned processors, this means that
  300. *
  301. *                           all 16- & 32-bit words MUST start on addresses that are multiples of 2 octets
  302. *
  303. *                   (2) For 32-bit word-aligned processors, this means that
  304. *
  305. *                           all 16-bit       words MUST start on addresses that are multiples of 2 octets
  306. *                           all 32-bit       words MUST start on addresses that are multiples of 4 octets
  307. *
  308. *               (b) However, some data values macro's appropriately access data values from any CPU addresses,
  309. *                   word-aligned or not.  Thus for processors that require data word alignment, data words can
  310. *                   be accessed to/from any CPU address, word-aligned or not, without generating data-word-
  311. *                   alignment exceptions/faults.
  312. *********************************************************************************************************
  313. */
  314. /*$PAGE*/
  315. /*
  316. *********************************************************************************************************
  317. *                                          MEM_VAL_GET_xxx()
  318. *
  319. * Description : Decode data values from any CPU memory address.
  320. *
  321. * Argument(s) : addr        Lowest CPU memory address of data value to decode (see Notes #2 & #3a).
  322. *
  323. * Return(s)   : Decoded data value from CPU memory address (see Notes #1 & #3b).
  324. *
  325. * Caller(s)   : Application.
  326. *
  327. * Note(s)     : (1) Decode data values based on the values' data-word order in CPU memory :
  328. *
  329. *                       MEM_VAL_GET_xxx_BIG()           Decode big-   endian data values -- data words' most
  330. *                                                           significant octet @ lowest memory address
  331. *                       MEM_VAL_GET_xxx_LITTLE()        Decode little-endian data values -- data words' least
  332. *                                                           significant octet @ lowest memory address
  333. *                       MEM_VAL_GET_xxx()               Decode data values using CPU's native or configured
  334. *                                                           data-word order
  335. *
  336. *                   See also 'cpu.h  CPU WORD CONFIGURATION  Note #2'.
  337. *
  338. *               (2) CPU memory addresses/pointers NOT checked for NULL.
  339. *
  340. *               (3) (a) MEM_VAL_GET_xxx() macro's decode data values without regard to CPU word-aligned addresses.
  341. *                       Thus for processors that require data word alignment, data words can be decoded from any
  342. *                       CPU address, word-aligned or not, without generating data-word-alignment exceptions/faults.
  343. *
  344. *                   (b) However, any variable to receive the returned data value MUST start on an appropriate CPU
  345. *                       word-aligned address.
  346. *
  347. *                   See also 'MEMORY DATA VALUE MACRO'S  Note #1'.
  348. *
  349. *               (4) MEM_VAL_COPY_GET_xxx() macro's are more efficient than MEM_VAL_GET_xxx() macro's & are
  350. *                   also independent of CPU data-word-alignment & SHOULD be used whenever possible.
  351. *
  352. *                   See also 'MEM_VAL_COPY_GET_xxx()  Note #4'.
  353. *
  354. *               (5) The 'CPU_CFG_ENDIAN_TYPE' pre-processor 'else'-conditional code SHOULD never be compiled/
  355. *                   linked since each 'cpu.h' SHOULD ensure that the CPU data-word-memory order configuration
  356. *                   constant (CPU_CFG_ENDIAN_TYPE) is configured with an appropriate data-word-memory order
  357. *                   value (see 'cpu.h  CPU WORD CONFIGURATION  Note #2').  The 'else'-conditional code is
  358. *                   included as an extra precaution in case 'cpu.h' is incorrectly configured.
  359. *********************************************************************************************************
  360. */
  361. #define  MEM_VAL_GET_INT08U_BIG(addr)             (((CPU_INT08U)(*(((CPU_INT08U *)(addr)) + 0))) << (0 * DEF_OCTET_NBR_BITS))
  362. #define  MEM_VAL_GET_INT16U_BIG(addr)            ((((CPU_INT16U)(*(((CPU_INT08U *)(addr)) + 0))) << (1 * DEF_OCTET_NBR_BITS)) + 
  363.                                                   (((CPU_INT16U)(*(((CPU_INT08U *)(addr)) + 1))) << (0 * DEF_OCTET_NBR_BITS)))
  364. #define  MEM_VAL_GET_INT32U_BIG(addr)            ((((CPU_INT32U)(*(((CPU_INT08U *)(addr)) + 0))) << (3 * DEF_OCTET_NBR_BITS)) + 
  365.                                                   (((CPU_INT32U)(*(((CPU_INT08U *)(addr)) + 1))) << (2 * DEF_OCTET_NBR_BITS)) + 
  366.                                                   (((CPU_INT32U)(*(((CPU_INT08U *)(addr)) + 2))) << (1 * DEF_OCTET_NBR_BITS)) + 
  367.                                                   (((CPU_INT32U)(*(((CPU_INT08U *)(addr)) + 3))) << (0 * DEF_OCTET_NBR_BITS)))
  368. #define  MEM_VAL_GET_INT08U_LITTLE(addr)          (((CPU_INT08U)(*(((CPU_INT08U *)(addr)) + 0))) << (0 * DEF_OCTET_NBR_BITS))
  369. #define  MEM_VAL_GET_INT16U_LITTLE(addr)         ((((CPU_INT16U)(*(((CPU_INT08U *)(addr)) + 0))) << (0 * DEF_OCTET_NBR_BITS)) + 
  370.                                                   (((CPU_INT16U)(*(((CPU_INT08U *)(addr)) + 1))) << (1 * DEF_OCTET_NBR_BITS)))
  371. #define  MEM_VAL_GET_INT32U_LITTLE(addr)         ((((CPU_INT32U)(*(((CPU_INT08U *)(addr)) + 0))) << (0 * DEF_OCTET_NBR_BITS)) + 
  372.                                                   (((CPU_INT32U)(*(((CPU_INT08U *)(addr)) + 1))) << (1 * DEF_OCTET_NBR_BITS)) + 
  373.                                                   (((CPU_INT32U)(*(((CPU_INT08U *)(addr)) + 2))) << (2 * DEF_OCTET_NBR_BITS)) + 
  374.                                                   (((CPU_INT32U)(*(((CPU_INT08U *)(addr)) + 3))) << (3 * DEF_OCTET_NBR_BITS)))
  375. #if     (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_BIG)
  376. #define  MEM_VAL_GET_INT08U(addr)                               MEM_VAL_GET_INT08U_BIG(addr)
  377. #define  MEM_VAL_GET_INT16U(addr)                               MEM_VAL_GET_INT16U_BIG(addr)
  378. #define  MEM_VAL_GET_INT32U(addr)                               MEM_VAL_GET_INT32U_BIG(addr)
  379. #elif   (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_LITTLE)
  380. #define  MEM_VAL_GET_INT08U(addr)                               MEM_VAL_GET_INT08U_LITTLE(addr)
  381. #define  MEM_VAL_GET_INT16U(addr)                               MEM_VAL_GET_INT16U_LITTLE(addr)
  382. #define  MEM_VAL_GET_INT32U(addr)                               MEM_VAL_GET_INT32U_LITTLE(addr)
  383. #else                                                                           /* See Note #5.                         */
  384. #error  "CPU_CFG_ENDIAN_TYPE  illegally #defined in 'cpu.h'      "
  385. #error  "                     [See 'cpu.h  CONFIGURATION ERRORS']"
  386. #endif
  387. /*$PAGE*/
  388. /*
  389. *********************************************************************************************************
  390. *                                          MEM_VAL_SET_xxx()
  391. *
  392. * Description : Encode data values to any CPU memory address.
  393. *
  394. * Argument(s) : addr        Lowest CPU memory address to encode data value (see Notes #2 & #3a).
  395. *
  396. *               val         Data value to encode (see Notes #1 & #3b).
  397. *
  398. * Return(s)   : none.
  399. *
  400. * Caller(s)   : Application.
  401. *
  402. * Note(s)     : (1) Encode data values into CPU memory based on the values' data-word order :
  403. *
  404. *                       MEM_VAL_SET_xxx_BIG()           Encode big-   endian data values -- data words' most
  405. *                                                           significant octet @ lowest memory address
  406. *                       MEM_VAL_SET_xxx_LITTLE()        Encode little-endian data values -- data words' least
  407. *                                                           significant octet @ lowest memory address
  408. *                       MEM_VAL_SET_xxx()               Encode data values using CPU's native or configured
  409. *                                                           data-word order
  410. *
  411. *                   See also 'cpu.h  CPU WORD CONFIGURATION  Note #2'.
  412. *
  413. *               (2) CPU memory addresses/pointers NOT checked for NULL.
  414. *
  415. *               (3) (a) MEM_VAL_SET_xxx() macro's encode data values without regard to CPU word-aligned addresses.
  416. *                       Thus for processors that require data word alignment, data words can be encoded to any
  417. *                       CPU address, word-aligned or not, without generating data-word-alignment exceptions/faults.
  418. *
  419. *                   (b) However, 'val' data value to encode MUST start on an appropriate CPU word-aligned address.
  420. *
  421. *                   See also 'MEMORY DATA VALUE MACRO'S  Note #1'.
  422. *
  423. *               (4) MEM_VAL_COPY_SET_xxx() macro's are more efficient than MEM_VAL_SET_xxx() macro's & are
  424. *                   also independent of CPU data-word-alignment & SHOULD be used whenever possible.
  425. *
  426. *                   See also 'MEM_VAL_COPY_SET_xxx()  Note #4'.
  427. *
  428. *               (5) The 'CPU_CFG_ENDIAN_TYPE' pre-processor 'else'-conditional code SHOULD never be compiled/
  429. *                   linked since each 'cpu.h' SHOULD ensure that the CPU data-word-memory order configuration
  430. *                   constant (CPU_CFG_ENDIAN_TYPE) is configured with an appropriate data-word-memory order
  431. *                   value (see 'cpu.h  CPU WORD CONFIGURATION  Note #2').  The 'else'-conditional code is
  432. *                   included as an extra precaution in case 'cpu.h' is incorrectly configured.
  433. *********************************************************************************************************
  434. */
  435. #define  MEM_VAL_SET_INT08U_BIG(addr, val)                    { (*(((CPU_INT08U *)(addr)) + 0)) = ((CPU_INT08U)((((CPU_INT08U)(val)) &       0xFF) >> (0 * DEF_OCTET_NBR_BITS))); }
  436. #define  MEM_VAL_SET_INT16U_BIG(addr, val)                    { (*(((CPU_INT08U *)(addr)) + 0)) = ((CPU_INT08U)((((CPU_INT16U)(val)) &     0xFF00) >> (1 * DEF_OCTET_NBR_BITS))); 
  437.                                                                 (*(((CPU_INT08U *)(addr)) + 1)) = ((CPU_INT08U)((((CPU_INT16U)(val)) &     0x00FF) >> (0 * DEF_OCTET_NBR_BITS))); }
  438. #define  MEM_VAL_SET_INT32U_BIG(addr, val)                    { (*(((CPU_INT08U *)(addr)) + 0)) = ((CPU_INT08U)((((CPU_INT32U)(val)) & 0xFF000000) >> (3 * DEF_OCTET_NBR_BITS))); 
  439.                                                                 (*(((CPU_INT08U *)(addr)) + 1)) = ((CPU_INT08U)((((CPU_INT32U)(val)) & 0x00FF0000) >> (2 * DEF_OCTET_NBR_BITS))); 
  440.                                                                 (*(((CPU_INT08U *)(addr)) + 2)) = ((CPU_INT08U)((((CPU_INT32U)(val)) & 0x0000FF00) >> (1 * DEF_OCTET_NBR_BITS))); 
  441.                                                                 (*(((CPU_INT08U *)(addr)) + 3)) = ((CPU_INT08U)((((CPU_INT32U)(val)) & 0x000000FF) >> (0 * DEF_OCTET_NBR_BITS))); }
  442. #define  MEM_VAL_SET_INT08U_LITTLE(addr, val)                 { (*(((CPU_INT08U *)(addr)) + 0)) = ((CPU_INT08U)((((CPU_INT08U)(val)) &       0xFF) >> (0 * DEF_OCTET_NBR_BITS))); }
  443. #define  MEM_VAL_SET_INT16U_LITTLE(addr, val)                 { (*(((CPU_INT08U *)(addr)) + 0)) = ((CPU_INT08U)((((CPU_INT16U)(val)) &     0x00FF) >> (0 * DEF_OCTET_NBR_BITS))); 
  444.                                                                 (*(((CPU_INT08U *)(addr)) + 1)) = ((CPU_INT08U)((((CPU_INT16U)(val)) &     0xFF00) >> (1 * DEF_OCTET_NBR_BITS))); }
  445. #define  MEM_VAL_SET_INT32U_LITTLE(addr, val)                 { (*(((CPU_INT08U *)(addr)) + 0)) = ((CPU_INT08U)((((CPU_INT32U)(val)) & 0x000000FF) >> (0 * DEF_OCTET_NBR_BITS))); 
  446.                                                                 (*(((CPU_INT08U *)(addr)) + 1)) = ((CPU_INT08U)((((CPU_INT32U)(val)) & 0x0000FF00) >> (1 * DEF_OCTET_NBR_BITS))); 
  447.                                                                 (*(((CPU_INT08U *)(addr)) + 2)) = ((CPU_INT08U)((((CPU_INT32U)(val)) & 0x00FF0000) >> (2 * DEF_OCTET_NBR_BITS))); 
  448.                                                                 (*(((CPU_INT08U *)(addr)) + 3)) = ((CPU_INT08U)((((CPU_INT32U)(val)) & 0xFF000000) >> (3 * DEF_OCTET_NBR_BITS))); }
  449. #if     (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_BIG)
  450. #define  MEM_VAL_SET_INT08U(addr, val)                          MEM_VAL_SET_INT08U_BIG(addr, val)
  451. #define  MEM_VAL_SET_INT16U(addr, val)                          MEM_VAL_SET_INT16U_BIG(addr, val)
  452. #define  MEM_VAL_SET_INT32U(addr, val)                          MEM_VAL_SET_INT32U_BIG(addr, val)
  453. #elif   (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_LITTLE)
  454. #define  MEM_VAL_SET_INT08U(addr, val)                          MEM_VAL_SET_INT08U_LITTLE(addr, val)
  455. #define  MEM_VAL_SET_INT16U(addr, val)                          MEM_VAL_SET_INT16U_LITTLE(addr, val)
  456. #define  MEM_VAL_SET_INT32U(addr, val)                          MEM_VAL_SET_INT32U_LITTLE(addr, val)
  457. #else                                                                           /* See Note #5.                         */
  458. #error  "CPU_CFG_ENDIAN_TYPE  illegally #defined in 'cpu.h'      "
  459. #error  "                     [See 'cpu.h  CONFIGURATION ERRORS']"
  460. #endif
  461. /*$PAGE*/
  462. /*
  463. *********************************************************************************************************
  464. *                                       MEM_VAL_COPY_GET_xxx()
  465. *
  466. * Description : Copy & decode data values from any CPU memory address to any CPU memory address.
  467. *
  468. * Argument(s) : addr_dest       Lowest CPU memory address to copy/decode source address's data value
  469. *                                   (see Notes #2 & #3).
  470. *
  471. *               addr_src        Lowest CPU memory address of data value to copy/decode
  472. *                                   (see Notes #2 & #3).
  473. *
  474. * Return(s)   : none.
  475. *
  476. * Caller(s)   : Application.
  477. *
  478. * Note(s)     : (1) Copy/decode data values based on the values' data-word order :
  479. *
  480. *                       MEM_VAL_COPY_GET_xxx_BIG()      Decode big-   endian data values -- data words' most
  481. *                                                           significant octet @ lowest memory address
  482. *                       MEM_VAL_COPY_GET_xxx_LITTLE()   Decode little-endian data values -- data words' least
  483. *                                                           significant octet @ lowest memory address
  484. *                       MEM_VAL_COPY_GET_xxx()          Decode data values using CPU's native or configured
  485. *                                                           data-word order
  486. *
  487. *                   See also 'cpu.h  CPU WORD CONFIGURATION  Note #2'.
  488. *
  489. *               (2) CPU memory addresses/pointers NOT checked for NULL.
  490. *
  491. *               (3) MEM_VAL_COPY_GET_xxx() macro's copy/decode data values without regard to CPU word-aligned
  492. *                   addresses.  Thus for processors that require data word alignment, data words can be copied/
  493. *                   decoded to/from any CPU address, word-aligned or not, without generating data-word-alignment
  494. *                   exceptions/faults.
  495. *
  496. *               (4) MEM_VAL_COPY_GET_xxx() macro's are more efficient than MEM_VAL_GET_xxx() macro's & are
  497. *                   also independent of CPU data-word-alignment & SHOULD be used whenever possible.
  498. *
  499. *                   See also 'MEM_VAL_GET_xxx()  Note #4'.
  500. *
  501. *               (5) Since octet-order copy/conversion are inverse operations, memory data value gets/sets are
  502. *                   inverse operations.
  503. *
  504. *                   See also 'MEM_VAL_COPY_SET_xxx()  Note #5'.
  505. *
  506. *               (6) The 'CPU_CFG_ENDIAN_TYPE' pre-processor 'else'-conditional code SHOULD never be compiled/
  507. *                   linked since each 'cpu.h' SHOULD ensure that the CPU data-word-memory order configuration
  508. *                   constant (CPU_CFG_ENDIAN_TYPE) is configured with an appropriate data-word-memory order
  509. *                   value (see 'cpu.h  CPU WORD CONFIGURATION  Note #2').  The 'else'-conditional code is
  510. *                   included as an extra precaution in case 'cpu.h' is incorrectly configured.
  511. *********************************************************************************************************
  512. */
  513. /*$PAGE*/
  514. #if     (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_BIG)
  515. #define  MEM_VAL_COPY_GET_INT08U_BIG(addr_dest, addr_src)     { (*(((CPU_INT08U *)(addr_dest)) + 0)) = (*(((CPU_INT08U *)(addr_src)) + 0)); }
  516. #define  MEM_VAL_COPY_GET_INT16U_BIG(addr_dest, addr_src)     { (*(((CPU_INT08U *)(addr_dest)) + 0)) = (*(((CPU_INT08U *)(addr_src)) + 0)); 
  517.                                                                 (*(((CPU_INT08U *)(addr_dest)) + 1)) = (*(((CPU_INT08U *)(addr_src)) + 1)); }
  518. #define  MEM_VAL_COPY_GET_INT32U_BIG(addr_dest, addr_src)     { (*(((CPU_INT08U *)(addr_dest)) + 0)) = (*(((CPU_INT08U *)(addr_src)) + 0)); 
  519.                                                                 (*(((CPU_INT08U *)(addr_dest)) + 1)) = (*(((CPU_INT08U *)(addr_src)) + 1)); 
  520.                                                                 (*(((CPU_INT08U *)(addr_dest)) + 2)) = (*(((CPU_INT08U *)(addr_src)) + 2)); 
  521.                                                                 (*(((CPU_INT08U *)(addr_dest)) + 3)) = (*(((CPU_INT08U *)(addr_src)) + 3)); }
  522. #define  MEM_VAL_COPY_GET_INT08U_LITTLE(addr_dest, addr_src)  { (*(((CPU_INT08U *)(addr_dest)) + 0)) = (*(((CPU_INT08U *)(addr_src)) + 0)); }
  523. #define  MEM_VAL_COPY_GET_INT16U_LITTLE(addr_dest, addr_src)  { (*(((CPU_INT08U *)(addr_dest)) + 0)) = (*(((CPU_INT08U *)(addr_src)) + 1)); 
  524.                                                                 (*(((CPU_INT08U *)(addr_dest)) + 1)) = (*(((CPU_INT08U *)(addr_src)) + 0)); }
  525. #define  MEM_VAL_COPY_GET_INT32U_LITTLE(addr_dest, addr_src)  { (*(((CPU_INT08U *)(addr_dest)) + 0)) = (*(((CPU_INT08U *)(addr_src)) + 3)); 
  526.                                                                 (*(((CPU_INT08U *)(addr_dest)) + 1)) = (*(((CPU_INT08U *)(addr_src)) + 2)); 
  527.                                                                 (*(((CPU_INT08U *)(addr_dest)) + 2)) = (*(((CPU_INT08U *)(addr_src)) + 1)); 
  528.                                                                 (*(((CPU_INT08U *)(addr_dest)) + 3)) = (*(((CPU_INT08U *)(addr_src)) + 0)); }
  529. #define  MEM_VAL_COPY_GET_INT08U(addr_dest, addr_src)           MEM_VAL_COPY_GET_INT08U_BIG(addr_dest, addr_src)
  530. #define  MEM_VAL_COPY_GET_INT16U(addr_dest, addr_src)           MEM_VAL_COPY_GET_INT16U_BIG(addr_dest, addr_src)
  531. #define  MEM_VAL_COPY_GET_INT32U(addr_dest, addr_src)           MEM_VAL_COPY_GET_INT32U_BIG(addr_dest, addr_src)
  532. #elif   (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_LITTLE)
  533. #define  MEM_VAL_COPY_GET_INT08U_BIG(addr_dest, addr_src)     { (*(((CPU_INT08U *)(addr_dest)) + 0)) = (*(((CPU_INT08U *)(addr_src)) + 0)); }
  534. #define  MEM_VAL_COPY_GET_INT16U_BIG(addr_dest, addr_src)     { (*(((CPU_INT08U *)(addr_dest)) + 0)) = (*(((CPU_INT08U *)(addr_src)) + 1)); 
  535.                                                                 (*(((CPU_INT08U *)(addr_dest)) + 1)) = (*(((CPU_INT08U *)(addr_src)) + 0)); }
  536. #define  MEM_VAL_COPY_GET_INT32U_BIG(addr_dest, addr_src)     { (*(((CPU_INT08U *)(addr_dest)) + 0)) = (*(((CPU_INT08U *)(addr_src)) + 3)); 
  537.                                                                 (*(((CPU_INT08U *)(addr_dest)) + 1)) = (*(((CPU_INT08U *)(addr_src)) + 2)); 
  538.                                                                 (*(((CPU_INT08U *)(addr_dest)) + 2)) = (*(((CPU_INT08U *)(addr_src)) + 1)); 
  539.                                                                 (*(((CPU_INT08U *)(addr_dest)) + 3)) = (*(((CPU_INT08U *)(addr_src)) + 0)); }
  540. #define  MEM_VAL_COPY_GET_INT08U_LITTLE(addr_dest, addr_src)  { (*(((CPU_INT08U *)(addr_dest)) + 0)) = (*(((CPU_INT08U *)(addr_src)) + 0)); }
  541. #define  MEM_VAL_COPY_GET_INT16U_LITTLE(addr_dest, addr_src)  { (*(((CPU_INT08U *)(addr_dest)) + 0)) = (*(((CPU_INT08U *)(addr_src)) + 0)); 
  542.                                                                 (*(((CPU_INT08U *)(addr_dest)) + 1)) = (*(((CPU_INT08U *)(addr_src)) + 1)); }
  543. #define  MEM_VAL_COPY_GET_INT32U_LITTLE(addr_dest, addr_src)  { (*(((CPU_INT08U *)(addr_dest)) + 0)) = (*(((CPU_INT08U *)(addr_src)) + 0)); 
  544.                                                                 (*(((CPU_INT08U *)(addr_dest)) + 1)) = (*(((CPU_INT08U *)(addr_src)) + 1)); 
  545.                                                                 (*(((CPU_INT08U *)(addr_dest)) + 2)) = (*(((CPU_INT08U *)(addr_src)) + 2)); 
  546.                                                                 (*(((CPU_INT08U *)(addr_dest)) + 3)) = (*(((CPU_INT08U *)(addr_src)) + 3)); }
  547. #define  MEM_VAL_COPY_GET_INT08U(addr_dest, addr_src)           MEM_VAL_COPY_GET_INT08U_LITTLE(addr_dest, addr_src)
  548. #define  MEM_VAL_COPY_GET_INT16U(addr_dest, addr_src)           MEM_VAL_COPY_GET_INT16U_LITTLE(addr_dest, addr_src)
  549. #define  MEM_VAL_COPY_GET_INT32U(addr_dest, addr_src)           MEM_VAL_COPY_GET_INT32U_LITTLE(addr_dest, addr_src)
  550. #else                                                                           /* See Note #6.                         */
  551. #error  "CPU_CFG_ENDIAN_TYPE  illegally #defined in 'cpu.h'      "
  552. #error  "                     [See 'cpu.h  CONFIGURATION ERRORS']"
  553. #endif
  554. /*$PAGE*/
  555. /*
  556. *********************************************************************************************************
  557. *                                       MEM_VAL_COPY_SET_xxx()
  558. *
  559. * Description : Copy & encode data values from any CPU memory address to any CPU memory address.
  560. *
  561. * Argument(s) : addr_dest       Lowest CPU memory address to copy/encode source address's data value
  562. *                                   (see Notes #2 & #3).
  563. *
  564. *               addr_src        Lowest CPU memory address of data value to copy/encode
  565. *                                   (see Notes #2 & #3).
  566. *
  567. * Return(s)   : none.
  568. *
  569. * Caller(s)   : Application.
  570. *
  571. * Note(s)     : (1) Copy/encode data values based on the values' data-word order :
  572. *
  573. *                       MEM_VAL_COPY_SET_xxx_BIG()      Encode big-   endian data values -- data words' most
  574. *                                                           significant octet @ lowest memory address
  575. *                       MEM_VAL_COPY_SET_xxx_LITTLE()   Encode little-endian data values -- data words' least
  576. *                                                           significant octet @ lowest memory address
  577. *                       MEM_VAL_COPY_SET_xxx()          Encode data values using CPU's native or configured
  578. *                                                           data-word order
  579. *
  580. *                   See also 'cpu.h  CPU WORD CONFIGURATION  Note #2'.
  581. *
  582. *               (2) CPU memory addresses/pointers NOT checked for NULL.
  583. *
  584. *               (3) MEM_VAL_COPY_SET_xxx() macro's copy/encode data values without regard to CPU word-aligned
  585. *                   addresses.  Thus for processors that require data word alignment, data words can be copied/
  586. *                   encoded to/from any CPU address, word-aligned or not, without generating data-word-alignment
  587. *                   exceptions/faults.
  588. *
  589. *               (4) MEM_VAL_COPY_SET_xxx() macro's are more efficient than MEM_VAL_SET_xxx() macro's & are
  590. *                   also independent of CPU data-word-alignment & SHOULD be used whenever possible.
  591. *
  592. *                   See also 'MEM_VAL_SET_xxx()  Note #4'.
  593. *
  594. *               (5) Since octet-order copy/conversion are inverse operations, memory data value gets/sets
  595. *                   are inverse operations.
  596. *
  597. *                   See also 'MEM_VAL_COPY_GET_xxx()  Note #5'.
  598. *********************************************************************************************************
  599. */
  600.                                                                                 /* See Note #5.                         */
  601. #define  MEM_VAL_COPY_SET_INT08U_BIG(addr_dest, addr_src)       MEM_VAL_COPY_GET_INT08U_BIG(addr_dest, addr_src)
  602. #define  MEM_VAL_COPY_SET_INT16U_BIG(addr_dest, addr_src)       MEM_VAL_COPY_GET_INT16U_BIG(addr_dest, addr_src)
  603. #define  MEM_VAL_COPY_SET_INT32U_BIG(addr_dest, addr_src)       MEM_VAL_COPY_GET_INT32U_BIG(addr_dest, addr_src)
  604. #define  MEM_VAL_COPY_SET_INT08U_LITTLE(addr_dest, addr_src)    MEM_VAL_COPY_GET_INT08U_LITTLE(addr_dest, addr_src)
  605. #define  MEM_VAL_COPY_SET_INT16U_LITTLE(addr_dest, addr_src)    MEM_VAL_COPY_GET_INT16U_LITTLE(addr_dest, addr_src)
  606. #define  MEM_VAL_COPY_SET_INT32U_LITTLE(addr_dest, addr_src)    MEM_VAL_COPY_GET_INT32U_LITTLE(addr_dest, addr_src)
  607. #define  MEM_VAL_COPY_SET_INT08U(addr_dest, addr_src)           MEM_VAL_COPY_GET_INT08U(addr_dest, addr_src)
  608. #define  MEM_VAL_COPY_SET_INT16U(addr_dest, addr_src)           MEM_VAL_COPY_GET_INT16U(addr_dest, addr_src)
  609. #define  MEM_VAL_COPY_SET_INT32U(addr_dest, addr_src)           MEM_VAL_COPY_GET_INT32U(addr_dest, addr_src)
  610. /*$PAGE*/
  611. /*
  612. *********************************************************************************************************
  613. *                                         MEM_VAL_COPY_xxx()
  614. *
  615. * Description : Copy data values from any CPU memory address to any CPU memory address.
  616. *
  617. * Argument(s) : addr_dest       Lowest CPU memory address to copy source address's data value
  618. *                                   (see Notes #2 & #3).
  619. *
  620. *               addr_src        Lowest CPU memory address of data value to copy
  621. *                                   (see Notes #2 & #3).
  622. *
  623. * Return(s)   : none.
  624. *
  625. * Caller(s)   : Application.
  626. *
  627. * Note(s)     : (1) MEM_VAL_COPY_xxx() macro's copy data values based on CPU's native data-word order.
  628. *
  629. *                   See also 'cpu.h  CPU WORD CONFIGURATION  Note #2'.
  630. *
  631. *               (2) CPU memory addresses/pointers NOT checked for NULL.
  632. *
  633. *               (3) MEM_VAL_COPY_xxx() macro's copy data values without regard to CPU word-aligned addresses.
  634. *                   Thus for processors that require data word alignment, data words can be copied to/from any
  635. *                   CPU address, word-aligned or not, without generating data-word-alignment exceptions/faults.
  636. *********************************************************************************************************
  637. */
  638. #define  MEM_VAL_COPY_08(addr_dest, addr_src)                 { (*(((CPU_INT08U *)(addr_dest)) + 0)) = (*(((CPU_INT08U *)(addr_src)) + 0)); }
  639. #define  MEM_VAL_COPY_16(addr_dest, addr_src)                 { (*(((CPU_INT08U *)(addr_dest)) + 0)) = (*(((CPU_INT08U *)(addr_src)) + 0)); 
  640.                                                                 (*(((CPU_INT08U *)(addr_dest)) + 1)) = (*(((CPU_INT08U *)(addr_src)) + 1)); }
  641. #define  MEM_VAL_COPY_32(addr_dest, addr_src)                 { (*(((CPU_INT08U *)(addr_dest)) + 0)) = (*(((CPU_INT08U *)(addr_src)) + 0)); 
  642.                                                                 (*(((CPU_INT08U *)(addr_dest)) + 1)) = (*(((CPU_INT08U *)(addr_src)) + 1)); 
  643.                                                                 (*(((CPU_INT08U *)(addr_dest)) + 2)) = (*(((CPU_INT08U *)(addr_src)) + 2)); 
  644.                                                                 (*(((CPU_INT08U *)(addr_dest)) + 3)) = (*(((CPU_INT08U *)(addr_src)) + 3)); }
  645. /*$PAGE*/
  646. /*
  647. *********************************************************************************************************
  648. *                                         FUNCTION PROTOTYPES
  649. *********************************************************************************************************
  650. */
  651. void          Mem_Init       (void);
  652.                                                                         /* -------------- MEM API  FNCTS -------------- */
  653. void          Mem_Clr        (void        *pmem,
  654.                               CPU_SIZE_T   size);
  655. void          Mem_Set        (void        *pmem,
  656.                               CPU_INT08U   data_val,
  657.                               CPU_SIZE_T   size);
  658. void          Mem_Copy       (void        *pdest,
  659.                               void        *psrc,
  660.                               CPU_SIZE_T   size);
  661. CPU_BOOLEAN   Mem_Cmp        (void        *p1_mem,
  662.                               void        *p2_mem,
  663.                               CPU_SIZE_T   size);
  664. #if (LIB_MEM_CFG_POOL_EN == DEF_ENABLED)                                /* -------------- MEM POOL FNCTS -------------- */
  665. void          Mem_PoolCreate (MEM_POOL    *pmem_pool,
  666.                               void        *pmem_base_addr,
  667.                               CPU_SIZE_T   mem_size,
  668.                               CPU_SIZE_T   blk_nbr,
  669.                               CPU_SIZE_T   blk_size,
  670.                               CPU_SIZE_T   blk_align,
  671.                               CPU_SIZE_T  *poctets_reqd,
  672.                               LIB_ERR     *perr);
  673. void         *Mem_PoolBlkGet (MEM_POOL    *pmem_pool,
  674.                               CPU_SIZE_T   size,
  675.                               LIB_ERR     *perr);
  676. void          Mem_PoolBlkFree(MEM_POOL    *pmem_pool,
  677.                               void        *pmem_blk,
  678.                               LIB_ERR     *perr);
  679. #endif
  680. /*$PAGE*/
  681. /*
  682. *********************************************************************************************************
  683. *                                        CONFIGURATION ERRORS
  684. *********************************************************************************************************
  685. */
  686. #ifndef  LIB_MEM_CFG_ARG_CHK_EXT_EN
  687. #error  "LIB_MEM_CFG_ARG_CHK_EXT_EN        not #define'd in 'app_cfg.h'"
  688. #error  "                            [MUST be  DEF_DISABLED]           "
  689. #error  "                            [     ||  DEF_ENABLED ]           "
  690. #elif  ((LIB_MEM_CFG_ARG_CHK_EXT_EN != DEF_DISABLED) && 
  691.         (LIB_MEM_CFG_ARG_CHK_EXT_EN != DEF_ENABLED ))
  692. #error  "LIB_MEM_CFG_ARG_CHK_EXT_EN  illegally #define'd in 'app_cfg.h'"
  693. #error  "                            [MUST be  DEF_DISABLED]           "
  694. #error  "                            [     ||  DEF_ENABLED ]           "
  695. #endif
  696. #ifndef  LIB_MEM_CFG_POOL_EN
  697. #error  "LIB_MEM_CFG_POOL_EN               not #define'd in 'app_cfg.h'"
  698. #error  "                            [MUST be  DEF_DISABLED]           "
  699. #error  "                            [     ||  DEF_ENABLED ]           "
  700. #elif  ((LIB_MEM_CFG_POOL_EN != DEF_DISABLED) && 
  701.         (LIB_MEM_CFG_POOL_EN != DEF_ENABLED ))
  702. #error  "LIB_MEM_CFG_POOL_EN         illegally #define'd in 'app_cfg.h'"
  703. #error  "                            [MUST be  DEF_DISABLED]           "
  704. #error  "                            [     ||  DEF_ENABLED ]           "
  705. #elif   (LIB_MEM_CFG_POOL_EN == DEF_ENABLED)
  706. #ifndef  LIB_MEM_CFG_HEAP_SIZE
  707. #error  "LIB_MEM_CFG_HEAP_SIZE             not #define'd in 'app_cfg.h'"
  708. #error  "                            [MUST be  > 0]                    "
  709. #elif   (LIB_MEM_CFG_HEAP_SIZE < 1)
  710. #error  "LIB_MEM_CFG_HEAP_SIZE       illegally #define'd in 'app_cfg.h'"
  711. #error  "                            [MUST be  > 0]                    "
  712. #endif
  713. #endif
  714. /*$PAGE*/
  715. /*
  716. *********************************************************************************************************
  717. *                                             MODULE END
  718. *********************************************************************************************************
  719. */
  720. #endif                                                          /* End of lib mem module include.                       */