Add 64 bit direct message handling to libsp
* Change direct message struct to allow 64 bit arguments
* Add 64 bit direct message req/resp functions to FF-A layer
* Distinguish 32/64 bit messages on SP layer by field in sp_msg
* Update tests and mocks
The FF-A direct message response must match the request's 32/64bit mode
which is the responsibility of the callee and it should be validated by
the SPMC.
Signed-off-by: Imre Kis <imre.kis@arm.com>
Change-Id: Ibbd64ca0291dfe142a23471a649a07ba1a036824
diff --git a/components/messaging/ffa/libsp/include/ffa_api.h b/components/messaging/ffa/libsp/include/ffa_api.h
index ec5cb04..4b7073b 100644
--- a/components/messaging/ffa/libsp/include/ffa_api.h
+++ b/components/messaging/ffa/libsp/include/ffa_api.h
@@ -126,8 +126,8 @@
/** Messaging interfaces */
/**
- * @brief Sends a partition message in parameter registers as a request and
- * blocks until the response is available.
+ * @brief Sends a 32 bit partition message in parameter registers as a
+ * request and blocks until the response is available.
* @note The ffa_interrupt_handler function can be called during the
* execution of this function
*
@@ -138,13 +138,14 @@
*
* @return The FF-A error status code
*/
-ffa_result ffa_msg_send_direct_req(uint16_t source, uint16_t dest, uint32_t a0,
- uint32_t a1, uint32_t a2, uint32_t a3,
- uint32_t a4, struct ffa_direct_msg *msg);
+ffa_result ffa_msg_send_direct_req_32(uint16_t source, uint16_t dest,
+ uint32_t a0, uint32_t a1, uint32_t a2,
+ uint32_t a3, uint32_t a4,
+ struct ffa_direct_msg *msg);
/**
- * @brief Sends a partition message in parameter registers as a response
- * and blocks until the response is available.
+ * @brief Sends a 64 bit partition message in parameter registers as a
+ * request and blocks until the response is available.
* @note The ffa_interrupt_handler function can be called during the
* execution of this function
*
@@ -155,9 +156,46 @@
*
* @return The FF-A error status code
*/
-ffa_result ffa_msg_send_direct_resp(uint16_t source, uint16_t dest, uint32_t a0,
- uint32_t a1, uint32_t a2, uint32_t a3,
- uint32_t a4, struct ffa_direct_msg *msg);
+ffa_result ffa_msg_send_direct_req_64(uint16_t source, uint16_t dest,
+ uint64_t a0, uint64_t a1, uint64_t a2,
+ uint64_t a3, uint64_t a4,
+ struct ffa_direct_msg *msg);
+
+/**
+ * @brief Sends a 32 bit partition message in parameter registers as a
+ * response and blocks until the response is available.
+ * @note The ffa_interrupt_handler function can be called during the
+ * execution of this function
+ *
+ * @param[in] source Source endpoint ID
+ * @param[in] dest Destination endpoint ID
+ * @param[in] a0,a1,a2,a3,a4 Implementation defined message values
+ * @param[out] msg The response message
+ *
+ * @return The FF-A error status code
+ */
+ffa_result ffa_msg_send_direct_resp_32(uint16_t source, uint16_t dest,
+ uint32_t a0, uint32_t a1, uint32_t a2,
+ uint32_t a3, uint32_t a4,
+ struct ffa_direct_msg *msg);
+
+/**
+ * @brief Sends a 64 bit partition message in parameter registers as a
+ * response and blocks until the response is available.
+ * @note The ffa_interrupt_handler function can be called during the
+ * execution of this function
+ *
+ * @param[in] source Source endpoint ID
+ * @param[in] dest Destination endpoint ID
+ * @param[in] a0,a1,a2,a3,a4 Implementation defined message values
+ * @param[out] msg The response message
+ *
+ * @return The FF-A error status code
+ */
+ffa_result ffa_msg_send_direct_resp_64(uint16_t source, uint16_t dest,
+ uint64_t a0, uint64_t a1, uint64_t a2,
+ uint64_t a3, uint64_t a4,
+ struct ffa_direct_msg *msg);
/**
* Memory management interfaces
diff --git a/components/messaging/ffa/libsp/include/ffa_api_defines.h b/components/messaging/ffa/libsp/include/ffa_api_defines.h
index 95bcb0c..163a0cd 100644
--- a/components/messaging/ffa/libsp/include/ffa_api_defines.h
+++ b/components/messaging/ffa/libsp/include/ffa_api_defines.h
@@ -58,6 +58,11 @@
#define FFA_MEM_PERM_GET UINT32_C(0x84000088)
#define FFA_MEM_PERM_SET UINT32_C(0x84000089)
+/* Utility macros */
+#define FFA_TO_32_BIT_FUNC(x) ((x) & (~UINT32_C(0x40000000)))
+#define FFA_IS_32_BIT_FUNC(x) (((x) & UINT32_C(0x40000000)) == 0)
+#define FFA_IS_64_BIT_FUNC(x) (((x) & UINT32_C(0x40000000)) != 0)
+
/* Special value for MBZ parameters */
#define FFA_PARAM_MBZ UINT32_C(0x0)
diff --git a/components/messaging/ffa/libsp/include/ffa_api_types.h b/components/messaging/ffa/libsp/include/ffa_api_types.h
index 3686e2e..b1be7ac 100644
--- a/components/messaging/ffa/libsp/include/ffa_api_types.h
+++ b/components/messaging/ffa/libsp/include/ffa_api_types.h
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: BSD-3-Clause */
/*
- * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
*/
#ifndef LIBSP_INCLUDE_FFA_API_TYPES_H_
@@ -80,7 +80,10 @@
uint32_t function_id;
uint16_t source_id;
uint16_t destination_id;
- uint32_t args[5];
+ union {
+ uint32_t args32[5];
+ uint64_t args64[5];
+ } args;
};
/**
diff --git a/components/messaging/ffa/libsp/include/sp_messaging.h b/components/messaging/ffa/libsp/include/sp_messaging.h
index 4bb45f7..7173a92 100644
--- a/components/messaging/ffa/libsp/include/sp_messaging.h
+++ b/components/messaging/ffa/libsp/include/sp_messaging.h
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: BSD-3-Clause */
/*
- * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
*/
#ifndef LIBSP_INCLUDE_SP_MESSAGING_H_
@@ -9,6 +9,7 @@
#include "sp_api_defines.h"
#include "sp_api_types.h"
+#include <stdbool.h>
#include <stdint.h>
#ifdef __cplusplus
@@ -23,7 +24,11 @@
struct sp_msg {
uint16_t source_id;
uint16_t destination_id;
- uint32_t args[SP_MSG_ARG_COUNT];
+ bool is_64bit_message;
+ union {
+ uint32_t args32[SP_MSG_ARG_COUNT];
+ uint64_t args64[SP_MSG_ARG_COUNT];
+ } args;
};
/**