blob: be36e2e4890f8f78008fbc748be393e242e1bc28 [file] [log] [blame]
Ashutosh Singhf4d88672017-11-29 13:35:43 +00001/*
Mate Toth-Pal2a6f8c22018-12-13 16:37:17 +01002 * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
Ashutosh Singhf4d88672017-11-29 13:35:43 +00003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#ifndef __TFM_API_H__
9#define __TFM_API_H__
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
Mate Toth-Palce61afa2018-08-03 13:51:01 +020015#include <stdint.h>
16
Miklos Balintbf25a402018-06-14 17:43:54 +020017#include "psa_client.h"
18
Mate Toth-Pal261df462018-08-07 12:02:42 +020019#define TFM_INVALID_CLIENT_ID 0
20
21/**
22 * \brief Checks if the provided client ID is a secure client ID.
23 *
24 * \param[in] client_id Client ID to check
25 *
26 * \return Returns 1 if the client Id is secure. Otherwise, returns 0.
27 */
28#define TFM_CLIENT_ID_IS_S(client_id) ((client_id)>0)
29
30/**
31 * \brief Checks if the provided client ID is a non-secure client ID.
32 *
33 * \param[in] client_id Client ID to check
34 *
35 * \return Returns 1 if the client Id is non-secure. Otherwise, returns 0.
36 */
37#define TFM_CLIENT_ID_IS_NS(client_id) ((client_id)<0)
38
Mate Toth-Palb8ce0dd2018-07-25 10:18:34 +020039/* Maximum number of input and output vectors */
40#define PSA_MAX_IOVEC (4)
41
Ashutosh Singhf4d88672017-11-29 13:35:43 +000042/* FixMe: sort out DEBUG compile option and limit return value options
43 * on external interfaces */
Mate Toth-Pal2a6f8c22018-12-13 16:37:17 +010044/* For secure functions using prorietary signatures
Ashutosh Singhf4d88672017-11-29 13:35:43 +000045 * TFM will only return values recognized and parsed by TFM core.
46 * Service return codes are not automatically passed on to REE.
47 * Any non-zero return value is interpreted as an error that may trigger
48 * TEE error handling flow.
Mate Toth-Pal2a6f8c22018-12-13 16:37:17 +010049 * For secure functions using the veneers in secure_fw/ns_callable/tfm_veneers.c
50 * (iovec API) this limitation does not apply.
Ashutosh Singhf4d88672017-11-29 13:35:43 +000051 */
52enum tfm_status_e
53{
54 TFM_SUCCESS = 0,
Mate Toth-Pal7de74b52018-02-23 15:46:47 +010055 TFM_PARTITION_BUSY,
Ashutosh Singhf4d88672017-11-29 13:35:43 +000056 TFM_ERROR_SECURE_DOMAIN_LOCKED,
57 TFM_ERROR_INVALID_PARAMETER,
Mate Toth-Pal7de74b52018-02-23 15:46:47 +010058 TFM_ERROR_PARTITION_NON_REENTRANT,
Ashutosh Singhf4d88672017-11-29 13:35:43 +000059 TFM_ERROR_NS_THREAD_MODE_CALL,
Miklos Balint1fdb12f2018-09-11 11:30:30 +020060 TFM_ERROR_NOT_INITIALIZED,
61 TFM_ERROR_NO_ACTIVE_PARTITION,
Ashutosh Singhf4d88672017-11-29 13:35:43 +000062 TFM_ERROR_INVALID_EXC_MODE,
63 TFM_SECURE_LOCK_FAILED,
64 TFM_SECURE_UNLOCK_FAILED,
65 TFM_ERROR_GENERIC = 0x1F,
Mate Toth-Pal7de74b52018-02-23 15:46:47 +010066 TFM_PARTITION_SPECIFIC_ERROR_MIN,
Ashutosh Singhf4d88672017-11-29 13:35:43 +000067};
68
69//==================== Secure function declarations ==========================//
70
Mate Toth-Palce61afa2018-08-03 13:51:01 +020071/**
72 * \brief Assign client ID to the current TZ context
73 *
74 * \param[in] ns_client_id The client ID to be assigned to the current
75 * context
76 * \return TFM_SUCCESS if the client ID assigned successfully, an error code
77 * according to \ref tfm_status_e in case of error.
78 *
79 * \note This function have to be called from handler mode.
80 */
81enum tfm_status_e tfm_register_client_id (int32_t ns_client_id);
Ashutosh Singhf4d88672017-11-29 13:35:43 +000082
83//================ End Secure function declarations ==========================//
84
85#ifdef __cplusplus
86}
87#endif
88
89#endif /* __TFM_API_H__ */