Kevin Peng | 33d0394 | 2021-06-08 11:28:41 +0800 | [diff] [blame] | 1 | /* |
Gergely Korcsák | 9710269 | 2024-02-09 15:23:33 +0100 | [diff] [blame] | 2 | * Copyright (c) 2021-2024, Arm Limited. All rights reserved. |
Chris Brand | eecbd8f | 2024-03-28 12:08:47 -0700 | [diff] [blame] | 3 | * Copyright (c) 2024 Cypress Semiconductor Corporation (an Infineon |
| 4 | * company) or an affiliate of Cypress Semiconductor Corporation. All rights |
| 5 | * reserved. |
Kevin Peng | 33d0394 | 2021-06-08 11:28:41 +0800 | [diff] [blame] | 6 | * |
| 7 | * SPDX-License-Identifier: BSD-3-Clause |
| 8 | * |
| 9 | */ |
| 10 | |
Gergely Korcsák | 9710269 | 2024-02-09 15:23:33 +0100 | [diff] [blame] | 11 | #include "tfm_hal_device_header.h" |
Kevin Peng | 33d0394 | 2021-06-08 11:28:41 +0800 | [diff] [blame] | 12 | #include "fih.h" |
Kevin Peng | aaf994d | 2021-07-20 17:38:18 +0800 | [diff] [blame] | 13 | #include "psa/service.h" |
Kevin Peng | 33d0394 | 2021-06-08 11:28:41 +0800 | [diff] [blame] | 14 | |
| 15 | void tfm_idle_thread(void) |
| 16 | { |
| 17 | while (1) { |
Kevin Peng | aaf994d | 2021-07-20 17:38:18 +0800 | [diff] [blame] | 18 | /* |
Antonio de Angelis | 06df9f2 | 2025-01-06 14:41:04 +0000 | [diff] [blame^] | 19 | * There could be other Partitions becoming RUNNABLE after wake up. |
Kevin Peng | aaf994d | 2021-07-20 17:38:18 +0800 | [diff] [blame] | 20 | * This is a dummy psa_wait to let SPM check possible scheduling. |
| 21 | * It does not expect any signals. |
| 22 | */ |
| 23 | if (psa_wait(PSA_WAIT_ANY, PSA_POLL) == 0) { |
chesun01 | 8c29224 | 2023-03-02 11:25:49 +0800 | [diff] [blame] | 24 | __DSB(); |
Kevin Peng | aaf994d | 2021-07-20 17:38:18 +0800 | [diff] [blame] | 25 | __WFI(); |
| 26 | } |
Kevin Peng | 33d0394 | 2021-06-08 11:28:41 +0800 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | #ifdef TFM_FIH_PROFILE_ON |
Bohdan Hunko | bc8abe4 | 2024-11-12 15:03:38 +0200 | [diff] [blame] | 30 | /* Suppress Pe111 (statement is unreachable) for IAR as redundant code is needed for FIH */ |
| 31 | #if defined(__ICCARM__) |
| 32 | #pragma diag_suppress = Pe111 |
| 33 | #endif |
Chris Brand | eecbd8f | 2024-03-28 12:08:47 -0700 | [diff] [blame] | 34 | (void)fih_delay(); |
Kevin Peng | 33d0394 | 2021-06-08 11:28:41 +0800 | [diff] [blame] | 35 | |
| 36 | while (1) { |
Kevin Peng | aaf994d | 2021-07-20 17:38:18 +0800 | [diff] [blame] | 37 | /* |
Antonio de Angelis | 06df9f2 | 2025-01-06 14:41:04 +0000 | [diff] [blame^] | 38 | * There could be other Partitions becoming RUNNABLE after wake up. |
Kevin Peng | aaf994d | 2021-07-20 17:38:18 +0800 | [diff] [blame] | 39 | * This is a dummy psa_wait to let SPM check possible scheduling. |
| 40 | * It does not expect any signals. |
| 41 | */ |
| 42 | if (psa_wait(PSA_WAIT_ANY, PSA_POLL) == 0) { |
chesun01 | 8c29224 | 2023-03-02 11:25:49 +0800 | [diff] [blame] | 43 | __DSB(); |
Kevin Peng | aaf994d | 2021-07-20 17:38:18 +0800 | [diff] [blame] | 44 | __WFI(); |
| 45 | } |
Kevin Peng | 33d0394 | 2021-06-08 11:28:41 +0800 | [diff] [blame] | 46 | } |
Bohdan Hunko | bc8abe4 | 2024-11-12 15:03:38 +0200 | [diff] [blame] | 47 | #if defined(__ICCARM__) |
| 48 | #pragma diag_default = Pe111 |
| 49 | #endif |
Kevin Peng | 33d0394 | 2021-06-08 11:28:41 +0800 | [diff] [blame] | 50 | #endif |
| 51 | } |