aboutsummaryrefslogtreecommitdiff
path: root/applications/message_handler_openamp/message_handler.cpp
diff options
context:
space:
mode:
authorMikael Olsson <mikael.olsson@arm.com>2024-02-12 13:30:31 +0100
committerMikael Olsson <mikael.olsson@arm.com>2024-02-13 09:28:24 +0100
commit687095113aaafd4207e1acaacd6475174a60b4dc (patch)
treeb8fab2298b58056c015948579d44b3928ef25174 /applications/message_handler_openamp/message_handler.cpp
parent34b190bf804639805fb958c637c365dd831916b7 (diff)
downloadethos-u-core-platform-687095113aaafd4207e1acaacd6475174a60b4dc.tar.gz
Update rpmsg type names in message handler
With the restructuring of the Linux kernel driver source files, some macros and types in the rpmsg header was renamed to better namespace their usage. The message handler openamp application has been updated accordingly. Change-Id: Ibfc11ced58cddd23463bb2060d658cc9b374e035 Signed-off-by: Mikael Olsson <mikael.olsson@arm.com>
Diffstat (limited to 'applications/message_handler_openamp/message_handler.cpp')
-rw-r--r--applications/message_handler_openamp/message_handler.cpp89
1 files changed, 43 insertions, 46 deletions
diff --git a/applications/message_handler_openamp/message_handler.cpp b/applications/message_handler_openamp/message_handler.cpp
index 953372f..fa93a48 100644
--- a/applications/message_handler_openamp/message_handler.cpp
+++ b/applications/message_handler_openamp/message_handler.cpp
@@ -122,7 +122,7 @@ MessageHandler::~MessageHandler() {
}
int MessageHandler::handleMessage(void *data, size_t len, uint32_t src) {
- auto rpmsg = static_cast<EthosU::ethosu_core_rpmsg *>(data);
+ auto rpmsg = static_cast<EthosU::ethosu_rpmsg *>(data);
LOG_DEBUG("Msg: src=%" PRIX32 ", len=%zu, magic=%" PRIX32 ", type=%" PRIu32,
src,
@@ -130,27 +130,26 @@ int MessageHandler::handleMessage(void *data, size_t len, uint32_t src) {
rpmsg->header.magic,
rpmsg->header.type);
- if (rpmsg->header.magic != ETHOSU_CORE_MSG_MAGIC) {
+ if (rpmsg->header.magic != ETHOSU_RPMSG_MAGIC) {
LOG_WARN("Msg: Invalid Magic");
- sendError(src, EthosU::ETHOSU_CORE_MSG_ERR_INVALID_MAGIC, "Invalid magic");
+ sendError(src, EthosU::ETHOSU_RPMSG_ERR_INVALID_MAGIC, "Invalid magic");
return 0;
}
switch (rpmsg->header.type) {
- case EthosU::ETHOSU_CORE_MSG_PING: {
+ case EthosU::ETHOSU_RPMSG_PING: {
LOG_INFO("Msg: Ping");
sendPong(src, rpmsg->header.msg_id);
break;
}
- case EthosU::ETHOSU_CORE_MSG_VERSION_REQ: {
+ case EthosU::ETHOSU_RPMSG_VERSION_REQ: {
LOG_INFO("Msg: Version request");
sendVersionRsp(src, rpmsg->header.msg_id);
break;
}
- case EthosU::ETHOSU_CORE_MSG_CAPABILITIES_REQ: {
+ case EthosU::ETHOSU_RPMSG_CAPABILITIES_REQ: {
if (len != sizeof(rpmsg->header)) {
- sendError(
- src, EthosU::ETHOSU_CORE_MSG_ERR_INVALID_PAYLOAD, "Incorrect capabilities request payload length.");
+ sendError(src, EthosU::ETHOSU_RPMSG_ERR_INVALID_PAYLOAD, "Incorrect capabilities request payload length.");
break;
}
@@ -159,19 +158,19 @@ int MessageHandler::handleMessage(void *data, size_t len, uint32_t src) {
sendCapabilitiesRsp(src, rpmsg->header.msg_id);
break;
}
- case EthosU::ETHOSU_CORE_MSG_INFERENCE_REQ: {
+ case EthosU::ETHOSU_RPMSG_INFERENCE_REQ: {
if (len != sizeof(rpmsg->header) + sizeof(rpmsg->inf_req)) {
- sendError(src, EthosU::ETHOSU_CORE_MSG_ERR_INVALID_PAYLOAD, "Incorrect inference request payload length.");
+ sendError(src, EthosU::ETHOSU_RPMSG_ERR_INVALID_PAYLOAD, "Incorrect inference request payload length.");
break;
}
forwardInferenceReq(src, rpmsg->header.msg_id, rpmsg->inf_req);
break;
}
- case EthosU::ETHOSU_CORE_MSG_CANCEL_INFERENCE_REQ: {
+ case EthosU::ETHOSU_RPMSG_CANCEL_INFERENCE_REQ: {
if (len != sizeof(rpmsg->header) + sizeof(rpmsg->cancel_req)) {
sendError(
- src, EthosU::ETHOSU_CORE_MSG_ERR_INVALID_PAYLOAD, "Incorrect cancel inference request payload length.");
+ src, EthosU::ETHOSU_RPMSG_ERR_INVALID_PAYLOAD, "Incorrect cancel inference request payload length.");
break;
}
@@ -188,16 +187,15 @@ int MessageHandler::handleMessage(void *data, size_t len, uint32_t src) {
});
if (found) {
- sendInferenceRsp(src, request.inference_handle, EthosU::ETHOSU_CORE_STATUS_ABORTED);
+ sendInferenceRsp(src, request.inference_handle, EthosU::ETHOSU_RPMSG_STATUS_ABORTED);
}
- sendCancelInferenceRsp(src, rpmsg->header.msg_id, EthosU::ETHOSU_CORE_STATUS_OK);
+ sendCancelInferenceRsp(src, rpmsg->header.msg_id, EthosU::ETHOSU_RPMSG_STATUS_OK);
break;
}
- case EthosU::ETHOSU_CORE_MSG_NETWORK_INFO_REQ: {
+ case EthosU::ETHOSU_RPMSG_NETWORK_INFO_REQ: {
if (len != sizeof(rpmsg->header) + sizeof(rpmsg->net_info_req)) {
- sendError(
- src, EthosU::ETHOSU_CORE_MSG_ERR_INVALID_PAYLOAD, "Incorrect network info request payload length.");
+ sendError(src, EthosU::ETHOSU_RPMSG_ERR_INVALID_PAYLOAD, "Incorrect network info request payload length.");
break;
}
@@ -218,15 +216,15 @@ int MessageHandler::handleMessage(void *data, size_t len, uint32_t src) {
snprintf(
&errMsg[0], sizeof(errMsg), "Msg: Unknown message. type=%" PRIu32 ", length=%zu", rpmsg->header.type, len);
- sendError(src, EthosU::ETHOSU_CORE_MSG_ERR_UNSUPPORTED_TYPE, errMsg);
+ sendError(src, EthosU::ETHOSU_RPMSG_ERR_UNSUPPORTED_TYPE, errMsg);
}
}
return 0;
}
-void MessageHandler::sendError(const uint32_t src, const EthosU::ethosu_core_err_type type, const char *msg) {
- auto message = new Message(src, EthosU::ETHOSU_CORE_MSG_ERR, 0, sizeof(EthosU::ethosu_core_msg_err));
+void MessageHandler::sendError(const uint32_t src, const EthosU::ethosu_rpmsg_err_type type, const char *msg) {
+ auto message = new Message(src, EthosU::ETHOSU_RPMSG_ERR, 0, sizeof(EthosU::ethosu_rpmsg_err));
message->rpmsg.error.type = type;
@@ -238,19 +236,18 @@ void MessageHandler::sendError(const uint32_t src, const EthosU::ethosu_core_err
}
void MessageHandler::sendPong(const uint32_t src, const uint64_t msgId) {
- auto message = new Message(src, EthosU::ETHOSU_CORE_MSG_PONG, msgId);
+ auto message = new Message(src, EthosU::ETHOSU_RPMSG_PONG, msgId);
responseQueue.send(message);
}
void MessageHandler::sendVersionRsp(const uint32_t src, const uint64_t msgId) {
- auto message =
- new Message(src, EthosU::ETHOSU_CORE_MSG_VERSION_RSP, msgId, sizeof(EthosU::ethosu_core_msg_version_rsp));
+ auto message = new Message(src, EthosU::ETHOSU_RPMSG_VERSION_RSP, msgId, sizeof(EthosU::ethosu_rpmsg_version_rsp));
message->rpmsg.version_rsp = {
- ETHOSU_CORE_MSG_VERSION_MAJOR,
- ETHOSU_CORE_MSG_VERSION_MINOR,
- ETHOSU_CORE_MSG_VERSION_PATCH,
+ ETHOSU_RPMSG_VERSION_MAJOR,
+ ETHOSU_RPMSG_VERSION_MINOR,
+ ETHOSU_RPMSG_VERSION_PATCH,
0,
};
@@ -258,16 +255,16 @@ void MessageHandler::sendVersionRsp(const uint32_t src, const uint64_t msgId) {
}
void MessageHandler::sendCapabilitiesRsp(const uint32_t src, const uint64_t msgId) {
- auto message = new Message(
- src, EthosU::ETHOSU_CORE_MSG_CAPABILITIES_RSP, msgId, sizeof(EthosU::ethosu_core_msg_capabilities_rsp));
+ auto message =
+ new Message(src, EthosU::ETHOSU_RPMSG_CAPABILITIES_RSP, msgId, sizeof(EthosU::ethosu_rpmsg_capabilities_rsp));
message->rpmsg.cap_rsp = capabilities;
responseQueue.send(message);
}
-EthosU::ethosu_core_msg_capabilities_rsp MessageHandler::getCapabilities() const {
- EthosU::ethosu_core_msg_capabilities_rsp cap = {};
+EthosU::ethosu_rpmsg_capabilities_rsp MessageHandler::getCapabilities() const {
+ EthosU::ethosu_rpmsg_capabilities_rsp cap = {};
#ifdef ETHOSU
ethosu_driver_version version;
@@ -298,9 +295,9 @@ EthosU::ethosu_core_msg_capabilities_rsp MessageHandler::getCapabilities() const
void MessageHandler::sendNetworkInfoRsp(const uint32_t src,
const uint64_t msgId,
- EthosU::ethosu_core_network_buffer &network) {
- auto message = new Message(
- src, EthosU::ETHOSU_CORE_MSG_NETWORK_INFO_RSP, msgId, sizeof(EthosU::ethosu_core_msg_network_info_rsp));
+ EthosU::ethosu_rpmsg_network_buffer &network) {
+ auto message =
+ new Message(src, EthosU::ETHOSU_RPMSG_NETWORK_INFO_RSP, msgId, sizeof(EthosU::ethosu_rpmsg_network_info_rsp));
auto &rsp = message->rpmsg.net_info_rsp;
rsp.ifm_count = 0;
@@ -314,19 +311,19 @@ void MessageHandler::sendNetworkInfoRsp(const uint32_t src,
failed = parser.parseModel(reinterpret_cast<void *>(network.buffer.ptr),
network.buffer.size,
rsp.desc,
- InferenceProcess::makeArray(rsp.ifm_size, rsp.ifm_count, ETHOSU_CORE_BUFFER_MAX),
- InferenceProcess::makeArray(rsp.ofm_size, rsp.ofm_count, ETHOSU_CORE_BUFFER_MAX));
+ InferenceProcess::makeArray(rsp.ifm_size, rsp.ifm_count, ETHOSU_RPMSG_BUFFER_MAX),
+ InferenceProcess::makeArray(rsp.ofm_size, rsp.ofm_count, ETHOSU_RPMSG_BUFFER_MAX));
}
- rsp.status = failed ? EthosU::ETHOSU_CORE_STATUS_ERROR : EthosU::ETHOSU_CORE_STATUS_OK;
+ rsp.status = failed ? EthosU::ETHOSU_RPMSG_STATUS_ERROR : EthosU::ETHOSU_RPMSG_STATUS_OK;
responseQueue.send(message);
}
void MessageHandler::forwardInferenceReq(const uint32_t src,
const uint64_t msgId,
- const EthosU::ethosu_core_msg_inference_req &inference) {
- auto message = new Message(src, EthosU::ETHOSU_CORE_MSG_INFERENCE_REQ, msgId);
+ const EthosU::ethosu_rpmsg_inference_req &inference) {
+ auto message = new Message(src, EthosU::ETHOSU_RPMSG_INFERENCE_REQ, msgId);
auto &req = message->rpmsg.inf_req;
req = inference;
@@ -338,9 +335,9 @@ void MessageHandler::forwardInferenceReq(const uint32_t src,
void MessageHandler::sendInferenceRsp(const uint32_t src,
const uint64_t msgId,
- const EthosU::ethosu_core_status status) {
+ const EthosU::ethosu_rpmsg_status status) {
auto message =
- new Message(src, EthosU::ETHOSU_CORE_MSG_INFERENCE_RSP, msgId, sizeof(EthosU::ethosu_core_msg_inference_rsp));
+ new Message(src, EthosU::ETHOSU_RPMSG_INFERENCE_RSP, msgId, sizeof(EthosU::ethosu_rpmsg_inference_rsp));
message->rpmsg.inf_rsp.status = status;
@@ -349,27 +346,27 @@ void MessageHandler::sendInferenceRsp(const uint32_t src,
void MessageHandler::sendCancelInferenceRsp(const uint32_t src,
const uint64_t msgId,
- const EthosU::ethosu_core_status status) {
+ const EthosU::ethosu_rpmsg_status status) {
auto message = new Message(
- src, EthosU::ETHOSU_CORE_MSG_CANCEL_INFERENCE_RSP, msgId, sizeof(EthosU::ethosu_core_msg_cancel_inference_rsp));
+ src, EthosU::ETHOSU_RPMSG_CANCEL_INFERENCE_RSP, msgId, sizeof(EthosU::ethosu_rpmsg_cancel_inference_rsp));
message->rpmsg.cancel_rsp.status = status;
responseQueue.send(message);
}
-bool MessageHandler::getNetwork(EthosU::ethosu_core_network_buffer &buffer) {
+bool MessageHandler::getNetwork(EthosU::ethosu_rpmsg_network_buffer &buffer) {
switch (buffer.type) {
- case EthosU::ETHOSU_CORE_NETWORK_BUFFER:
+ case EthosU::ETHOSU_RPMSG_NETWORK_BUFFER:
return false;
- case EthosU::ETHOSU_CORE_NETWORK_INDEX: {
+ case EthosU::ETHOSU_RPMSG_NETWORK_INDEX: {
void *ptr;
size_t size;
if (getIndexedNetwork(buffer.index, ptr, size)) {
return true;
}
- buffer.type = EthosU::ETHOSU_CORE_NETWORK_BUFFER;
+ buffer.type = EthosU::ETHOSU_RPMSG_NETWORK_BUFFER;
buffer.buffer.ptr = reinterpret_cast<uint32_t>(ptr);
buffer.buffer.size = size;