TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
audit_core.c File Reference
#include <stdint.h>
#include <string.h>
#include <stddef.h>
#include "audit_core.h"
#include "psa_audit_defs.h"
#include "tfm_secure_api.h"
Include dependency graph for audit_core.c:

Go to the source code of this file.

Data Structures

struct  log_vars
 Contains the state variables associated to the current state of the audit log. More...
 

Macros

#define AUDIT_UART_REDIRECTION   (0U)
 If set to 1 by the build system, UART redirection is enabled. Keep it disabled by default. More...
 
#define MEMBER_SIZE(type, member)   sizeof(((type *)0)->member)
 Standard macro to get size of elements in a struct. More...
 
#define LOG_FIXED_FIELD_SIZE
 Size of the mandatory header fields that are before the info received from the client partition, i.e. [TIMESTAMP][IV_COUNTER][PARTITION_ID][SIZE]. More...
 
#define LOG_SIZE   (1024)
 Size of the allocated space for the log, in bytes. More...
 

Functions

__STATIC_INLINE struct log_hdrGET_LOG_POINTER (const uint32_t idx)
 Static inline function to get the log buffer ptr from index. More...
 
__STATIC_INLINE uint32_t * GET_SIZE_FIELD_POINTER (const uint32_t idx)
 Static inline function to get the pointer to the SIZE field. More...
 
__STATIC_INLINE uint32_t COMPUTE_LOG_ENTRY_SIZE (const uint32_t size)
 Static inline function to compute the full log entry size starting from the value of the size field. More...
 
__STATIC_INLINE uint32_t GET_NEXT_LOG_INDEX (const uint32_t idx)
 Static inline function to get the index to the base of the log buffer for the next item with respect to the current item. More...
 
psa_status_t audit_core_init (void)
 Initializes the Audit logging service during the TFM boot up process. More...
 
psa_status_t audit_core_delete_record (psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
 
psa_status_t audit_core_get_info (psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
 
psa_status_t audit_core_get_record_info (psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
 
psa_status_t audit_core_add_record (psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
 
psa_status_t audit_core_retrieve_record (psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
 

Macro Definition Documentation

#define AUDIT_UART_REDIRECTION   (0U)

If set to 1 by the build system, UART redirection is enabled. Keep it disabled by default.

Definition at line 22 of file audit_core.c.

#define LOG_FIXED_FIELD_SIZE
Value:
(MEMBER_SIZE(struct log_hdr, timestamp) + \
MEMBER_SIZE(struct log_hdr, iv_counter) + \
MEMBER_SIZE(struct log_hdr, partition_id) + \
MEMBER_SIZE(struct log_hdr, size))
Fixed size header for a log record.
Definition: audit_core.h:99
#define MEMBER_SIZE(type, member)
Standard macro to get size of elements in a struct.
Definition: audit_core.c:67

Size of the mandatory header fields that are before the info received from the client partition, i.e. [TIMESTAMP][IV_COUNTER][PARTITION_ID][SIZE].

Definition at line 76 of file audit_core.c.

#define LOG_SIZE   (1024)

Size of the allocated space for the log, in bytes.

Note
Must be a multiple of 8 bytes.

Definition at line 87 of file audit_core.c.

#define MEMBER_SIZE (   type,
  member 
)    sizeof(((type *)0)->member)

Standard macro to get size of elements in a struct.

Definition at line 67 of file audit_core.c.

Function Documentation

__STATIC_INLINE uint32_t COMPUTE_LOG_ENTRY_SIZE ( const uint32_t  size)

Static inline function to compute the full log entry size starting from the value of the size field.

Parameters
[in]sizeSize of the log line from which derive the size of the whole log item
Returns
Full log item size

Definition at line 181 of file audit_core.c.

Here is the caller graph for this function:

__STATIC_INLINE struct log_hdr* GET_LOG_POINTER ( const uint32_t  idx)

Static inline function to get the log buffer ptr from index.

Parameters
[in]idxByte index to be converted to pointer in the log buffer
Returns
Pointer at the beginning of the log item in the log buffer

Definition at line 152 of file audit_core.c.

Here is the caller graph for this function:

__STATIC_INLINE uint32_t GET_NEXT_LOG_INDEX ( const uint32_t  idx)

Static inline function to get the index to the base of the log buffer for the next item with respect to the current item.

Parameters
[in]idxByte index of the current item in the log
Returns
Index of the next item in the log

Definition at line 195 of file audit_core.c.

Here is the call graph for this function:

Here is the caller graph for this function:

__STATIC_INLINE uint32_t* GET_SIZE_FIELD_POINTER ( const uint32_t  idx)

Static inline function to get the pointer to the SIZE field.

Parameters
[in]idxByte index to which retrieve the corresponding size pointer
Returns
Pointer to the size field in the log item header

Definition at line 165 of file audit_core.c.

Here is the call graph for this function:

Here is the caller graph for this function: