123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- #ifndef __ALT_IRQ_H__
- #define __ALT_IRQ_H__
- #include <errno.h>
- #include "nios2.h"
- #include "alt_types.h"
- #include "system.h"
- #ifdef __cplusplus
- extern "C"
- {
- #endif
- #define ALT_IRQ_ENABLED 1
- #define ALT_IRQ_DISABLED 0
- #define ALT_NIRQ NIOS2_NIRQ
- typedef int alt_irq_context;
- #ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT
- typedef void (*alt_isr_func)(void* isr_context);
- #else
- typedef void (*alt_isr_func)(void* isr_context, alt_u32 id);
- #endif
-
- static ALT_INLINE int ALT_ALWAYS_INLINE alt_irq_enabled (void)
- {
- int status;
- NIOS2_READ_STATUS (status);
- return status & NIOS2_STATUS_PIE_MSK;
- }
- static ALT_INLINE alt_irq_context ALT_ALWAYS_INLINE
- alt_irq_disable_all (void)
- {
- alt_irq_context context;
- NIOS2_READ_STATUS (context);
- NIOS2_WRITE_STATUS (context & ~NIOS2_STATUS_PIE_MSK);
-
- return context;
- }
- static ALT_INLINE void ALT_ALWAYS_INLINE
- alt_irq_enable_all (alt_irq_context context)
- {
- #if (NIOS2_NUM_OF_SHADOW_REG_SETS > 0) || (defined NIOS2_EIC_PRESENT) || \
- (defined NIOS2_MMU_PRESENT) || (defined NIOS2_MPU_PRESENT)
- alt_irq_context status;
-
- NIOS2_READ_STATUS (status);
-
- status &= ~NIOS2_STATUS_PIE_MSK;
- status |= (context & NIOS2_STATUS_PIE_MSK);
-
- NIOS2_WRITE_STATUS (status);
- #else
- NIOS2_WRITE_STATUS (context);
- #endif
- }
- extern void alt_irq_init (const void* base);
- static ALT_INLINE void ALT_ALWAYS_INLINE
- alt_irq_cpu_enable_interrupts (void)
- {
- NIOS2_WRITE_STATUS(NIOS2_STATUS_PIE_MSK
- #if defined(NIOS2_EIC_PRESENT) && (NIOS2_NUM_OF_SHADOW_REG_SETS > 0)
- | NIOS2_STATUS_RSIE_MSK
- #endif
- );
- }
- #ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT
- extern int alt_ic_isr_register(alt_u32 ic_id,
- alt_u32 irq,
- alt_isr_func isr,
- void *isr_context,
- void *flags);
- int alt_ic_irq_enable (alt_u32 ic_id, alt_u32 irq);
- int alt_ic_irq_disable(alt_u32 ic_id, alt_u32 irq);
-
-
- alt_u32 alt_ic_irq_enabled(alt_u32 ic_id, alt_u32 irq);
- #else
- #include "priv/alt_legacy_irq.h"
- #endif
- #ifndef NIOS2_EIC_PRESENT
- static ALT_INLINE alt_u32 ALT_ALWAYS_INLINE alt_irq_pending (void)
- {
- alt_u32 active;
- NIOS2_READ_IPENDING (active);
- return active;
- }
- #endif
- #ifdef __cplusplus
- }
- #endif
- #endif
|