2008-07-18 04:55:51 +00:00
|
|
|
/*
|
2008-07-27 21:00:59 +00:00
|
|
|
* include/asm/irqflags.h
|
2008-07-18 04:55:51 +00:00
|
|
|
*
|
|
|
|
* IRQ flags handling
|
|
|
|
*
|
|
|
|
* This file gets included from lowlevel asm headers too, to provide
|
|
|
|
* wrapped versions of the local_irq_*() APIs, based on the
|
2010-10-07 13:08:55 +00:00
|
|
|
* arch_local_irq_*() functions from the lowlevel headers.
|
2008-07-18 04:55:51 +00:00
|
|
|
*/
|
|
|
|
#ifndef _ASM_IRQFLAGS_H
|
|
|
|
#define _ASM_IRQFLAGS_H
|
|
|
|
|
2008-11-24 05:55:29 +00:00
|
|
|
#include <asm/pil.h>
|
|
|
|
|
2008-07-18 04:55:51 +00:00
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
|
2010-10-07 13:08:55 +00:00
|
|
|
static inline unsigned long arch_local_save_flags(void)
|
2008-07-18 04:55:51 +00:00
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"rdpr %%pil, %0"
|
|
|
|
: "=r" (flags)
|
|
|
|
);
|
|
|
|
|
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
2010-10-07 13:08:55 +00:00
|
|
|
static inline void arch_local_irq_restore(unsigned long flags)
|
2008-07-18 04:55:51 +00:00
|
|
|
{
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"wrpr %0, %%pil"
|
|
|
|
: /* no output */
|
|
|
|
: "r" (flags)
|
|
|
|
: "memory"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2010-10-07 13:08:55 +00:00
|
|
|
static inline void arch_local_irq_disable(void)
|
2008-07-18 04:55:51 +00:00
|
|
|
{
|
|
|
|
__asm__ __volatile__(
|
2008-11-24 05:55:29 +00:00
|
|
|
"wrpr %0, %%pil"
|
2008-07-18 04:55:51 +00:00
|
|
|
: /* no outputs */
|
2008-11-24 05:55:29 +00:00
|
|
|
: "i" (PIL_NORMAL_MAX)
|
2008-07-18 04:55:51 +00:00
|
|
|
: "memory"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2010-10-07 13:08:55 +00:00
|
|
|
static inline void arch_local_irq_enable(void)
|
2008-07-18 04:55:51 +00:00
|
|
|
{
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"wrpr 0, %%pil"
|
|
|
|
: /* no outputs */
|
|
|
|
: /* no inputs */
|
|
|
|
: "memory"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2010-10-07 13:08:55 +00:00
|
|
|
static inline int arch_irqs_disabled_flags(unsigned long flags)
|
2008-07-18 04:55:51 +00:00
|
|
|
{
|
|
|
|
return (flags > 0);
|
|
|
|
}
|
|
|
|
|
2010-10-07 13:08:55 +00:00
|
|
|
static inline int arch_irqs_disabled(void)
|
2008-07-18 04:55:51 +00:00
|
|
|
{
|
2010-10-07 13:08:55 +00:00
|
|
|
return arch_irqs_disabled_flags(arch_local_save_flags());
|
2008-07-18 04:55:51 +00:00
|
|
|
}
|
|
|
|
|
2010-10-07 13:08:55 +00:00
|
|
|
static inline unsigned long arch_local_irq_save(void)
|
2008-07-18 04:55:51 +00:00
|
|
|
{
|
2010-04-13 05:21:52 +00:00
|
|
|
unsigned long flags, tmp;
|
2008-07-18 04:55:51 +00:00
|
|
|
|
2010-04-13 05:21:52 +00:00
|
|
|
/* Disable interrupts to PIL_NORMAL_MAX unless we already
|
|
|
|
* are using PIL_NMI, in which case PIL_NMI is retained.
|
2010-04-13 08:50:43 +00:00
|
|
|
*
|
|
|
|
* The only values we ever program into the %pil are 0,
|
|
|
|
* PIL_NORMAL_MAX and PIL_NMI.
|
|
|
|
*
|
|
|
|
* Since PIL_NMI is the largest %pil value and all bits are
|
|
|
|
* set in it (0xf), it doesn't matter what PIL_NORMAL_MAX
|
|
|
|
* actually is.
|
2010-04-13 05:21:52 +00:00
|
|
|
*/
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"rdpr %%pil, %0\n\t"
|
|
|
|
"or %0, %2, %1\n\t"
|
|
|
|
"wrpr %1, 0x0, %%pil"
|
|
|
|
: "=r" (flags), "=r" (tmp)
|
|
|
|
: "i" (PIL_NORMAL_MAX)
|
|
|
|
: "memory"
|
|
|
|
);
|
2008-07-18 04:55:51 +00:00
|
|
|
|
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* (__ASSEMBLY__) */
|
|
|
|
|
|
|
|
#endif /* !(_ASM_IRQFLAGS_H) */
|