1 /*
2  * Copyright (c) 2021, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef __TFM_CRITICAL_SECTION_H__ /* TFM prefix to avoid clash */
9 #define __TFM_CRITICAL_SECTION_H__
10 
11 #include <stdint.h>
12 #include "tfm_arch.h"
13 
14 struct critical_section_t {
15     uint32_t   state;
16 };
17 
18 #define CRITICAL_SECTION_STATIC_INIT   {.state = 0,}
19 #define CRITICAL_SECTION_INIT(cs)      (cs).state = (0)
20 #define CRITICAL_SECTION_ENTER(cs)     (cs).state = __save_disable_irq()
21 #define CRITICAL_SECTION_LEAVE(cs)     __restore_irq((cs).state)
22 
23 #endif /* __TFM_CRITICAL_SECTION_H__ */
24