aboutsummaryrefslogtreecommitdiff
path: root/components/rpc/ffarpc/endpoint
diff options
context:
space:
mode:
Diffstat (limited to 'components/rpc/ffarpc/endpoint')
-rw-r--r--components/rpc/ffarpc/endpoint/ffarpc_call_args.h14
-rw-r--r--components/rpc/ffarpc/endpoint/ffarpc_call_ep.c39
-rw-r--r--components/rpc/ffarpc/endpoint/ffarpc_call_ep.h8
-rw-r--r--components/rpc/ffarpc/endpoint/ffarpc_call_ops.h16
4 files changed, 47 insertions, 30 deletions
diff --git a/components/rpc/ffarpc/endpoint/ffarpc_call_args.h b/components/rpc/ffarpc/endpoint/ffarpc_call_args.h
index 402e4f5..fbe7320 100644
--- a/components/rpc/ffarpc/endpoint/ffarpc_call_args.h
+++ b/components/rpc/ffarpc/endpoint/ffarpc_call_args.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
*/
@@ -17,11 +17,21 @@ extern "C" {
* normal world RPC caller and the RPC listener in the SP.
*/
+/* Macros for parameters carried in a single register */
+#define FFA_CALL_ARGS_COMBINE_IFACE_ID_OPCODE(i, o) \
+ (((i) << 16) | ((o) & 0xffff))
+#define FFA_CALL_ARGS_EXTRACT_IFACE(reg) \
+ ((reg) >> 16)
+#define FFA_CALL_ARGS_EXTRACT_OPCODE(reg) \
+ ((reg) & 0xffff)
+
/* Common req & resp arg offests into msg_args structure */
-#define FFA_CALL_ARGS_OPCODE (0)
+#define FFA_CALL_ARGS_IFACE_ID_OPCODE (0)
/* Req arg offsets */
#define FFA_CALL_ARGS_REQ_DATA_LEN (1)
+#define FFA_CALL_ARGS_CALLER_ID (2)
+#define FFA_CALL_ARGS_ENCODING (3)
/* Resp arg offsets */
#define FFA_CALL_ARGS_RESP_DATA_LEN (1)
diff --git a/components/rpc/ffarpc/endpoint/ffarpc_call_ep.c b/components/rpc/ffarpc/endpoint/ffarpc_call_ep.c
index bb40cf3..1139e73 100644
--- a/components/rpc/ffarpc/endpoint/ffarpc_call_ep.c
+++ b/components/rpc/ffarpc/endpoint/ffarpc_call_ep.c
@@ -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
*/
@@ -16,16 +16,16 @@
/* TODO: remove this when own ID will be available in libsp */
extern uint16_t own_id;
-static void set_resp_args(uint32_t *resp_args, uint32_t opcode, uint32_t data_len,
+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)
{
- resp_args[FFA_CALL_ARGS_OPCODE] = opcode;
+ resp_args[FFA_CALL_ARGS_IFACE_ID_OPCODE] = ifaceid_opcode;
resp_args[FFA_CALL_ARGS_RESP_DATA_LEN] = data_len;
resp_args[FFA_CALL_ARGS_RESP_RPC_STATUS] = rpc_status;
resp_args[FFA_CALL_ARGS_RESP_OP_STATUS] = opstatus;
}
-static void set_mgmt_resp_args(uint32_t *resp_args, uint32_t opcode,
+static void set_mgmt_resp_args(uint32_t *resp_args, uint32_t ifaceid_opcode,
rpc_status_t rpc_status)
{
/*
@@ -33,7 +33,7 @@ static void set_mgmt_resp_args(uint32_t *resp_args, uint32_t opcode,
* rather than from a higher layer service. These responses are not
* associated with a shared buffer for any additional message payload.
*/
- set_resp_args(resp_args, opcode, 0, rpc_status, 0);
+ set_resp_args(resp_args, ifaceid_opcode, 0, rpc_status, 0);
}
static void init_shmem_buf(struct ffa_call_ep *call_ep, uint16_t source_id,
@@ -68,7 +68,7 @@ static void init_shmem_buf(struct ffa_call_ep *call_ep, uint16_t source_id,
EMSG("memory retrieve error: %d", sp_res);
}
- set_mgmt_resp_args(resp_args, req_args[FFA_CALL_ARGS_OPCODE], rpc_status);
+ set_mgmt_resp_args(resp_args, req_args[FFA_CALL_ARGS_IFACE_ID_OPCODE], rpc_status);
}
static void deinit_shmem_buf(struct ffa_call_ep *call_ep, const uint32_t *req_args,
@@ -94,7 +94,7 @@ static void deinit_shmem_buf(struct ffa_call_ep *call_ep, const uint32_t *req_ar
EMSG("memory relinquish error: %d", sp_res);
}
- set_mgmt_resp_args(resp_args, req_args[FFA_CALL_ARGS_OPCODE], rpc_status);
+ set_mgmt_resp_args(resp_args, req_args[FFA_CALL_ARGS_IFACE_ID_OPCODE], rpc_status);
}
static void handle_service_msg(struct ffa_call_ep *call_ep, uint16_t source_id,
@@ -103,8 +103,12 @@ static void handle_service_msg(struct ffa_call_ep *call_ep, uint16_t source_id,
rpc_status_t rpc_status;
struct call_req call_req;
+ uint32_t ifaceid_opcode = req_args[FFA_CALL_ARGS_IFACE_ID_OPCODE];
+
call_req.caller_id = source_id;
- call_req.opcode = req_args[FFA_CALL_ARGS_OPCODE];
+ call_req.interface_id = FFA_CALL_ARGS_EXTRACT_IFACE(ifaceid_opcode);
+ call_req.opcode = FFA_CALL_ARGS_EXTRACT_OPCODE(ifaceid_opcode);
+ call_req.encoding = req_args[FFA_CALL_ARGS_ENCODING];
call_req.req_buf.data = call_ep->shmem_buf;
call_req.req_buf.data_len = req_args[FFA_CALL_ARGS_REQ_DATA_LEN];
@@ -114,10 +118,10 @@ static void handle_service_msg(struct ffa_call_ep *call_ep, uint16_t source_id,
call_req.resp_buf.data_len = 0;
call_req.resp_buf.size = call_ep->shmem_buf_size;
- rpc_status = call_ep_receive(call_ep->call_ep, &call_req);
+ rpc_status = rpc_interface_receive(call_ep->iface, &call_req);
set_resp_args(resp_args,
- call_req.opcode,
+ ifaceid_opcode,
call_req.resp_buf.data_len,
rpc_status,
call_req.opstatus);
@@ -126,7 +130,8 @@ static void handle_service_msg(struct ffa_call_ep *call_ep, uint16_t source_id,
static void handle_mgmt_msg(struct ffa_call_ep *call_ep, uint16_t source_id,
const uint32_t *req_args, uint32_t *resp_args)
{
- uint32_t opcode = req_args[FFA_CALL_ARGS_OPCODE];
+ uint32_t ifaceid_opcode = req_args[FFA_CALL_ARGS_IFACE_ID_OPCODE];
+ uint32_t opcode = FFA_CALL_ARGS_EXTRACT_OPCODE(ifaceid_opcode);
/*
* TODO: shouldn't this be used to keep track of multiple
@@ -142,14 +147,14 @@ static void handle_mgmt_msg(struct ffa_call_ep *call_ep, uint16_t source_id,
deinit_shmem_buf(call_ep, req_args, resp_args);
break;
default:
- set_mgmt_resp_args(resp_args, opcode, TS_RPC_ERROR_INVALID_OPCODE);
+ set_mgmt_resp_args(resp_args, ifaceid_opcode, TS_RPC_ERROR_INVALID_OPCODE);
break;
}
}
-void ffa_call_ep_init(struct ffa_call_ep *ffa_call_ep, struct call_ep *call_ep)
+void ffa_call_ep_init(struct ffa_call_ep *ffa_call_ep, struct rpc_interface *iface)
{
- ffa_call_ep->call_ep = call_ep;
+ ffa_call_ep->iface = iface;
ffa_call_ep->shmem_buf_handle = 0;
ffa_call_ep->shmem_buf_size = 0;
ffa_call_ep->shmem_buf = NULL;
@@ -163,9 +168,9 @@ void ffa_call_ep_receive(struct ffa_call_ep *call_ep,
uint32_t *resp_args = resp_msg->args;
uint16_t source_id = req_msg->source_id;
- uint32_t opcode = req_args[FFA_CALL_ARGS_OPCODE];
+ uint32_t ifaceid_opcode = req_args[FFA_CALL_ARGS_IFACE_ID_OPCODE];
- if (FFA_CALL_OPCODE_IS_MGMT(opcode)) {
+ if (FFA_CALL_ARGS_EXTRACT_IFACE(ifaceid_opcode) == FFA_CALL_MGMT_IFACE_ID) {
/* It's an RPC layer management request */
handle_mgmt_msg(call_ep, source_id, req_args, resp_args);
} else {
@@ -177,6 +182,6 @@ void ffa_call_ep_receive(struct ffa_call_ep *call_ep,
if (call_ep->shmem_buf)
handle_service_msg(call_ep, source_id, req_args, resp_args);
else
- set_mgmt_resp_args(resp_args, opcode, TS_RPC_ERROR_NOT_READY);
+ set_mgmt_resp_args(resp_args, ifaceid_opcode, TS_RPC_ERROR_NOT_READY);
}
}
diff --git a/components/rpc/ffarpc/endpoint/ffarpc_call_ep.h b/components/rpc/ffarpc/endpoint/ffarpc_call_ep.h
index b4bcdd6..cc67f6e 100644
--- a/components/rpc/ffarpc/endpoint/ffarpc_call_ep.h
+++ b/components/rpc/ffarpc/endpoint/ffarpc_call_ep.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
*/
@@ -8,7 +8,7 @@
#define FFA_CALL_EP_H
#include <ffa_api.h>
-#include <components/rpc/common/endpoint/call_ep.h>
+#include <components/rpc/common/endpoint/rpc_interface.h>
#include <stddef.h>
#include <stdint.h>
@@ -17,13 +17,13 @@ extern "C" {
#endif
struct ffa_call_ep {
- struct call_ep *call_ep;
+ struct rpc_interface *iface;
unsigned long shmem_buf_handle;
volatile uint8_t *shmem_buf;
size_t shmem_buf_size;
};
-void ffa_call_ep_init(struct ffa_call_ep *ffa_call_ep, struct call_ep *call_ep);
+void ffa_call_ep_init(struct ffa_call_ep *ffa_call_ep, struct rpc_interface *iface);
void ffa_call_ep_receive(struct ffa_call_ep *call_ep,
const struct ffa_direct_msg *req_msg,
struct ffa_direct_msg *resp_msg);
diff --git a/components/rpc/ffarpc/endpoint/ffarpc_call_ops.h b/components/rpc/ffarpc/endpoint/ffarpc_call_ops.h
index 3f14fc7..de22678 100644
--- a/components/rpc/ffarpc/endpoint/ffarpc_call_ops.h
+++ b/components/rpc/ffarpc/endpoint/ffarpc_call_ops.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
*/
@@ -12,13 +12,15 @@ extern "C" {
#endif
/* Common opcodes used by the FFA based RPC layer for management operations */
-#define FFA_CALL_OPCODE_BASE (0x10)
-#define FFA_CALL_OPCODE_SHARE_BUF (FFA_CALL_OPCODE_BASE + 0)
-#define FFA_CALL_OPCODE_UNSHARE_BUF (FFA_CALL_OPCODE_BASE + 1)
-#define FFA_CALL_OPCODE_LIMIT (FFA_CALL_OPCODE_BASE + 2)
+enum
+{
+ FFA_CALL_OPCODE_SHARE_BUF = 0,
+ FFA_CALL_OPCODE_UNSHARE_BUF = 1,
+ FFA_CALL_OPCODE_LIMIT
+};
-#define FFA_CALL_OPCODE_IS_MGMT(opcode) \
- ((opcode >= FFA_CALL_OPCODE_BASE) && (opcode < FFA_CALL_OPCODE_LIMIT))
+/* Interface ID for FFA management interface */
+#define FFA_CALL_MGMT_IFACE_ID (0x1000)
#ifdef __cplusplus
}