test: enable specifying options for sp_fwd_sleep command
The options parameter will package two fields:
- hint_interrupted
- mask interrupts
This feature will be needed in the subsequent patch.
Signed-off-by: Madhukar Pappireddy <madhukar.pappireddy@arm.com>
Change-Id: Ia7323fbb56f8e491a8654d83b0fb0c5ad41b8cf9
diff --git a/test/vmapi/ffa_secure_partitions/dir_msg.c b/test/vmapi/ffa_secure_partitions/dir_msg.c
index 0f43166..51ebdbe 100644
--- a/test/vmapi/ffa_secure_partitions/dir_msg.c
+++ b/test/vmapi/ffa_secure_partitions/dir_msg.c
@@ -176,7 +176,7 @@
* there by putting receiver SP in BLOCKED state.
*/
res = sp_fwd_sleep_cmd_send(own_id, receiver_id, companion_id,
- SP_SLEEP_LONG, false);
+ SP_SLEEP_LONG, 0);
EXPECT_EQ(res.func, FFA_MSG_SEND_DIRECT_RESP_32);
EXPECT_EQ(sp_resp(res), SP_SUCCESS);
diff --git a/test/vmapi/ffa_secure_partitions/secure_interrupts.c b/test/vmapi/ffa_secure_partitions/secure_interrupts.c
index 06cb089..f3b984c 100644
--- a/test/vmapi/ffa_secure_partitions/secure_interrupts.c
+++ b/test/vmapi/ffa_secure_partitions/secure_interrupts.c
@@ -146,7 +146,8 @@
enable_trigger_trusted_wdog_timer(own_id, receiver_id, 400);
/* Send request to the SP to sleep uninterrupted. */
- res = sp_sleep_cmd_send(own_id, receiver_id, SP_SLEEP_TIME, 1);
+ res = sp_sleep_cmd_send(own_id, receiver_id, SP_SLEEP_TIME,
+ OPTIONS_MASK_INTERRUPTS);
/*
* Secure interrupt should trigger during this time, SP will handle the
@@ -213,7 +214,7 @@
* there by putting receiver SP in BLOCKED state.
*/
res = sp_fwd_sleep_cmd_send(own_id, receiver_id, companion_id,
- SP_SLEEP_TIME, false);
+ SP_SLEEP_TIME, 0);
/*
* Secure interrupt should trigger during this time, receiver SP will
diff --git a/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/inc/partition_services.h b/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/inc/partition_services.h
index f7cd578..75b682c 100644
--- a/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/inc/partition_services.h
+++ b/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/inc/partition_services.h
@@ -15,6 +15,10 @@
#define SP_SUCCESS 0
#define SP_ERROR -1
+/* Various fields encoded in `options` parameter. */
+#define OPTIONS_MASK_INTERRUPTS (1 << 0)
+#define OPTIONS_HINT_INTERRUPTED (1 << 1)
+
static inline struct ffa_value sp_success(ffa_id_t sender, ffa_id_t receiver,
uint64_t val)
{
@@ -404,11 +408,10 @@
ffa_id_t dest,
ffa_id_t fwd_dest,
uint32_t busy_wait,
- bool hint_interrupted)
+ uint32_t options)
{
return ffa_msg_send_direct_req(source, dest, SP_FWD_SLEEP_CMD,
- busy_wait, fwd_dest, hint_interrupted,
- 0);
+ busy_wait, fwd_dest, options, 0);
}
static inline uint32_t sp_get_sleep_time(struct ffa_value ret)
@@ -421,13 +424,13 @@
return (ffa_id_t)ret.arg5;
}
-static inline bool sp_get_fwd_sleep_interrupted_hint(struct ffa_value ret)
+static inline uint32_t sp_get_fwd_sleep_options(struct ffa_value ret)
{
- return (bool)ret.arg6;
+ return (uint32_t)ret.arg6;
}
struct ffa_value sp_fwd_sleep_cmd(ffa_id_t source, uint32_t sleep_ms,
- ffa_id_t fwd_dest, bool hint_interrupted);
+ ffa_id_t fwd_dest, uint32_t options);
/**
* Command to request SP to resume the task requested by current endpoint after
diff --git a/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/message_loop.c b/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/message_loop.c
index cc9eba0..194e842 100644
--- a/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/message_loop.c
+++ b/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/message_loop.c
@@ -85,7 +85,7 @@
case SP_FWD_SLEEP_CMD:
res = sp_fwd_sleep_cmd(ffa_sender(res), sp_get_sleep_time(res),
sp_get_fwd_sleep_dest(res),
- sp_get_fwd_sleep_interrupted_hint(res));
+ sp_get_fwd_sleep_options(res));
break;
case SP_CHECK_PARTITION_INFO_GET_REGS_CMD:
res = sp_check_partition_info_get_regs_cmd(ffa_sender(res));
diff --git a/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/secure_interrupts.c b/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/secure_interrupts.c
index 347b18b..329f586 100644
--- a/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/secure_interrupts.c
+++ b/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/secure_interrupts.c
@@ -175,7 +175,7 @@
static inline bool mask_interrupts(uint32_t options)
{
- return ((options & 0x1) == 1);
+ return ((options & OPTIONS_MASK_INTERRUPTS) != 0);
}
struct ffa_value sp_sleep_cmd(ffa_id_t source, uint32_t sleep_ms,
@@ -199,17 +199,27 @@
return sp_success(own_id, source, time_lapsed);
}
+static inline bool get_hint_interrupted(uint32_t options)
+{
+ return ((options & OPTIONS_HINT_INTERRUPTED) != 0);
+}
+
struct ffa_value sp_fwd_sleep_cmd(ffa_id_t source, uint32_t sleep_ms,
- ffa_id_t fwd_dest, bool hint_interrupted)
+ ffa_id_t fwd_dest, uint32_t options)
{
struct ffa_value ffa_ret;
ffa_id_t own_id = hf_vm_get_id();
bool fwd_dest_interrupted = false;
+ bool hint_interrupted = false;
HFTEST_LOG("VM%x requested %x to sleep for %ums", source, fwd_dest,
sleep_ms);
- ffa_ret = sp_sleep_cmd_send(own_id, fwd_dest, sleep_ms, 0);
+ ffa_ret = sp_sleep_cmd_send(own_id, fwd_dest, sleep_ms, options);
+
+ if (get_hint_interrupted(options)) {
+ hint_interrupted = true;
+ }
/*
* The target of the direct request could be pre-empted any number of