TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tfm_pools.h File Reference
#include <stdbool.h>
Include dependency graph for tfm_pools.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  tfm_pool_chunk_t
 
struct  tfm_pool_chunk_s_t
 
struct  tfm_pool_instance_t
 

Macros

#define TFM_POOL_DECLARE(name, chunksz, num)
 
#define POOL_HEAD_SIZE
 
#define POOL_BUFFER_SIZE(name)   sizeof(name##_pool_buf)
 

Functions

int32_t tfm_pool_init (struct tfm_pool_instance_t *pool, size_t poolsz, size_t chunksz, size_t num)
 Register a memory pool. More...
 
void * tfm_pool_alloc (struct tfm_pool_instance_t *pool)
 Allocate a memory from pool. More...
 
void tfm_pool_free (void *ptr)
 Free the allocated memory. More...
 
bool is_valid_chunk_data_in_pool (struct tfm_pool_instance_t *pool, uint8_t *data)
 Checks whether a pointer points to a chunk data in the pool. More...
 

Macro Definition Documentation

#define POOL_BUFFER_SIZE (   name)    sizeof(name##_pool_buf)

Definition at line 67 of file tfm_pools.h.

#define POOL_HEAD_SIZE
Value:

Definition at line 63 of file tfm_pools.h.

#define TFM_POOL_DECLARE (   name,
  chunksz,
  num 
)
Value:
static uint8_t name##_pool_buf[((chunksz) + \
sizeof(struct tfm_pool_chunk_t)) * (num) \
+ sizeof(struct tfm_pool_instance_t)] \
__attribute__((aligned(4))); \
static struct tfm_pool_instance_t *name = \
(struct tfm_pool_instance_t *)name##_pool_buf

Definition at line 54 of file tfm_pools.h.

Function Documentation

bool is_valid_chunk_data_in_pool ( struct tfm_pool_instance_t pool,
uint8_t *  data 
)

Checks whether a pointer points to a chunk data in the pool.

Parameters
[in]poolPointer to memory pool declared by TFM_POOL_DECLARE.
[in]dataThe pointer to check.
Return values
trueData is a chunk data in the pool.
falseData is not a chunk data in the pool.

Definition at line 90 of file tfm_pools.c.

Here is the caller graph for this function:

void* tfm_pool_alloc ( struct tfm_pool_instance_t pool)

Allocate a memory from pool.

Parameters
[in]poolpool pointer decleared by TFM_POOL_DECLARE
Return values
bufferpointer Success.
NULLFailed.

Definition at line 58 of file tfm_pools.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void tfm_pool_free ( void *  ptr)

Free the allocated memory.

Parameters
[in]ptrBuffer pointer want to free.

Definition at line 80 of file tfm_pools.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int32_t tfm_pool_init ( struct tfm_pool_instance_t pool,
size_t  poolsz,
size_t  chunksz,
size_t  num 
)

Register a memory pool.

Parameters
[in]poolPointer to memory pool declared by TFM_POOL_DECLARE
[in]poolszSize of the pool buffer.
[in]chunkszSize of chunks.
[in]numNumber of chunks.
Return values
IPC_SUCCESSSuccess.
IPC_ERROR_BAD_PARAMETERSParameters error.

Definition at line 22 of file tfm_pools.c.

Here is the call graph for this function:

Here is the caller graph for this function: