aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJ-Alves <joao.alves@arm.com>2021-02-11 16:08:08 +0000
committerJ-Alves <joao.alves@arm.com>2021-03-11 09:29:16 +0000
commit7d28b336e1f31afa88b6dac8ac9c5db73cdaae81 (patch)
tree69c9386e7a73b9257647bd079862f4b92e97fd7d
parent06373c564bbdca87b0043f8f0a4b0f047d6a7457 (diff)
downloadtf-a-tests-7d28b336e1f31afa88b6dac8ac9c5db73cdaae81.tar.gz
Cactus: Extend arguments in commands responses
In the test commands framework, added template to extend number of values to include in a command response. This allows for a more complete use of the available registers in direct message interfaces. Signed-off-by: J-Alves <joao.alves@arm.com> Change-Id: I34947f100c6322ca7319847cf44e844d63855c9d
-rw-r--r--spm/cactus/cactus_main.c21
-rw-r--r--spm/cactus/cactus_test_cmds.h85
2 files changed, 69 insertions, 37 deletions
diff --git a/spm/cactus/cactus_main.c b/spm/cactus/cactus_main.c
index cb83d876..9388ec55 100644
--- a/spm/cactus/cactus_main.c
+++ b/spm/cactus/cactus_main.c
@@ -97,7 +97,7 @@ static void __dead2 message_loop(ffa_vm_id_t vm_id, struct mailbox_buffers *mb)
* If execution gets to this point means all operations
* with memory retrieval went well, as such replying
*/
- ffa_ret = cactus_success_resp(vm_id, source);
+ ffa_ret = cactus_success_resp(vm_id, source, 0);
break;
case CACTUS_REQ_MEM_SEND_CMD:
{
@@ -137,14 +137,14 @@ static void __dead2 message_loop(ffa_vm_id_t vm_id, struct mailbox_buffers *mb)
if (!is_ffa_direct_response(ffa_ret)) {
ERROR("Failed to send message. error: %x\n",
ffa_error_code(ffa_ret));
- ffa_ret = cactus_error_resp(vm_id, source);
+ ffa_ret = cactus_error_resp(vm_id, source, 0);
break;
}
/* If anything went bad on the receiver's end. */
if (cactus_get_response(ffa_ret) == CACTUS_ERROR) {
ERROR("Received error from receiver!\n");
- ffa_ret = cactus_error_resp(vm_id, source);
+ ffa_ret = cactus_error_resp(vm_id, source, 0);
break;
}
@@ -159,7 +159,7 @@ static void __dead2 message_loop(ffa_vm_id_t vm_id, struct mailbox_buffers *mb)
.ret0 == FFA_ERROR) {
ERROR("Failed to reclaim memory!\n");
ffa_ret = cactus_error_resp(vm_id,
- source);
+ source, 0);
break;
}
@@ -181,7 +181,7 @@ static void __dead2 message_loop(ffa_vm_id_t vm_id, struct mailbox_buffers *mb)
#endif
}
- ffa_ret = cactus_success_resp(vm_id, source);
+ ffa_ret = cactus_success_resp(vm_id, source, 0);
break;
}
case CACTUS_ECHO_CMD:
@@ -217,8 +217,9 @@ static void __dead2 message_loop(ffa_vm_id_t vm_id, struct mailbox_buffers *mb)
success = false;
}
- ffa_ret = success ? cactus_success_resp(vm_id, source) :
- cactus_error_resp(vm_id, source);
+ ffa_ret = success ?
+ cactus_success_resp(vm_id, source, 0) :
+ cactus_error_resp(vm_id, source, 0);
break;
}
case CACTUS_DEADLOCK_CMD:
@@ -273,18 +274,18 @@ static void __dead2 message_loop(ffa_vm_id_t vm_id, struct mailbox_buffers *mb)
* created the deadlock. As such, reply back
* to the partitions.
*/
- ffa_ret = cactus_success_resp(vm_id, source);
+ ffa_ret = cactus_success_resp(vm_id, source, 0);
break;
}
/* Shouldn't get to this point */
ERROR("Deadlock test went wrong!\n");
- ffa_ret = cactus_error_resp(vm_id, source);
+ ffa_ret = cactus_error_resp(vm_id, source, 0);
break;
}
case CACTUS_REQ_SIMD_FILL_CMD:
fill_simd_vectors();
- ffa_ret = cactus_success_resp(vm_id, source);
+ ffa_ret = cactus_success_resp(vm_id, source, 0);
break;
default:
/*
diff --git a/spm/cactus/cactus_test_cmds.h b/spm/cactus/cactus_test_cmds.h
index c662d273..f814ba56 100644
--- a/spm/cactus/cactus_test_cmds.h
+++ b/spm/cactus/cactus_test_cmds.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
+ * Copyright (c) 2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -36,6 +36,63 @@ static inline smc_ret_values cactus_send_cmd(
val2, val3);
}
+/**
+ * Template for responses to Cactus commands.
+ * 'cactus_send_response' is the template for custom responses, in case there is
+ * a need to propagate more than one value in the response of a command.
+ */
+static inline smc_ret_values cactus_send_response(
+ ffa_vm_id_t source, ffa_vm_id_t dest, uint32_t resp, uint32_t val0,
+ uint64_t val1, uint64_t val2, uint64_t val3)
+{
+ return ffa_msg_send_direct_resp64_5args(source, dest, resp, val0, val1,
+ val2, val3);
+}
+
+/**
+ * For responses of one value only.
+ */
+static inline smc_ret_values cactus_response(
+ ffa_vm_id_t source, ffa_vm_id_t dest, uint32_t response)
+{
+ return ffa_msg_send_direct_resp(source, dest, response);
+}
+
+static inline uint32_t cactus_get_response(smc_ret_values ret)
+{
+ return (uint32_t)ret.ret3;
+}
+
+/**
+ * In a successful test, in case the SP needs to propagate an extra value
+ * to conclude the test.
+ * If more arguments are needed, a custom response should be defined for the
+ * specific test.
+ */
+static inline smc_ret_values cactus_success_resp(
+ ffa_vm_id_t source, ffa_vm_id_t dest, uint64_t value)
+{
+ return cactus_send_response(source, dest, CACTUS_SUCCESS, value,
+ 0, 0, 0);
+}
+
+/**
+ * In case the test fails on the SP side, the 'error_code' should help specify
+ * the reason, which can be specific to the test, or general ones as defined
+ * in the error code list.
+ */
+static inline smc_ret_values cactus_error_resp(
+ ffa_vm_id_t source, ffa_vm_id_t dest, uint32_t error_code)
+{
+ return cactus_send_response(source, dest, CACTUS_ERROR, error_code,
+ 0, 0, 0);
+}
+
+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, \
@@ -189,30 +246,4 @@ static inline smc_ret_values cactus_req_simd_fill_send_cmd(
return cactus_send_cmd(source, dest, CACTUS_REQ_SIMD_FILL_CMD, 0, 0, 0, 0);
}
-/**
- * Template for responses to CACTUS commands.
- */
-static inline smc_ret_values cactus_response(
- ffa_vm_id_t source, ffa_vm_id_t dest, uint32_t response)
-{
- return ffa_msg_send_direct_resp(source, dest, response);
-}
-
-static inline smc_ret_values cactus_success_resp(
- ffa_vm_id_t source, ffa_vm_id_t dest)
-{
- return cactus_response(source, dest, CACTUS_SUCCESS);
-}
-
-static inline smc_ret_values cactus_error_resp(
- ffa_vm_id_t source, ffa_vm_id_t dest)
-{
- return cactus_response(source, dest, CACTUS_ERROR);
-}
-
-static inline uint32_t cactus_get_response(smc_ret_values ret)
-{
- return (uint32_t)ret.ret3;
-}
-
#endif