Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
asm_inline_gcc.h
Go to the documentation of this file.
1/*
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
20#include <zephyr/types.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26static 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();
36
37 return key;
38}
39
40static ALWAYS_INLINE void arch_irq_unlock(unsigned int key)
41{
42 write_daif(key);
43}
44
45static 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_ */
static ALWAYS_INLINE void write_daif(uint64_t val)
Definition lib_helpers.h:69
static ALWAYS_INLINE void disable_irq(void)
Definition lib_helpers.h:138
static ALWAYS_INLINE uint64_t read_daif(void)
Definition lib_helpers.h:69
#define DAIF_IRQ_BIT
Definition cpu.h:24
static ALWAYS_INLINE unsigned int arch_irq_lock(void)
Definition asm_inline_gcc.h:44
static ALWAYS_INLINE void arch_irq_unlock(unsigned int key)
Definition asm_inline_gcc.h:80
static ALWAYS_INLINE bool arch_irq_unlocked(unsigned int key)
Definition asm_inline_gcc.h:102
#define ALWAYS_INLINE
Definition common.h:129