1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#ifndef __ASM_NDS_SYSTEM_H
25#define __ASM_NDS_SYSTEM_H
26
27
28
29
30
31extern int irq_flags;
32
33#define local_irq_enable() \
34 __asm__ __volatile__ ( \
35 "mfsr %0, $psw\n\t" \
36 "andi %0, %0, 0x1\n\t" \
37 "setgie.e\n\t" \
38 : \
39 : "r" (irq_flags) \
40 )
41
42#define local_irq_disable() \
43 do { \
44 int __tmp_dummy; \
45 __asm__ __volatile__ ( \
46 "mfsr %0, $psw\n\t" \
47 "andi %0, %0, 0x1\n\t" \
48 "setgie.d\n\t" \
49 "dsb\n\t" \
50 : "=r" (__tmp_dummy) \
51 ); \
52 } while (0)
53
54#define local_irq_save(x) \
55 __asm__ __volatile__ ( \
56 "mfsr %0, $psw\n\t" \
57 "andi %0, %0, 0x1\n\t" \
58 "setgie.d\n\t" \
59 "dsb\n\t" \
60 : "=&r" (x) \
61 )
62
63#define local_save_flags(x) \
64 __asm__ __volatile__ ( \
65 "mfsr %0, $psw\n\t" \
66 "andi %0, %0, 0x1\n\t" \
67 "setgie.e\n\t" \
68 "setgie.d\n\t" \
69 : "=r" (x) \
70 )
71
72#define irqs_enabled_from_flags(x) ((x) != 0x1f)
73
74#define local_irq_restore(x) \
75 do { \
76 if (irqs_enabled_from_flags(x)) \
77 local_irq_enable(); \
78 } while (0)
79
80
81
82
83#define nop() asm volatile ("nop;\n\t" : : )
84#define mb() asm volatile ("" : : : "memory")
85#define rmb() asm volatile ("" : : : "memory")
86#define wmb() asm volatile ("" : : : "memory")
87
88#endif
89