1 /* 2 * Copyright (C) 2010 Thomas Chou <thomas@wytron.com.tw> 3 * 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. 8 * 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. 13 * 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/>. 16 * 17 */ 18 #ifndef _ASM_IRQFLAGS_H 19 #define _ASM_IRQFLAGS_H 20 21 #include <asm/registers.h> 22 23 static inline unsigned long arch_local_save_flags(void) 24 { 25 return RDCTL(CTL_STATUS); 26 } 27 28 /* 29 * This will restore ALL status register flags, not only the interrupt 30 * mask flag. 31 */ 32 static inline void arch_local_irq_restore(unsigned long flags) 33 { 34 WRCTL(CTL_STATUS, flags); 35 } 36 37 static inline void arch_local_irq_disable(void) 38 { 39 unsigned long flags; 40 41 flags = arch_local_save_flags(); 42 arch_local_irq_restore(flags & ~STATUS_PIE); 43 } 44 45 static inline void arch_local_irq_enable(void) 46 { 47 unsigned long flags; 48 49 flags = arch_local_save_flags(); 50 arch_local_irq_restore(flags | STATUS_PIE); 51 } 52 53 static inline int arch_irqs_disabled_flags(unsigned long flags) 54 { 55 return (flags & STATUS_PIE) == 0; 56 } 57 58 static inline int arch_irqs_disabled(void) 59 { 60 return arch_irqs_disabled_flags(arch_local_save_flags()); 61 } 62 63 static inline unsigned long arch_local_irq_save(void) 64 { 65 unsigned long flags; 66 67 flags = arch_local_save_flags(); 68 arch_local_irq_restore(flags & ~STATUS_PIE); 69 return flags; 70 } 71 72 #endif /* _ASM_IRQFLAGS_H */ 73