summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorSoby Mathew <soby.mathew@arm.com>2016-05-05 12:49:09 +0100
committerSoby Mathew <soby.mathew@arm.com>2016-08-10 12:35:46 +0100
commit1ae0a49a37b0c0e9f54a488f41b2d24eadae16ea (patch)
treee00fd21b5cafe8206dbbdfde89ea37c7c480e0d7 /common
parentbc202b44939eabf061d78e03fdced3112325ef92 (diff)
AArch32: Add API to invoke runtime service handler
This patch adds an API in runtime service framework to invoke the registered handler corresponding to the SMC function identifier. This is helpful for AArch32 because the number of arguments required by the handler is more than registers available as per AArch32 program calling conventions and requires the use of stack. Hence this new API will do the necessary argument setup and invoke the appropriate handler. Although this API is primarily intended for AArch32, it can be used for AArch64 as well. Change-Id: Iefa15947fe5a1df55b0859886e677446a0fd7241
Diffstat (limited to 'common')
-rw-r--r--common/runtime_svc.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/common/runtime_svc.c b/common/runtime_svc.c
index b8af6cd8..df0d64ca 100644
--- a/common/runtime_svc.c
+++ b/common/runtime_svc.c
@@ -52,6 +52,34 @@ static rt_svc_desc_t *rt_svc_descs;
/ sizeof(rt_svc_desc_t))
/*******************************************************************************
+ * Function to invoke the registered `handle` corresponding to the smc_fid.
+ ******************************************************************************/
+uintptr_t handle_runtime_svc(uint32_t smc_fid,
+ void *cookie,
+ void *handle,
+ unsigned int flags)
+{
+ u_register_t x1, x2, x3, x4;
+ int index, idx;
+ const rt_svc_desc_t *rt_svc_descs;
+
+ assert(handle);
+ idx = get_unique_oen_from_smc_fid(smc_fid);
+ assert(idx >= 0 && idx < MAX_RT_SVCS);
+
+ index = rt_svc_descs_indices[idx];
+ if (index < 0 || index >= RT_SVC_DECS_NUM)
+ SMC_RET1(handle, SMC_UNK);
+
+ rt_svc_descs = (rt_svc_desc_t *) RT_SVC_DESCS_START;
+
+ get_smc_params_from_ctx(handle, x1, x2, x3, x4);
+
+ return rt_svc_descs[index].handle(smc_fid, x1, x2, x3, x4, cookie,
+ handle, flags);
+}
+
+/*******************************************************************************
* Simple routine to sanity check a runtime service descriptor before using it
******************************************************************************/
static int32_t validate_rt_svc_desc(const rt_svc_desc_t *desc)