Line data Source code
1 0 : /*
2 : * Copyright (c) 2019 Carlo Caione <ccaione@baylibre.com>
3 : *
4 : * SPDX-License-Identifier: Apache-2.0
5 : */
6 :
7 : /* Either public functions or macros or invoked by public functions */
8 :
9 : #ifndef ZEPHYR_INCLUDE_ARCH_ARM64_ASM_INLINE_GCC_H_
10 : #define ZEPHYR_INCLUDE_ARCH_ARM64_ASM_INLINE_GCC_H_
11 :
12 : /*
13 : * The file must not be included directly
14 : * Include arch/cpu.h instead
15 : */
16 :
17 : #ifndef _ASMLANGUAGE
18 :
19 : #include <zephyr/arch/arm64/lib_helpers.h>
20 : #include <zephyr/types.h>
21 :
22 : #ifdef __cplusplus
23 : extern "C" {
24 : #endif
25 :
26 0 : static ALWAYS_INLINE unsigned int arch_irq_lock(void)
27 : {
28 : unsigned int key;
29 :
30 : /*
31 : * Return the whole DAIF register as key but use DAIFSET to disable
32 : * IRQs.
33 : */
34 : key = read_daif();
35 : disable_irq();
36 :
37 : return key;
38 : }
39 :
40 0 : static ALWAYS_INLINE void arch_irq_unlock(unsigned int key)
41 : {
42 : write_daif(key);
43 : }
44 :
45 0 : static ALWAYS_INLINE bool arch_irq_unlocked(unsigned int key)
46 : {
47 : /* We only check the (I)RQ bit on the DAIF register */
48 : return (key & DAIF_IRQ_BIT) == 0;
49 : }
50 :
51 : #ifdef __cplusplus
52 : }
53 : #endif
54 :
55 : #endif /* _ASMLANGUAGE */
56 :
57 : #endif /* ZEPHYR_INCLUDE_ARCH_ARM64_ASM_INLINE_GCC_H_ */
|