driver-icarus.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*
  2. * Copyright 2012-2015 Luke Dashjr
  3. * Copyright 2014 Nate Woolls
  4. * Copyright 2012 Xiangfu
  5. * Copyright 2012 Andrew Smith
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the Free
  9. * Software Foundation; either version 3 of the License, or (at your option)
  10. * any later version. See COPYING for more details.
  11. */
  12. #ifndef BFG_DRIVER_ICARUS_H
  13. #define BFG_DRIVER_ICARUS_H
  14. #include <stdbool.h>
  15. #include <stdint.h>
  16. #include <sys/time.h>
  17. #include "deviceapi.h"
  18. #include "dynclock.h"
  19. #include "miner.h"
  20. #define ICARUS_READ_FAULT_DECISECONDS 1
  21. #define NANOSEC 1000000000.0
  22. // Default value for ICARUS_INFO->read_size
  23. #define ICARUS_DEFAULT_READ_SIZE 4
  24. #define ICA_GETS_ERROR -1
  25. #define ICA_GETS_OK 0
  26. #define ICA_GETS_RESTART 1
  27. #define ICA_GETS_TIMEOUT 2
  28. // Store the last INFO_HISTORY data sets
  29. // [0] = current data, not yet ready to be included as an estimate
  30. // Each new data set throws the last old set off the end thus
  31. // keeping a ongoing average of recent data
  32. #define INFO_HISTORY 10
  33. extern struct device_drv icarus_drv;
  34. struct ICARUS_HISTORY {
  35. struct timeval finish;
  36. double sumXiTi;
  37. double sumXi;
  38. double sumTi;
  39. double sumXi2;
  40. uint32_t values;
  41. uint32_t hash_count_min;
  42. uint32_t hash_count_max;
  43. };
  44. enum timing_mode { MODE_DEFAULT, MODE_SHORT, MODE_LONG, MODE_VALUE };
  45. enum icarus_reopen_mode {
  46. IRM_NEVER,
  47. IRM_TIMEOUT,
  48. IRM_CYCLE,
  49. };
  50. enum icarus_user_settings {
  51. IUS_WORK_DIVISION = 1,
  52. IUS_FPGA_COUNT = 2,
  53. };
  54. struct ICARUS_INFO {
  55. // time to calculate the golden_ob
  56. struct timeval golden_tv;
  57. // History structures for calculating read_count
  58. // when info->do_icarus_timing is true
  59. struct ICARUS_HISTORY history[INFO_HISTORY+1];
  60. uint32_t min_data_count;
  61. // Timeout scanning for a nonce
  62. unsigned read_timeout_ms;
  63. // Timeout scanning for a golden nonce (deciseconds)
  64. int probe_read_count;
  65. // ds limit for (short=/long=) read_count
  66. int read_count_limit;
  67. enum timing_mode timing_mode;
  68. bool do_icarus_timing;
  69. int do_default_detection;
  70. double fullnonce;
  71. int count;
  72. double W;
  73. uint32_t values;
  74. uint64_t hash_count_range;
  75. // Determine the cost of history processing
  76. // (which will only affect W)
  77. uint64_t history_count;
  78. struct timeval history_time;
  79. // icarus-options
  80. int baud;
  81. // Used to calculate / display hash count when nonce is NOT found
  82. // seconds per Hash
  83. double Hs;
  84. // Used to calculate / display hash count when a nonce is found
  85. int work_division;
  86. int fpga_count;
  87. uint32_t nonce_mask;
  88. enum icarus_reopen_mode reopen_mode;
  89. bool reopen_now;
  90. uint8_t user_set;
  91. bool continue_search;
  92. dclk_change_clock_func_t dclk_change_clock_func;
  93. struct dclk_data dclk;
  94. // Bytes to read from Icarus for nonce
  95. int read_size;
  96. // Settings used when probing / detecting
  97. size_t ob_size;
  98. const char *golden_ob;
  99. const char *golden_nonce;
  100. bool nonce_littleendian;
  101. // Don't check the golden nonce returned when probing
  102. bool ignore_golden_nonce;
  103. // Custom driver functions
  104. bool (*detect_init_func)(const char *devpath, int fd, struct ICARUS_INFO *);
  105. bool (*job_start_func)(struct thr_info *);
  106. bool has_bm1382_freq_register;
  107. #ifdef USE_DUALMINER
  108. #ifdef USE_SCRYPT
  109. bool scrypt;
  110. #endif
  111. bool dual_mode;
  112. #endif
  113. #ifdef USE_ZEUSMINER
  114. // Hardware information, doesn't affect anything directly
  115. uint16_t freq;
  116. uint16_t chips;
  117. #endif
  118. };
  119. struct icarus_state {
  120. bool firstrun;
  121. struct timeval tv_workstart;
  122. struct timeval tv_workfinish;
  123. struct work *last_work;
  124. struct work *last2_work;
  125. bool changework;
  126. bool identify;
  127. uint8_t *ob_bin;
  128. };
  129. extern struct cgpu_info *icarus_detect_custom(const char *devpath, struct device_drv *, struct ICARUS_INFO *);
  130. extern int icarus_read(const char *repr, uint8_t *buf, int fd, struct timeval *tvp_finish, struct thr_info *, const struct timeval *tvp_timeout, struct timeval *tvp_now, int read_size);
  131. extern int icarus_write(const char * const repr, int fd, const void *buf, size_t bufLen);
  132. extern bool icarus_init(struct thr_info *);
  133. extern void do_icarus_close(struct thr_info *thr);
  134. extern bool icarus_job_start(struct thr_info *);
  135. extern const char *icarus_set_baud(struct cgpu_info *proc, const char *optname, const char *newvalue, char *replybuf, enum bfg_set_device_replytype *out_success);
  136. extern const char *icarus_set_work_division(struct cgpu_info *proc, const char *optname, const char *newvalue, char *replybuf, enum bfg_set_device_replytype *out_success);
  137. extern const char *icarus_set_reopen(struct cgpu_info *proc, const char *optname, const char *newvalue, char *replybuf, enum bfg_set_device_replytype *out_success);
  138. extern const char *icarus_set_timing(struct cgpu_info *proc, const char *optname, const char *newvalue, char *replybuf, enum bfg_set_device_replytype *out_success);
  139. #endif