2006-08-27 18:07:02 +07:00
|
|
|
#ifndef __ASM_ARM_IRQFLAGS_H
|
|
|
|
#define __ASM_ARM_IRQFLAGS_H
|
|
|
|
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
|
|
|
|
#include <asm/ptrace.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* CPU interrupt mask handling.
|
|
|
|
*/
|
2010-05-22 00:06:41 +07:00
|
|
|
#ifdef CONFIG_CPU_V7M
|
|
|
|
#define IRQMASK_REG_NAME_R "primask"
|
|
|
|
#define IRQMASK_REG_NAME_W "primask"
|
|
|
|
#define IRQMASK_I_BIT 1
|
|
|
|
#else
|
|
|
|
#define IRQMASK_REG_NAME_R "cpsr"
|
|
|
|
#define IRQMASK_REG_NAME_W "cpsr_c"
|
|
|
|
#define IRQMASK_I_BIT PSR_I_BIT
|
|
|
|
#endif
|
|
|
|
|
2006-08-27 18:07:02 +07:00
|
|
|
#if __LINUX_ARM_ARCH__ >= 6
|
|
|
|
|
2015-06-10 18:25:15 +07:00
|
|
|
#define arch_local_irq_save arch_local_irq_save
|
2010-10-07 20:08:55 +07:00
|
|
|
static inline unsigned long arch_local_irq_save(void)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
asm volatile(
|
2010-05-22 00:06:41 +07:00
|
|
|
" mrs %0, " IRQMASK_REG_NAME_R " @ arch_local_irq_save\n"
|
2010-10-07 20:08:55 +07:00
|
|
|
" cpsid i"
|
|
|
|
: "=r" (flags) : : "memory", "cc");
|
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
2015-06-10 18:25:15 +07:00
|
|
|
#define arch_local_irq_enable arch_local_irq_enable
|
2010-10-07 20:08:55 +07:00
|
|
|
static inline void arch_local_irq_enable(void)
|
|
|
|
{
|
|
|
|
asm volatile(
|
|
|
|
" cpsie i @ arch_local_irq_enable"
|
|
|
|
:
|
|
|
|
:
|
|
|
|
: "memory", "cc");
|
|
|
|
}
|
|
|
|
|
2015-06-10 18:25:15 +07:00
|
|
|
#define arch_local_irq_disable arch_local_irq_disable
|
2010-10-07 20:08:55 +07:00
|
|
|
static inline void arch_local_irq_disable(void)
|
|
|
|
{
|
|
|
|
asm volatile(
|
|
|
|
" cpsid i @ arch_local_irq_disable"
|
|
|
|
:
|
|
|
|
:
|
|
|
|
: "memory", "cc");
|
|
|
|
}
|
2006-08-27 18:07:02 +07:00
|
|
|
|
|
|
|
#define local_fiq_enable() __asm__("cpsie f @ __stf" : : : "memory", "cc")
|
|
|
|
#define local_fiq_disable() __asm__("cpsid f @ __clf" : : : "memory", "cc")
|
|
|
|
#else
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Save the current interrupt enable state & disable IRQs
|
|
|
|
*/
|
2015-06-10 18:25:15 +07:00
|
|
|
#define arch_local_irq_save arch_local_irq_save
|
2010-10-07 20:08:55 +07:00
|
|
|
static inline unsigned long arch_local_irq_save(void)
|
|
|
|
{
|
|
|
|
unsigned long flags, temp;
|
|
|
|
|
|
|
|
asm volatile(
|
|
|
|
" mrs %0, cpsr @ arch_local_irq_save\n"
|
|
|
|
" orr %1, %0, #128\n"
|
|
|
|
" msr cpsr_c, %1"
|
|
|
|
: "=r" (flags), "=r" (temp)
|
|
|
|
:
|
|
|
|
: "memory", "cc");
|
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
2006-08-27 18:07:02 +07:00
|
|
|
/*
|
|
|
|
* Enable IRQs
|
|
|
|
*/
|
2015-06-10 18:25:15 +07:00
|
|
|
#define arch_local_irq_enable arch_local_irq_enable
|
2010-10-07 20:08:55 +07:00
|
|
|
static inline void arch_local_irq_enable(void)
|
|
|
|
{
|
|
|
|
unsigned long temp;
|
|
|
|
asm volatile(
|
|
|
|
" mrs %0, cpsr @ arch_local_irq_enable\n"
|
|
|
|
" bic %0, %0, #128\n"
|
|
|
|
" msr cpsr_c, %0"
|
|
|
|
: "=r" (temp)
|
|
|
|
:
|
|
|
|
: "memory", "cc");
|
|
|
|
}
|
2006-08-27 18:07:02 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Disable IRQs
|
|
|
|
*/
|
2015-06-10 18:25:15 +07:00
|
|
|
#define arch_local_irq_disable arch_local_irq_disable
|
2010-10-07 20:08:55 +07:00
|
|
|
static inline void arch_local_irq_disable(void)
|
|
|
|
{
|
|
|
|
unsigned long temp;
|
|
|
|
asm volatile(
|
|
|
|
" mrs %0, cpsr @ arch_local_irq_disable\n"
|
|
|
|
" orr %0, %0, #128\n"
|
|
|
|
" msr cpsr_c, %0"
|
|
|
|
: "=r" (temp)
|
|
|
|
:
|
|
|
|
: "memory", "cc");
|
|
|
|
}
|
2006-08-27 18:07:02 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable FIQs
|
|
|
|
*/
|
|
|
|
#define local_fiq_enable() \
|
|
|
|
({ \
|
|
|
|
unsigned long temp; \
|
|
|
|
__asm__ __volatile__( \
|
|
|
|
"mrs %0, cpsr @ stf\n" \
|
|
|
|
" bic %0, %0, #64\n" \
|
|
|
|
" msr cpsr_c, %0" \
|
|
|
|
: "=r" (temp) \
|
|
|
|
: \
|
|
|
|
: "memory", "cc"); \
|
|
|
|
})
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disable FIQs
|
|
|
|
*/
|
|
|
|
#define local_fiq_disable() \
|
|
|
|
({ \
|
|
|
|
unsigned long temp; \
|
|
|
|
__asm__ __volatile__( \
|
|
|
|
"mrs %0, cpsr @ clf\n" \
|
|
|
|
" orr %0, %0, #64\n" \
|
|
|
|
" msr cpsr_c, %0" \
|
|
|
|
: "=r" (temp) \
|
|
|
|
: \
|
|
|
|
: "memory", "cc"); \
|
|
|
|
})
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Save the current interrupt enable state.
|
|
|
|
*/
|
2015-06-10 18:25:15 +07:00
|
|
|
#define arch_local_save_flags arch_local_save_flags
|
2010-10-07 20:08:55 +07:00
|
|
|
static inline unsigned long arch_local_save_flags(void)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
asm volatile(
|
2010-05-22 00:06:41 +07:00
|
|
|
" mrs %0, " IRQMASK_REG_NAME_R " @ local_save_flags"
|
2010-10-07 20:08:55 +07:00
|
|
|
: "=r" (flags) : : "memory", "cc");
|
|
|
|
return flags;
|
|
|
|
}
|
2006-08-27 18:07:02 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* restore saved IRQ & FIQ state
|
|
|
|
*/
|
2015-06-10 18:25:15 +07:00
|
|
|
#define arch_local_irq_restore arch_local_irq_restore
|
2010-10-07 20:08:55 +07:00
|
|
|
static inline void arch_local_irq_restore(unsigned long flags)
|
|
|
|
{
|
|
|
|
asm volatile(
|
2010-05-22 00:06:41 +07:00
|
|
|
" msr " IRQMASK_REG_NAME_W ", %0 @ local_irq_restore"
|
2010-10-07 20:08:55 +07:00
|
|
|
:
|
|
|
|
: "r" (flags)
|
|
|
|
: "memory", "cc");
|
|
|
|
}
|
2006-08-27 18:07:02 +07:00
|
|
|
|
2015-06-10 18:25:15 +07:00
|
|
|
#define arch_irqs_disabled_flags arch_irqs_disabled_flags
|
2010-10-07 20:08:55 +07:00
|
|
|
static inline int arch_irqs_disabled_flags(unsigned long flags)
|
|
|
|
{
|
2010-05-22 00:06:41 +07:00
|
|
|
return flags & IRQMASK_I_BIT;
|
2010-10-07 20:08:55 +07:00
|
|
|
}
|
2006-08-27 18:07:02 +07:00
|
|
|
|
2015-06-10 18:25:15 +07:00
|
|
|
#include <asm-generic/irqflags.h>
|
|
|
|
|
2010-05-22 00:06:41 +07:00
|
|
|
#endif /* ifdef __KERNEL__ */
|
|
|
|
#endif /* ifndef __ASM_ARM_IRQFLAGS_H */
|