1 | /** |
---|
2 | * @file rtems/malloc.h |
---|
3 | */ |
---|
4 | |
---|
5 | /* |
---|
6 | * RTEMS Malloc Extensions |
---|
7 | * |
---|
8 | * COPYRIGHT (c) 1989-1997. |
---|
9 | * On-Line Applications Research Corporation (OAR). |
---|
10 | * |
---|
11 | * The license and distribution terms for this file may in |
---|
12 | * the file LICENSE in this distribution or at |
---|
13 | * http://www.rtems.com/license/LICENSE. |
---|
14 | * |
---|
15 | * $ld: |
---|
16 | */ |
---|
17 | |
---|
18 | #ifndef _RTEMS_MALLOC_H |
---|
19 | #define _RTEMS_MALLOC_H |
---|
20 | |
---|
21 | #include <rtems.h> |
---|
22 | #include <rtems/bspIo.h> |
---|
23 | |
---|
24 | #include <stdint.h> |
---|
25 | |
---|
26 | /* |
---|
27 | * Malloc Statistics Structure |
---|
28 | */ |
---|
29 | typedef struct { |
---|
30 | uint32_t space_available; /* current size of malloc area */ |
---|
31 | uint32_t malloc_calls; /* # calls to malloc */ |
---|
32 | uint32_t memalign_calls; /* # calls to memalign */ |
---|
33 | uint32_t free_calls; |
---|
34 | uint32_t realloc_calls; |
---|
35 | uint32_t calloc_calls; |
---|
36 | uint32_t max_depth; /* most ever malloc'd at 1 time */ |
---|
37 | uintmax_t lifetime_allocated; |
---|
38 | uintmax_t lifetime_freed; |
---|
39 | } rtems_malloc_statistics_t; |
---|
40 | |
---|
41 | /* |
---|
42 | * Malloc statistics plugin |
---|
43 | */ |
---|
44 | typedef struct { |
---|
45 | void (*initialize)(void); |
---|
46 | void (*at_malloc)(void *); |
---|
47 | void (*at_free)(void *); |
---|
48 | } rtems_malloc_statististics_functions_t; |
---|
49 | |
---|
50 | extern rtems_malloc_statististics_functions_t |
---|
51 | rtems_malloc_statistics_helpers_table; |
---|
52 | extern rtems_malloc_statististics_functions_t *rtems_malloc_statistics_helpers; |
---|
53 | |
---|
54 | /* |
---|
55 | * Malloc boundary support plugin |
---|
56 | */ |
---|
57 | typedef struct { |
---|
58 | void (*initialize)(void); |
---|
59 | uint32_t (*overhead)(void); |
---|
60 | void (*at_malloc)(void *, size_t); |
---|
61 | void (*at_free)(void *); |
---|
62 | void (*at_realloc)(void *, size_t); |
---|
63 | } rtems_malloc_boundary_functions_t; |
---|
64 | |
---|
65 | extern rtems_malloc_boundary_functions_t rtems_malloc_boundary_helpers_table; |
---|
66 | extern rtems_malloc_boundary_functions_t *rtems_malloc_boundary_helpers; |
---|
67 | |
---|
68 | |
---|
69 | |
---|
70 | /** @brief Print Malloc Statistic Usage Report |
---|
71 | * |
---|
72 | * This method fills in the called provided malloc statistics area. |
---|
73 | * |
---|
74 | * @return This method returns 0 if successful and -1 on error. |
---|
75 | */ |
---|
76 | int malloc_get_statistics( |
---|
77 | rtems_malloc_statistics_t *stats |
---|
78 | ); |
---|
79 | |
---|
80 | /** @brief Print Malloc Statistic Usage Report |
---|
81 | * |
---|
82 | * This method prints a malloc statistics report. |
---|
83 | * |
---|
84 | * @note It uses printk to print the report. |
---|
85 | */ |
---|
86 | void malloc_report_statistics(void); |
---|
87 | |
---|
88 | /** @brief Print Malloc Statistic Usage Report |
---|
89 | * |
---|
90 | * This method prints a malloc statistics report. |
---|
91 | * |
---|
92 | * @param[in] context is the context to pass to the print handler |
---|
93 | * @param[in] print is the print handler |
---|
94 | * |
---|
95 | * @note It uses the CALLER's routine to print the report. |
---|
96 | */ |
---|
97 | void malloc_report_statistics_with_plugin( |
---|
98 | void *context, |
---|
99 | rtems_printk_plugin_t print |
---|
100 | ); |
---|
101 | |
---|
102 | #endif |
---|