TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tfm_core_svcalls_func.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 <string.h>
9 
10 #include "tfm/tfm_core_svc.h"
11 #include "tfm_secure_api.h"
12 #include "region_defs.h"
13 #include "spm_func.h"
14 #include "spm_partition_defs.h"
15 #include "tfm_api.h"
16 #include "tfm_memory_utils.h"
17 #include "tfm_arch.h"
18 #include "tfm_peripherals_def.h"
19 #include "tfm_irq_list.h"
20 #include "common/tfm_boot_data.h"
21 
22 #ifdef PLATFORM_SVC_HANDLERS
23 extern int32_t platform_svc_handlers(tfm_svc_number_t svc_num,
24  uint32_t *svc_args, uint32_t lr);
25 #endif
26 
27 /* Include the definitions of the privileged IRQ handlers in case of library
28  * model
29  */
31 
32 uint32_t tfm_core_svc_handler(uint32_t *svc_args, uint32_t lr, uint32_t *msp)
33 {
34  uint8_t svc_number = 0;
35  /*
36  * Stack contains:
37  * r0, r1, r2, r3, r12, r14 (lr), the return address and xPSR
38  * First argument (r0) is svc_args[0]
39  */
40  if (is_return_secure_stack(lr)) {
41  /* SV called directly from secure context. Check instruction for
42  * svc_number
43  */
44  svc_number = ((uint8_t *)svc_args[6])[-2];
45  } else {
46  /* Secure SV executing with NS return.
47  * NS cannot directly trigger S SVC so this should not happen. This is
48  * an unrecoverable error.
49  */
51  }
52  switch (svc_number) {
54  lr = tfm_spm_partition_request_svc_handler(svc_args, lr);
55  break;
56  case TFM_SVC_SFN_RETURN:
58  break;
61  break;
63  tfm_spm_request_handler((struct tfm_state_context_t *)svc_args);
64  break;
65  case TFM_SVC_DEPRIV_REQ:
66  lr = tfm_spm_depriv_req_handler(svc_args, lr);
67  break;
68  case TFM_SVC_DEPRIV_RET:
69  lr = tfm_spm_depriv_return_handler(msp, lr);
70  break;
71  case TFM_SVC_PSA_WAIT:
72  tfm_spm_psa_wait(svc_args);
73  break;
74  case TFM_SVC_PSA_EOI:
75  tfm_spm_psa_eoi(svc_args);
76  break;
77  case TFM_SVC_ENABLE_IRQ:
79  break;
82  break;
85  break;
86  default:
87 #ifdef PLATFORM_SVC_HANDLERS
88  svc_args[0] = platform_svc_handlers(svc_num, svc_args, lr);
89 #endif
90  break;
91  }
92 
93  return lr;
94 }
95 
97 {
98  while (1) {
99  ;
100  }
101 }
void tfm_spm_psa_eoi(uint32_t *svc_args)
Handle request to record IRQ processed.
Definition: spm_func.c:1118
void tfm_core_get_boot_data_handler(uint32_t args[])
Retrieve secure partition related data from shared memory area, which stores shared data between boot...
uint32_t tfm_spm_depriv_req_handler(uint32_t *svc_args, uint32_t excReturn)
Handle deprivileged request.
Definition: spm_func.c:921
void tfm_access_violation_handler(void)
Should be called in case of access violation.
void tfm_spm_disable_irq_handler(uint32_t *svc_args)
Handle IRQ disable request.
Definition: spm_func.c:1060
void tfm_core_panic(void)
Definition: utilities.c:11
uint32_t tfm_spm_partition_return_handler(uint32_t lr)
Called when secure service returns.
Definition: spm_func.c:949
void tfm_spm_get_caller_client_id_handler(uint32_t *svc_args)
Stores caller's client id in state context.
Definition: spm_func.c:851
void tfm_spm_psa_wait(uint32_t *svc_args)
Handle signal wait request.
Definition: spm_func.c:1087
void tfm_spm_enable_irq_handler(uint32_t *svc_args)
Handle IRQ enable request.
Definition: spm_func.c:1033
void tfm_spm_request_handler(const struct tfm_state_context_t *svc_ctx)
Handle an SPM request by a secure service.
Definition: spm_func.c:1382
tfm_svc_number_t
Definition: tfm_core_svc.h:13
uint32_t tfm_core_svc_handler(uint32_t *svc_args, uint32_t lr, uint32_t *msp)
uint32_t tfm_spm_partition_request_svc_handler(const uint32_t *svc_args, uint32_t lr)
Called if veneer is running in thread mode.
Definition: spm_func.c:894
__STATIC_INLINE bool is_return_secure_stack(uint32_t lr)
Check whether Secure or Non-secure stack is used to restore stack frame on exception return...
uint32_t tfm_spm_depriv_return_handler(uint32_t *irq_svc_args, uint32_t lr)
Handle request to return to privileged.
Definition: spm_func.c:976