diff options
Diffstat (limited to 'applications/message_process')
-rw-r--r-- | applications/message_process/CMakeLists.txt | 2 | ||||
-rw-r--r-- | applications/message_process/include/message_process.hpp | 10 | ||||
-rw-r--r-- | applications/message_process/src/message_process.cc | 17 |
3 files changed, 21 insertions, 8 deletions
diff --git a/applications/message_process/CMakeLists.txt b/applications/message_process/CMakeLists.txt index 51d514b..9c80672 100644 --- a/applications/message_process/CMakeLists.txt +++ b/applications/message_process/CMakeLists.txt @@ -18,4 +18,4 @@ add_library(message_process STATIC src/message_process.cc) target_include_directories(message_process PUBLIC include ${LINUX_DRIVER_STACK_PATH}/kernel) -target_link_libraries(message_process PRIVATE cmsis_core inference_process) +target_link_libraries(message_process PRIVATE cmsis_core inference_process mailbox) diff --git a/applications/message_process/include/message_process.hpp b/applications/message_process/include/message_process.hpp index e820b60..b3c1bdd 100644 --- a/applications/message_process/include/message_process.hpp +++ b/applications/message_process/include/message_process.hpp @@ -21,6 +21,7 @@ #include <ethosu_core_interface.h> #include <inference_process.hpp> +#include <mailbox.hpp> #include <cstddef> #include <cstdio> @@ -82,10 +83,12 @@ private: class MessageProcess { public: - MessageProcess(ethosu_core_queue &in, ethosu_core_queue &out, InferenceProcess::InferenceProcess &inferenceProcess); + MessageProcess(ethosu_core_queue &in, + ethosu_core_queue &out, + Mailbox::Mailbox &mbox, + InferenceProcess::InferenceProcess &inferenceProcess); void run(); - void handleIrq(); bool handleMessage(); void sendPong(); void sendInferenceRsp(uint64_t userArg, std::vector<InferenceProcess::DataPtr> &ofm, bool failed); @@ -93,7 +96,10 @@ public: private: QueueImpl queueIn; QueueImpl queueOut; + Mailbox::Mailbox &mailbox; InferenceProcess::InferenceProcess &inferenceProcess; + void handleIrq(); + static void mailboxCallback(void *userArg); }; } // namespace MessageProcess 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<volatile uint32_t *>(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<void *>(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<DataPtr> &ofm, bool failed) { @@ -259,5 +259,12 @@ void MessageProcess::sendInferenceRsp(uint64_t userArg, vector<DataPtr> &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<MessageProcess *>(userArg); + _this->handleIrq(); +} + } // namespace MessageProcess |