2 * Copyright (C) 2010 Thomas Chou <thomas@wytron.com.tw>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef _ASM_IRQFLAGS_H
19 #define _ASM_IRQFLAGS_H
21 #include <asm/registers.h>
23 static inline unsigned long arch_local_save_flags(void)
25 return RDCTL(CTL_STATUS
);
29 * This will restore ALL status register flags, not only the interrupt
32 static inline void arch_local_irq_restore(unsigned long flags
)
34 WRCTL(CTL_STATUS
, flags
);
37 static inline void arch_local_irq_disable(void)
41 flags
= arch_local_save_flags();
42 arch_local_irq_restore(flags
& ~STATUS_PIE
);
45 static inline void arch_local_irq_enable(void)
49 flags
= arch_local_save_flags();
50 arch_local_irq_restore(flags
| STATUS_PIE
);
53 static inline int arch_irqs_disabled_flags(unsigned long flags
)
55 return (flags
& STATUS_PIE
) == 0;
58 static inline int arch_irqs_disabled(void)
60 return arch_irqs_disabled_flags(arch_local_save_flags());
63 static inline unsigned long arch_local_irq_save(void)
67 flags
= arch_local_save_flags();
68 arch_local_irq_restore(flags
& ~STATUS_PIE
);
72 #endif /* _ASM_IRQFLAGS_H */