aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/runtime_services/cactus_message_loop.h44
-rw-r--r--include/runtime_services/cactus_test_cmds.h43
-rw-r--r--spm/cactus/cactus.mk2
-rw-r--r--spm/cactus/cactus_main.c4
-rw-r--r--spm/cactus/cactus_tests/cactus_message_loop.c (renamed from spm/cactus/cactus_tests/cactus_test_cmds.c)11
-rw-r--r--spm/cactus/cactus_tests/cactus_test_cpu_features.c1
-rw-r--r--spm/cactus/cactus_tests/cactus_test_direct_messaging.c1
-rw-r--r--spm/cactus/cactus_tests/cactus_test_memory_sharing.c2
8 files changed, 61 insertions, 47 deletions
diff --git a/include/runtime_services/cactus_message_loop.h b/include/runtime_services/cactus_message_loop.h
new file mode 100644
index 000000000..d69e77ce9
--- /dev/null
+++ b/include/runtime_services/cactus_message_loop.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <ffa_helpers.h>
+#include <spm_common.h>
+
+/**
+ * Pairs a command id with a function call, to handle the command ID.
+ */
+struct cactus_cmd_handler {
+ const uint64_t id;
+ smc_ret_values (*fn)(const smc_ret_values *args,
+ struct mailbox_buffers *mb);
+};
+
+/**
+ * Helper to create the name of a handler function.
+ */
+#define CACTUS_HANDLER_FN_NAME(name) cactus_##name##_handler
+
+/**
+ * Define handler's function signature.
+ */
+#define CACTUS_HANDLER_FN(name) \
+ static smc_ret_values CACTUS_HANDLER_FN_NAME(name)( \
+ const smc_ret_values *args, struct mailbox_buffers *mb)
+
+/**
+ * Helper to define Cactus command handler, and pair it with a command ID.
+ * It also creates a table with this information, to be traversed by
+ * 'cactus_handle_cmd' function.
+ */
+#define CACTUS_CMD_HANDLER(name, ID) \
+ CACTUS_HANDLER_FN(name); \
+ struct cactus_cmd_handler name __section(".cactus_handler") = { \
+ .id = ID, .fn = CACTUS_HANDLER_FN_NAME(name), \
+ }; \
+ CACTUS_HANDLER_FN(name)
+
+bool cactus_handle_cmd(smc_ret_values *cmd_args, smc_ret_values *ret,
+ struct mailbox_buffers *mb);
diff --git a/include/runtime_services/cactus_test_cmds.h b/include/runtime_services/cactus_test_cmds.h
index c65816f5c..246f4f979 100644
--- a/include/runtime_services/cactus_test_cmds.h
+++ b/include/runtime_services/cactus_test_cmds.h
@@ -7,9 +7,7 @@
#ifndef CACTUS_TEST_CMDS
#define CACTUS_TEST_CMDS
-#include <debug.h>
#include <ffa_helpers.h>
-#include <spm_common.h>
/**
* Success and error return to be sent over a msg response.
@@ -102,11 +100,6 @@ static inline uint32_t cactus_error_code(smc_ret_values ret)
return (uint32_t) ret.ret4;
}
-#define PRINT_CMD(smc_ret) \
- VERBOSE("cmd %lx; args: %lx, %lx, %lx, %lx\n", \
- smc_ret.ret3, smc_ret.ret4, smc_ret.ret5, \
- smc_ret.ret6, smc_ret.ret7)
-
/**
* With this test command the sender transmits a 64-bit value that it then
* expects to receive on the respective command response.
@@ -256,40 +249,4 @@ static inline smc_ret_values cactus_req_simd_fill_send_cmd(
0);
}
-/**
- * Pairs a command id with a function call, to handle the command ID.
- */
-struct cactus_cmd_handler {
- const uint64_t id;
- smc_ret_values (*fn)(const smc_ret_values *args,
- struct mailbox_buffers *mb);
-};
-
-/**
- * Helper to create the name of a handler function.
- */
-#define CACTUS_HANDLER_FN_NAME(name) cactus_##name##_handler
-
-/**
- * Define handler's function signature.
- */
-#define CACTUS_HANDLER_FN(name) \
- static smc_ret_values CACTUS_HANDLER_FN_NAME(name)( \
- const smc_ret_values *args, struct mailbox_buffers *mb)
-
-/**
- * Helper to define Cactus command handler, and pair it with a command ID.
- * It also creates a table with this information, to be traversed by
- * 'cactus_handle_cmd' function.
- */
-#define CACTUS_CMD_HANDLER(name, ID) \
- CACTUS_HANDLER_FN(name); \
- struct cactus_cmd_handler name __section(".cactus_handler") = { \
- .id = ID, .fn = CACTUS_HANDLER_FN_NAME(name), \
- }; \
- CACTUS_HANDLER_FN(name)
-
-bool cactus_handle_cmd(smc_ret_values *cmd_args, smc_ret_values *ret,
- struct mailbox_buffers *mb);
-
#endif
diff --git a/spm/cactus/cactus.mk b/spm/cactus/cactus.mk
index 31ac990c9..08b824c13 100644
--- a/spm/cactus/cactus.mk
+++ b/spm/cactus/cactus.mk
@@ -40,8 +40,8 @@ CACTUS_SOURCES := \
sp_helpers.c \
) \
$(addprefix spm/cactus/cactus_tests/, \
+ cactus_message_loop.c \
cactus_test_cpu_features.c \
- cactus_test_cmds.c \
cactus_test_direct_messaging.c \
cactus_test_ffa.c \
cactus_test_memory_sharing.c \
diff --git a/spm/cactus/cactus_main.c b/spm/cactus/cactus_main.c
index 650f06d2b..7e3f40bf8 100644
--- a/spm/cactus/cactus_main.c
+++ b/spm/cactus/cactus_main.c
@@ -8,8 +8,8 @@
#include <errno.h>
#include <debug.h>
+#include <cactus_message_loop.h>
#include <cactus_platform_def.h>
-#include <cactus_test_cmds.h>
#include <drivers/arm/pl011.h>
#include <drivers/console.h>
#include <lib/aarch64/arch_helpers.h>
@@ -74,8 +74,6 @@ static void __dead2 message_loop(ffa_vm_id_t vm_id, struct mailbox_buffers *mb)
break;
}
- PRINT_CMD(ffa_ret);
-
if (!cactus_handle_cmd(&ffa_ret, &ffa_ret, mb)) {
break;
}
diff --git a/spm/cactus/cactus_tests/cactus_test_cmds.c b/spm/cactus/cactus_tests/cactus_message_loop.c
index e13e40d34..11207dca8 100644
--- a/spm/cactus/cactus_tests/cactus_test_cmds.c
+++ b/spm/cactus/cactus_tests/cactus_message_loop.c
@@ -4,8 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include "cactus_message_loop.h"
#include "cactus_test_cmds.h"
#include <ffa_helpers.h>
+#include <debug.h>
+
/**
* Begin and end of command handler table, respectively. Both symbols defined by
@@ -14,6 +17,11 @@
extern struct cactus_cmd_handler cactus_cmd_handler_begin[];
extern struct cactus_cmd_handler cactus_cmd_handler_end[];
+#define PRINT_CMD(smc_ret) \
+ VERBOSE("cmd %lx; args: %lx, %lx, %lx, %lx\n", \
+ smc_ret.ret3, smc_ret.ret4, smc_ret.ret5, \
+ smc_ret.ret6, smc_ret.ret7)
+
/**
* Traverses command table from section ".cactus_handler", searches for a
* registered command and invokes the respective handler.
@@ -28,6 +36,8 @@ bool cactus_handle_cmd(smc_ret_values *cmd_args, smc_ret_values *ret,
return false;
}
+ PRINT_CMD((*cmd_args));
+
in_cmd = cactus_get_cmd(*cmd_args);
for (struct cactus_cmd_handler *it_cmd = cactus_cmd_handler_begin;
@@ -39,6 +49,7 @@ bool cactus_handle_cmd(smc_ret_values *cmd_args, smc_ret_values *ret,
}
}
+ ERROR("Unhandled test command!\n");
*ret = cactus_error_resp(ffa_dir_msg_dest(*cmd_args),
ffa_dir_msg_source(*cmd_args),
CACTUS_ERROR_UNHANDLED);
diff --git a/spm/cactus/cactus_tests/cactus_test_cpu_features.c b/spm/cactus/cactus_tests/cactus_test_cpu_features.c
index d39bdc411..7bf6e830b 100644
--- a/spm/cactus/cactus_tests/cactus_test_cpu_features.c
+++ b/spm/cactus/cactus_tests/cactus_test_cpu_features.c
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include "cactus_message_loop.h"
#include "cactus_test_cmds.h"
#include "spm_common.h"
diff --git a/spm/cactus/cactus_tests/cactus_test_direct_messaging.c b/spm/cactus/cactus_tests/cactus_test_direct_messaging.c
index 31324b623..a59cfa24a 100644
--- a/spm/cactus/cactus_tests/cactus_test_direct_messaging.c
+++ b/spm/cactus/cactus_tests/cactus_test_direct_messaging.c
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include "cactus_message_loop.h"
#include "cactus_test_cmds.h"
#include <debug.h>
#include <ffa_helpers.h>
diff --git a/spm/cactus/cactus_tests/cactus_test_memory_sharing.c b/spm/cactus/cactus_tests/cactus_test_memory_sharing.c
index f7d9235c3..e7bce50f4 100644
--- a/spm/cactus/cactus_tests/cactus_test_memory_sharing.c
+++ b/spm/cactus/cactus_tests/cactus_test_memory_sharing.c
@@ -5,8 +5,10 @@
*/
#include <cactus_def.h>
+#include "cactus_message_loop.h"
#include "cactus_test_cmds.h"
#include "cactus_tests.h"
+#include <debug.h>
#include <ffa_helpers.h>
#include <sp_helpers.h>
#include <xlat_tables_defs.h>