2012-02-03 06:08:17 -05:00
|
|
|
#ifndef __IRQ_H
|
|
|
|
#define __IRQ_H
|
|
|
|
|
2013-03-25 09:38:58 -04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2014-05-14 04:24:56 -04:00
|
|
|
#ifdef __or1k__
|
|
|
|
#include <system.h>
|
|
|
|
#endif
|
|
|
|
|
2012-02-06 17:53:29 -05:00
|
|
|
static inline unsigned int irq_getie(void)
|
2012-02-03 06:08:17 -05:00
|
|
|
{
|
2014-05-14 04:24:56 -04:00
|
|
|
#if defined (__lm32__)
|
|
|
|
unsigned int ie;
|
|
|
|
__asm__ __volatile__("rcsr %0, IE" : "=r" (ie));
|
|
|
|
return ie;
|
|
|
|
#elif defined (__or1k__)
|
|
|
|
return !!(mfspr(SPR_SR) & SPR_SR_IEE);
|
|
|
|
#else
|
|
|
|
#error Unsupported architecture
|
|
|
|
#endif
|
2012-02-06 17:53:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void irq_setie(unsigned int ie)
|
|
|
|
{
|
2014-05-14 04:24:56 -04:00
|
|
|
#if defined (__lm32__)
|
|
|
|
__asm__ __volatile__("wcsr IE, %0" : : "r" (ie));
|
|
|
|
#elif defined (__or1k__)
|
|
|
|
if (ie & 0x1)
|
|
|
|
mtspr(SPR_SR, mfspr(SPR_SR) | SPR_SR_IEE);
|
|
|
|
else
|
|
|
|
mtspr(SPR_SR, mfspr(SPR_SR) & ~SPR_SR_IEE);
|
|
|
|
#else
|
|
|
|
#error Unsupported architecture
|
|
|
|
#endif
|
2012-02-03 06:08:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned int irq_getmask(void)
|
|
|
|
{
|
2014-05-14 04:24:56 -04:00
|
|
|
#if defined (__lm32__)
|
|
|
|
unsigned int mask;
|
|
|
|
__asm__ __volatile__("rcsr %0, IM" : "=r" (mask));
|
|
|
|
return mask;
|
|
|
|
#elif defined (__or1k__)
|
|
|
|
return mfspr(SPR_PICMR);
|
|
|
|
#else
|
|
|
|
#error Unsupported architecture
|
|
|
|
#endif
|
2012-02-03 06:08:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void irq_setmask(unsigned int mask)
|
|
|
|
{
|
2014-05-14 04:24:56 -04:00
|
|
|
#if defined (__lm32__)
|
|
|
|
__asm__ __volatile__("wcsr IM, %0" : : "r" (mask));
|
|
|
|
#elif defined (__or1k__)
|
|
|
|
mtspr(SPR_PICMR, mask);
|
|
|
|
#else
|
|
|
|
#error Unsupported architecture
|
|
|
|
#endif
|
2012-02-03 06:08:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned int irq_pending(void)
|
|
|
|
{
|
2014-05-14 04:24:56 -04:00
|
|
|
#if defined (__lm32__)
|
|
|
|
unsigned int pending;
|
|
|
|
__asm__ __volatile__("rcsr %0, IP" : "=r" (pending));
|
|
|
|
return pending;
|
|
|
|
#elif defined (__or1k__)
|
|
|
|
return mfspr(SPR_PICSR);
|
|
|
|
#else
|
|
|
|
#error Unsupported architecture
|
|
|
|
#endif
|
2012-02-03 06:08:17 -05:00
|
|
|
}
|
|
|
|
|
2013-03-25 09:38:58 -04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-02-03 06:08:17 -05:00
|
|
|
#endif /* __IRQ_H */
|