TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ps_nv_counters.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #include "ps_nv_counters.h"
9 #include "tfm_platform_api.h"
10 
11 psa_status_t ps_read_nv_counter(enum tfm_nv_counter_t counter_id,
12  uint32_t *val)
13 {
14  enum tfm_platform_err_t err;
15 
17  (uint8_t *)val);
18  if (err != TFM_PLATFORM_ERR_SUCCESS) {
20  }
21 
22  return PSA_SUCCESS;
23 }
24 
25 psa_status_t ps_increment_nv_counter(enum tfm_nv_counter_t counter_id)
26 {
27  enum tfm_platform_err_t err;
28 
29  /* NOTE: tfm_plat_increment_nv_counter returns TFM_PLAT_ERR_MAX_VALUE when
30  * the counter reaches its maximum value. The current PS
31  * implementation treats this condition as an error as, from that
32  * moment onwards, the rollback protection can not be achieved based
33  * on the NV counters.
34  */
35  err = tfm_platform_nv_counter_increment(counter_id);
36  if (err != TFM_PLATFORM_ERR_SUCCESS) {
38  }
39 
40  return PSA_SUCCESS;
41 }
#define PS_NV_COUNTER_SIZE
enum tfm_platform_err_t tfm_platform_nv_counter_read(uint32_t counter_id, uint32_t size, uint8_t *val)
Reads the given non-volatile (NV) counter.
psa_status_t ps_increment_nv_counter(enum tfm_nv_counter_t counter_id)
Increments the given non-volatile (NV) counter.
#define PSA_SUCCESS
Definition: crypto_values.h:35
psa_status_t ps_read_nv_counter(enum tfm_nv_counter_t counter_id, uint32_t *val)
Reads the given non-volatile (NV) counter.
#define PSA_ERROR_GENERIC_ERROR
Definition: crypto_values.h:43
enum tfm_platform_err_t tfm_platform_nv_counter_increment(uint32_t counter_id)
Increments the given non-volatile (NV) counter by one.
tfm_platform_err_t
Platform service error types.
int32_t psa_status_t
Function return status.
Definition: crypto_types.h:43