SYS/BIOS  7.00
HeapTrack.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  */
61 /*
62  * ======== HeapTrack.h ========
63  */
64 
65 #ifndef ti_sysbios_heaps_HeapTrack__include
66 #define ti_sysbios_heaps_HeapTrack__include
67 
68 #include <stdbool.h>
69 #include <stddef.h>
70 #include <stdint.h>
71 
72 #include <ti/sysbios/knl/Queue.h>
73 #include <ti/sysbios/knl/Task.h>
74 
78 
80 /* BIOS 6.x compatibility, use -Dxdc_std__include to disable */
81 #include <xdc/std.h>
82 
83 #define ti_sysbios_heaps_HeapTrack_long_names
84 #include "HeapTrack_defs.h"
87 #ifdef __cplusplus
88 extern "C" {
89 #endif
90 
94 #define HeapTrack_A_doubleFree "Buffer already free"
95 
100 #define HeapTrack_A_bufOverflow "Buffer overflow"
101 
105 #define HeapTrack_A_notEmpty "Heap not empty"
106 
110 #define HeapTrack_A_nullObject "HeapTrack_printHeap called with null obj"
111 
140 typedef struct {
141  uintptr_t scribble;
143  size_t size;
144  uint32_t tick;
147 
148 typedef struct {
149  IHeap_Handle heap;
151 
152 typedef struct {
153  IHeap_Object iheap;
158  IHeap_Handle internalHeap;
160  size_t size;
161  size_t peak;
165 
166 typedef struct {
169 
171 #define ti_sysbios_heaps_HeapTrack_NOSCRIBBLE 0x05101920
172 #define ti_sysbios_heaps_HeapTrack_STARTSCRIBBLE 0xa5a5a5a5
173 
176 
184 #define ti_sysbios_heaps_HeapTrack_Handle_upCast(handle) ((IHeap_Handle)(handle))
185 
192 extern void * HeapTrack_alloc(HeapTrack_Handle heap, size_t size, size_t align, Error_Block *eb);
193 
197 extern void HeapTrack_free(HeapTrack_Handle heap, void * buf, size_t size);
198 
209 extern bool HeapTrack_isBlocking(HeapTrack_Handle heap);
210 
217 extern void HeapTrack_getStats(HeapTrack_Handle heap, Memory_Stats *stats);
218 
226 extern void HeapTrack_printTask(Task_Handle task);
227 
234 extern void HeapTrack_printHeap(HeapTrack_Handle heap);
235 
244 extern HeapTrack_Handle HeapTrack_Object_first(void);
245 
256 extern HeapTrack_Handle HeapTrack_Object_next(HeapTrack_Handle heap);
257 
266 extern HeapTrack_Handle HeapTrack_create(const HeapTrack_Params *params, Error_Block *eb);
267 
279 extern HeapTrack_Handle HeapTrack_construct(HeapTrack_Struct *obj, const HeapTrack_Params *params);
280 
289 extern void HeapTrack_delete(HeapTrack_Handle *heap);
290 
296 extern void HeapTrack_destruct(HeapTrack_Struct *obj);
297 
309 extern void HeapTrack_Params_init(HeapTrack_Params *prms);
310 
319 extern HeapTrack_Handle HeapTrack_Object_first(void);
320 
331 extern HeapTrack_Handle HeapTrack_Object_next(HeapTrack_Handle heap);
332 
333 static inline HeapTrack_Handle HeapTrack_handle(HeapTrack_Struct *str)
334 {
335  return ((HeapTrack_Handle)str);
336 }
337 
338 static inline HeapTrack_Struct * HeapTrack_struct(HeapTrack_Handle h)
339 {
340  return ((HeapTrack_Struct *)h);
341 }
342 
344 extern void HeapTrack_init(void);
345 #define HeapTrack_module ((HeapTrack_Module_State *) &(HeapTrack_Module_state))
346 
348 #ifdef __cplusplus
349 }
350 #endif
351 
352 #endif
353 
355 #undef ti_sysbios_heaps_HeapTrack_long_names
356 #include "HeapTrack_defs.h"
void HeapTrack_destruct(HeapTrack_Struct *obj)
Destruct a HeapTrack heap.
HeapTrack_Handle HeapTrack_Object_first(void)
return handle of the first HeapTrack on HeapTrack list
Structure added to the end of each allocated block.
Definition: HeapTrack.h:140
uint32_t tick
Definition: HeapTrack.h:144
void HeapTrack_printHeap(HeapTrack_Handle heap)
Print details for a HeapTrack instance.
size_t size
Definition: HeapTrack.h:160
Queue_Struct trackQueue
Definition: HeapTrack.h:159
size_t size
Definition: HeapTrack.h:143
Static and run-time memory manager.
Definition: HeapTrack.h:148
Definition: HeapTrack.h:152
void HeapTrack_free(HeapTrack_Handle heap, void *buf, size_t size)
Free a block of memory back to the heap.
HeapTrack_Handle HeapTrack_Object_next(HeapTrack_Handle heap)
return handle of the next HeapTrack on HeapTrack list
Opaque queue element.
Definition: Queue.h:204
Runtime error manager.
Queue Manager.
IHeap_Object iheap
Definition: HeapTrack.h:153
Queue_Elem queElem
Definition: HeapTrack.h:142
void HeapTrack_delete(HeapTrack_Handle *heap)
Delete a HeapTrack heap.
bool HeapTrack_isBlocking(HeapTrack_Handle heap)
Can this heap block the caller.
Error block.
Definition: Error.h:152
HeapTrack_Handle HeapTrack_construct(HeapTrack_Struct *obj, const HeapTrack_Params *params)
Construct a HeapTrack heap.
HeapTrack_Struct HeapTrack_Object
Definition: HeapTrack.h:175
void HeapTrack_Params_init(HeapTrack_Params *prms)
Initialize the HeapTrack_Params structure with default values.
Interface to heap functions.
void * HeapTrack_alloc(HeapTrack_Handle heap, size_t size, size_t align, Error_Block *eb)
Allocate a block of memory from the heap.
Queue_Struct objQ
Definition: HeapTrack.h:167
Task_Handle taskHandle
Definition: HeapTrack.h:145
Memory heap statistics.
Definition: Memory.h:94
struct HeapTrack_Struct * HeapTrack_Handle
Task Manager.
uintptr_t scribble
Definition: HeapTrack.h:141
Definition: HeapTrack.h:166
size_t sizeWithoutTracker
Definition: HeapTrack.h:162
Queue_Elem objElem
Definition: HeapTrack.h:154
struct Task_Struct * Task_Handle
Definition: Task.h:526
HeapTrack_Handle HeapTrack_create(const HeapTrack_Params *params, Error_Block *eb)
Create a HeapTrack heap.
size_t peakWithoutTracker
Definition: HeapTrack.h:163
IHeap_Handle internalHeap
Heap to use with HeapTrack.
Definition: HeapTrack.h:158
void HeapTrack_getStats(HeapTrack_Handle heap, Memory_Stats *stats)
get memory stats for a HeapTrack object
size_t peak
Definition: HeapTrack.h:161
void HeapTrack_printTask(Task_Handle task)
Print out the blocks that are currently allocated by a task.
IHeap_Handle heap
Definition: HeapTrack.h:149
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale