libbitfury.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #ifndef __LIBBITFURY_H__
  2. #define __LIBBITFURY_H__
  3. #include "miner.h"
  4. #include "spidevc.h"
  5. #define BITFURY_STAT_N 1024
  6. struct bitfury_payload {
  7. unsigned char midstate[32];
  8. unsigned int junk[8];
  9. unsigned m7;
  10. unsigned ntime;
  11. unsigned nbits;
  12. unsigned nnonce;
  13. };
  14. struct freq_stat {
  15. double mh_52;
  16. double s_52;
  17. double mh_53;
  18. double s_53;
  19. double mh_54;
  20. double s_54;
  21. double mh_55;
  22. double s_55;
  23. double mh_56;
  24. double s_56;
  25. double omh;
  26. double os;
  27. int best_osc;
  28. int best_done;
  29. };
  30. struct bitfury_device {
  31. struct spi_port *spi;
  32. unsigned char osc6_bits;
  33. unsigned newbuf[17];
  34. unsigned oldbuf[17];
  35. bool oldjob;
  36. int active;
  37. struct work * work;
  38. struct work * owork;
  39. struct work * o2work;
  40. int job_switched;
  41. uint32_t atrvec[20];
  42. struct bitfury_payload payload;
  43. struct bitfury_payload opayload;
  44. struct bitfury_payload o2payload;
  45. struct freq_stat chip_stat;
  46. unsigned int results[16];
  47. int results_n;
  48. time_t stat_ts[BITFURY_STAT_N];
  49. unsigned int stat_counter;
  50. unsigned int future_nonce;
  51. unsigned int old_nonce;
  52. struct timeval timer1;
  53. struct timeval timer2;
  54. struct timeval otimer1;
  55. struct timeval otimer2;
  56. struct timeval predict1;
  57. struct timeval predict2;
  58. struct timeval tv_stat;
  59. unsigned int counter1, counter2;
  60. unsigned int ocounter1, ocounter2;
  61. unsigned int skip_stat;
  62. int rate; //per msec
  63. int osc_slow;
  64. int osc_fast;
  65. int req1_done, req2_done;
  66. double mhz;
  67. double ns;
  68. unsigned slot;
  69. unsigned fasync;
  70. unsigned strange_counter;
  71. bool second_run;
  72. bool force_reinit;
  73. int desync_counter;
  74. int sample_hwe;
  75. int sample_tot;
  76. time_t short_out_t;
  77. time_t long_out_t;
  78. };
  79. extern void libbitfury_sendHashData1(int chip_id, struct bitfury_device *, struct thr_info *);
  80. void work_to_payload(struct bitfury_payload *p, struct work *w);
  81. extern void payload_to_atrvec(uint32_t *atrvec, struct bitfury_payload *);
  82. extern void send_reinit(struct spi_port *, int slot, int chip_n, int n);
  83. extern void send_shutdown(struct spi_port *, int slot, int chip_n);
  84. extern void send_freq(struct spi_port *, int slot, int chip_n, int bits);
  85. extern int libbitfury_detectChips1(struct spi_port *);
  86. extern unsigned bitfury_decnonce(unsigned);
  87. extern bool bitfury_fudge_nonce(const void *midstate, const uint32_t m7, const uint32_t ntime, const uint32_t nbits, uint32_t *nonce_p);
  88. #endif /* __LIBBITFURY_H__ */