aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJ-Alves <joao.alves@arm.com>2021-03-11 09:54:21 +0000
committerJ-Alves <joao.alves@arm.com>2021-03-12 14:28:28 +0000
commiteeb2547b9a774c90824e867ce7c331b319fc7c0d (patch)
tree528f9e5be4c325c5c467989780b0f28cc3ac460e
parent43887ec0836c35feb433c02f00678085d1513782 (diff)
downloadtf-a-tests-eeb2547b9a774c90824e867ce7c331b319fc7c0d.tar.gz
Cactus: tidy message loop and commands definitions
Creating specific header and source file for the message loop code, separating it from the definition of test commands. Thus message loop won't be included in tftf target. Signed-off-by: J-Alves <joao.alves@arm.com> Change-Id: Ieb0c4b0bf56ed0cbbf3323cac57dd9d9b37fae92
-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 00000000..d69e77ce
--- /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 c65816f5..246f4f97 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 31ac990c..08b824c1 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 650f06d2..7e3f40bf 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 e13e40d3..11207dca 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 d39bdc41..7bf6e830 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 31324b62..a59cfa24 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 f7d9235c..e7bce50f 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>