|
| 1 | +# |
| 2 | +# This file is part of AtomVM. |
| 3 | +# |
| 4 | +# Copyright 2023 Paul Guyot <[email protected]> |
| 5 | +# |
| 6 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +# you may not use this file except in compliance with the License. |
| 8 | +# You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, software |
| 13 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +# See the License for the specific language governing permissions and |
| 16 | +# limitations under the License. |
| 17 | +# |
| 18 | +# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later |
| 19 | +# |
| 20 | + |
| 21 | +diff --git a/components/esp_ipc/src/esp_ipc_isr/esp_ipc_isr.c b/components/esp_ipc/src/esp_ipc_isr/esp_ipc_isr.c |
| 22 | +index dbdbe9027b..97025d5c65 100644 |
| 23 | +--- a/components/esp_ipc/src/esp_ipc_isr/esp_ipc_isr.c |
| 24 | ++++ b/components/esp_ipc/src/esp_ipc_isr/esp_ipc_isr.c |
| 25 | +@@ -57,7 +57,7 @@ typedef enum { |
| 26 | + #define IPC_ISR_EXIT_CRITICAL() portEXIT_CRITICAL_SAFE(&s_ipc_isr_mux) |
| 27 | + |
| 28 | + static void esp_ipc_isr_call_and_wait(esp_ipc_isr_func_t func, void* arg, esp_ipc_isr_wait_t wait_for); |
| 29 | +- |
| 30 | ++static void IRAM_ATTR esp_ipc_isr_wait_for_end(); |
| 31 | + |
| 32 | + /* Initializing IPC_ISR */ |
| 33 | + |
| 34 | +@@ -130,6 +130,8 @@ void IRAM_ATTR esp_ipc_isr_release_other_cpu(void) |
| 35 | + const uint32_t cpu_id = xPortGetCoreID(); |
| 36 | + if (--s_count_of_nested_calls[cpu_id] == 0) { |
| 37 | + esp_ipc_isr_finish_cmd = 1; |
| 38 | ++ // Make sure end flag is cleared and esp_ipc_isr_waiting_for_finish_cmd is done. |
| 39 | ++ esp_ipc_isr_wait_for_end(); |
| 40 | + IPC_ISR_EXIT_CRITICAL(); |
| 41 | + portCLEAR_INTERRUPT_MASK_FROM_ISR(s_stored_interrupt_level); |
| 42 | + } else if (s_count_of_nested_calls[cpu_id] < 0) { |
| 43 | +@@ -174,7 +176,7 @@ static void IRAM_ATTR esp_ipc_isr_call_and_wait(esp_ipc_isr_func_t func, void* a |
| 44 | + const uint32_t cpu_id = xPortGetCoreID(); |
| 45 | + |
| 46 | + // waiting for the end of the previous call |
| 47 | +- while (!esp_ipc_isr_end_fl) {}; |
| 48 | ++ esp_ipc_isr_wait_for_end(); |
| 49 | + |
| 50 | + esp_ipc_func = func; |
| 51 | + esp_ipc_func_arg = arg; |
| 52 | +@@ -196,8 +198,13 @@ static void IRAM_ATTR esp_ipc_isr_call_and_wait(esp_ipc_isr_func_t func, void* a |
| 53 | + while (!esp_ipc_isr_start_fl) {}; |
| 54 | + } else { |
| 55 | + // IPC_ISR_WAIT_FOR_END |
| 56 | +- while (!esp_ipc_isr_end_fl) {}; |
| 57 | ++ esp_ipc_isr_wait_for_end(); |
| 58 | + } |
| 59 | + } |
| 60 | + |
| 61 | ++static void IRAM_ATTR esp_ipc_isr_wait_for_end() |
| 62 | ++{ |
| 63 | ++ while (!esp_ipc_isr_end_fl) {}; |
| 64 | ++} |
| 65 | ++ |
| 66 | + /* End private functions*/ |
| 67 | +diff --git a/components/esp_ipc/src/esp_ipc_isr/esp_ipc_isr_handler.S b/components/esp_ipc/src/esp_ipc_isr/esp_ipc_isr_handler.S |
| 68 | +index 0fb4ae676a..20638a6895 100644 |
| 69 | +--- a/components/esp_ipc/src/esp_ipc_isr/esp_ipc_isr_handler.S |
| 70 | ++++ b/components/esp_ipc/src/esp_ipc_isr/esp_ipc_isr_handler.S |
| 71 | +@@ -96,6 +96,7 @@ esp_ipc_isr_handler: |
| 72 | + |
| 73 | + /* set the start flag */ |
| 74 | + movi a0, esp_ipc_isr_start_fl |
| 75 | ++ memw |
| 76 | + s32i a0, a0, 0 |
| 77 | + |
| 78 | + /* Call the esp_ipc_function(void* arg) */ |
| 79 | +@@ -113,6 +114,7 @@ esp_ipc_isr_handler: |
| 80 | + |
| 81 | + /* set the end flag */ |
| 82 | + movi a0, esp_ipc_isr_end_fl |
| 83 | ++ memw |
| 84 | + s32i a0, a0, 0 |
| 85 | + |
| 86 | + /* restore a0 */ |
| 87 | +diff --git a/components/esp_ipc/src/esp_ipc_isr/esp_ipc_isr_routines.S b/components/esp_ipc/src/esp_ipc_isr/esp_ipc_isr_routines.S |
| 88 | +index 01ddf8b528..e947c3ed2f 100644 |
| 89 | +--- a/components/esp_ipc/src/esp_ipc_isr/esp_ipc_isr_routines.S |
| 90 | ++++ b/components/esp_ipc/src/esp_ipc_isr/esp_ipc_isr_routines.S |
| 91 | +@@ -23,6 +23,7 @@ |
| 92 | + esp_ipc_isr_waiting_for_finish_cmd: |
| 93 | + /* waiting for the finish command */ |
| 94 | + .check_finish_cmd: |
| 95 | ++ memw |
| 96 | + l32i a3, a2, 0 |
| 97 | + beqz a3, .check_finish_cmd |
| 98 | + ret |
0 commit comments