]>
Commit | Line | Data |
---|---|---|
6d60b6ee PD |
1 | /* |
2 | * Copyright (C) 2012 Regents of the University of California | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or | |
5 | * modify it under the terms of the GNU General Public License | |
6 | * as published by the Free Software Foundation, version 2. | |
7 | * | |
8 | * This program is distributed in the hope that it will be useful, | |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | * GNU General Public License for more details. | |
12 | */ | |
13 | ||
14 | ||
15 | #ifndef _ASM_RISCV_IRQFLAGS_H | |
16 | #define _ASM_RISCV_IRQFLAGS_H | |
17 | ||
18 | #include <asm/processor.h> | |
19 | #include <asm/csr.h> | |
20 | ||
21 | /* read interrupt enabled status */ | |
22 | static inline unsigned long arch_local_save_flags(void) | |
23 | { | |
24 | return csr_read(sstatus); | |
25 | } | |
26 | ||
27 | /* unconditionally enable interrupts */ | |
28 | static inline void arch_local_irq_enable(void) | |
29 | { | |
1125203c | 30 | csr_set(sstatus, SR_SIE); |
6d60b6ee PD |
31 | } |
32 | ||
33 | /* unconditionally disable interrupts */ | |
34 | static inline void arch_local_irq_disable(void) | |
35 | { | |
1125203c | 36 | csr_clear(sstatus, SR_SIE); |
6d60b6ee PD |
37 | } |
38 | ||
39 | /* get status and disable interrupts */ | |
40 | static inline unsigned long arch_local_irq_save(void) | |
41 | { | |
1125203c | 42 | return csr_read_clear(sstatus, SR_SIE); |
6d60b6ee PD |
43 | } |
44 | ||
45 | /* test flags */ | |
46 | static inline int arch_irqs_disabled_flags(unsigned long flags) | |
47 | { | |
1125203c | 48 | return !(flags & SR_SIE); |
6d60b6ee PD |
49 | } |
50 | ||
51 | /* test hardware interrupt enable bit */ | |
52 | static inline int arch_irqs_disabled(void) | |
53 | { | |
54 | return arch_irqs_disabled_flags(arch_local_save_flags()); | |
55 | } | |
56 | ||
57 | /* set interrupt enabled status */ | |
58 | static inline void arch_local_irq_restore(unsigned long flags) | |
59 | { | |
1125203c | 60 | csr_set(sstatus, flags & SR_SIE); |
6d60b6ee PD |
61 | } |
62 | ||
63 | #endif /* _ASM_RISCV_IRQFLAGS_H */ |