diff options
author | Jonny Svärd <jonny.svaerd@arm.com> | 2024-04-17 18:07:01 +0200 |
---|---|---|
committer | Jonny Svärd <jonny.svaerd@arm.com> | 2024-04-22 10:08:38 +0000 |
commit | 39ef89bd41150b76ab6b2634065f2fa656036295 (patch) | |
tree | dfd7a7048b3d902cba1234bb37c99c0258f6b0b9 | |
parent | b2407962cbb970fb89c44e6c4b2e1c21714ca46b (diff) | |
download | ethos-u-core-platform-39ef89bd41150b76ab6b2634065f2fa656036295.tar.gz |
Add missing mutex/semaphore destroy overrides
Override NPU driver weak function prototypes to properly free
up resources after use.
Change-Id: I4f3141d6106e5feeb1523452ca5fe2dbe66903be
Signed-off-by: Jonny Svärd <jonny.svaerd@arm.com>
-rw-r--r-- | applications/message_handler_openamp/core_driver_mutex.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/applications/message_handler_openamp/core_driver_mutex.cpp b/applications/message_handler_openamp/core_driver_mutex.cpp index 7948bd0..5f2e6cc 100644 --- a/applications/message_handler_openamp/core_driver_mutex.cpp +++ b/applications/message_handler_openamp/core_driver_mutex.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 @@ -24,11 +24,15 @@ #include <stdio.h> extern "C" { - void *ethosu_mutex_create(void) { return xSemaphoreCreateMutex(); } +void ethosu_mutex_destroy(void *mutex) { + SemaphoreHandle_t handle = reinterpret_cast<SemaphoreHandle_t>(mutex); + vSemaphoreDelete(handle); +} + int ethosu_mutex_lock(void *mutex) { SemaphoreHandle_t handle = reinterpret_cast<SemaphoreHandle_t>(mutex); if (xSemaphoreTake(handle, portMAX_DELAY) != pdTRUE) { @@ -51,6 +55,11 @@ void *ethosu_semaphore_create(void) { return xSemaphoreCreateCounting(255, 0); } +void ethosu_semaphore_destroy(void *sem) { + SemaphoreHandle_t handle = reinterpret_cast<SemaphoreHandle_t>(sem); + vSemaphoreDelete(handle); +} + int ethosu_semaphore_take(void *sem, uint64_t timeout) { SemaphoreHandle_t handle = reinterpret_cast<SemaphoreHandle_t>(sem); if (xSemaphoreTake(handle, (TickType_t)timeout) != pdTRUE) { |