Core: Enable platform specific extensions to the core set of SVC handlers
Support is provided for both the PSA IPC and Library models.
To enable platform specific SVC handlers, add
-DPLATFORM_SVC_HANDLERS=True to the CMAKE command line.
When PLATFORM_SVC_HANDLERS is defined, user must provide an
implementation of:
int32_t platform_svc_handlers(tfm_svc_number_t svc_num,
uint32_t *ctx, uint32_t lr);
Change-Id: I5fc641038732d2630e954f6c9b12df929b65c24a
Signed-off-by: Alan DeMars <ademars@ti.com>
diff --git a/CommonConfig.cmake b/CommonConfig.cmake
index 0c9c764..0e83118 100644
--- a/CommonConfig.cmake
+++ b/CommonConfig.cmake
@@ -155,6 +155,10 @@
# Option to demonstrate usage of secure-only peripheral
set (SECURE_UART1 OFF)
+if (PLATFORM_SVC_HANDLERS)
+ add_definitions(-DPLATFORM_SVC_HANDLERS)
+endif()
+
if (REGRESSION)
set(SERVICES_TEST_ENABLED ON)
endif()
diff --git a/secure_fw/core/ipc/tfm_svcalls.c b/secure_fw/core/ipc/tfm_svcalls.c
index 3721ba2..c1a7c15 100644
--- a/secure_fw/core/ipc/tfm_svcalls.c
+++ b/secure_fw/core/ipc/tfm_svcalls.c
@@ -28,6 +28,11 @@
#include "tfm_psa_client_call.h"
#include "tfm_rpc.h"
+#ifdef PLATFORM_SVC_HANDLERS
+extern int32_t platform_svc_handlers(tfm_svc_number_t svc_num,
+ uint32_t *ctx, uint32_t lr);
+#endif
+
void tfm_irq_handler(uint32_t partition_id, psa_signal_t signal,
int32_t irq_line);
@@ -1012,8 +1017,12 @@
break;
default:
+#ifdef PLATFORM_SVC_HANDLERS
+ return (platform_svc_handlers(svc_num, ctx, lr));
+#else
LOG_MSG("Unknown SVC number requested!");
return PSA_ERROR_GENERIC_ERROR;
+#endif
}
return PSA_SUCCESS;
}
diff --git a/secure_fw/core/tfm_core_svcalls_func.c b/secure_fw/core/tfm_core_svcalls_func.c
index 3332508..ef0a649 100644
--- a/secure_fw/core/tfm_core_svcalls_func.c
+++ b/secure_fw/core/tfm_core_svcalls_func.c
@@ -19,6 +19,11 @@
#include "tfm_peripherals_def.h"
#include "tfm_irq_list.h"
+#ifdef PLATFORM_SVC_HANDLERS
+extern int32_t platform_svc_handlers(tfm_svc_number_t svc_num,
+ uint32_t *svc_args, uint32_t lr);
+#endif
+
/* Include the definitions of the privileged IRQ handlers in case of library
* model
*/
@@ -88,6 +93,9 @@
tfm_core_get_boot_data_handler(svc_args);
break;
default:
+#ifdef PLATFORM_SVC_HANDLERS
+ svc_args[0] = platform_svc_handlers(svc_num, svc_args, lr);
+#endif
break;
}
diff --git a/secure_fw/include/core/tfm_core_svc.h b/secure_fw/include/core/tfm_core_svc.h
index a96b7f7..426ed34 100644
--- a/secure_fw/include/core/tfm_core_svc.h
+++ b/secure_fw/include/core/tfm_core_svc.h
@@ -44,6 +44,7 @@
TFM_SVC_PSA_NOTIFY,
TFM_SVC_PSA_CLEAR,
#endif
+ TFM_SVC_PLATFORM_BASE = 50 /* leave room for additional Core handlers */
} tfm_svc_number_t;
#define SVC(code) __ASM volatile("svc %0" : : "I" (code))