Safe API Framework 0.1.0 build 384e6ae
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Loading...
Searching...
No Matches
rte_memory.c
Go to the documentation of this file.
1
10
12
14
18
20
22
23
26{
27 rte_status_t lifecycle_status;
28
29 if (osadapter == NULL)
30 {
32 }
33 /* REQ-LIFECYCLE-001 (ADR-026): registering an OSAdapter is a setup-only
34 * action - refuse once the application's setup phase has been locked. */
35 lifecycle_status = rte_lifecycle_check_setup_allowed();
36 if (lifecycle_status != RTE_STATUS_OK)
37 {
38 return lifecycle_status;
39 }
40 s_osadapter = osadapter;
41 return RTE_STATUS_OK;
42}
43
44rte_status_t rte_mem_pool_create(rte_mem_pool_storage_t *storage,
45 const rte_mem_pool_config_t *config,
46 rte_mem_pool_handle_t *out_handle)
47{
48 rte_status_t lifecycle_status;
49
50 if ((storage == NULL) || (config == NULL) || (out_handle == NULL))
51 {
53 }
54 if ((config->block_size == 0U) || (config->block_count == 0U))
55 {
57 }
58 *out_handle = NULL;
59 /* REQ-LIFECYCLE-001 (ADR-026): a memory pool is a setup-only resource -
60 * refuse once the application's setup phase has been locked. */
61 lifecycle_status = rte_lifecycle_check_setup_allowed();
62 if (lifecycle_status != RTE_STATUS_OK)
63 {
64 return lifecycle_status;
65 }
66 if (s_osadapter == NULL)
67 {
69 }
70 if (s_osadapter->create == NULL)
71 {
73 }
74 return s_osadapter->create(storage, config, out_handle);
75}
76
78{
79 if ((handle == NULL) || (out_block == NULL))
80 {
82 }
83 *out_block = NULL;
84 if (s_osadapter == NULL)
85 {
87 }
88 if (s_osadapter->acquire == NULL)
89 {
91 }
92 return s_osadapter->acquire(handle, out_block);
93}
94
96{
97 if ((handle == NULL) || (block == NULL))
98 {
100 }
101 if (s_osadapter == NULL)
102 {
104 }
105 if (s_osadapter->release == NULL)
106 {
108 }
109 return s_osadapter->release(handle, block);
110}
111
113 size_t *out_free_blocks,
114 size_t *out_used_blocks)
115{
116 if ((handle == NULL) || (out_free_blocks == NULL) || (out_used_blocks == NULL))
117 {
119 }
120 *out_free_blocks = 0U;
121 *out_used_blocks = 0U;
122 if (s_osadapter == NULL)
123 {
125 }
126 if (s_osadapter->stats == NULL)
127 {
129 }
130 return s_osadapter->stats(handle, out_free_blocks, out_used_blocks);
131}
rte_status_t rte_lifecycle_check_setup_allowed(void)
Convenience check for a setup-only constructor: call this as one of the first checks in any function ...
rte_status_t rte_mem_pool_release(rte_mem_pool_handle_t handle, void *block)
Returns a previously acquired block to its pool.
Definition rte_memory.c:95
rte_status_t rte_mem_pool_acquire(rte_mem_pool_handle_t handle, void **out_block)
Acquires one fixed-size block from the pool.
Definition rte_memory.c:77
struct rte_mem_pool_impl_s * rte_mem_pool_handle_t
Opaque handle to a reserved pool, returned by rte_mem_pool_create().
Definition rte_memory.h:32
rte_status_t rte_mem_pool_stats(rte_mem_pool_handle_t handle, size_t *out_free_blocks, size_t *out_used_blocks)
Reports current free/used block counts for diagnostics.
Definition rte_memory.c:112
rte_status_t rte_mem_pool_create(rte_mem_pool_storage_t *storage, const rte_mem_pool_config_t *config, rte_mem_pool_handle_t *out_handle)
Reserves a fixed-size-block memory pool.
Definition rte_memory.c:44
rte_status_t
Common result/status codes.
Definition rte_status.h:27
@ RTE_STATUS_OK
Definition rte_status.h:28
@ RTE_STATUS_INVALID_PARAM
Definition rte_status.h:29
@ RTE_STATUS_NOT_SUPPORTED
Definition rte_status.h:34
@ RTE_STATUS_NOT_INITIALIZED
Definition rte_status.h:30
static const rte_osadapter_clocksync_t * s_osadapter
Process-wide application setup-phase lock (ADR-026).
OS Abstraction Layer - Static memory reservation service.
OSAdapter interface for static memory pool management.
rte_status_t rte_osadapter_memory_register(const rte_osadapter_memory_t *adapter)
Registers the OSAdapter memory implementation.
Definition rte_memory.c:25
Configuration for rte_mem_pool_create().
Definition rte_memory.h:36
OSAdapter memory pool operations vtable.