irq.h 878 B

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