abcio.h 1.4 KB

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