00001 /** 00002 * @file Memory.h 00003 * 00004 * @brief Memory manager interface definitions. 00005 * 00006 * This abstracts the Memory management interface to be used with 00007 * SysLink code. Allocation, Freeing-up, copy and address translate 00008 * are supported for the memory management. 00009 * 00010 * 00011 * @ver 02.00.00.68_beta1 00012 * 00013 * ============================================================================ 00014 * 00015 * Copyright (c) 2008-2009, Texas Instruments Incorporated 00016 * 00017 * Redistribution and use in source and binary forms, with or without 00018 * modification, are permitted provided that the following conditions 00019 * are met: 00020 * 00021 * * Redistributions of source code must retain the above copyright 00022 * notice, this list of conditions and the following disclaimer. 00023 * 00024 * * Redistributions in binary form must reproduce the above copyright 00025 * notice, this list of conditions and the following disclaimer in the 00026 * documentation and/or other materials provided with the distribution. 00027 * 00028 * * Neither the name of Texas Instruments Incorporated nor the names of 00029 * its contributors may be used to endorse or promote products derived 00030 * from this software without specific prior written permission. 00031 * 00032 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00033 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 00034 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00035 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 00036 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00037 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00038 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 00039 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00040 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 00041 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 00042 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00043 * Contact information for paper mail: 00044 * Texas Instruments 00045 * Post Office Box 655303 00046 * Dallas, Texas 75265 00047 * Contact information: 00048 * http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm? 00049 * DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact 00050 * ============================================================================ 00051 * 00052 */ 00053 00054 00055 #ifndef MEMORY_H_0xC97E 00056 #define MEMORY_H_0xC97E 00057 00058 00059 /* OSAL and utils */ 00060 #include <ti/syslink/utils/MemoryDefs.h> 00061 #include <ti/syslink/utils/MemoryOS.h> 00062 00063 /* Module headers */ 00064 #include <ti/syslink/utils/IHeap.h> 00065 00066 00067 #if defined (__cplusplus) 00068 extern "C" { 00069 #endif 00070 00071 00072 /* ============================================================================= 00073 * Macros 00074 * ============================================================================= 00075 */ 00076 /*! 00077 * @brief Blocking quality 00078 * Heaps with this "quality" may cause the calling thread to block; 00079 * i.e., suspend execution until another thread leaves the gate. 00080 */ 00081 #define Memory_Q_BLOCKING 1 00082 00083 /* ============================================================================= 00084 * Structures & Enums. See MemoryDefs.h 00085 * ============================================================================= 00086 */ 00087 00088 /* ============================================================================= 00089 * APIs 00090 * ============================================================================= 00091 */ 00092 /*! 00093 * @brief Allocates the specified number of bytes. 00094 * 00095 * @param heap Handle to the heap from which the memory is to be 00096 * allocated. Specify NULL to allocate from local memory. 00097 * @param size Amount of memory to be allocated. 00098 * @param align Alignment constraints (power of 2) 00099 * @param eb Not used. Pass as NULL. 00100 * 00101 * @retval Pointer Success: Pointer to allocated buffer 00102 * @retval NULL Failed to allocate memory 00103 * 00104 * @sa Memory_calloc 00105 */ 00106 Ptr Memory_alloc (IHeap_Handle heap, SizeT size, SizeT align, Ptr eb); 00107 00108 /*! 00109 * @brief Allocates the specified number of bytes and memory is set to 00110 * zero. 00111 * 00112 * @param heap Handle to the heap from which the memory is to be 00113 * allocated. Specify NULL to allocate from local memory. 00114 * @param size Amount of memory to be allocated. 00115 * @param align Alignment constraints (power of 2) 00116 * @param eb Not used. Pass as NULL. 00117 * 00118 * @retval Pointer Success: Pointer to allocated buffer 00119 * @retval NULL Failed to allocate memory 00120 * 00121 * @sa Memory_alloc, MemoryOS_calloc 00122 */ 00123 Ptr Memory_calloc (IHeap_Handle heap, SizeT size, SizeT align, Ptr eb); 00124 00125 /*! 00126 * @brief Frees up the specified chunk of memory. 00127 * 00128 * @param heap Handle to the heap 00129 * @param block Block of memory to be freed 00130 * @param size Amount of memory to be freed 00131 * 00132 * @sa IHeap_free, MemoryOS_free 00133 */ 00134 Void Memory_free (IHeap_Handle heap, Ptr block, SizeT size); 00135 00136 /*! 00137 * @brief Function to obtain statistics from a heap. 00138 * 00139 * @param heap Handle to the heap 00140 * @param stats Pointer to the Memory stats structure to be filled. 00141 * 00142 * @sa 00143 */ 00144 Void Memory_getStats (IHeap_Handle heap, Memory_Stats * stats); 00145 00146 /*! 00147 * @brief Function to test for a particular IHeap quality 00148 * 00149 * @param heap Handle to the heap 00150 * @param qual Quality to be queried. 00151 * 00152 * @sa Memory_Q_BLOCKING 00153 */ 00154 Bool Memory_query (IHeap_Handle heap, Int qual); 00155 00156 /*! 00157 * @brief Function to get memory alignment 00158 * 00159 * @retval Alignment Maximum default alignment 00160 */ 00161 SizeT Memory_getMaxDefaultTypeAlign (Void); 00162 00163 /*! 00164 * @brief Allocates the specified number of bytes and memory is set to 00165 * the specified value. 00166 * 00167 * @param heap Handle to the heap from which the memory is to be 00168 * allocated. Specify NULL to allocate from local memory. 00169 * @param size Amount of memory to be allocated. 00170 * @param align Alignment constraints (power of 2) 00171 * @param value Value to be set for all bytes in the buffer 00172 * @param eb Not used. Pass as NULL. 00173 * 00174 * @retval Pointer Success: Pointer to allocated buffer 00175 * @retval NULL Failed to allocate memory 00176 * 00177 * @sa Memory_alloc, MemoryOS_calloc 00178 */ 00179 Ptr Memory_valloc (IHeap_Handle heap, 00180 SizeT size, 00181 SizeT align, 00182 Char value, 00183 Ptr eb); 00184 00185 /*! 00186 * @brief Function to translate an address. 00187 * 00188 * @param srcAddr source address. 00189 * @param flags Tranlation flags. 00190 * 00191 * @retval Pointer Success: Pointer to translated buffer 00192 * @retval NULL Failed to translate 00193 */ 00194 Ptr Memory_translate (Ptr srcAddr, Memory_XltFlags flags); 00195 00196 00197 /* ============================================================================= 00198 * APIs that are added for MemoryOS 00199 * ============================================================================= 00200 */ 00201 /*! 00202 * @brief Maps a memory area into virtual space. 00203 * @sa Memory_unmap 00204 */ 00205 #define Memory_map MemoryOS_map 00206 00207 /*! 00208 * @brief Unmaps a memory area into virtual space. 00209 * @sa Memory_unmap 00210 */ 00211 #define Memory_unmap MemoryOS_unmap 00212 00213 /*! 00214 * @brief Copies the data between memory areas. 00215 */ 00216 #define Memory_copy MemoryOS_copy 00217 00218 /*! 00219 * @brief Set the specific value in the said memory area. 00220 */ 00221 #define Memory_set MemoryOS_set 00222 00223 00224 #if defined (__cplusplus) 00225 } 00226 #endif /* defined (__cplusplus) */ 00227 00228 #endif /* ifndef MEMORY_H_0xC97E */
1.4.4