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

Go to the source code of this file.

Macros

#define PS_INVALID_FID   0
 
#define PS_DEFAULT_EMPTY_BUFF_VAL   0
 
#define PS_UTILS_BOUND_CHECK(err_msg, data_size, data_buf_size)   typedef char err_msg[(data_size <= data_buf_size)*2 - 1]
 Macro to check, at compilation time, if data fits in data buffer. More...
 
#define PS_UTILS_MIN(x, y)   (((x) < (y)) ? (x) : (y))
 Evaluates to the minimum of the two parameters. More...
 

Functions

psa_status_t ps_utils_check_contained_in (uint32_t superset_size, uint32_t subset_offset, uint32_t subset_size)
 Checks if a subset region is fully contained within a superset region. More...
 

Macro Definition Documentation

#define PS_DEFAULT_EMPTY_BUFF_VAL   0

Definition at line 21 of file ps_utils.h.

#define PS_INVALID_FID   0

Definition at line 20 of file ps_utils.h.

#define PS_UTILS_BOUND_CHECK (   err_msg,
  data_size,
  data_buf_size 
)    typedef char err_msg[(data_size <= data_buf_size)*2 - 1]

Macro to check, at compilation time, if data fits in data buffer.

Parameters
[in]err_msgError message which will be displayed in first instance if the error is triggered
[in]data_sizeData size to check if it fits
[in]data_buf_sizeSize of the data buffer
Returns
Triggers a compilation error if data_size is bigger than data_buf_size. The compilation error should be "... error: 'err_msg' declared as an array with a negative size"

Definition at line 35 of file ps_utils.h.

#define PS_UTILS_MIN (   x,
 
)    (((x) < (y)) ? (x) : (y))

Evaluates to the minimum of the two parameters.

Definition at line 41 of file ps_utils.h.

Function Documentation

psa_status_t ps_utils_check_contained_in ( uint32_t  superset_size,
uint32_t  subset_offset,
uint32_t  subset_size 
)

Checks if a subset region is fully contained within a superset region.

Parameters
[in]superset_sizeSize of superset region
[in]subset_offsetOffset of start of subset region from start of superset region
[in]subset_sizeSize of subset region
Returns
Returns error code as specified in psa_status_t
Return values
PSA_SUCCESSThe subset is contained within the superset
PSA_ERROR_INVALID_ARGUMENTThe subset offset is greater than the size of the superset or when the subset offset is valid, but the subset offset + size is greater than the size of the superset

Definition at line 10 of file ps_utils.c.

Here is the caller graph for this function: