Merge branch 'fix/hda' into for-linus
[sfrench/cifs-2.6.git] / arch / microblaze / include / asm / irqflags.h
1 /*
2  * Copyright (C) 2006 Atmark Techno, Inc.
3  *
4  * This file is subject to the terms and conditions of the GNU General Public
5  * License. See the file "COPYING" in the main directory of this archive
6  * for more details.
7  */
8
9 #ifndef _ASM_MICROBLAZE_IRQFLAGS_H
10 #define _ASM_MICROBLAZE_IRQFLAGS_H
11
12 #include <linux/irqflags.h>
13 #include <asm/registers.h>
14
15 # if CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR
16
17 # define raw_local_irq_save(flags)                      \
18         do {                                            \
19                 asm volatile (" msrclr %0, %1;          \
20                                 nop;"                   \
21                                 : "=r"(flags)           \
22                                 : "i"(MSR_IE)           \
23                                 : "memory");            \
24         } while (0)
25
26 # define raw_local_irq_disable()                        \
27         do {                                            \
28                 asm volatile (" msrclr r0, %0;          \
29                                 nop;"                   \
30                                 :                       \
31                                 : "i"(MSR_IE)           \
32                                 : "memory");            \
33         } while (0)
34
35 # define raw_local_irq_enable()                         \
36         do {                                            \
37                 asm volatile (" msrset  r0, %0;         \
38                                 nop;"                   \
39                                 :                       \
40                                 : "i"(MSR_IE)           \
41                                 : "memory");            \
42         } while (0)
43
44 # else /* CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR == 0 */
45
46 # define raw_local_irq_save(flags)                              \
47         do {                                                    \
48                 register unsigned tmp;                          \
49                 asm volatile (" mfs     %0, rmsr;               \
50                                 nop;                            \
51                                 andi    %1, %0, %2;             \
52                                 mts     rmsr, %1;               \
53                                 nop;"                           \
54                                 : "=r"(flags), "=r" (tmp)       \
55                                 : "i"(~MSR_IE)                  \
56                                 : "memory");                    \
57         } while (0)
58
59 # define raw_local_irq_disable()                                \
60         do {                                                    \
61                 register unsigned tmp;                          \
62                 asm volatile (" mfs     %0, rmsr;               \
63                                 nop;                            \
64                                 andi    %0, %0, %1;             \
65                                 mts     rmsr, %0;               \
66                                 nop;"                   \
67                                 : "=r"(tmp)                     \
68                                 : "i"(~MSR_IE)                  \
69                                 : "memory");                    \
70         } while (0)
71
72 # define raw_local_irq_enable()                                 \
73         do {                                                    \
74                 register unsigned tmp;                          \
75                 asm volatile (" mfs     %0, rmsr;               \
76                                 nop;                            \
77                                 ori     %0, %0, %1;             \
78                                 mts     rmsr, %0;               \
79                                 nop;"                           \
80                                 : "=r"(tmp)                     \
81                                 : "i"(MSR_IE)                   \
82                                 : "memory");                    \
83         } while (0)
84
85 # endif /* CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR */
86
87 #define raw_local_irq_restore(flags)                            \
88         do {                                                    \
89                 asm volatile (" mts     rmsr, %0;               \
90                                 nop;"                           \
91                                 :                               \
92                                 : "r"(flags)                    \
93                                 : "memory");                    \
94         } while (0)
95
96 static inline unsigned long get_msr(void)
97 {
98         unsigned long flags;
99         asm volatile (" mfs     %0, rmsr;       \
100                         nop;"                   \
101                         : "=r"(flags)           \
102                         :                       \
103                         : "memory");            \
104         return flags;
105 }
106
107 #define raw_local_save_flags(flags)     ((flags) = get_msr())
108 #define raw_irqs_disabled()             ((get_msr() & MSR_IE) == 0)
109 #define raw_irqs_disabled_flags(flags)  ((flags & MSR_IE) == 0)
110
111 #endif /* _ASM_MICROBLAZE_IRQFLAGS_H */