1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
#ifndef _ASM_SCORE_IRQFLAGS_H
#define _ASM_SCORE_IRQFLAGS_H
#ifndef __ASSEMBLY__
#define raw_local_irq_save(x) \
{ \
__asm__ __volatile__( \
"mfcr r8, cr0;" \
"li r9, 0xfffffffe;" \
"nop;" \
"mv %0, r8;" \
"and r8, r8, r9;" \
"mtcr r8, cr0;" \
"nop;" \
"nop;" \
"nop;" \
"nop;" \
"nop;" \
: "=r" (x) \
: \
: "r8", "r9" \
); \
}
#define raw_local_irq_restore(x) \
{ \
__asm__ __volatile__( \
"mfcr r8, cr0;" \
"ldi r9, 0x1;" \
"and %0, %0, r9;" \
"or r8, r8, %0;" \
"mtcr r8, cr0;" \
"nop;" \
"nop;" \
"nop;" \
"nop;" \
"nop;" \
: \
: "r"(x) \
: "r8", "r9" \
); \
}
#define raw_local_irq_enable(void) \
{ \
__asm__ __volatile__( \
"mfcr\tr8,cr0;" \
"nop;" \
"nop;" \
"ori\tr8,0x1;" \
"mtcr\tr8,cr0;" \
"nop;" \
"nop;" \
"nop;" \
"nop;" \
"nop;" \
: \
: \
: "r8"); \
}
#define raw_local_irq_disable(void) \
{ \
__asm__ __volatile__( \
"mfcr\tr8,cr0;" \
"nop;" \
"nop;" \
"srli\tr8,r8,1;" \
"slli\tr8,r8,1;" \
"mtcr\tr8,cr0;" \
"nop;" \
"nop;" \
"nop;" \
"nop;" \
"nop;" \
: \
: \
: "r8"); \
}
#define raw_local_save_flags(x) \
{ \
__asm__ __volatile__( \
"mfcr r8, cr0;" \
"nop;" \
"nop;" \
"mv %0, r8;" \
"nop;" \
"nop;" \
"nop;" \
"nop;" \
"nop;" \
"ldi r9, 0x1;" \
"and %0, %0, r9;" \
: "=r" (x) \
: \
: "r8", "r9" \
); \
}
static inline int raw_irqs_disabled_flags(unsigned long flags)
{
return !(flags & 1);
}
#endif
#endif /* _ASM_SCORE_IRQFLAGS_H */
|