icarus-common.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #ifndef ICARUS_COMMON_H
  2. #define ICARUS_COMMON_H
  3. #include <stdbool.h>
  4. #include <stdint.h>
  5. #include <sys/time.h>
  6. #include "dynclock.h"
  7. #include "miner.h"
  8. // Fraction of a second, USB timeout is measured in
  9. // i.e. 10 means 1/10 of a second
  10. // Right now, it MUST be 10 due to other assumptions.
  11. #define TIME_FACTOR 10
  12. // It's 10 per second, thus value = 10/TIME_FACTOR =
  13. #define ICARUS_READ_FAULT_DECISECONDS 1
  14. #define NANOSEC 1000000000.0
  15. // Store the last INFO_HISTORY data sets
  16. // [0] = current data, not yet ready to be included as an estimate
  17. // Each new data set throws the last old set off the end thus
  18. // keeping a ongoing average of recent data
  19. #define INFO_HISTORY 10
  20. struct ICARUS_HISTORY {
  21. struct timeval finish;
  22. double sumXiTi;
  23. double sumXi;
  24. double sumTi;
  25. double sumXi2;
  26. uint32_t values;
  27. uint32_t hash_count_min;
  28. uint32_t hash_count_max;
  29. };
  30. enum timing_mode { MODE_DEFAULT, MODE_SHORT, MODE_LONG, MODE_VALUE };
  31. struct ICARUS_INFO {
  32. // time to calculate the golden_ob
  33. uint64_t golden_hashes;
  34. struct timeval golden_tv;
  35. struct ICARUS_HISTORY history[INFO_HISTORY+1];
  36. uint32_t min_data_count;
  37. // seconds per Hash
  38. double Hs;
  39. int read_count;
  40. enum timing_mode timing_mode;
  41. bool do_icarus_timing;
  42. int do_default_detection;
  43. double fullnonce;
  44. int count;
  45. double W;
  46. uint32_t values;
  47. uint64_t hash_count_range;
  48. // Determine the cost of history processing
  49. // (which will only affect W)
  50. uint64_t history_count;
  51. struct timeval history_time;
  52. // icarus-options
  53. int baud;
  54. int work_division;
  55. int fpga_count;
  56. uint32_t nonce_mask;
  57. bool quirk_reopen;
  58. dclk_change_clock_func_t dclk_change_clock_func;
  59. struct dclk_data dclk;
  60. };
  61. struct icarus_state {
  62. bool firstrun;
  63. struct timeval tv_workstart;
  64. struct timeval tv_workfinish;
  65. struct work last_work;
  66. bool changework;
  67. };
  68. bool icarus_detect_custom(const char *devpath, struct device_api *, struct ICARUS_INFO *);
  69. extern int icarus_gets(unsigned char *, int fd, struct timeval *tv_finish, struct thr_info *, int read_count);
  70. #endif