aboutsummaryrefslogtreecommitdiff
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
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>
-rw-r--r--applications/message_handler_openamp/inference_runner.cpp20
-rw-r--r--applications/message_handler_openamp/inference_runner.hpp9
-rw-r--r--applications/message_handler_openamp/message_handler.cpp89
-rw-r--r--applications/message_handler_openamp/message_handler.hpp29
4 files changed, 71 insertions, 76 deletions
diff --git a/applications/message_handler_openamp/inference_runner.cpp b/applications/message_handler_openamp/inference_runner.cpp
index b462b44..bf07819 100644
--- a/applications/message_handler_openamp/inference_runner.cpp
+++ b/applications/message_handler_openamp/inference_runner.cpp
@@ -1,5 +1,5 @@
/*
- * SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
+ * SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or its affiliates <open-source-office@arm.com>
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
@@ -78,7 +78,7 @@ void InferenceRunner::inferenceTask(void *param) {
auto &rpmsg = message->rpmsg;
switch (rpmsg.header.type) {
- case EthosU::ETHOSU_CORE_MSG_INFERENCE_REQ: {
+ case EthosU::ETHOSU_RPMSG_INFERENCE_REQ: {
_this->handleInferenceRequest(message->src, rpmsg.header.msg_id, rpmsg.inf_req);
break;
}
@@ -93,15 +93,15 @@ void InferenceRunner::inferenceTask(void *param) {
void InferenceRunner::handleInferenceRequest(const uint32_t src,
const uint64_t msgId,
- const EthosU::ethosu_core_msg_inference_req &request) {
+ const EthosU::ethosu_rpmsg_inference_req &request) {
auto jobContext = new JobContext(
- 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)));
auto &response = jobContext->rsp->rpmsg.inf_rsp;
// Setup PMU configuration
response.pmu_cycle_counter_enable = request.pmu_cycle_counter_enable;
- for (int i = 0; i < ETHOSU_CORE_PMU_MAX; i++) {
+ for (int i = 0; i < ETHOSU_RPMSG_PMU_MAX; i++) {
response.pmu_event_config[i] = request.pmu_event_config[i];
}
@@ -113,7 +113,7 @@ void InferenceRunner::handleInferenceRequest(const uint32_t src,
// Send response rpmsg
response.ofm_count = job.output.size();
- response.status = failed ? EthosU::ETHOSU_CORE_STATUS_ERROR : EthosU::ETHOSU_CORE_STATUS_OK;
+ response.status = failed ? EthosU::ETHOSU_RPMSG_STATUS_ERROR : EthosU::ETHOSU_RPMSG_STATUS_OK;
for (size_t i = 0; i < job.output.size(); ++i) {
response.ofm_size[i] = job.output[i].size;
@@ -123,7 +123,7 @@ void InferenceRunner::handleInferenceRequest(const uint32_t src,
delete jobContext;
}
-InferenceProcess::InferenceJob InferenceRunner::makeInferenceJob(const EthosU::ethosu_core_msg_inference_req &request,
+InferenceProcess::InferenceJob InferenceRunner::makeInferenceJob(const EthosU::ethosu_rpmsg_inference_req &request,
JobContext &jobContext) {
InferenceProcess::InferenceJob job;
@@ -155,7 +155,7 @@ void ethosu_inference_begin(ethosu_driver *drv, void *userArg) {
auto &response = context->rsp->rpmsg.inf_rsp;
// Calculate maximum number of events
- const int numEvents = std::min(static_cast<int>(ETHOSU_PMU_Get_NumEventCounters()), ETHOSU_CORE_PMU_MAX);
+ const int numEvents = std::min(static_cast<int>(ETHOSU_PMU_Get_NumEventCounters()), ETHOSU_RPMSG_PMU_MAX);
// Enable PMU
ETHOSU_PMU_Enable(drv);
@@ -197,7 +197,7 @@ void ethosu_inference_end(ethosu_driver *drv, void *userArg) {
}
// Calculate maximum number of events
- const int numEvents = std::min(static_cast<int>(ETHOSU_PMU_Get_NumEventCounters()), ETHOSU_CORE_PMU_MAX);
+ const int numEvents = std::min(static_cast<int>(ETHOSU_PMU_Get_NumEventCounters()), ETHOSU_RPMSG_PMU_MAX);
// Get event counters
int i;
@@ -207,7 +207,7 @@ void ethosu_inference_end(ethosu_driver *drv, void *userArg) {
ethosu_profiler_add_to_pmu_event(&context->profiler_context, i, eventValue);
}
- for (; i < ETHOSU_CORE_PMU_MAX; i++) {
+ for (; i < ETHOSU_RPMSG_PMU_MAX; i++) {
response.pmu_event_config[i] = 0;
response.pmu_event_count[i] = 0;
}
diff --git a/applications/message_handler_openamp/inference_runner.hpp b/applications/message_handler_openamp/inference_runner.hpp
index f87aa7a..84d5e16 100644
--- a/applications/message_handler_openamp/inference_runner.hpp
+++ b/applications/message_handler_openamp/inference_runner.hpp
@@ -1,5 +1,5 @@
/*
- * SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
+ * SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or its affiliates <open-source-office@arm.com>
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
@@ -46,10 +46,9 @@ public:
private:
static void inferenceTask(void *param);
- void handleInferenceRequest(const uint32_t src,
- const uint64_t msgId,
- const EthosU::ethosu_core_msg_inference_req &request);
- InferenceProcess::InferenceJob makeInferenceJob(const EthosU::ethosu_core_msg_inference_req &request,
+ void
+ handleInferenceRequest(const uint32_t src, const uint64_t msgId, const EthosU::ethosu_rpmsg_inference_req &request);
+ InferenceProcess::InferenceJob makeInferenceJob(const EthosU::ethosu_rpmsg_inference_req &request,
JobContext &context);
MessageHandler::InferenceQueue &inferenceQueue;
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;
diff --git a/applications/message_handler_openamp/message_handler.hpp b/applications/message_handler_openamp/message_handler.hpp
index 9461569..ea8bc3e 100644
--- a/applications/message_handler_openamp/message_handler.hpp
+++ b/applications/message_handler_openamp/message_handler.hpp
@@ -35,19 +35,19 @@ struct Message {
Message() {}
Message(const uint32_t _src,
- const EthosU::ethosu_core_msg_type _type = EthosU::ETHOSU_CORE_MSG_MAX,
- const uint64_t msgId = 0,
- const uint32_t _length = 0) :
+ const EthosU::ethosu_rpmsg_type _type = EthosU::ETHOSU_RPMSG_MAX,
+ const uint64_t msgId = 0,
+ const uint32_t _length = 0) :
src(_src),
length(_length) {
- rpmsg.header.magic = ETHOSU_CORE_MSG_MAGIC;
+ rpmsg.header.magic = ETHOSU_RPMSG_MAGIC;
rpmsg.header.type = _type;
rpmsg.header.msg_id = msgId;
}
uint32_t src = 0;
uint32_t length = 0;
- EthosU::ethosu_core_rpmsg rpmsg;
+ EthosU::ethosu_rpmsg rpmsg;
};
/*****************************************************************************
@@ -75,19 +75,18 @@ protected:
int handleMessage(void *data, size_t len, uint32_t src) override;
// Outgoing messages
- void sendError(const uint32_t src, const EthosU::ethosu_core_err_type type, const char *message);
+ void sendError(const uint32_t src, const EthosU::ethosu_rpmsg_err_type type, const char *message);
void sendPong(const uint32_t src, const uint64_t msgId);
void sendVersionRsp(const uint32_t src, const uint64_t msgId);
void sendCapabilitiesRsp(const uint32_t src, const uint64_t msgId);
- void sendNetworkInfoRsp(const uint32_t src, const uint64_t msgId, EthosU::ethosu_core_network_buffer &network);
- void forwardInferenceReq(const uint32_t src,
- const uint64_t msgId,
- const EthosU::ethosu_core_msg_inference_req &inference);
- void sendInferenceRsp(const uint32_t src, const uint64_t msgId, const EthosU::ethosu_core_status status);
- void sendCancelInferenceRsp(const uint32_t src, const uint64_t msgId, const EthosU::ethosu_core_status status);
+ void sendNetworkInfoRsp(const uint32_t src, const uint64_t msgId, EthosU::ethosu_rpmsg_network_buffer &network);
+ void
+ forwardInferenceReq(const uint32_t src, const uint64_t msgId, const EthosU::ethosu_rpmsg_inference_req &inference);
+ void sendInferenceRsp(const uint32_t src, const uint64_t msgId, const EthosU::ethosu_rpmsg_status status);
+ void sendCancelInferenceRsp(const uint32_t src, const uint64_t msgId, const EthosU::ethosu_rpmsg_status status);
- EthosU::ethosu_core_msg_capabilities_rsp getCapabilities() const;
- bool getNetwork(EthosU::ethosu_core_network_buffer &buffer);
+ EthosU::ethosu_rpmsg_capabilities_rsp getCapabilities() const;
+ bool getNetwork(EthosU::ethosu_rpmsg_network_buffer &buffer);
// Tasks returning response messages
static void responseTask(void *param);
@@ -95,7 +94,7 @@ protected:
private:
InferenceQueue inferenceQueue;
ResponseQueue responseQueue;
- EthosU::ethosu_core_msg_capabilities_rsp capabilities;
+ EthosU::ethosu_rpmsg_capabilities_rsp capabilities;
// FreeRTOS
TaskHandle_t taskHandle;