feat(rmm-eac4): Add support for new RMI_VERSION cmd
This patch adds the necessary support for the new RMI_VERSION
command as mentioned EAC4 specification.
Signed-off-by: Soby Mathew <soby.mathew@arm.com>
Change-Id: I4629357b42d05d291fd81aaea97edf0a0c4518f5
diff --git a/plat/host/common/include/host_rmi_wrappers.h b/plat/host/common/include/host_rmi_wrappers.h
index f1f09f6..992b455 100644
--- a/plat/host/common/include/host_rmi_wrappers.h
+++ b/plat/host/common/include/host_rmi_wrappers.h
@@ -8,6 +8,7 @@
#include <smc-rmi.h>
+void host_rmi_version(unsigned long rmi_verion, struct smc_result *res);
void host_rmi_granule_delegate(void *granule_address, struct smc_result *res);
void host_rmi_granule_undelegate(void *granule_address, struct smc_result *res);
void host_rmi_realm_create(void *rd, void *params_ptr, struct smc_result *res);
diff --git a/plat/host/common/src/host_rmi_wrappers.c b/plat/host/common/src/host_rmi_wrappers.c
index 244a8ce..7221eb8 100644
--- a/plat/host/common/src/host_rmi_wrappers.c
+++ b/plat/host/common/src/host_rmi_wrappers.c
@@ -15,6 +15,14 @@
unsigned long arg5,
struct smc_result *res);
+void host_rmi_version(unsigned long rmi_verion, struct smc_result *res)
+{
+ handle_ns_smc(SMC_RMM_VERSION,
+ rmi_verion,
+ 0, 0, 0, 0, 0,
+ res);
+}
+
void host_rmi_granule_delegate(void *granule_address, struct smc_result *res)
{
handle_ns_smc(SMC_RMM_GRANULE_DELEGATE,
diff --git a/plat/host/host_build/src/host_setup.c b/plat/host/host_build/src/host_setup.c
index a3ebb93..fadc4ee 100644
--- a/plat/host/host_build/src/host_setup.c
+++ b/plat/host/host_build/src/host_setup.c
@@ -145,6 +145,8 @@
struct rmi_rec_params *rec_params = allocate_granule();
struct rmi_rec_run *rec_run = allocate_granule();
+ host_rmi_version(RMI_ABI_VERSION, &result);
+ CHECK_RMI_RESULT();
host_rmi_granule_delegate(rd, &result);
CHECK_RMI_RESULT();
host_rmi_granule_delegate(rec, &result);
diff --git a/runtime/core/handler.c b/runtime/core/handler.c
index 3dbff55..29c73fc 100644
--- a/runtime/core/handler.c
+++ b/runtime/core/handler.c
@@ -126,7 +126,7 @@
* The 4th value enables the error log.
*/
static const struct smc_handler smc_handlers[] = {
- HANDLER(VERSION, 0, 0, smc_version, true, true),
+ HANDLER(VERSION, 1, 1, smc_version, true, true),
HANDLER(FEATURES, 1, 1, smc_read_feature_register, true, true),
HANDLER(GRANULE_DELEGATE, 1, 0, smc_granule_delegate, false, true),
HANDLER(GRANULE_UNDELEGATE, 1, 0, smc_granule_undelegate, false, true),
@@ -181,15 +181,6 @@
return;
}
- if (function_id == SMC_RMM_VERSION) {
- /*
- * RMM_VERSION is special because it returns the
- * version number, not the error code.
- */
- INFO("SMC_RMM_%-21s > %lx\n", handler->fn_name, res->x[0]);
- return;
- }
-
rc = unpack_return_code(res->x[0]);
if ((handler->log_exec) ||
diff --git a/runtime/include/smc-handler.h b/runtime/include/smc-handler.h
index 685f3c5..5965078 100644
--- a/runtime/include/smc-handler.h
+++ b/runtime/include/smc-handler.h
@@ -8,7 +8,8 @@
#include <smc.h>
-unsigned long smc_version(void);
+void smc_version(unsigned long rmi_version,
+ struct smc_result *res);
void smc_read_feature_register(unsigned long index,
struct smc_result *res);
diff --git a/runtime/rmi/system.c b/runtime/rmi/system.c
index 024d419..5847350 100644
--- a/runtime/rmi/system.c
+++ b/runtime/rmi/system.c
@@ -9,7 +9,13 @@
COMPILER_ASSERT(RMI_ABI_VERSION_MAJOR <= 0x7FFF);
COMPILER_ASSERT(RMI_ABI_VERSION_MINOR <= 0xFFFF);
-unsigned long smc_version(void)
+void smc_version(unsigned long rmi_version, struct smc_result *res)
{
- return RMI_ABI_VERSION;
+ if (rmi_version != RMI_ABI_VERSION) {
+ res->x[0] = RMI_ERROR_INPUT;
+ } else {
+ res->x[0] = RMI_SUCCESS;
+ }
+
+ res->x[1] = RMI_ABI_VERSION;
}