IPC API  3.40.00.06
HeapBufMP.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2013, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
70 #ifndef ti_ipc_HeapBufMP__include
71 #define ti_ipc_HeapBufMP__include
72 
73 #if defined (__cplusplus)
74 extern "C" {
75 #endif
76 
77 #include <ti/ipc/GateMP.h>
78 
79 /* =============================================================================
80  * All success and failure codes for the module
81  * =============================================================================
82  */
83 
87 #define HeapBufMP_S_BUSY 2
88 
92 #define HeapBufMP_S_ALREADYSETUP 1
93 
97 #define HeapBufMP_S_SUCCESS 0
98 
102 #define HeapBufMP_E_FAIL -1
103 
107 #define HeapBufMP_E_INVALIDARG -2
108 
112 #define HeapBufMP_E_MEMORY -3
113 
117 #define HeapBufMP_E_ALREADYEXISTS -4
118 
122 #define HeapBufMP_E_NOTFOUND -5
123 
127 #define HeapBufMP_E_TIMEOUT -6
128 
132 #define HeapBufMP_E_INVALIDSTATE -7
133 
137 #define HeapBufMP_E_OSFAILURE -8
138 
142 #define HeapBufMP_E_RESOURCE -9
143 
147 #define HeapBufMP_E_RESTART -10
148 
149 /* =============================================================================
150  * Structures & Enums
151  * =============================================================================
152  */
153 
157 typedef struct HeapBufMP_Object *HeapBufMP_Handle;
158 
164 typedef struct HeapBufMP_Params {
165  String name;
176  UInt16 regionId;
184  Ptr sharedAddr;
194  SizeT blockSize;
207  UInt numBlocks;
213  SizeT align;
224  Bool exact;
240 
246 typedef struct HeapBufMP_ExtendedStats {
257 
258 /* =============================================================================
259  * HeapBufMP Module-wide Functions
260  * =============================================================================
261  */
262 
278 Int HeapBufMP_close(HeapBufMP_Handle *handlePtr);
279 
289 HeapBufMP_Handle HeapBufMP_create(const HeapBufMP_Params *params);
290 
301 Int HeapBufMP_delete(HeapBufMP_Handle *handlePtr);
302 
327 Int HeapBufMP_open(String name, HeapBufMP_Handle *handlePtr);
328 
330 Int HeapBufMP_openByAddr(Ptr sharedAddr, HeapBufMP_Handle *handlePtr);
331 
342 
352 SizeT HeapBufMP_sharedMemReq(const HeapBufMP_Params *params);
353 
356 /* =============================================================================
357  * HeapBufMP Per-instance Functions
358  * =============================================================================
359  */
360 
386 Void *HeapBufMP_alloc(HeapBufMP_Handle handle, SizeT size, SizeT align);
387 
405 Void HeapBufMP_free(HeapBufMP_Handle handle, Ptr block, SizeT size);
406 
422 Void HeapBufMP_getExtendedStats(HeapBufMP_Handle handle,
423  HeapBufMP_ExtendedStats *stats);
424 
433 Void HeapBufMP_getStats(HeapBufMP_Handle handle, Ptr stats);
434 
435 #if defined (__cplusplus)
436 }
437 #endif /* defined (__cplusplus) */
438 #endif /* ti_ipc_HeapBufMP__include */
SizeT blockSize
Size (in MAUs) of each block.
Definition: HeapBufMP.h:194
Void HeapBufMP_getExtendedStats(HeapBufMP_Handle handle, HeapBufMP_ExtendedStats *stats)
Get extended memory statistics.
HeapBufMP_Handle HeapBufMP_create(const HeapBufMP_Params *params)
Create a HeapBufMP instance.
struct GateMP_Object * GateMP_Handle
GateMP_Handle type.
Definition: GateMP.h:222
GateMP_Handle gate
GateMP used for critical region management of the shared memory.
Definition: HeapBufMP.h:232
struct HeapBufMP_Object * HeapBufMP_Handle
HeapBufMP_Handle type.
Definition: HeapBufMP.h:157
Int HeapBufMP_close(HeapBufMP_Handle *handlePtr)
Close a HeapBufMP instance.
UInt maxAllocatedBlocks
Definition: HeapBufMP.h:247
Stats structure for HeapBufMP_getExtendedStats()
Definition: HeapBufMP.h:246
struct HeapBufMP_Params HeapBufMP_Params
Structure defining parameters for the HeapBufMP module.
SizeT align
Alignment (in MAUs) of each block.
Definition: HeapBufMP.h:213
Multiple processor gate that provides local and remote context protection.
Void HeapBufMP_getStats(HeapBufMP_Handle handle, Ptr stats)
Get memory statistics.
struct HeapBufMP_ExtendedStats HeapBufMP_ExtendedStats
Stats structure for HeapBufMP_getExtendedStats()
Void HeapBufMP_free(HeapBufMP_Handle handle, Ptr block, SizeT size)
Frees a block of memory.
UInt16 regionId
Shared region ID.
Definition: HeapBufMP.h:176
Bool exact
Use exact matching.
Definition: HeapBufMP.h:224
String name
Name of this instance.
Definition: HeapBufMP.h:165
Void * HeapBufMP_alloc(HeapBufMP_Handle handle, SizeT size, SizeT align)
Allocate a block of memory of specified size and alignment.
UInt numBlocks
Number of fixed-size blocks.
Definition: HeapBufMP.h:207
Structure defining parameters for the HeapBufMP module.
Definition: HeapBufMP.h:164
Void HeapBufMP_Params_init(HeapBufMP_Params *params)
Initialize a HeapBufMP parameters struct.
Int HeapBufMP_delete(HeapBufMP_Handle *handlePtr)
Delete a created HeapBufMP instance.
UInt numAllocatedBlocks
Definition: HeapBufMP.h:252
Int HeapBufMP_open(String name, HeapBufMP_Handle *handlePtr)
Open a created HeapBufMP instance.
Copyright 2015, Texas Instruments Incorporated