• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  *  C6X IRQ flag handling
4  *
5  * Copyright (C) 2010 Texas Instruments Incorporated
6  * Written by Mark Salter (msalter@redhat.com)
7  */
8 
9 #ifndef _ASM_IRQFLAGS_H
10 #define _ASM_IRQFLAGS_H
11 
12 #ifndef __ASSEMBLY__
13 
14 /* read interrupt enabled status */
arch_local_save_flags(void)15 static inline unsigned long arch_local_save_flags(void)
16 {
17 	unsigned long flags;
18 
19 	asm volatile (" mvc .s2 CSR,%0\n" : "=b"(flags));
20 	return flags;
21 }
22 
23 /* set interrupt enabled status */
arch_local_irq_restore(unsigned long flags)24 static inline void arch_local_irq_restore(unsigned long flags)
25 {
26 	asm volatile (" mvc .s2 %0,CSR\n" : : "b"(flags) : "memory");
27 }
28 
29 /* unconditionally enable interrupts */
arch_local_irq_enable(void)30 static inline void arch_local_irq_enable(void)
31 {
32 	unsigned long flags = arch_local_save_flags();
33 	flags |= 1;
34 	arch_local_irq_restore(flags);
35 }
36 
37 /* unconditionally disable interrupts */
arch_local_irq_disable(void)38 static inline void arch_local_irq_disable(void)
39 {
40 	unsigned long flags = arch_local_save_flags();
41 	flags &= ~1;
42 	arch_local_irq_restore(flags);
43 }
44 
45 /* get status and disable interrupts */
arch_local_irq_save(void)46 static inline unsigned long arch_local_irq_save(void)
47 {
48 	unsigned long flags;
49 
50 	flags = arch_local_save_flags();
51 	arch_local_irq_restore(flags & ~1);
52 	return flags;
53 }
54 
55 /* test flags */
arch_irqs_disabled_flags(unsigned long flags)56 static inline int arch_irqs_disabled_flags(unsigned long flags)
57 {
58 	return (flags & 1) == 0;
59 }
60 
61 /* test hardware interrupt enable bit */
arch_irqs_disabled(void)62 static inline int arch_irqs_disabled(void)
63 {
64 	return arch_irqs_disabled_flags(arch_local_save_flags());
65 }
66 
67 #endif /* __ASSEMBLY__ */
68 #endif /* __ASM_IRQFLAGS_H */
69