Add common RPC interface components
Add rpc_status_t, service_status_t and rpc_uuid definitions which are
intended to be used across different RPC implementations and in both
client and endpoint code.
Signed-off-by: Imre Kis <imre.kis@arm.com>
Change-Id: Icba3c7098657cde2904fe94e7154610253ad2438
diff --git a/components/rpc/common/interface/component.cmake b/components/rpc/common/interface/component.cmake
index e4b2477..51f1f24 100644
--- a/components/rpc/common/interface/component.cmake
+++ b/components/rpc/common/interface/component.cmake
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
+# Copyright (c) 2020-2023, Arm Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -11,9 +11,13 @@
set_property(TARGET ${TGT} APPEND PROPERTY PUBLIC_HEADER
"${CMAKE_CURRENT_LIST_DIR}/rpc_caller.h"
"${CMAKE_CURRENT_LIST_DIR}/rpc_status.h"
+ "${CMAKE_CURRENT_LIST_DIR}/rpc_uuid.h"
)
target_include_directories(${TGT} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>"
- "$<INSTALL_INTERFACE:${TS_ENV}/include>"
+ )
+
+target_sources(${TGT} PRIVATE
+ "${CMAKE_CURRENT_LIST_DIR}/rpc_uuid.c"
)
diff --git a/components/rpc/common/interface/rpc_status.h b/components/rpc/common/interface/rpc_status.h
index cba9dac..5cd2590 100644
--- a/components/rpc/common/interface/rpc_status.h
+++ b/components/rpc/common/interface/rpc_status.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2020-2023, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -13,22 +13,24 @@
extern "C" {
#endif
-/** \brief RPC status code type
- *
- * Used for returning the status of an RPC transaction. This is
- * different from the opstatus which is used to return an endpoint
- * specific status value.
+/**
+ * Used for returning the status of an RPC transaction. These values indicating the result of the
+ * RPC layer operations. Service level result must be handled in a service specific way.
*/
+
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;
+#define RPC_SUCCESS (0)
+#define RPC_ERROR_INTERNAL (-1)
+#define RPC_ERROR_INVALID_VALUE (-2)
+#define RPC_ERROR_NOT_FOUND (-3)
+#define RPC_ERROR_INVALID_STATE (-4)
+#define RPC_ERROR_TRANSPORT_LAYER (-5)
+#define RPC_ERROR_INVALID_REQUEST_BODY (-6)
+#define RPC_ERROR_INVALID_RESPONSE_BODY (-7)
+#define RPC_ERROR_RESOURCE_FAILURE (-8)
+
+typedef int64_t service_status_t;
#ifdef __cplusplus
}
diff --git a/components/rpc/common/interface/rpc_uuid.c b/components/rpc/common/interface/rpc_uuid.c
new file mode 100644
index 0000000..fd88b6e
--- /dev/null
+++ b/components/rpc/common/interface/rpc_uuid.c
@@ -0,0 +1,13 @@
+/*
+ * Copyright (c) 2023, Arm Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "rpc_uuid.h"
+#include <string.h>
+
+bool rpc_uuid_equal(const struct rpc_uuid *uuid_a, const struct rpc_uuid *uuid_b)
+{
+ return memcmp(uuid_a->uuid, uuid_b->uuid, sizeof(uuid_a->uuid)) == 0;
+}
diff --git a/components/rpc/common/interface/rpc_uuid.h b/components/rpc/common/interface/rpc_uuid.h
new file mode 100644
index 0000000..52782c7
--- /dev/null
+++ b/components/rpc/common/interface/rpc_uuid.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2023, Arm Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef RPC_UUID_H
+#define RPC_UUID_H
+
+#include <stdbool.h>
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief RPC UUID
+ *
+ * Describes a UUID for identifying an RPC service.
+ */
+struct rpc_uuid {
+ uint8_t uuid[16];
+};
+
+/**
+ * @brief Checks if two RPC UUIDs are equal
+ *
+ * @param uuid_a UUID A
+ * @param uuid_b UUID B
+ * @return true
+ * @return false
+ */
+bool rpc_uuid_equal(const struct rpc_uuid *uuid_a, const struct rpc_uuid *uuid_b);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RPC_UUID_H */