blob: 6b7d0e6f67e056d10092898d0e6cafa9fe630f32 [file] [log] [blame]
Antonio de Angelisf1c08512018-02-05 14:55:09 +00001/*
2 * Copyright (c) 2018, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#ifndef __TFM_LOG_API__
9#define __TFM_LOG_API__
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15#include "tfm_log_defs.h"
16
17/**
18 * \brief Retrieves the audit log
19 *
Antonio de Angelis9a5bfea2018-03-27 13:13:55 +010020 * \details The function reads the audit log into the buffer provided.
21 * If provided buffer size is too small to fit the full log,
22 * the function will read the maximum number of items in the
23 * log that fit the available space in the buffer
24 *
Antonio de Angelisf1c08512018-02-05 14:55:09 +000025 * \param[in] size Maximum number of bytes to retrieve from the log
Antonio de Angelis9a5bfea2018-03-27 13:13:55 +010026 * \param[in] start Index of element from where to start retrieval
Antonio de Angelisf1c08512018-02-05 14:55:09 +000027 * \param[out] buffer Pointer to the buffer that will hold the log
Antonio de Angelis9a5bfea2018-03-27 13:13:55 +010028 * \param[out] info Pointer to the \ref tfm_log_info structure
29 * contained information related to the retrieved
30 * portion of the log (size and number of items)
Antonio de Angelisf1c08512018-02-05 14:55:09 +000031 *
32 * \return Returns TFM_LOG_ERR_SUCCESS if retrieval has been completed,
33 * otherwise error as specified in \ref tfm_log_err
Antonio de Angelis9a5bfea2018-03-27 13:13:55 +010034 *
35 * \note If start is equal to TFM_ALG_READ_RECENT, the function will
36 * retrieve the most recent elements that fit the provided size
Antonio de Angelisf1c08512018-02-05 14:55:09 +000037 */
38enum tfm_log_err tfm_log_retrieve(uint32_t size,
Antonio de Angelis9a5bfea2018-03-27 13:13:55 +010039 int32_t start,
Antonio de Angelisf1c08512018-02-05 14:55:09 +000040 uint8_t *buffer,
Antonio de Angelis9a5bfea2018-03-27 13:13:55 +010041 struct tfm_log_info *info);
42
43/**
44 * \brief Gets the log information
45 *
46 * \param[out] info Pointer to the \ref tfm_log_info structure that
47 * holds the current log size (both in bytes and items)
48 *
49 * \return Returns TFM_LOG_ERR_SUCCESS if reading has been completed,
50 * otherwise error as specified in \ref tfm_log_err
51 */
52enum tfm_log_err tfm_log_get_info(struct tfm_log_info *info);
53
54/**
55 * \brief Deletes one or more elements from the head of the log
56 *
57 * \param[in] num_items Number of elements to be deleted
58 * \param[out] rem_items Pointer to the number of elements removed. This
59 * value indicates the number of elements actually
60 * removed from the log. In case the number of items
61 * stored is less than the number of items requested
62 * to remove, this value will reflect the number of
63 * items effectively removed.
64 *
65 * \return Returns TFM_LOG_ERR_SUCCESS if removal has been completed,
66 * otherwise error as specified in \ref tfm_log_err
67 */
68enum tfm_log_err tfm_log_delete_items(uint32_t num_items,
69 uint32_t *rem_items);
Antonio de Angelisf1c08512018-02-05 14:55:09 +000070
71#ifdef __cplusplus
72}
73#endif
74
75#endif /* __TFM_LOG_API__ */