2019-05-29 21:18:00 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2017-07-11 08:05:09 +07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2012 Regents of the University of California
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _ASM_RISCV_IRQFLAGS_H
|
|
|
|
#define _ASM_RISCV_IRQFLAGS_H
|
|
|
|
|
|
|
|
#include <asm/processor.h>
|
|
|
|
#include <asm/csr.h>
|
|
|
|
|
|
|
|
/* read interrupt enabled status */
|
|
|
|
static inline unsigned long arch_local_save_flags(void)
|
|
|
|
{
|
2019-04-25 15:38:41 +07:00
|
|
|
return csr_read(CSR_SSTATUS);
|
2017-07-11 08:05:09 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* unconditionally enable interrupts */
|
|
|
|
static inline void arch_local_irq_enable(void)
|
|
|
|
{
|
2019-04-25 15:38:41 +07:00
|
|
|
csr_set(CSR_SSTATUS, SR_SIE);
|
2017-07-11 08:05:09 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* unconditionally disable interrupts */
|
|
|
|
static inline void arch_local_irq_disable(void)
|
|
|
|
{
|
2019-04-25 15:38:41 +07:00
|
|
|
csr_clear(CSR_SSTATUS, SR_SIE);
|
2017-07-11 08:05:09 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* get status and disable interrupts */
|
|
|
|
static inline unsigned long arch_local_irq_save(void)
|
|
|
|
{
|
2019-04-25 15:38:41 +07:00
|
|
|
return csr_read_clear(CSR_SSTATUS, SR_SIE);
|
2017-07-11 08:05:09 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* test flags */
|
|
|
|
static inline int arch_irqs_disabled_flags(unsigned long flags)
|
|
|
|
{
|
2018-01-05 00:35:03 +07:00
|
|
|
return !(flags & SR_SIE);
|
2017-07-11 08:05:09 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* test hardware interrupt enable bit */
|
|
|
|
static inline int arch_irqs_disabled(void)
|
|
|
|
{
|
|
|
|
return arch_irqs_disabled_flags(arch_local_save_flags());
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set interrupt enabled status */
|
|
|
|
static inline void arch_local_irq_restore(unsigned long flags)
|
|
|
|
{
|
2019-04-25 15:38:41 +07:00
|
|
|
csr_set(CSR_SSTATUS, flags & SR_SIE);
|
2017-07-11 08:05:09 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* _ASM_RISCV_IRQFLAGS_H */
|