RTEMS: cpukit/include/rtems/rtl/rtl-allocator.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
rtl-allocator.h
Go to the documentation of this file.
1/*
2 * COPYRIGHT (c) 2012, 2018 Chris Johns <chrisj@rtems.org>
3 *
4 * The license and distribution terms for this file may be
5 * found in the file LICENSE in this distribution or at
6 * http://www.rtems.org/license/LICENSE.
7 */
16#if !defined (_RTEMS_RTL_ALLOCATOR_H_)
17#define _RTEMS_RTL_ALLOCATOR_H_
18
19#include <stdbool.h>
20
21#include "rtl-indirect-ptr.h"
22
23#ifdef __cplusplus
24extern "C" {
25#endif /* __cplusplus */
26
33 enum rtems_rtl_alloc_tags {
34 RTEMS_RTL_ALLOC_OBJECT,
35 RTEMS_RTL_ALLOC_SYMBOL,
36 RTEMS_RTL_ALLOC_EXTERNAL,
37 RTEMS_RTL_ALLOC_READ,
38 RTEMS_RTL_ALLOC_READ_WRITE,
39 RTEMS_RTL_ALLOC_READ_EXEC
40};
41
45 typedef enum rtems_rtl_alloc_tags rtems_rtl_alloc_tag;
46
50 enum rtems_rtl_alloc_cmd {
51 RTEMS_RTL_ALLOC_NEW,
52 RTEMS_RTL_ALLOC_DEL,
53 RTEMS_RTL_ALLOC_LOCK,
54 RTEMS_RTL_ALLOC_UNLOCK,
55 RTEMS_RTL_ALLOC_WR_ENABLE,
56 RTEMS_RTL_ALLOC_WR_DISABLE,
57};
58
62 typedef enum rtems_rtl_alloc_cmd rtems_rtl_alloc_cmd;
63
67#define RTEMS_RTL_ALLOC_TAGS ((size_t) (RTEMS_RTL_ALLOC_READ_EXEC + 1))
68
83 typedef void (*rtems_rtl_allocator)(rtems_rtl_alloc_cmd cmd,
84 rtems_rtl_alloc_tag tag,
85 void** address,
86 size_t size);
87
91 struct rtems_rtl_alloc_data {
93 rtems_rtl_allocator allocator;
95 rtems_chain_control indirects[RTEMS_RTL_ALLOC_TAGS];
96};
97
98typedef struct rtems_rtl_alloc_data rtems_rtl_alloc_data;
99
105void rtems_rtl_alloc_initialise (rtems_rtl_alloc_data* data);
106
116void* rtems_rtl_alloc_new (rtems_rtl_alloc_tag tag, size_t size, bool zero);
117
124void rtems_rtl_alloc_del (rtems_rtl_alloc_tag tag, void* address);
125
133void rtems_rtl_alloc_lock (void);
134
142void rtems_rtl_alloc_unlock (void);
143
150void rtems_rtl_alloc_wr_enable (rtems_rtl_alloc_tag tag, void* address);
151
158void rtems_rtl_alloc_wr_disable (rtems_rtl_alloc_tag tag, void* address);
159
169 rtems_rtl_allocator rtems_rtl_alloc_hook (rtems_rtl_allocator handler);
170
178void rtems_rtl_alloc_indirect_new (rtems_rtl_alloc_tag tag,
179 rtems_rtl_ptr* handle,
180 size_t size);
181
188void rtems_rtl_alloc_indirect_del (rtems_rtl_alloc_tag tag,
189 rtems_rtl_ptr* handle);
190
196 rtems_rtl_alloc_tag rtems_rtl_alloc_text_tag (void);
197
203 rtems_rtl_alloc_tag rtems_rtl_alloc_const_tag (void);
204
210 rtems_rtl_alloc_tag rtems_rtl_alloc_eh_tag (void);
211
217 rtems_rtl_alloc_tag rtems_rtl_alloc_data_tag (void);
218
224 rtems_rtl_alloc_tag rtems_rtl_alloc_bss_tag (void);
225
244bool rtems_rtl_alloc_module_new (void** text_base, size_t text_size,
245 void** const_base, size_t const_size,
246 void** eh_base, size_t eh_size,
247 void** data_base, size_t data_size,
248 void** bss_base, size_t bss_size);
249
259void rtems_rtl_alloc_module_del (void** text_base, void** const_base,
260 void** eh_base, void** data_base,
261 void** bss_base);
262
263#ifdef __cplusplus
264}
265#endif /* __cplusplus */
266
267#endif
rtems_rtl_alloc_bss_tag
rtems_rtl_alloc_tag rtems_rtl_alloc_bss_tag(void)
Definition: rtl-allocator.c:246
rtems_rtl_alloc_indirect_new
void rtems_rtl_alloc_indirect_new(rtems_rtl_alloc_tag tag, rtems_rtl_ptr *handle, size_t size)
Definition: rtl-allocator.c:172
rtems_rtl_alloc_text_tag
rtems_rtl_alloc_tag rtems_rtl_alloc_text_tag(void)
Definition: rtl-allocator.c:222
rtems_rtl_alloc_unlock
void rtems_rtl_alloc_unlock(void)
Definition: rtl-allocator.c:129
rtems_rtl_alloc_initialise
void rtems_rtl_alloc_initialise(rtems_rtl_alloc_data *data)
Definition: rtl-allocator.c:42
rtems_rtl_alloc_hook
rtems_rtl_allocator rtems_rtl_alloc_hook(rtems_rtl_allocator handler)
Definition: rtl-allocator.c:162
rtems_rtl_alloc_wr_enable
void rtems_rtl_alloc_wr_enable(rtems_rtl_alloc_tag tag, void *address)
Definition: rtl-allocator.c:94
rtems_rtl_alloc_tag
enum rtems_rtl_alloc_tags rtems_rtl_alloc_tag
Definition: rtl-allocator.h:45
rtems_rtl_alloc_del
void rtems_rtl_alloc_del(rtems_rtl_alloc_tag tag, void *address)
Definition: rtl-allocator.c:79
RTEMS_RTL_ALLOC_TAGS
#define RTEMS_RTL_ALLOC_TAGS
Definition: rtl-allocator.h:67
rtems_rtl_alloc_module_del
void rtems_rtl_alloc_module_del(void **text_base, void **const_base, void **eh_base, void **data_base, void **bss_base)
Definition: rtl-allocator.c:322
rtems_rtl_alloc_tags
rtems_rtl_alloc_tags
Definition: rtl-allocator.h:33
RTEMS_RTL_ALLOC_READ
@ RTEMS_RTL_ALLOC_READ
Definition: rtl-allocator.h:37
RTEMS_RTL_ALLOC_READ_EXEC
@ RTEMS_RTL_ALLOC_READ_EXEC
Definition: rtl-allocator.h:39
RTEMS_RTL_ALLOC_EXTERNAL
@ RTEMS_RTL_ALLOC_EXTERNAL
Definition: rtl-allocator.h:36
RTEMS_RTL_ALLOC_SYMBOL
@ RTEMS_RTL_ALLOC_SYMBOL
Definition: rtl-allocator.h:35
RTEMS_RTL_ALLOC_READ_WRITE
@ RTEMS_RTL_ALLOC_READ_WRITE
Definition: rtl-allocator.h:38
RTEMS_RTL_ALLOC_OBJECT
@ RTEMS_RTL_ALLOC_OBJECT
Definition: rtl-allocator.h:34
rtems_rtl_alloc_wr_disable
void rtems_rtl_alloc_wr_disable(rtems_rtl_alloc_tag tag, void *address)
Definition: rtl-allocator.c:145
rtems_rtl_alloc_new
void * rtems_rtl_alloc_new(rtems_rtl_alloc_tag tag, size_t size, bool zero)
Definition: rtl-allocator.c:51
rtems_rtl_allocator
void(* rtems_rtl_allocator)(rtems_rtl_alloc_cmd cmd, rtems_rtl_alloc_tag tag, void **address, size_t size)
Definition: rtl-allocator.h:83
rtems_rtl_alloc_cmd
rtems_rtl_alloc_cmd
Definition: rtl-allocator.h:50
RTEMS_RTL_ALLOC_UNLOCK
@ RTEMS_RTL_ALLOC_UNLOCK
Definition: rtl-allocator.h:54
RTEMS_RTL_ALLOC_DEL
@ RTEMS_RTL_ALLOC_DEL
Definition: rtl-allocator.h:52
RTEMS_RTL_ALLOC_NEW
@ RTEMS_RTL_ALLOC_NEW
Definition: rtl-allocator.h:51
RTEMS_RTL_ALLOC_WR_ENABLE
@ RTEMS_RTL_ALLOC_WR_ENABLE
Definition: rtl-allocator.h:55
RTEMS_RTL_ALLOC_LOCK
@ RTEMS_RTL_ALLOC_LOCK
Definition: rtl-allocator.h:53
RTEMS_RTL_ALLOC_WR_DISABLE
@ RTEMS_RTL_ALLOC_WR_DISABLE
Definition: rtl-allocator.h:56
rtems_rtl_alloc_data_tag
rtems_rtl_alloc_tag rtems_rtl_alloc_data_tag(void)
Definition: rtl-allocator.c:240
rtems_rtl_alloc_eh_tag
rtems_rtl_alloc_tag rtems_rtl_alloc_eh_tag(void)
Definition: rtl-allocator.c:234
rtems_rtl_alloc_const_tag
rtems_rtl_alloc_tag rtems_rtl_alloc_const_tag(void)
Definition: rtl-allocator.c:228
rtems_rtl_alloc_lock
void rtems_rtl_alloc_lock(void)
Definition: rtl-allocator.c:111
rtems_rtl_alloc_module_new
bool rtems_rtl_alloc_module_new(void **text_base, size_t text_size, void **const_base, size_t const_size, void **eh_base, size_t eh_size, void **data_base, size_t data_size, void **bss_base, size_t bss_size)
Definition: rtl-allocator.c:252
rtems_rtl_alloc_indirect_del
void rtems_rtl_alloc_indirect_del(rtems_rtl_alloc_tag tag, rtems_rtl_ptr *handle)
Definition: rtl-allocator.c:200
rtl-indirect-ptr.h
RTEMS Run-Time Linker Indirect Pointer Management allows memory compaction in the allocator.
rtems_rtl_alloc_data
Definition: rtl-allocator.h:91
rtems_rtl_alloc_data::allocator
rtems_rtl_allocator allocator
Definition: rtl-allocator.h:93
rtems_rtl_ptr
Definition: rtl-indirect-ptr.h:29
Chain_Control
Definition: chain.h:86