0001
0002
0003
0004
0005
0006
0007 #ifndef __ASM_IRQFLAGS_ARCOMPACT_H
0008 #define __ASM_IRQFLAGS_ARCOMPACT_H
0009
0010
0011
0012
0013
0014
0015
0016 #include <asm/arcregs.h>
0017
0018
0019 #define STATUS_E1_BIT 1
0020 #define STATUS_E2_BIT 2
0021 #define STATUS_A1_BIT 3
0022 #define STATUS_A2_BIT 4
0023 #define STATUS_AE_BIT 5
0024
0025 #define STATUS_E1_MASK (1<<STATUS_E1_BIT)
0026 #define STATUS_E2_MASK (1<<STATUS_E2_BIT)
0027 #define STATUS_A1_MASK (1<<STATUS_A1_BIT)
0028 #define STATUS_A2_MASK (1<<STATUS_A2_BIT)
0029 #define STATUS_AE_MASK (1<<STATUS_AE_BIT)
0030 #define STATUS_IE_MASK (STATUS_E1_MASK | STATUS_E2_MASK)
0031
0032
0033 #define AUX_IRQ_LEV 0x200
0034 #define AUX_IRQ_HINT 0x201
0035 #define AUX_IRQ_LV12 0x43
0036
0037 #define AUX_IENABLE 0x40c
0038 #define AUX_ITRIGGER 0x40d
0039 #define AUX_IPULSE 0x415
0040
0041 #define ISA_INIT_STATUS_BITS STATUS_IE_MASK
0042
0043 #ifndef __ASSEMBLY__
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065 static inline long arch_local_irq_save(void)
0066 {
0067 unsigned long temp, flags;
0068
0069 __asm__ __volatile__(
0070 " lr %1, [status32] \n"
0071 " bic %0, %1, %2 \n"
0072 " and.f 0, %1, %2 \n"
0073 " flag.nz %0 \n"
0074 : "=r"(temp), "=r"(flags)
0075 : "n"((STATUS_E1_MASK | STATUS_E2_MASK))
0076 : "memory", "cc");
0077
0078 return flags;
0079 }
0080
0081
0082
0083
0084 static inline void arch_local_irq_restore(unsigned long flags)
0085 {
0086
0087 __asm__ __volatile__(
0088 " flag %0 \n"
0089 :
0090 : "r"(flags)
0091 : "memory");
0092 }
0093
0094
0095
0096
0097 #ifdef CONFIG_ARC_COMPACT_IRQ_LEVELS
0098 extern void arch_local_irq_enable(void);
0099 #else
0100 static inline void arch_local_irq_enable(void)
0101 {
0102 unsigned long temp;
0103
0104 __asm__ __volatile__(
0105 " lr %0, [status32] \n"
0106 " or %0, %0, %1 \n"
0107 " flag %0 \n"
0108 : "=&r"(temp)
0109 : "n"((STATUS_E1_MASK | STATUS_E2_MASK))
0110 : "cc", "memory");
0111 }
0112 #endif
0113
0114
0115
0116
0117 static inline void arch_local_irq_disable(void)
0118 {
0119 unsigned long temp;
0120
0121 __asm__ __volatile__(
0122 " lr %0, [status32] \n"
0123 " and %0, %0, %1 \n"
0124 " flag %0 \n"
0125 : "=&r"(temp)
0126 : "n"(~(STATUS_E1_MASK | STATUS_E2_MASK))
0127 : "memory");
0128 }
0129
0130
0131
0132
0133 static inline long arch_local_save_flags(void)
0134 {
0135 unsigned long temp;
0136
0137 __asm__ __volatile__(
0138 " lr %0, [status32] \n"
0139 : "=&r"(temp)
0140 :
0141 : "memory");
0142
0143 return temp;
0144 }
0145
0146
0147
0148
0149 static inline int arch_irqs_disabled_flags(unsigned long flags)
0150 {
0151 return !(flags & (STATUS_E1_MASK
0152 #ifdef CONFIG_ARC_COMPACT_IRQ_LEVELS
0153 | STATUS_E2_MASK
0154 #endif
0155 ));
0156 }
0157
0158 static inline int arch_irqs_disabled(void)
0159 {
0160 return arch_irqs_disabled_flags(arch_local_save_flags());
0161 }
0162
0163 #else
0164
0165 #ifdef CONFIG_TRACE_IRQFLAGS
0166
0167 .macro TRACE_ASM_IRQ_DISABLE
0168 bl trace_hardirqs_off
0169 .endm
0170
0171 .macro TRACE_ASM_IRQ_ENABLE
0172 bl trace_hardirqs_on
0173 .endm
0174
0175 #else
0176
0177 .macro TRACE_ASM_IRQ_DISABLE
0178 .endm
0179
0180 .macro TRACE_ASM_IRQ_ENABLE
0181 .endm
0182
0183 #endif
0184
0185 .macro IRQ_DISABLE scratch
0186 lr \scratch, [status32]
0187 bic \scratch, \scratch, (STATUS_E1_MASK | STATUS_E2_MASK)
0188 flag \scratch
0189 TRACE_ASM_IRQ_DISABLE
0190 .endm
0191
0192 .macro IRQ_ENABLE scratch
0193 TRACE_ASM_IRQ_ENABLE
0194 lr \scratch, [status32]
0195 or \scratch, \scratch, (STATUS_E1_MASK | STATUS_E2_MASK)
0196 flag \scratch
0197 .endm
0198
0199 #endif
0200
0201 #endif