1 /*
2  *  C6X IRQ flag handling
3  *
4  * Copyright (C) 2010 Texas Instruments Incorporated
5  * Written by Mark Salter (msalter@redhat.com)
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public Licence
9  * as published by the Free Software Foundation; either version
10  * 2 of the Licence, or (at your option) any later version.
11  */
12 
13 #ifndef _ASM_IRQFLAGS_H
14 #define _ASM_IRQFLAGS_H
15 
16 #ifndef __ASSEMBLY__
17 
18 /* read interrupt enabled status */
arch_local_save_flags(void)19 static inline unsigned long arch_local_save_flags(void)
20 {
21 	unsigned long flags;
22 
23 	asm volatile (" mvc .s2 CSR,%0\n" : "=b"(flags));
24 	return flags;
25 }
26 
27 /* set interrupt enabled status */
arch_local_irq_restore(unsigned long flags)28 static inline void arch_local_irq_restore(unsigned long flags)
29 {
30 	asm volatile (" mvc .s2 %0,CSR\n" : : "b"(flags));
31 }
32 
33 /* unconditionally enable interrupts */
arch_local_irq_enable(void)34 static inline void arch_local_irq_enable(void)
35 {
36 	unsigned long flags = arch_local_save_flags();
37 	flags |= 1;
38 	arch_local_irq_restore(flags);
39 }
40 
41 /* unconditionally disable interrupts */
arch_local_irq_disable(void)42 static inline void arch_local_irq_disable(void)
43 {
44 	unsigned long flags = arch_local_save_flags();
45 	flags &= ~1;
46 	arch_local_irq_restore(flags);
47 }
48 
49 /* get status and disable interrupts */
arch_local_irq_save(void)50 static inline unsigned long arch_local_irq_save(void)
51 {
52 	unsigned long flags;
53 
54 	flags = arch_local_save_flags();
55 	arch_local_irq_restore(flags & ~1);
56 	return flags;
57 }
58 
59 /* test flags */
arch_irqs_disabled_flags(unsigned long flags)60 static inline int arch_irqs_disabled_flags(unsigned long flags)
61 {
62 	return (flags & 1) == 0;
63 }
64 
65 /* test hardware interrupt enable bit */
arch_irqs_disabled(void)66 static inline int arch_irqs_disabled(void)
67 {
68 	return arch_irqs_disabled_flags(arch_local_save_flags());
69 }
70 
71 #endif /* __ASSEMBLY__ */
72 #endif /* __ASM_IRQFLAGS_H */
73