blob: c987ed7a584f807832eae004ad60461421b6538c [file] [log] [blame]
Marc Moreno Berengue4cc81fc2018-08-10 14:32:01 +01001/*
2 * Copyright (c) 2018, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#ifndef __TFM_PLAT_NV_COUNTERS_H__
9#define __TFM_PLAT_NV_COUNTERS_H__
10
11/**
12 * \file tfm_plat_nv_counters.h
13 *
14 * \note The interfaces defined in this file must be implemented for each
15 * SoC.
16 */
17
18#include <stdint.h>
19#include "tfm_plat_defs.h"
20
21enum tfm_nv_counter_t {
22 TFM_SST_NV_COUNTER_1 = 0,
23 TFM_SST_NV_COUNTER_2,
24 TFM_SST_NV_COUNTER_3,
25};
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31/**
32 * \brief Initialises all non-volatile (NV) counters.
33 *
34 * \return TFM_PLAT_ERR_SUCCESS if the initialization succeeds, otherwise
35 * TFM_PLAT_ERR_SYSTEM_ERR
36 */
37enum tfm_plat_err_t tfm_plat_init_nv_counter(void);
38
39/**
40 * \brief Reads the given non-volatile (NV) counter.
41 *
42 * \param[in] counter_id NV counter ID.
43 * \param[in] size Size of the buffer to store NV counter value
44 * in bytes.
45 * \param[out] val Pointer to store the current NV counter value.
46 *
47 * \return TFM_PLAT_ERR_SUCCESS if the value is read correctly. Otherwise,
48 * it returns TFM_PLAT_ERR_SYSTEM_ERR.
49 */
50enum tfm_plat_err_t tfm_plat_read_nv_counter(enum tfm_nv_counter_t counter_id,
51 uint32_t size, uint8_t *val);
52
53/**
54 * \brief Increments the given non-volatile (NV) counter.
55 *
56 * \param[in] counter_id NV counter ID.
57 *
58 * \return When the NV counter reaches its maximum value, the
59 * TFM_PLAT_ERR_MAX_VALUE error is returned to indicate the value
60 * cannot be incremented. Otherwise, it returns TFM_PLAT_ERR_SUCCESS.
61 */
62enum tfm_plat_err_t tfm_plat_increment_nv_counter(
63 enum tfm_nv_counter_t counter_id);
64
65#ifdef __cplusplus
66}
67#endif
68
69#endif /* __TFM_PLAT_NV_COUNTERS_H__ */