OSAL_Memory.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /**************************************************************************************************
  2. Filename: OSAL_Memory.h
  3. Revised: $Date: 2010-07-28 08:42:48 -0700 (Wed, 28 Jul 2010) $
  4. Revision: $Revision: 23160 $
  5. Description: This module defines the OSAL memory control functions.
  6. Copyright 2004-2007 Texas Instruments Incorporated. All rights reserved.
  7. IMPORTANT: Your use of this Software is limited to those specific rights
  8. granted under the terms of a software license agreement between the user
  9. who downloaded the software, his/her employer (which must be your employer)
  10. and Texas Instruments Incorporated (the "License"). You may not use this
  11. Software unless you agree to abide by the terms of the License. The License
  12. limits your use, and you acknowledge, that the Software may not be modified,
  13. copied or distributed unless embedded on a Texas Instruments microcontroller
  14. or used solely and exclusively in conjunction with a Texas Instruments radio
  15. frequency transceiver, which is integrated into your product. Other than for
  16. the foregoing purpose, you may not use, reproduce, copy, prepare derivative
  17. works of, modify, distribute, perform, display or sell this Software and/or
  18. its documentation for any purpose.
  19. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  20. PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  21. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  22. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  23. TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
  24. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  25. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  26. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  27. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  28. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  29. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  30. Should you have any questions regarding your right to use this Software,
  31. contact Texas Instruments Incorporated at www.TI.com.
  32. **************************************************************************************************/
  33. #ifndef OSAL_MEMORY_H
  34. #define OSAL_MEMORY_H
  35. #ifdef __cplusplus
  36. extern "C"
  37. {
  38. #endif
  39. /*********************************************************************
  40. * INCLUDES
  41. */
  42. #include "comdef.h"
  43. /*********************************************************************
  44. * CONSTANTS
  45. */
  46. #if !defined ( OSALMEM_METRICS )
  47. #define OSALMEM_METRICS FALSE
  48. #endif
  49. /*********************************************************************
  50. * MACROS
  51. */
  52. #define osal_stack_used() OnBoard_stack_used()
  53. /*********************************************************************
  54. * TYPEDEFS
  55. */
  56. /*********************************************************************
  57. * GLOBAL VARIABLES
  58. */
  59. /*********************************************************************
  60. * FUNCTIONS
  61. */
  62. /*
  63. * Initialize memory manager.
  64. */
  65. void osal_mem_init( void );
  66. /*
  67. * Setup efficient search for the first free block of heap.
  68. */
  69. void osal_mem_kick( void );
  70. /*
  71. * Allocate a block of memory.
  72. */
  73. #ifdef DPRINTF_OSALHEAPTRACE
  74. void *osal_mem_alloc_dbg( uint16 size, const char *fname, unsigned lnum );
  75. #define osal_mem_alloc(_size ) osal_mem_alloc_dbg(_size, __FILE__, __LINE__)
  76. #else /* DPRINTF_OSALHEAPTRACE */
  77. void *osal_mem_alloc( uint16 size );
  78. #endif /* DPRINTF_OSALHEAPTRACE */
  79. /*
  80. * Free a block of memory.
  81. */
  82. #ifdef DPRINTF_OSALHEAPTRACE
  83. void osal_mem_free_dbg( void *ptr, const char *fname, unsigned lnum );
  84. #define osal_mem_free(_ptr ) osal_mem_free_dbg(_ptr, __FILE__, __LINE__)
  85. #else /* DPRINTF_OSALHEAPTRACE */
  86. void osal_mem_free( void *ptr );
  87. #endif /* DPRINTF_OSALHEAPTRACE */
  88. #if ( OSALMEM_METRICS )
  89. /*
  90. * Return the maximum number of blocks ever allocated at once.
  91. */
  92. uint16 osal_heap_block_max( void );
  93. /*
  94. * Return the current number of blocks now allocated.
  95. */
  96. uint16 osal_heap_block_cnt( void );
  97. /*
  98. * Return the current number of free blocks.
  99. */
  100. uint16 osal_heap_block_free( void );
  101. /*
  102. * Return the current number of bytes allocated.
  103. */
  104. uint16 osal_heap_mem_used( void );
  105. #endif
  106. #if defined (ZTOOL_P1) || defined (ZTOOL_P2)
  107. /*
  108. * Return the highest number of bytes ever used in the heap.
  109. */
  110. uint16 osal_heap_high_water( void );
  111. #endif
  112. /*********************************************************************
  113. *********************************************************************/
  114. #ifdef __cplusplus
  115. }
  116. #endif
  117. #endif /* #ifndef OSAL_MEMORY_H */