abcio.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #ifndef ABCIO_H
  2. #define ABCIO_H
  3. #include <stddef.h>
  4. #include <stdint.h>
  5. #define DEVSEL_NONE 64 /* No device at all selected */
  6. struct abc_dev;
  7. /* Called from an interrupt handler, so hot */
  8. #define ABC_CALLBACK(func) \
  9. void __hot func(struct abc_dev *dev __attribute__((unused)), \
  10. uint8_t data __attribute__((unused)), \
  11. uint8_t addr __attribute__((unused)))
  12. typedef ABC_CALLBACK((*abc_callback_t));
  13. struct abc_dev {
  14. uint8_t *out_buf;
  15. size_t out_cnt;
  16. const uint8_t *inp_buf;
  17. size_t inp_cnt;
  18. uint16_t callback_mask;
  19. uint16_t event_mask; /* Can be a superset of callback_mask */
  20. uint8_t status_first_out_mask;
  21. uint8_t status_first_inp_mask;
  22. uint8_t out_data[6]; /* [1] is devsel, all 8 bits */
  23. union {
  24. struct {
  25. uint8_t inp_data[2];
  26. uint8_t inp_en;
  27. uint8_t inp_data_def; /* inp_data[0] when no queue active */
  28. };
  29. uint32_t inp_data_w;
  30. };
  31. abc_callback_t callback_out[6];
  32. abc_callback_t callback_inp[2];
  33. abc_callback_t callback_rst;
  34. };
  35. void abc_setup_out_queue(struct abc_dev *dev, void *buf, size_t len,
  36. uint8_t status);
  37. void abc_setup_inp_queue(struct abc_dev *dev, const void *buf, size_t len,
  38. uint8_t status);
  39. void abc_set_inp_default(struct abc_dev *dev, uint8_t val);
  40. void abc_set_inp_status(struct abc_dev *dev, uint8_t val);
  41. void abc_register(struct abc_dev *dev, unsigned int devsel);
  42. void abc_init(void);
  43. void abcdisk_init(void);
  44. void abcdisk_io_poll(void);
  45. void abc_init_memmap(void);
  46. #endif /* ABCIO_H */