blob: 8c9b0db1fa0088aaaa46c13704bd81d5bf9b7aff [file] [log] [blame]
Marc Moreno Berengue8e0fa7a2018-10-04 18:25:13 +01001/*
Galanakis, Minosef5118b2020-01-21 15:27:14 +00002 * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
Marc Moreno Berengue8e0fa7a2018-10-04 18:25:13 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#ifndef __TFM_PLATFORM_API__
9#define __TFM_PLATFORM_API__
10
11#include <limits.h>
Tamas Kaman262dc7b2019-03-20 13:37:12 +010012#include <stdbool.h>
Miklos Balintc7b1b6c2019-04-24 12:38:36 +020013#include <stdint.h>
Marc Moreno Berengue8e0fa7a2018-10-04 18:25:13 +010014#include "tfm_api.h"
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20/**
21 * \brief TFM secure partition platform API version
22 */
23#define TFM_PLATFORM_API_VERSION_MAJOR (0)
Miklos Balintc7b1b6c2019-04-24 12:38:36 +020024#define TFM_PLATFORM_API_VERSION_MINOR (3)
Marc Moreno Berengue8e0fa7a2018-10-04 18:25:13 +010025
Galanakis, Minosef5118b2020-01-21 15:27:14 +000026#define TFM_PLATFORM_API_ID_NV_READ (1010)
27#define TFM_PLATFORM_API_ID_NV_INCREMENT (1011)
28
Marc Moreno Berengue8e0fa7a2018-10-04 18:25:13 +010029/*!
30 * \enum tfm_platform_err_t
31 *
32 * \brief Platform service error types
33 *
34 */
35enum tfm_platform_err_t {
36 TFM_PLATFORM_ERR_SUCCESS = 0,
Mate Toth-Pal8af8b032019-07-18 10:49:00 +020037 TFM_PLATFORM_ERR_SYSTEM_ERROR,
Tamas Kaman262dc7b2019-03-20 13:37:12 +010038 TFM_PLATFORM_ERR_INVALID_PARAM,
Miklos Balintc7b1b6c2019-04-24 12:38:36 +020039 TFM_PLATFORM_ERR_NOT_SUPPORTED,
Marc Moreno Berengue8e0fa7a2018-10-04 18:25:13 +010040
41 /* Following entry is only to ensure the error code of int size */
42 TFM_PLATFORM_ERR_FORCE_INT_SIZE = INT_MAX
43};
44
Miklos Balintc7b1b6c2019-04-24 12:38:36 +020045typedef int32_t tfm_platform_ioctl_req_t;
46
Marc Moreno Berengue8e0fa7a2018-10-04 18:25:13 +010047/*!
48 * \brief Resets the system.
49 *
50 * \return Returns values as specified by the \ref tfm_platform_err_t
51 */
52enum tfm_platform_err_t tfm_platform_system_reset(void);
53
Tamas Kaman262dc7b2019-03-20 13:37:12 +010054/*!
Miklos Balintc7b1b6c2019-04-24 12:38:36 +020055 * \brief Performs a platform-specific service
Tamas Kaman262dc7b2019-03-20 13:37:12 +010056 *
Miklos Balintc7b1b6c2019-04-24 12:38:36 +020057 * \param[in] request Request identifier (valid values vary
Tamas Kaman262dc7b2019-03-20 13:37:12 +010058 * based on the platform)
Miklos Balintc7b1b6c2019-04-24 12:38:36 +020059 * \param[in] input Input buffer to the requested service (or NULL)
60 * \param[in,out] output Output buffer to the requested service (or NULL)
Tamas Kaman262dc7b2019-03-20 13:37:12 +010061 *
62 * \return Returns values as specified by the \ref tfm_platform_err_t
63 */
Miklos Balintc7b1b6c2019-04-24 12:38:36 +020064enum tfm_platform_err_t tfm_platform_ioctl(tfm_platform_ioctl_req_t request,
65 psa_invec *input,
66 psa_outvec *output);
Tamas Kaman262dc7b2019-03-20 13:37:12 +010067
Galanakis, Minosef5118b2020-01-21 15:27:14 +000068/*!
69 * \brief Increments the given non-volatile (NV) counter by one
70 *
71 * \param[in] counter_id NV counter ID.
72 *
73 * \return TFM_PLATFORM_ERR_SUCCESS if the value is read correctly. Otherwise,
74 * it returns TFM_PLATFORM_ERR_SYSTEM_ERROR.
75 */
76enum tfm_platform_err_t
77tfm_platform_nv_counter_increment(uint32_t counter_id);
78
79/*!
80 * \brief Reads the given non-volatile (NV) counter
81 *
82 * \param[in] counter_id NV counter ID.
83 * \param[in] size Size of the buffer to store NV counter value
84 * in bytes.
85 * \param[out] val Pointer to store the current NV counter value.
86 *
87 * \return TFM_PLATFORM_ERR_SUCCESS if the value is read correctly. Otherwise,
88 * it returns TFM_PLATFORM_ERR_SYSTEM_ERROR.
89 */
90enum tfm_platform_err_t
91tfm_platform_nv_counter_read(uint32_t counter_id,
92 uint32_t size, uint8_t *val);
Tamas Kaman262dc7b2019-03-20 13:37:12 +010093
Marc Moreno Berengue8e0fa7a2018-10-04 18:25:13 +010094#ifdef __cplusplus
95}
96#endif
97
98#endif /* __TFM_PLATFORM_API__ */