TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tfm_ns_interface.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 #include <stdint.h>
8 #include <stdbool.h>
9 
10 #include "os_wrapper/mutex.h"
11 
12 #include "tfm_api.h"
13 #include "tfm_ns_interface.h"
14 
18 static void *ns_lock_handle = NULL;
19 
20 __attribute__((weak))
22  uint32_t arg0, uint32_t arg1,
23  uint32_t arg2, uint32_t arg3)
24 {
25  int32_t result;
26 
27  /* TFM request protected by NS lock */
29  != OS_WRAPPER_SUCCESS) {
30  return (int32_t)TFM_ERROR_GENERIC;
31  }
32 
33  result = fn(arg0, arg1, arg2, arg3);
34 
35  if (os_wrapper_mutex_release(ns_lock_handle) != OS_WRAPPER_SUCCESS) {
36  return (int32_t)TFM_ERROR_GENERIC;
37  }
38 
39  return result;
40 }
41 
42 __attribute__((weak))
44 {
45  void *handle;
46 
47  handle = os_wrapper_mutex_create();
48  if (!handle) {
49  return TFM_ERROR_GENERIC;
50  }
51 
52  ns_lock_handle = handle;
53  return TFM_SUCCESS;
54 }
tfm_status_e
Definition: tfm_api.h:45
psa_handle_t handle
Definition: tfm_mailbox.h:92
uint32_t os_wrapper_mutex_release(void *handle)
Releases the mutex acquired previously.
int32_t(* veneer_fn)(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint32_t arg3)
#define OS_WRAPPER_WAIT_FOREVER
Definition: common.h:19
enum tfm_status_e tfm_ns_interface_init(void)
NS interface, Initialise the NS interface.
void * os_wrapper_mutex_create(void)
Creates a mutex for mutual exclusion of resources.
#define OS_WRAPPER_SUCCESS
Definition: common.h:17
int32_t tfm_ns_interface_dispatch(veneer_fn fn, uint32_t arg0, uint32_t arg1, uint32_t arg2, uint32_t arg3)
NS interface, veneer function dispatcher.
uint32_t os_wrapper_mutex_acquire(void *handle, uint32_t timeout)
Acquires a mutex that is created by os_wrapper_mutex_create()