Antonio de Angelis | f1c0851 | 2018-02-05 14:55:09 +0000 | [diff] [blame] | 1 | /* |
| 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 |
| 12 | extern "C" { |
| 13 | #endif |
| 14 | |
| 15 | #include "tfm_log_defs.h" |
| 16 | |
| 17 | /** |
| 18 | * \brief Retrieves the audit log |
| 19 | * |
Antonio de Angelis | 9a5bfea | 2018-03-27 13:13:55 +0100 | [diff] [blame] | 20 | * \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 Angelis | f1c0851 | 2018-02-05 14:55:09 +0000 | [diff] [blame] | 25 | * \param[in] size Maximum number of bytes to retrieve from the log |
Antonio de Angelis | 9a5bfea | 2018-03-27 13:13:55 +0100 | [diff] [blame] | 26 | * \param[in] start Index of element from where to start retrieval |
Antonio de Angelis | f1c0851 | 2018-02-05 14:55:09 +0000 | [diff] [blame] | 27 | * \param[out] buffer Pointer to the buffer that will hold the log |
Antonio de Angelis | 9a5bfea | 2018-03-27 13:13:55 +0100 | [diff] [blame] | 28 | * \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 Angelis | f1c0851 | 2018-02-05 14:55:09 +0000 | [diff] [blame] | 31 | * |
| 32 | * \return Returns TFM_LOG_ERR_SUCCESS if retrieval has been completed, |
| 33 | * otherwise error as specified in \ref tfm_log_err |
Antonio de Angelis | 9a5bfea | 2018-03-27 13:13:55 +0100 | [diff] [blame] | 34 | * |
| 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 Angelis | f1c0851 | 2018-02-05 14:55:09 +0000 | [diff] [blame] | 37 | */ |
| 38 | enum tfm_log_err tfm_log_retrieve(uint32_t size, |
Antonio de Angelis | 9a5bfea | 2018-03-27 13:13:55 +0100 | [diff] [blame] | 39 | int32_t start, |
Antonio de Angelis | f1c0851 | 2018-02-05 14:55:09 +0000 | [diff] [blame] | 40 | uint8_t *buffer, |
Antonio de Angelis | 9a5bfea | 2018-03-27 13:13:55 +0100 | [diff] [blame] | 41 | 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 | */ |
| 52 | enum 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 | */ |
| 68 | enum tfm_log_err tfm_log_delete_items(uint32_t num_items, |
| 69 | uint32_t *rem_items); |
Antonio de Angelis | f1c0851 | 2018-02-05 14:55:09 +0000 | [diff] [blame] | 70 | |
| 71 | #ifdef __cplusplus |
| 72 | } |
| 73 | #endif |
| 74 | |
| 75 | #endif /* __TFM_LOG_API__ */ |