icarus-common.h 2.3 KB

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