Blame view

arch/arm/include/asm/irqflags.h 3.34 KB
7ad1bcb25   Russell King   [ARM] Add ARM irq...
1
2
3
4
5
6
7
8
9
10
  #ifndef __ASM_ARM_IRQFLAGS_H
  #define __ASM_ARM_IRQFLAGS_H
  
  #ifdef __KERNEL__
  
  #include <asm/ptrace.h>
  
  /*
   * CPU interrupt mask handling.
   */
55bdd6941   Catalin Marinas   ARM: Add base sup...
11
12
13
14
15
16
17
18
19
  #ifdef CONFIG_CPU_V7M
  #define IRQMASK_REG_NAME_R "primask"
  #define IRQMASK_REG_NAME_W "primask"
  #define IRQMASK_I_BIT	1
  #else
  #define IRQMASK_REG_NAME_R "cpsr"
  #define IRQMASK_REG_NAME_W "cpsr_c"
  #define IRQMASK_I_BIT	PSR_I_BIT
  #endif
7ad1bcb25   Russell King   [ARM] Add ARM irq...
20
  #if __LINUX_ARM_ARCH__ >= 6
df9ee2927   David Howells   Fix IRQ flag hand...
21
22
23
24
25
  static inline unsigned long arch_local_irq_save(void)
  {
  	unsigned long flags;
  
  	asm volatile(
55bdd6941   Catalin Marinas   ARM: Add base sup...
26
27
  		"	mrs	%0, " IRQMASK_REG_NAME_R "	@ arch_local_irq_save
  "
df9ee2927   David Howells   Fix IRQ flag hand...
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
  		"	cpsid	i"
  		: "=r" (flags) : : "memory", "cc");
  	return flags;
  }
  
  static inline void arch_local_irq_enable(void)
  {
  	asm volatile(
  		"	cpsie i			@ arch_local_irq_enable"
  		:
  		:
  		: "memory", "cc");
  }
  
  static inline void arch_local_irq_disable(void)
  {
  	asm volatile(
  		"	cpsid i			@ arch_local_irq_disable"
  		:
  		:
  		: "memory", "cc");
  }
7ad1bcb25   Russell King   [ARM] Add ARM irq...
50

7ad1bcb25   Russell King   [ARM] Add ARM irq...
51
52
  #define local_fiq_enable()  __asm__("cpsie f	@ __stf" : : : "memory", "cc")
  #define local_fiq_disable() __asm__("cpsid f	@ __clf" : : : "memory", "cc")
cd613aaa2   Lucas Stach   ARM: 8422/1: enab...
53
54
55
56
57
58
59
60
  
  #ifndef CONFIG_CPU_V7M
  #define local_abt_enable()  __asm__("cpsie a	@ __sta" : : : "memory", "cc")
  #define local_abt_disable() __asm__("cpsid a	@ __cla" : : : "memory", "cc")
  #else
  #define local_abt_enable()	do { } while (0)
  #define local_abt_disable()	do { } while (0)
  #endif
7ad1bcb25   Russell King   [ARM] Add ARM irq...
61
62
63
64
65
  #else
  
  /*
   * Save the current interrupt enable state & disable IRQs
   */
df9ee2927   David Howells   Fix IRQ flag hand...
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
  static inline unsigned long arch_local_irq_save(void)
  {
  	unsigned long flags, temp;
  
  	asm volatile(
  		"	mrs	%0, cpsr	@ arch_local_irq_save
  "
  		"	orr	%1, %0, #128
  "
  		"	msr	cpsr_c, %1"
  		: "=r" (flags), "=r" (temp)
  		:
  		: "memory", "cc");
  	return flags;
  }
7ad1bcb25   Russell King   [ARM] Add ARM irq...
81
82
83
  /*
   * Enable IRQs
   */
df9ee2927   David Howells   Fix IRQ flag hand...
84
85
86
87
88
89
90
91
92
93
94
95
96
  static inline void arch_local_irq_enable(void)
  {
  	unsigned long temp;
  	asm volatile(
  		"	mrs	%0, cpsr	@ arch_local_irq_enable
  "
  		"	bic	%0, %0, #128
  "
  		"	msr	cpsr_c, %0"
  		: "=r" (temp)
  		:
  		: "memory", "cc");
  }
