![]() |
![]() |
00001 00016 /* 00017 * ============================================================================ 00018 * 00019 * Copyright (c) 2008-2012, Texas Instruments Incorporated 00020 * 00021 * Redistribution and use in source and binary forms, with or without 00022 * modification, are permitted provided that the following conditions 00023 * are met: 00024 * 00025 * * Redistributions of source code must retain the above copyright 00026 * notice, this list of conditions and the following disclaimer. 00027 * 00028 * * Redistributions in binary form must reproduce the above copyright 00029 * notice, this list of conditions and the following disclaimer in the 00030 * documentation and/or other materials provided with the distribution. 00031 * 00032 * * Neither the name of Texas Instruments Incorporated nor the names of 00033 * its contributors may be used to endorse or promote products derived 00034 * from this software without specific prior written permission. 00035 * 00036 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00037 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 00038 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00039 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 00040 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00041 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00042 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 00043 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00044 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 00045 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 00046 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00047 * Contact information for paper mail: 00048 * Texas Instruments 00049 * Post Office Box 655303 00050 * Dallas, Texas 75265 00051 * Contact information: 00052 * http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm? 00053 * DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact 00054 * ============================================================================ 00055 * 00056 */ 00057 00058 00059 #ifndef ti_syslink_utils_IpcMemMgr__include 00060 #define ti_syslink_utils_IpcMemMgr__include 00061 00062 #include <ti/syslink/osal/OsalTypes.h> 00063 00064 #if defined (__cplusplus) 00065 extern "C" { 00066 #endif 00067 00068 00069 /* ============================================================================= 00070 * Macros 00071 * ============================================================================= 00072 */ 00076 #define IpcMemMgr_MODULEID (0x434D) 00077 00078 #define IpcMemMgr_S_NOTLAST 2 00079 #define IpcMemMgr_S_ALREADYSETUP 1 00080 #define IpcMemMgr_S_SUCCESS 0 00081 #define IpcMemMgr_E_FAIL -1 00082 #define IpcMemMgr_E_INVALIDSTATE -2 00083 #define IpcMemMgr_E_INVALIDARG -3 00084 #define IpcMemMgr_E_MEMORY -4 00085 #define IpcMemMgr_E_OSFAILURE -5 00086 #define IpcMemMgr_E_TOOMANYNAMEDALLOCS -6 00087 #define IpcMemMgr_E_NOTFOUND -7 00088 #define IpcMemMgr_E_WRONGSIZE -8 00089 00090 #define IpcMemMgr_SHAREDMEMNAME "/syslink_shm" 00091 #define IpcMemMgr_MAXNAMEDBUFFERS 256 /* max named buffers */ 00092 #define IpcMemMgr_MAX_NAMELEN 63 /* max name length */ 00093 00094 00095 /* ============================================================================= 00096 * Struct & Enums 00097 * ============================================================================= 00098 */ 00099 /* Memory type */ 00100 typedef enum { 00101 IpcMemMgr_ALLOCTYPE_PSHMEM = 0x00000, 00102 IpcMemMgr_ALLOCTYPE_PHYS_CACHE = 0x00001, 00103 IpcMemMgr_ALLOCTYPE_PHYS_NOCACHE = 0x00002, 00104 IpcMemMgr_ALLOCTYPE_END = 0x00003, 00105 } IpcMemMgr_MemType; 00106 00110 typedef struct IpcMemMgr_Config_t { 00111 UInt32 size; 00113 UInt32 minAlign; 00114 /* minimum alignement for the buffer allocations */ 00115 UInt32 gateOffset; 00116 /* shared memory offset for the process gate */ 00117 } IpcMemMgr_Config; 00118 00122 typedef UInt32 IpcMemMgr_SHPtr; 00123 00124 /* ============================================================================= 00125 * APIs 00126 * ============================================================================= 00127 */ 00128 /* Function to setup the system memory maanger */ 00129 Void IpcMemMgr_getConfig(IpcMemMgr_Config * config); 00130 00131 /* setup the ipc memory manager module */ 00132 Int IpcMemMgr_setup(IpcMemMgr_Config *cfg); 00133 00134 /* destroy the ipc memory manager module */ 00135 Int IpcMemMgr_destroy(Void); 00136 00137 /* allocate anonymous shared memory */ 00138 // Ptr IpcMemMgr_alloc(UInt32 size, UInt32 reqAlign, IpcMemMgr_MemType memType); 00139 Ptr IpcMemMgr_alloc(SizeT size); 00140 00141 /* allocate memory by name */ 00142 //Int IpcMemMgr_allocByName(String name, SizeT size, Ptr *addr, Bool *newAlloc); 00143 Int IpcMemMgr_acquire(String name, SizeT size, Ptr *addr, Bool *newAlloc); 00144 00145 /* free memory anonymous memory */ 00146 Void IpcMemMgr_free(Ptr adr, SizeT size); 00147 00148 /* free memory by name */ 00149 // Int IpcMemMgr_freeByName(String name); 00150 Int IpcMemMgr_release(String name); 00151 00152 /* map memory based on kernel virtual address */ 00153 /* Ptr IpcMemMgr_map(Ptr hint, Ptr buf, UInt32 size); */ 00154 00155 /* unmap memory */ 00156 /* Int IpcMemMgr_unmap(Ptr buf, UInt32 size); */ 00157 00158 /* 00159 * ======== IpcMemMgr_getPtr ======== 00160 * Convert the given shared memory offset into a local address pointer. 00161 */ 00162 Ptr IpcMemMgr_getPtr(UInt32 offset); 00163 00164 /* 00165 * ======== IpcMemMgr_getOffset ======== 00166 * Convert the given local address pointer into an offset from the 00167 * shared memory base address. 00168 */ 00169 UInt32 IpcMemMgr_getOffset(Ptr vaddr); 00170 00171 /* allocate inter-process shared memory */ 00172 Ptr IpcMemMgr_allocShmemHeap(String name, UInt32 size, UInt32 align); 00173 00174 /* free inter-process shared memory */ 00175 Int IpcMemMgr_freeShmemHeap(Ptr buf, UInt32 size); 00176 00177 /* free inter-process shared memory by name */ 00178 Int IpcMemMgr_freeShmemHeapByName(String name); 00179 00180 IArg IpcMemMgr_enterGate(Void); 00181 00182 Void IpcMemMgr_leaveGate(IArg key); 00183 00184 00185 #if defined (__cplusplus) 00186 } 00187 #endif 00188 00189 #endif /* ti_syslink_utils_IpcMemMgr__include */