deviceapi.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #ifndef __DEVICEAPI_H__
  2. #define __DEVICEAPI_H__
  3. #include <stdbool.h>
  4. #include <stdint.h>
  5. #include <sys/time.h>
  6. #include "miner.h"
  7. struct driver_registration;
  8. struct driver_registration {
  9. const struct device_drv *drv;
  10. UT_hash_handle hh; // hash & order by dname
  11. UT_hash_handle hh2; // hash by name, order by priority
  12. struct driver_registration *next; // DO NOT USE
  13. };
  14. extern struct driver_registration *_bfg_drvreg1;
  15. extern struct driver_registration *_bfg_drvreg2;
  16. extern void bfg_devapi_init();
  17. extern void _bfg_register_driver(const struct device_drv *);
  18. #define BFG_REGISTER_DRIVER(drv) \
  19. struct device_drv drv; \
  20. __attribute__((constructor)) \
  21. static void __bfg_register_drv_ ## drv() { \
  22. _bfg_register_driver(&drv); \
  23. } \
  24. // END BFG_REGISTER_DRIVER
  25. extern void request_work(struct thr_info *);
  26. extern struct work *get_work(struct thr_info *);
  27. extern bool hashes_done(struct thr_info *, int64_t hashes, struct timeval *tvp_hashes, uint32_t *max_nonce);
  28. extern bool hashes_done2(struct thr_info *, int64_t hashes, uint32_t *max_nonce);
  29. extern void mt_disable_start(struct thr_info *);
  30. extern void mt_disable_finish(struct thr_info *);
  31. extern void mt_disable(struct thr_info *); // blocks until reenabled
  32. extern int restart_wait(struct thr_info *, unsigned int ms);
  33. extern void minerloop_scanhash(struct thr_info *);
  34. extern bool do_job_prepare(struct thr_info *, struct timeval *tvp_now);
  35. extern void job_prepare_complete(struct thr_info *);
  36. extern void do_get_results(struct thr_info *, bool proceed_with_new_job);
  37. extern void job_results_fetched(struct thr_info *);
  38. extern void do_job_start(struct thr_info *);
  39. extern void mt_job_transition(struct thr_info *);
  40. extern void job_start_complete(struct thr_info *);
  41. extern void job_start_abort(struct thr_info *, bool failure);
  42. extern bool do_process_results(struct thr_info *, struct timeval *tvp_now, struct work *, bool stopping);
  43. extern void minerloop_async(struct thr_info *);
  44. extern void minerloop_queue(struct thr_info *);
  45. extern void *miner_thread(void *);
  46. extern void add_cgpu_live(void*);
  47. extern bool add_cgpu_slave(struct cgpu_info *, struct cgpu_info *master);
  48. typedef bool(*detectone_func_t)(const char*);
  49. typedef int(*autoscan_func_t)();
  50. enum generic_detect_flags {
  51. GDF_FORCE_AUTO = 1,
  52. GDF_REQUIRE_DNAME = 2,
  53. GDF_DEFAULT_NOAUTO = 4,
  54. };
  55. extern int _serial_detect(struct device_drv *api, detectone_func_t, autoscan_func_t, int flags);
  56. #define serial_detect_fauto(api, detectone, autoscan) \
  57. _serial_detect(api, detectone, autoscan, 1)
  58. #define serial_detect_auto(api, detectone, autoscan) \
  59. _serial_detect(api, detectone, autoscan, 0)
  60. #define serial_detect_auto_byname(api, detectone, autoscan) \
  61. _serial_detect(api, detectone, autoscan, 2)
  62. #define serial_detect(api, detectone) \
  63. _serial_detect(api, detectone, NULL, 0)
  64. #define serial_detect_byname(api, detectone) \
  65. _serial_detect(api, detectone, NULL, 2)
  66. #define noserial_detect(api, autoscan) \
  67. _serial_detect(api, NULL , autoscan, 0)
  68. #define noserial_detect_manual(api, autoscan) \
  69. _serial_detect(api, NULL , autoscan, 4)
  70. #define generic_detect(drv, detectone, autoscan, flags) _serial_detect(drv, detectone, autoscan, flags)
  71. extern FILE *open_bitstream(const char *dname, const char *filename);
  72. extern void close_device_fd(struct thr_info *);
  73. #endif