7ad1bcb25   Russell King   [ARM] Add ARM irq...
97
98
99
100
  
  /*
   * Disable IRQs
   */
df9ee2927   David Howells   Fix IRQ flag hand...
101
102
103
104
105
106
107
108
109
110
111
112
113
  static inline void arch_local_irq_disable(void)
  {
  	unsigned long temp;
  	asm volatile(
  		"	mrs	%0, cpsr	@ arch_local_irq_disable
  "
  		"	orr	%0, %0, #128
  "
  		"	msr	cpsr_c, %0"
  		: "=r" (temp)
  		:
  		: "memory", "cc");
  }
7ad1bcb25   Russell King   [ARM] Add ARM irq...
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
  
  /*
   * Enable FIQs
   */
  #define local_fiq_enable()					\
  	({							\
  		unsigned long temp;				\
  	__asm__ __volatile__(					\
  	"mrs	%0, cpsr		@ stf
  "		\
  "	bic	%0, %0, #64
  "					\
  "	msr	cpsr_c, %0"					\
  	: "=r" (temp)						\
  	:							\
  	: "memory", "cc");					\
  	})
  
  /*
   * Disable FIQs
   */
  #define local_fiq_disable()					\
  	({							\
  		unsigned long temp;				\
  	__asm__ __volatile__(					\
  	"mrs	%0, cpsr		@ clf
  "		\
  "	orr	%0, %0, #64
  "					\
  "	msr	cpsr_c, %0"					\
  	: "=r" (temp)						\
  	:							\
  	: "memory", "cc");					\
  	})
cd613aaa2   Lucas Stach   ARM: 8422/1: enab...
148
149
  #define local_abt_enable()	do { } while (0)
  #define local_abt_disable()	do { } while (0)
7ad1bcb25   Russell King   [ARM] Add ARM irq...
150
151
152
153
154
  #endif
  
  /*
   * Save the current interrupt enable state.
   */
df9ee2927   David Howells   Fix IRQ flag hand...
155
156
157
158
  static inline unsigned long arch_local_save_flags(void)
  {
  	unsigned long flags;
  	asm volatile(
55bdd6941   Catalin Marinas   ARM: Add base sup...
159
  		"	mrs	%0, " IRQMASK_REG_NAME_R "	@ local_save_flags"
df9ee2927   David Howells   Fix IRQ flag hand...
160
161
162
  		: "=r" (flags) : : "memory", "cc");
  	return flags;
  }
7ad1bcb25   Russell King   [ARM] Add ARM irq...
163
164
165
166
  
  /*
   * restore saved IRQ & FIQ state
   */
df9ee2927   David Howells   Fix IRQ flag hand...
167
168
169
  static inline void arch_local_irq_restore(unsigned long flags)
  {
  	asm volatile(
55bdd6941   Catalin Marinas   ARM: Add base sup...
170
  		"	msr	" IRQMASK_REG_NAME_W ", %0	@ local_irq_restore"
df9ee2927   David Howells   Fix IRQ flag hand...
171
172
173
174
  		:
  		: "r" (flags)
  		: "memory", "cc");
  }
7ad1bcb25   Russell King   [ARM] Add ARM irq...
175

df9ee2927   David Howells   Fix IRQ flag hand...
176
177
  static inline int arch_irqs_disabled_flags(unsigned long flags)
  {
55bdd6941   Catalin Marinas   ARM: Add base sup...
178
  	return flags & IRQMASK_I_BIT;
df9ee2927   David Howells   Fix IRQ flag hand...
179
  }
7ad1bcb25   Russell King   [ARM] Add ARM irq...
180

55bdd6941   Catalin Marinas   ARM: Add base sup...
181
182
  #endif /* ifdef __KERNEL__ */
  #endif /* ifndef __ASM_ARM_IRQFLAGS_H */