blob: 2e56e9efe0860b5c0d14cde227d7ff11e5eccea4 [file] [log] [blame]
Kevin Peng33d03942021-06-08 11:28:41 +08001/*
Gergely Korcsák97102692024-02-09 15:23:33 +01002 * Copyright (c) 2021-2024, Arm Limited. All rights reserved.
Chris Brandeecbd8f2024-03-28 12:08:47 -07003 * Copyright (c) 2024 Cypress Semiconductor Corporation (an Infineon
4 * company) or an affiliate of Cypress Semiconductor Corporation. All rights
5 * reserved.
Kevin Peng33d03942021-06-08 11:28:41 +08006 *
7 * SPDX-License-Identifier: BSD-3-Clause
8 *
9 */
10
Gergely Korcsák97102692024-02-09 15:23:33 +010011#include "tfm_hal_device_header.h"
Kevin Peng33d03942021-06-08 11:28:41 +080012#include "fih.h"
Kevin Pengaaf994d2021-07-20 17:38:18 +080013#include "psa/service.h"
Kevin Peng33d03942021-06-08 11:28:41 +080014
15void tfm_idle_thread(void)
16{
17 while (1) {
Kevin Pengaaf994d2021-07-20 17:38:18 +080018 /*
Antonio de Angelis06df9f22025-01-06 14:41:04 +000019 * There could be other Partitions becoming RUNNABLE after wake up.
Kevin Pengaaf994d2021-07-20 17:38:18 +080020 * 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) {
chesun018c292242023-03-02 11:25:49 +080024 __DSB();
Kevin Pengaaf994d2021-07-20 17:38:18 +080025 __WFI();
26 }
Kevin Peng33d03942021-06-08 11:28:41 +080027 }
28
29#ifdef TFM_FIH_PROFILE_ON
Bohdan Hunkobc8abe42024-11-12 15:03:38 +020030/* 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 Brandeecbd8f2024-03-28 12:08:47 -070034 (void)fih_delay();
Kevin Peng33d03942021-06-08 11:28:41 +080035
36 while (1) {
Kevin Pengaaf994d2021-07-20 17:38:18 +080037 /*
Antonio de Angelis06df9f22025-01-06 14:41:04 +000038 * There could be other Partitions becoming RUNNABLE after wake up.
Kevin Pengaaf994d2021-07-20 17:38:18 +080039 * 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) {
chesun018c292242023-03-02 11:25:49 +080043 __DSB();
Kevin Pengaaf994d2021-07-20 17:38:18 +080044 __WFI();
45 }
Kevin Peng33d03942021-06-08 11:28:41 +080046 }
Bohdan Hunkobc8abe42024-11-12 15:03:38 +020047#if defined(__ICCARM__)
48#pragma diag_default = Pe111
49#endif
Kevin Peng33d03942021-06-08 11:28:41 +080050#endif
51}