fw.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef FW_H
  2. #define FW_H
  3. #include <stdarg.h>
  4. #include <stddef.h>
  5. #include <stdint.h>
  6. #include <stdbool.h>
  7. #include "picorv32.h"
  8. #define likely(x) __builtin_expect(!!(x), 1)
  9. #define unlikely(x) __builtin_expect(!!(x), 0)
  10. extern void __attribute__((noreturn)) _die(void);
  11. extern void __attribute__((noreturn)) exit(int);
  12. extern void __attribute__((noreturn)) _exit(int);
  13. extern const uint8_t _end[];
  14. extern void *_sbrk(size_t);
  15. extern int disk_init(void);
  16. #define IRQ_VECTORS 32
  17. typedef void (*irq_handler_t)(unsigned int vector);
  18. extern irq_handler_t
  19. register_irq(unsigned int vector, irq_handler_t handler, bool enable);
  20. extern void null_irq_handler(unsigned int vector);
  21. static inline unsigned int mask_irq(unsigned int vector)
  22. {
  23. const uint32_t mask = 1U << vector;
  24. return p_maskirq(mask, ~mask);
  25. }
  26. static inline unsigned int unmask_irq(unsigned int vector)
  27. {
  28. const uint32_t mask = 1U << vector;
  29. return p_maskirq(0, ~mask);
  30. }
  31. static inline unsigned int irqmask(void)
  32. {
  33. return p_maskirq(0, ~0);
  34. }
  35. #endif /* FW_H */