fpgautils.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright 2012-2013 Luke Dashjr
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the Free
  6. * Software Foundation; either version 3 of the License, or (at your option)
  7. * any later version. See COPYING for more details.
  8. */
  9. #ifndef FPGAUTILS_H
  10. #define FPGAUTILS_H
  11. #include <stdbool.h>
  12. #include <stdint.h>
  13. #include <stdio.h>
  14. #include <unistd.h>
  15. struct device_api;
  16. struct cgpu_info;
  17. typedef bool(*detectone_func_t)(const char*);
  18. typedef int(*autoscan_func_t)();
  19. extern int _serial_detect(struct device_api *api, detectone_func_t, autoscan_func_t, int flags);
  20. #define serial_detect_fauto(api, detectone, autoscan) \
  21. _serial_detect(api, detectone, autoscan, 1)
  22. #define serial_detect_auto(api, detectone, autoscan) \
  23. _serial_detect(api, detectone, autoscan, 0)
  24. #define serial_detect_auto_byname(api, detectone, autoscan) \
  25. _serial_detect(api, detectone, autoscan, 2)
  26. #define serial_detect(api, detectone) \
  27. _serial_detect(api, detectone, NULL, 0)
  28. #define noserial_detect(api, autoscan) \
  29. _serial_detect(api, NULL , autoscan, 0)
  30. extern int _serial_autodetect(detectone_func_t, ...);
  31. #define serial_autodetect(...) _serial_autodetect(__VA_ARGS__, NULL)
  32. extern struct device_api *serial_claim(const char *devpath, struct device_api *);
  33. extern int serial_open(const char *devpath, unsigned long baud, uint8_t timeout, bool purge);
  34. extern ssize_t _serial_read(int fd, char *buf, size_t buflen, char *eol);
  35. #define serial_read(fd, buf, count) \
  36. _serial_read(fd, (char*)(buf), count, NULL)
  37. #define serial_read_line(fd, buf, bufsiz, eol) \
  38. _serial_read(fd, buf, bufsiz, &eol)
  39. #define serial_close(fd) close(fd)
  40. extern FILE *open_bitstream(const char *dname, const char *filename);
  41. extern FILE *open_xilinx_bitstream(const char *dname, const char *repr, const char *fwfile, unsigned long *out_len);
  42. #endif