From 44398c86f932b96911dd1558e2b66726943fcf46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonny=20Sv=C3=A4rd?= Date: Tue, 6 Oct 2020 14:18:28 +0200 Subject: Add a Mailbox interface Change-Id: If68e70709c496849cb781af5f7288fa3f7ddcdb5 --- applications/message_process/src/message_process.cc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'applications/message_process/src') diff --git a/applications/message_process/src/message_process.cc b/applications/message_process/src/message_process.cc index 4333640..4533455 100644 --- a/applications/message_process/src/message_process.cc +++ b/applications/message_process/src/message_process.cc @@ -100,10 +100,6 @@ bool QueueImpl::write(const Vec *vec, size_t length) { SCB_CleanDCache(); #endif - // TODO replace with mailbox driver APIs - volatile uint32_t *set = reinterpret_cast(0x41A00014); - *set = 0x1; - return true; } @@ -132,9 +128,12 @@ bool QueueImpl::skip(uint32_t length) { MessageProcess::MessageProcess(ethosu_core_queue &in, ethosu_core_queue &out, + Mailbox::Mailbox &mbox, ::InferenceProcess::InferenceProcess &_inferenceProcess) : queueIn(in), - queueOut(out), inferenceProcess(_inferenceProcess) {} + queueOut(out), mailbox(mbox), inferenceProcess(_inferenceProcess) { + mailbox.registerCallback(mailboxCallback, reinterpret_cast(this)); +} void MessageProcess::run() { while (true) { @@ -238,6 +237,7 @@ void MessageProcess::sendPong() { if (!queueOut.write(ETHOSU_CORE_MSG_PONG)) { printf("Failed to write pong.\n"); } + mailbox.sendMessage(); } void MessageProcess::sendInferenceRsp(uint64_t userArg, vector &ofm, bool failed) { @@ -259,5 +259,12 @@ void MessageProcess::sendInferenceRsp(uint64_t userArg, vector &ofm, bo if (!queueOut.write(ETHOSU_CORE_MSG_INFERENCE_RSP, rsp)) { printf("Failed to write inference.\n"); } + mailbox.sendMessage(); } + +void MessageProcess::mailboxCallback(void *userArg) { + MessageProcess *_this = reinterpret_cast(userArg); + _this->handleIrq(); +} + } // namespace MessageProcess -- cgit v1.2.1