Add support for 64-bit operation status values
For compatibility with 64-bit EFI status codes, opstatus values
are now treated as 64-bit rather than 32-bit. A new rpc_opstatus_t
type has been introduced in this change. Note that the FFARPC
still maps the opstatus value to a 32-bit regsiter value but
this is sign extended up to 64-bits in RPC callers. The MM
Communicate RPC caller and endpoint handle 64-bit status values.
Signed-off-by: Julian Hall <julian.hall@arm.com>
Change-Id: I06a0883394f370ccb543ebab797973bb604ff489
diff --git a/components/rpc/common/caller/rpc_caller.c b/components/rpc/common/caller/rpc_caller.c
index 00b559c..2dceabe 100644
--- a/components/rpc/common/caller/rpc_caller.c
+++ b/components/rpc/common/caller/rpc_caller.c
@@ -28,7 +28,7 @@
}
rpc_status_t rpc_caller_invoke(struct rpc_caller *s, rpc_call_handle handle,
- uint32_t opcode, int *opstatus, uint8_t **resp_buf, size_t *resp_len)
+ uint32_t opcode, rpc_opstatus_t *opstatus, uint8_t **resp_buf, size_t *resp_len)
{
return s->call_invoke(s->context, handle, opcode, opstatus, resp_buf, resp_len);
}
diff --git a/components/rpc/common/endpoint/rpc_interface.h b/components/rpc/common/endpoint/rpc_interface.h
index ba949de..eb98587 100644
--- a/components/rpc/common/endpoint/rpc_interface.h
+++ b/components/rpc/common/endpoint/rpc_interface.h
@@ -62,7 +62,7 @@
uint32_t interface_id;
uint32_t opcode;
uint32_t encoding;
- int opstatus;
+ rpc_opstatus_t opstatus;
struct call_param_buf req_buf;
struct call_param_buf resp_buf;
};
@@ -87,12 +87,12 @@
return req->encoding;
}
-static inline int call_req_get_opstatus(const struct call_req *req)
+static inline rpc_opstatus_t call_req_get_opstatus(const struct call_req *req)
{
return req->opstatus;
}
-static inline void call_req_set_opstatus(struct call_req *req, int opstatus)
+static inline void call_req_set_opstatus(struct call_req *req, rpc_opstatus_t opstatus)
{
req->opstatus = opstatus;
}
diff --git a/components/rpc/common/interface/rpc_caller.h b/components/rpc/common/interface/rpc_caller.h
index 879d2cb..387489c 100644
--- a/components/rpc/common/interface/rpc_caller.h
+++ b/components/rpc/common/interface/rpc_caller.h
@@ -42,7 +42,7 @@
rpc_call_handle (*call_begin)(void *context, uint8_t **req_buf, size_t req_len);
rpc_status_t (*call_invoke)(void *context, rpc_call_handle handle, uint32_t opcode,
- int *opstatus, uint8_t **resp_buf, size_t *resp_len);
+ rpc_opstatus_t *opstatus, uint8_t **resp_buf, size_t *resp_len);
void (*call_end)(void *context, rpc_call_handle handle);
};
@@ -79,7 +79,7 @@
* call_end() is called for the transaction.
*/
RPC_CALLER_EXPORTED rpc_status_t rpc_caller_invoke(struct rpc_caller *s, rpc_call_handle handle,
- uint32_t opcode, int *opstatus, uint8_t **resp_buf, size_t *resp_len);
+ uint32_t opcode, rpc_opstatus_t *opstatus, uint8_t **resp_buf, size_t *resp_len);
/*
* Ends the call transaction, allowing any resource associated with the
diff --git a/components/rpc/common/interface/rpc_status.h b/components/rpc/common/interface/rpc_status.h
index 0405a64..cba9dac 100644
--- a/components/rpc/common/interface/rpc_status.h
+++ b/components/rpc/common/interface/rpc_status.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -21,6 +21,15 @@
*/
typedef int32_t rpc_status_t;
+/** \brief RPC operation status code type
+ *
+ * Used for returning the endpoint specific operation status.
+ * Different service layer protocols will use different status
+ * value schemes. Status values returned by an operation are
+ * carried by the RPC layer using this type.
+ */
+typedef int64_t rpc_opstatus_t;
+
#ifdef __cplusplus
}
#endif
diff --git a/components/rpc/common/logging/logging_caller.c b/components/rpc/common/logging/logging_caller.c
index efc1184..07c33de 100644
--- a/components/rpc/common/logging/logging_caller.c
+++ b/components/rpc/common/logging/logging_caller.c
@@ -10,7 +10,7 @@
static rpc_call_handle call_begin(void *context, uint8_t **req_buf, size_t req_len);
static rpc_status_t call_invoke(void *context, rpc_call_handle handle, uint32_t opcode,
- int *opstatus, uint8_t **resp_buf, size_t *resp_len);
+ rpc_opstatus_t *opstatus, uint8_t **resp_buf, size_t *resp_len);
static void call_end(void *context, rpc_call_handle handle);
@@ -69,7 +69,7 @@
}
static rpc_status_t call_invoke(void *context, rpc_call_handle handle, uint32_t opcode,
- int *opstatus, uint8_t **resp_buf, size_t *resp_len)
+ rpc_opstatus_t *opstatus, uint8_t **resp_buf, size_t *resp_len)
{
struct logging_caller *this_instance = (struct logging_caller*)context;
rpc_status_t status = TS_RPC_ERROR_INVALID_TRANSACTION;
diff --git a/components/rpc/direct/direct_caller.c b/components/rpc/direct/direct_caller.c
index 14f1a91..61f25d7 100644
--- a/components/rpc/direct/direct_caller.c
+++ b/components/rpc/direct/direct_caller.c
@@ -14,7 +14,7 @@
static rpc_call_handle call_begin(void *context, uint8_t **req_buf, size_t req_len);
static rpc_status_t call_invoke(void *context, rpc_call_handle handle, uint32_t opcode,
- int *opstatus, uint8_t **resp_buf, size_t *resp_len);
+ rpc_opstatus_t *opstatus, uint8_t **resp_buf, size_t *resp_len);
static void call_end(void *context, rpc_call_handle handle);
@@ -85,7 +85,7 @@
}
static rpc_status_t call_invoke(void *context, rpc_call_handle handle, uint32_t opcode,
- int *opstatus, uint8_t **resp_buf, size_t *resp_len)
+ rpc_opstatus_t *opstatus, uint8_t **resp_buf, size_t *resp_len)
{
struct direct_caller *this_context = (struct direct_caller*)context;
rpc_status_t status = TS_RPC_ERROR_INVALID_TRANSACTION;
diff --git a/components/rpc/dummy/dummy_caller.c b/components/rpc/dummy/dummy_caller.c
index f55b418..da0f491 100644
--- a/components/rpc/dummy/dummy_caller.c
+++ b/components/rpc/dummy/dummy_caller.c
@@ -9,12 +9,12 @@
static rpc_call_handle call_begin(void *context, uint8_t **req_buf, size_t req_len);
static rpc_status_t call_invoke(void *context, rpc_call_handle handle, uint32_t opcode,
- int *opstatus, uint8_t **resp_buf, size_t *resp_len);
+ rpc_opstatus_t *opstatus, uint8_t **resp_buf, size_t *resp_len);
static void call_end(void *context, rpc_call_handle handle);
struct rpc_caller *dummy_caller_init(struct dummy_caller *s,
- rpc_status_t rpc_status, int opstatus)
+ rpc_status_t rpc_status, rpc_opstatus_t opstatus)
{
struct rpc_caller *base = &s->rpc_caller;
@@ -49,7 +49,7 @@
}
static rpc_status_t call_invoke(void *context, rpc_call_handle handle, uint32_t opcode,
- int *opstatus, uint8_t **resp_buf, size_t *resp_len)
+ rpc_opstatus_t *opstatus, uint8_t **resp_buf, size_t *resp_len)
{
struct dummy_caller *this_context = (struct dummy_caller*)context;
diff --git a/components/rpc/dummy/dummy_caller.h b/components/rpc/dummy/dummy_caller.h
index 27fe68a..b93c02f 100644
--- a/components/rpc/dummy/dummy_caller.h
+++ b/components/rpc/dummy/dummy_caller.h
@@ -26,12 +26,12 @@
{
struct rpc_caller rpc_caller;
rpc_status_t rpc_status;
- int opstatus;
+ rpc_opstatus_t opstatus;
uint8_t *req_buf;
};
struct rpc_caller *dummy_caller_init(struct dummy_caller *s,
- rpc_status_t rpc_status, int opstatus);
+ rpc_status_t rpc_status, rpc_opstatus_t opstatus);
void dummy_caller_deinit(struct dummy_caller *s);
#ifdef __cplusplus
diff --git a/components/rpc/ffarpc/caller/linux/ffarpc_caller.c b/components/rpc/ffarpc/caller/linux/ffarpc_caller.c
index ee879a0..1464a8a 100644
--- a/components/rpc/ffarpc/caller/linux/ffarpc_caller.c
+++ b/components/rpc/ffarpc/caller/linux/ffarpc_caller.c
@@ -25,7 +25,7 @@
static rpc_call_handle call_begin(void *context, uint8_t **req_buf, size_t req_len);
static rpc_status_t call_invoke(void *context, rpc_call_handle handle, uint32_t opcode,
- int *opstatus, uint8_t **resp_buf, size_t *resp_len);
+ rpc_opstatus_t *opstatus, uint8_t **resp_buf, size_t *resp_len);
static void call_end(void *context, rpc_call_handle handle);
static int kernel_write_req_buf(struct ffarpc_caller *s);
@@ -249,7 +249,7 @@
}
static rpc_status_t call_invoke(void *context, rpc_call_handle handle, uint32_t opcode,
- int *opstatus, uint8_t **resp_buf, size_t *resp_len)
+ rpc_opstatus_t *opstatus, uint8_t **resp_buf, size_t *resp_len)
{
rpc_status_t rpc_status = TS_RPC_ERROR_INTERNAL;
struct ffarpc_caller *s = (struct ffarpc_caller*)context;
@@ -283,8 +283,8 @@
if (kernel_op_status == 0) {
/* Send completed normally - ffa return args in msg_args struct */
s->resp_len = (size_t)direct_msg.args[FFA_CALL_ARGS_RESP_DATA_LEN];
- rpc_status = (int)direct_msg.args[FFA_CALL_ARGS_RESP_RPC_STATUS];
- *opstatus = (int)direct_msg.args[FFA_CALL_ARGS_RESP_OP_STATUS];
+ rpc_status = (rpc_status_t)direct_msg.args[FFA_CALL_ARGS_RESP_RPC_STATUS];
+ *opstatus = (rpc_opstatus_t)((int32_t)direct_msg.args[FFA_CALL_ARGS_RESP_OP_STATUS]);
if (s->resp_len > 0) {
s->resp_buf = malloc(s->resp_len);
diff --git a/components/rpc/ffarpc/caller/sp/ffarpc_caller.c b/components/rpc/ffarpc/caller/sp/ffarpc_caller.c
index 9df7476..250b178 100644
--- a/components/rpc/ffarpc/caller/sp/ffarpc_caller.c
+++ b/components/rpc/ffarpc/caller/sp/ffarpc_caller.c
@@ -57,7 +57,7 @@
}
static rpc_status_t call_invoke(void *context, rpc_call_handle handle, uint32_t opcode,
- int *opstatus, uint8_t **resp_buf, size_t *resp_len)
+ rpc_opstatus_t *opstatus, uint8_t **resp_buf, size_t *resp_len)
{
struct ffarpc_caller *this_context = (struct ffarpc_caller *)context;
sp_result sp_res = SP_RESULT_OK;
@@ -101,7 +101,7 @@
this_context->resp_len = (size_t)resp.args[SP_CALL_ARGS_RESP_DATA_LEN];
status = resp.args[SP_CALL_ARGS_RESP_RPC_STATUS];
- *opstatus = resp.args[SP_CALL_ARGS_RESP_OP_STATUS];
+ *opstatus = (rpc_status_t)((int32_t)resp.args[SP_CALL_ARGS_RESP_OP_STATUS]);
if (this_context->resp_len > 0) {
this_context->resp_buf = shared_buffer;
diff --git a/components/rpc/ffarpc/endpoint/ffarpc_call_ep.c b/components/rpc/ffarpc/endpoint/ffarpc_call_ep.c
index 9db53eb..17f957c 100644
--- a/components/rpc/ffarpc/endpoint/ffarpc_call_ep.c
+++ b/components/rpc/ffarpc/endpoint/ffarpc_call_ep.c
@@ -17,12 +17,12 @@
extern uint16_t own_id;
static void set_resp_args(uint32_t *resp_args, uint32_t ifaceid_opcode, uint32_t data_len,
- rpc_status_t rpc_status, uint32_t opstatus)
+ rpc_status_t rpc_status, rpc_opstatus_t opstatus)
{
resp_args[SP_CALL_ARGS_IFACE_ID_OPCODE] = ifaceid_opcode;
resp_args[SP_CALL_ARGS_RESP_DATA_LEN] = data_len;
resp_args[SP_CALL_ARGS_RESP_RPC_STATUS] = rpc_status;
- resp_args[SP_CALL_ARGS_RESP_OP_STATUS] = opstatus;
+ resp_args[SP_CALL_ARGS_RESP_OP_STATUS] = (uint32_t)opstatus;
}
static void set_mgmt_resp_args(uint32_t *resp_args, uint32_t ifaceid_opcode,