TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tfm_secure_api.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #include <stdbool.h>
9 #include "spm_func.h"
10 #include "tfm_secure_api.h"
11 
13 {
14  ERROR_MSG("Security violation when calling secure API");
16 }
17 
18 int32_t tfm_core_partition_request(uint32_t id, bool is_ns, void *fn,
19  int32_t arg1, int32_t arg2, int32_t arg3, int32_t arg4)
20 {
21  int32_t args[4] = {arg1, arg2, arg3, arg4};
22  struct tfm_sfn_req_s desc, *desc_ptr = &desc;
23 
24  desc.sp_id = id;
25  desc.sfn = (sfn_t) fn;
26  desc.args = args;
27  desc.ns_caller = is_ns;
28 
30  /* The veneer of a secure service had been called from Handler mode.
31  * This violates TF-M's programming model, and is considered an
32  * unrecoverable error.
33  */
35  } else {
36  if (desc.ns_caller) {
37  return tfm_core_sfn_request(desc_ptr);
38  } else {
39  return tfm_spm_sfn_request_thread_mode(desc_ptr);
40  }
41  }
42  return TFM_ERROR_GENERIC;
43 }
uint32_t sp_id
void tfm_secure_api_error_handler(void)
int32_t(* sfn_t)(int32_t, int32_t, int32_t, int32_t)
int32_t tfm_core_sfn_request(const struct tfm_sfn_req_s *desc_ptr)
int32_t tfm_core_partition_request(uint32_t id, bool is_ns, void *fn, int32_t arg1, int32_t arg2, int32_t arg3, int32_t arg4)
__STATIC_INLINE uint32_t __get_active_exc_num(void)
Definition: tfm_arch.h:65
void tfm_core_panic(void)
Definition: utilities.c:11
#define ERROR_MSG(msg)
Definition: utilities.h:36
int32_t tfm_spm_sfn_request_thread_mode(struct tfm_sfn_req_s *desc_ptr)
Definition: spm_func.c:780
int32_t * args
#define EXC_NUM_THREAD_MODE
Definition: spm_func.h:24