1 /* 2 * Copyright (C) 2014-15 Synopsys, Inc. (www.synopsys.com) 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 version 2 as 6 * published by the Free Software Foundation. 7 */ 8 9 #ifndef __ASM_IRQFLAGS_ARCV2_H 10 #define __ASM_IRQFLAGS_ARCV2_H 11 12 #include <asm/arcregs.h> 13 14 /* status32 Bits */ 15 #define STATUS_AD_BIT 19 /* Disable Align chk: core supports non-aligned */ 16 #define STATUS_IE_BIT 31 17 18 #define STATUS_AD_MASK (1<<STATUS_AD_BIT) 19 #define STATUS_IE_MASK (1<<STATUS_IE_BIT) 20 21 #define AUX_USER_SP 0x00D 22 #define AUX_IRQ_CTRL 0x00E 23 #define AUX_IRQ_ACT 0x043 /* Active Intr across all levels */ 24 #define AUX_IRQ_LVL_PEND 0x200 /* Pending Intr across all levels */ 25 #define AUX_IRQ_PRIORITY 0x206 26 #define ICAUSE 0x40a 27 #define AUX_IRQ_SELECT 0x40b 28 #define AUX_IRQ_ENABLE 0x40c 29 30 /* 0 is highest level, but taken by FIRQs, if present in design */ 31 #define ARCV2_IRQ_DEF_PRIO 0 32 33 /* seed value for status register */ 34 #define ISA_INIT_STATUS_BITS (STATUS_IE_MASK | STATUS_AD_MASK | \ 35 (ARCV2_IRQ_DEF_PRIO << 1)) 36 37 #ifndef __ASSEMBLY__ 38 39 /* 40 * Save IRQ state and disable IRQs 41 */ 42 static inline long arch_local_irq_save(void) 43 { 44 unsigned long flags; 45 46 __asm__ __volatile__(" clri %0 \n" : "=r" (flags) : : "memory"); 47 48 return flags; 49 } 50 51 /* 52 * restore saved IRQ state 53 */ 54 static inline void arch_local_irq_restore(unsigned long flags) 55 { 56 __asm__ __volatile__(" seti %0 \n" : : "r" (flags) : "memory"); 57 } 58 59 /* 60 * Unconditionally Enable IRQs 61 */ 62 static inline void arch_local_irq_enable(void) 63 { 64 __asm__ __volatile__(" seti \n" : : : "memory"); 65 } 66 67 /* 68 * Unconditionally Disable IRQs 69 */ 70 static inline void arch_local_irq_disable(void) 71 { 72 __asm__ __volatile__(" clri \n" : : : "memory"); 73 } 74 75 /* 76 * save IRQ state 77 */ 78 static inline long arch_local_save_flags(void) 79 { 80 unsigned long temp; 81 82 __asm__ __volatile__( 83 " lr %0, [status32] \n" 84 : "=&r"(temp) 85 : 86 : "memory"); 87 88 return temp; 89 } 90 91 /* 92 * Query IRQ state 93 */ 94 static inline int arch_irqs_disabled_flags(unsigned long flags) 95 { 96 return !(flags & (STATUS_IE_MASK)); 97 } 98 99 static inline int arch_irqs_disabled(void) 100 { 101 return arch_irqs_disabled_flags(arch_local_save_flags()); 102 } 103 104 #else 105 106 .macro IRQ_DISABLE scratch 107 clri 108 .endm 109 110 .macro IRQ_ENABLE scratch 111 seti 112 .endm 113 114 #endif /* __ASSEMBLY__ */ 115 116 #endif 117