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
Static Memory Reservation

Fixed-size memory pools reserved at initialization (ADR-001). More...

Files

file  src/oal/memory/rte_memory.c
 Memory pool service: validates parameters, then dispatches to the OSAdapter registered via rte_osadapter_memory_register() (ADR-005).

Data Structures

struct  rte_mem_pool_config_t
 Configuration for rte_mem_pool_create(). More...

Typedefs

typedef struct rte_mem_pool_impl_s * rte_mem_pool_handle_t
 Opaque handle to a reserved pool, returned by rte_mem_pool_create().

Functions

 RTE_DECLARE_STORAGE (rte_mem_pool_storage_t, 64U)
 Caller-owned, fixed-size storage backing one rte_mem_pool_handle_t.
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.
rte_status_t rte_mem_pool_acquire (rte_mem_pool_handle_t handle, void **out_block)
 Acquires one fixed-size block from the pool.
rte_status_t rte_mem_pool_release (rte_mem_pool_handle_t handle, void *block)
 Returns a previously acquired block to its pool.
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.

Detailed Description

Fixed-size memory pools reserved at initialization (ADR-001).

Typedef Documentation

◆ rte_mem_pool_handle_t

typedef struct rte_mem_pool_impl_s* rte_mem_pool_handle_t

Opaque handle to a reserved pool, returned by rte_mem_pool_create().

Definition at line 32 of file rte_memory.h.

Function Documentation

◆ rte_mem_pool_create()

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.

Parameters
storageCaller-owned storage for the handle's state. Must not be NULL.
configPool configuration. Must not be NULL; config->block_size and config->block_count must both be > 0.
out_handleReceives the created pool's handle. Must not be NULL.
Returns
RTE_STATUS_OK; RTE_STATUS_INVALID_PARAM for a bad argument; RTE_STATUS_NOT_INITIALIZED if no OSAdapter is registered (rte_osadapter_memory_register()); RTE_STATUS_NOT_SUPPORTED if the registered OSAdapter does not implement create; RTE_STATUS_TIMEOUT if the OSAdapter's pool lock was not acquired within its bound (no pool reserved, REQ-OAL-MEM-015). REQ-OAL-MEM-010

Definition at line 44 of file rte_memory.c.

◆ rte_mem_pool_acquire()

rte_status_t rte_mem_pool_acquire ( rte_mem_pool_handle_t handle,
void ** out_block )

Acquires one fixed-size block from the pool.

Parameters
handlePool handle. Must not be NULL.
out_blockReceives a pointer to the acquired block. Must not be NULL; set to NULL on failure.
Returns
RTE_STATUS_OK; RTE_STATUS_INVALID_PARAM; RTE_STATUS_RESOURCE_EXHAUSTED if no blocks remain; RTE_STATUS_NOT_INITIALIZED/RTE_STATUS_NOT_SUPPORTED as in rte_mem_pool_create(); RTE_STATUS_TIMEOUT if the OSAdapter's pool lock was not acquired within its bound (pool unchanged, *out_block NULL, REQ-OAL-MEM-015). REQ-OAL-MEM-011

Definition at line 77 of file rte_memory.c.

◆ rte_mem_pool_release()

rte_status_t rte_mem_pool_release ( rte_mem_pool_handle_t handle,
void * block )

Returns a previously acquired block to its pool.

Parameters
handlePool handle. Must not be NULL.
blockBlock previously returned by rte_mem_pool_acquire(). Must not be NULL.
Returns
RTE_STATUS_OK; RTE_STATUS_INVALID_PARAM; RTE_STATUS_NOT_INITIALIZED/ RTE_STATUS_NOT_SUPPORTED as in rte_mem_pool_create(); RTE_STATUS_TIMEOUT if the OSAdapter's pool lock was not acquired within its bound (pool unchanged, REQ-OAL-MEM-015): the block was not returned and still belongs to the caller, who may retry the release. REQ-OAL-MEM-012

Definition at line 95 of file rte_memory.c.

◆ rte_mem_pool_stats()

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.

Parameters
handlePool handle. Must not be NULL.
out_free_blocksReceives the number of free blocks. Must not be NULL.
out_used_blocksReceives the number of used blocks. Must not be NULL.
Returns
RTE_STATUS_OK; RTE_STATUS_INVALID_PARAM; RTE_STATUS_NOT_INITIALIZED/ RTE_STATUS_NOT_SUPPORTED as in rte_mem_pool_create(); RTE_STATUS_TIMEOUT if the OSAdapter's pool lock was not acquired within its bound (no counts read: both outputs stay 0, REQ-OAL-MEM-015). REQ-OAL-MEM-013

Definition at line 112 of file rte_memory.c.