SYS/BIOS  7.00
HeapMultiBuf.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020, Texas Instruments Incorporated - https://www.ti.com
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  *
32  */
219 /*
220  * ======== HeapMultiBuf.h ========
221  */
222 
223 #ifndef ti_sysbios_heaps_HeapMultiBuf__include
224 #define ti_sysbios_heaps_HeapMultiBuf__include
225 
226 #include <stdbool.h>
227 #include <stddef.h>
228 #include <stdint.h>
229 
231 
235 
237 /* BIOS 6.x compatibility, use -Dxdc_std__include to disable */
238 #include <xdc/std.h>
239 
240 #define ti_sysbios_heaps_HeapMultiBuf_long_names
241 #include "HeapMultiBuf_defs.h"
244 #ifdef __cplusplus
245 extern "C" {
246 #endif
247 
255 #define HeapMultiBuf_A_blockNotFreed "Invalid block address on the free. Failed to free block back to heap."
256 
260 #define HeapMultiBuf_E_size "requested size is too big: handle=0x%x, size=%u"
261 
262 typedef struct {
281  int numBufs;
295 
297 typedef struct {
298  HeapBuf_Handle heapBuf;
299  void * lastAddr;
300 } HeapMultiBuf_AddrPair;
303 typedef struct {
304  IHeap_Object iheap;
325  int numBufs;
327  HeapMultiBuf_AddrPair *bufsByAddr;
329 
331 
333 typedef struct {
334  Queue_Struct objQ;
335 } HeapMultiBuf_Module_State;
346 #define ti_sysbios_heaps_HeapMultiBuf_Handle_upCast(handle) ((IHeap_Handle)(handle))
347 
354 extern void * HeapMultiBuf_alloc(HeapMultiBuf_Handle handle, size_t size, size_t align, Error_Block *eb);
355 
360 extern void HeapMultiBuf_free(HeapMultiBuf_Handle handle, void * buf, size_t size);
361 
366 extern bool HeapMultiBuf_isBlocking(HeapMultiBuf_Handle handle);
367 
374 extern void HeapMultiBuf_getStats(HeapMultiBuf_Handle handle, Memory_Stats *statBuf);
375 
384 extern HeapMultiBuf_Handle HeapMultiBuf_create(const HeapMultiBuf_Params *params, Error_Block *eb);
385 
398 extern HeapMultiBuf_Handle HeapMultiBuf_construct(HeapMultiBuf_Struct *obj, const HeapMultiBuf_Params *params, Error_Block *eb);
399 
408 extern void HeapMultiBuf_delete(HeapMultiBuf_Handle *handle);
409 
416 
429 
438 extern HeapMultiBuf_Handle HeapMultiBuf_Object_first(void);
439 
450 extern HeapMultiBuf_Handle HeapMultiBuf_Object_next(HeapMultiBuf_Handle heap);
451 
453 static inline HeapMultiBuf_Handle HeapMultiBuf_handle(HeapMultiBuf_Struct *str)
454 {
455  return ((HeapMultiBuf_Handle)str);
456 }
457 
458 static inline HeapMultiBuf_Struct * HeapMultiBuf_struct(HeapMultiBuf_Handle h)
459 {
460  return ((HeapMultiBuf_Struct *)h);
461 }
462 
463 #define HeapMultiBuf_module ((HeapMultiBuf_Module_State *) &(HeapMultiBuf_Module_state))
464 
466 #ifdef __cplusplus
467 }
468 #endif
469 
470 #endif
471 
473 #undef ti_sysbios_heaps_HeapMultiBuf_long_names
474 #include "HeapMultiBuf_defs.h"
Definition: HeapMultiBuf.h:262
HeapMultiBuf_Handle HeapMultiBuf_Object_first(void)
return handle of the first HeapMultiBuf on HeapMultiBuf list
bool blockBorrow
Turn block borrowing on (true) or off (false)
Definition: HeapMultiBuf.h:272
Fixed size buffer heap manager.
HeapMultiBuf_Handle HeapMultiBuf_construct(HeapMultiBuf_Struct *obj, const HeapMultiBuf_Params *params, Error_Block *eb)
Construct a HeapMultiBuf heap.
void HeapMultiBuf_destruct(HeapMultiBuf_Struct *obj)
Destruct a HeapMultiBuf heap.
struct HeapMultiBuf_Struct * HeapMultiBuf_Handle
bool blockBorrow
Turn block borrowing on (true) or off (false)
Definition: HeapMultiBuf.h:315
void HeapMultiBuf_getStats(HeapMultiBuf_Handle handle, Memory_Stats *statBuf)
get memory stats for a HeapMultiBuf object
HeapMultiBuf_Struct HeapMultiBuf_Object
Definition: HeapMultiBuf.h:330
int numBufs
Number of memory buffers.
Definition: HeapMultiBuf.h:325
Static and run-time memory manager.
void HeapMultiBuf_Params_init(HeapMultiBuf_Params *prms)
Initialize the HeapMultiBuf_Params structure with default values.
Opaque queue element.
Definition: Queue.h:204
Runtime error manager.
Definition: HeapMultiBuf.h:303
Definition: HeapBuf.h:329
void * HeapMultiBuf_alloc(HeapMultiBuf_Handle handle, size_t size, size_t align, Error_Block *eb)
HeapMultiBuf will return a block that is >= &#39;size&#39; with an alignment that is >= &#39;align&#39;. The HeapMultiBuf will attempt to service a request for any size; the specified size does not need to match the configured block sizes of the buffers.
HeapBuf_Handle * bufsBySize
Definition: HeapMultiBuf.h:326
Error block.
Definition: Error.h:152
int numBufs
Number of memory buffers.
Definition: HeapMultiBuf.h:281
IHeap_Object iheap
Definition: HeapMultiBuf.h:304
HeapMultiBuf_Handle HeapMultiBuf_Object_next(HeapMultiBuf_Handle heap)
return handle of the next HeapMultiBuf on HeapMultiBuf list
void HeapMultiBuf_delete(HeapMultiBuf_Handle *handle)
Delete a HeapMultiBuf heap.
HeapMultiBuf_AddrPair * bufsByAddr
Definition: HeapMultiBuf.h:327
Queue_Elem objElem
Definition: HeapMultiBuf.h:305
Interface to heap functions.
HeapBuf_Params * bufParams
Config parameters for each buffer.
Definition: HeapMultiBuf.h:293
HeapMultiBuf_Handle HeapMultiBuf_create(const HeapMultiBuf_Params *params, Error_Block *eb)
Create a HeapMultiBuf heap.
Memory heap statistics.
Definition: Memory.h:94
int numHeapBufs
Definition: HeapMultiBuf.h:316
bool HeapMultiBuf_isBlocking(HeapMultiBuf_Handle handle)
This function always returns false since the alloc/free never block on a resource.
void HeapMultiBuf_free(HeapMultiBuf_Handle handle, void *buf, size_t size)
HeapMultiBuf ignores the &#39;size&#39; parameter to free. It determines the correct buffer to free the block...
Definition: HeapBuf.h:253
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale