SYS/BIOS  7.00
HeapCallback.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  */
74 /*
75  * ======== HeapCallback.h ========
76  */
77 
78 #ifndef ti_sysbios_heaps_HeapCallback__include
79 #define ti_sysbios_heaps_HeapCallback__include
80 
81 #include <stdbool.h>
82 #include <stddef.h>
83 #include <stdint.h>
84 
88 
90 /* BIOS 6.x compatibility, use -Dxdc_std__include to disable */
91 #include <xdc/std.h>
92 
93 #define ti_sysbios_heaps_HeapCallback_long_names
94 #include "HeapCallback_defs.h"
97 #ifdef __cplusplus
98 extern "C" {
99 #endif
100 
108 #define ti_sysbios_heaps_HeapCallback_Handle_upCast(handle) ((IHeap_Handle)(handle))
109 
117 typedef void * (*HeapCallback_AllocInstFxn)(uintptr_t context, size_t size, size_t align);
118 
126 typedef uintptr_t (*HeapCallback_CreateInstFxn)(uintptr_t arg);
127 
134 typedef void (*HeapCallback_DeleteInstFxn)(uintptr_t context);
135 
142 typedef void (*HeapCallback_FreeInstFxn)(uintptr_t context, void * addr, size_t size);
143 
150 typedef void (*HeapCallback_GetStatsInstFxn)(uintptr_t context, Memory_Stats *stats);
151 
158 typedef bool (*HeapCallback_IsBlockingInstFxn)(uintptr_t context);
159 
160 typedef struct {
173  uintptr_t arg;
175 
176 typedef struct {
177  IHeap_Object iheap;
179  uintptr_t context;
181 
183 
185 typedef struct {
186  Queue_Struct objQ;
187 } HeapCallback_Module_State;
193 extern void * HeapCallback_alloc(HeapCallback_Handle handle, size_t size, size_t align, Error_Block *eb);
194 
198 extern void HeapCallback_free(HeapCallback_Handle handle, void * buf, size_t size);
199 
210 extern bool HeapCallback_isBlocking(HeapCallback_Handle handle);
211 
218 extern void HeapCallback_getStats(HeapCallback_Handle handle, Memory_Stats *stats);
219 
228 extern HeapCallback_Handle HeapCallback_create(const HeapCallback_Params *params, Error_Block *eb);
229 
241 extern HeapCallback_Handle HeapCallback_construct(HeapCallback_Struct *obj, const HeapCallback_Params *params);
242 
251 extern void HeapCallback_delete(HeapCallback_Handle *handle);
252 
259 
272 
281 extern HeapCallback_Handle HeapCallback_Object_first(void);
282 
293 extern HeapCallback_Handle HeapCallback_Object_next(HeapCallback_Handle heap);
294 
295 static inline HeapCallback_Handle HeapCallback_handle(HeapCallback_Struct *str)
296 {
297  return ((HeapCallback_Handle)str);
298 }
299 
300 static inline HeapCallback_Struct * HeapCallback_struct(HeapCallback_Handle h)
301 {
302  return ((HeapCallback_Struct *)h);
303 }
304 
306 extern void HeapCallback_init(void);
307 #define HeapCallback_module ((HeapCallback_Module_State *) &(HeapCallback_Module_state))
308 
310 #ifdef __cplusplus
311 }
312 #endif
313 
314 #endif
315 
317 #undef ti_sysbios_heaps_HeapCallback_long_names
318 #include "HeapCallback_defs.h"
void HeapCallback_destruct(HeapCallback_Struct *obj)
Destruct a HeapCallback heap.
HeapCallback_Handle HeapCallback_construct(HeapCallback_Struct *obj, const HeapCallback_Params *params)
Construct a HeapCallback heap.
Static and run-time memory manager.
HeapCallback_Struct HeapCallback_Object
Definition: HeapCallback.h:182
void(* HeapCallback_FreeInstFxn)(uintptr_t context, void *addr, size_t size)
Instance free callback function signature.
Definition: HeapCallback.h:142
bool HeapCallback_isBlocking(HeapCallback_Handle handle)
Can this heap block the caller.
struct HeapCallback_Struct * HeapCallback_Handle
HeapCallback_Handle HeapCallback_Object_first(void)
return handle of the first HeapCallback on HeapCallback list
Opaque queue element.
Definition: Queue.h:204
IHeap_Object iheap
Definition: HeapCallback.h:177
Runtime error manager.
uintptr_t arg
User supplied argument for the user supplied create function.
Definition: HeapCallback.h:173
uintptr_t(* HeapCallback_CreateInstFxn)(uintptr_t arg)
Instance create callback function signature.
Definition: HeapCallback.h:126
uintptr_t context
Definition: HeapCallback.h:179
void HeapCallback_free(HeapCallback_Handle handle, void *buf, size_t size)
Free a block of memory back to the heap.
void(* HeapCallback_DeleteInstFxn)(uintptr_t context)
Instance delete callback function signature.
Definition: HeapCallback.h:134
Error block.
Definition: Error.h:152
bool(* HeapCallback_IsBlockingInstFxn)(uintptr_t context)
Instance isblocking callback function signature.
Definition: HeapCallback.h:158
void HeapCallback_Params_init(HeapCallback_Params *prms)
Initialize the HeapCallback_Params structure with default values.
void(* HeapCallback_GetStatsInstFxn)(uintptr_t context, Memory_Stats *stats)
Instance getStats callback function signature.
Definition: HeapCallback.h:150
HeapCallback_Handle HeapCallback_create(const HeapCallback_Params *params, Error_Block *eb)
Create a HeapCallback heap.
Definition: HeapCallback.h:176
Definition: HeapCallback.h:160
Interface to heap functions.
void HeapCallback_getStats(HeapCallback_Handle handle, Memory_Stats *stats)
get memory stats for a HeapCallback object
Memory heap statistics.
Definition: Memory.h:94
HeapCallback_Handle HeapCallback_Object_next(HeapCallback_Handle heap)
return handle of the next HeapCallback on HeapCallback list
Queue_Elem objElem
Definition: HeapCallback.h:178
SecureCB_Arg arg
Definition: SecureCB.h:145
void HeapCallback_delete(HeapCallback_Handle *handle)
Delete a HeapCallback heap.
void * HeapCallback_alloc(HeapCallback_Handle handle, size_t size, size_t align, Error_Block *eb)
Allocate a block of memory from the heap.
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale