Loading...
Searching...
No Matches
irq_arch.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2005-2008 by Thomas Hillebrandt and Heiko Will
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
17
18#include "VIC.h"
19#include <stdbool.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25#define IRQ_MASK 0x00000080
26
27static inline unsigned __get_cpsr(void)
28{
29 unsigned long retval;
30 __asm__ volatile(" mrs %0, cpsr" : "=r"(retval) : /* no inputs */ : "memory");
31 return retval;
32}
33
34static inline void __set_cpsr(unsigned val)
35{
36 __asm__ volatile(" msr cpsr, %0" : /* no outputs */ : "r"(val) : "memory");
37}
38
39static inline bool irq_is_in(void)
40{
41 return (__get_cpsr() & INTMode) == 18;
42}
43
44static inline __attribute__((always_inline)) unsigned irq_disable(void)
45{
46 unsigned _cpsr;
47
48 _cpsr = __get_cpsr();
49 __set_cpsr(_cpsr | IRQ_MASK);
50 return _cpsr;
51}
52
53static inline __attribute__((always_inline)) void irq_restore(unsigned oldCPSR)
54{
55 __set_cpsr(oldCPSR);
56}
57
58static inline __attribute__((always_inline)) unsigned irq_enable(void)
59{
60 unsigned _cpsr;
61
62 _cpsr = __get_cpsr();
63 __set_cpsr(_cpsr & ~IRQ_MASK);
64 return _cpsr;
65}
66
67static inline __attribute__((always_inline)) bool irq_is_enabled(void)
68{
69 return !(__get_cpsr() & IRQ_MASK);
70}
71
72#ifdef __cplusplus
73}
74#endif
75
MAYBE_INLINE void irq_restore(unsigned state)
This function restores the IRQ disable bit in the status register to the value contained within passe...
MAYBE_INLINE unsigned irq_disable(void)
This function sets the IRQ disable bit in the status register.
MAYBE_INLINE bool irq_is_enabled(void)
Test if IRQs are currently enabled.
MAYBE_INLINE unsigned irq_enable(void)
This function clears the IRQ disable bit in the status register.
MAYBE_INLINE bool irq_is_in(void)
Check whether called from interrupt service routine.