]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
6bc9a396 CL |
2 | #ifndef _ASM_SCORE_IRQFLAGS_H |
3 | #define _ASM_SCORE_IRQFLAGS_H | |
4 | ||
5 | #ifndef __ASSEMBLY__ | |
6 | ||
df9ee292 DH |
7 | #include <linux/types.h> |
8 | ||
9 | static inline unsigned long arch_local_save_flags(void) | |
10 | { | |
11 | unsigned long flags; | |
12 | ||
13 | asm volatile( | |
14 | " mfcr r8, cr0 \n" | |
15 | " nop \n" | |
16 | " nop \n" | |
17 | " mv %0, r8 \n" | |
18 | " nop \n" | |
19 | " nop \n" | |
20 | " nop \n" | |
21 | " nop \n" | |
22 | " nop \n" | |
23 | " ldi r9, 0x1 \n" | |
24 | " and %0, %0, r9 \n" | |
25 | : "=r" (flags) | |
26 | : | |
27 | : "r8", "r9"); | |
28 | return flags; | |
6bc9a396 CL |
29 | } |
30 | ||
df9ee292 DH |
31 | static inline unsigned long arch_local_irq_save(void) |
32 | { | |
fa73c5bf | 33 | unsigned long flags; |
df9ee292 DH |
34 | |
35 | asm volatile( | |
36 | " mfcr r8, cr0 \n" | |
37 | " li r9, 0xfffffffe \n" | |
38 | " nop \n" | |
39 | " mv %0, r8 \n" | |
40 | " and r8, r8, r9 \n" | |
41 | " mtcr r8, cr0 \n" | |
42 | " nop \n" | |
43 | " nop \n" | |
44 | " nop \n" | |
45 | " nop \n" | |
46 | " nop \n" | |
47 | : "=r" (flags) | |
48 | : | |
49 | : "r8", "r9", "memory"); | |
50 | ||
51 | return flags; | |
6bc9a396 CL |
52 | } |
53 | ||
df9ee292 DH |
54 | static inline void arch_local_irq_restore(unsigned long flags) |
55 | { | |
56 | asm volatile( | |
57 | " mfcr r8, cr0 \n" | |
58 | " ldi r9, 0x1 \n" | |
59 | " and %0, %0, r9 \n" | |
60 | " or r8, r8, %0 \n" | |
61 | " mtcr r8, cr0 \n" | |
62 | " nop \n" | |
63 | " nop \n" | |
64 | " nop \n" | |
65 | " nop \n" | |
66 | " nop \n" | |
67 | : | |
68 | : "r"(flags) | |
69 | : "r8", "r9", "memory"); | |
6bc9a396 CL |
70 | } |
71 | ||
df9ee292 DH |
72 | static inline void arch_local_irq_enable(void) |
73 | { | |
74 | asm volatile( | |
75 | " mfcr r8,cr0 \n" | |
76 | " nop \n" | |
77 | " nop \n" | |
78 | " ori r8,0x1 \n" | |
79 | " mtcr r8,cr0 \n" | |
80 | " nop \n" | |
81 | " nop \n" | |
82 | " nop \n" | |
83 | " nop \n" | |
84 | " nop \n" | |
85 | : | |
86 | : | |
87 | : "r8", "memory"); | |
6bc9a396 CL |
88 | } |
89 | ||
df9ee292 DH |
90 | static inline void arch_local_irq_disable(void) |
91 | { | |
92 | asm volatile( | |
93 | " mfcr r8,cr0 \n" | |
94 | " nop \n" | |
95 | " nop \n" | |
96 | " srli r8,r8,1 \n" | |
97 | " slli r8,r8,1 \n" | |
98 | " mtcr r8,cr0 \n" | |
99 | " nop \n" | |
100 | " nop \n" | |
101 | " nop \n" | |
102 | " nop \n" | |
103 | " nop \n" | |
104 | : | |
105 | : | |
106 | : "r8", "memory"); | |
6bc9a396 CL |
107 | } |
108 | ||
df9ee292 | 109 | static inline bool arch_irqs_disabled_flags(unsigned long flags) |
6bc9a396 CL |
110 | { |
111 | return !(flags & 1); | |
112 | } | |
113 | ||
df9ee292 DH |
114 | static inline bool arch_irqs_disabled(void) |
115 | { | |
116 | return arch_irqs_disabled_flags(arch_local_save_flags()); | |
117 | } | |
118 | ||
119 | #endif /* __ASSEMBLY__ */ | |
6bc9a396 CL |
120 | |
121 | #endif /* _ASM_SCORE_IRQFLAGS_H */ |