2
0

irq.h 791 B

12345678910111213141516171819202122232425262728293031323334
  1. #ifndef IRQ_H
  2. #define IRQ_H
  3. #include "picorv32.h"
  4. typedef void (*irqhandler_t)(unsigned int vector);
  5. extern irqhandler_t __irq_handler_table[];
  6. #define IRQHANDLER(x) \
  7. void irqhandler_ ##x (unsigned int); \
  8. void irqhandler_ ##x (unsigned int vector __attribute__((unused)))
  9. static inline unsigned int mask_irq(unsigned int vector)
  10. {
  11. const unsigned int mask = 1U << vector;
  12. return p_maskirq(mask, ~mask);
  13. }
  14. static inline unsigned int unmask_irq(unsigned int vector)
  15. {
  16. const unsigned int mask = 1U << vector;
  17. return p_maskirq(0, ~mask);
  18. }
  19. static inline unsigned int irqmask(void)
  20. {
  21. return p_maskirq(0, ~0);
  22. }
  23. static inline unsigned int waitfor(unsigned int vector)
  24. {
  25. const unsigned int mask = 1U << vector;
  26. return p_waitirq(mask, 0);
  27. }
  28. #endif /* IRQ_H */