libbitfury.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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;
  16. double *s;
  17. int osc6_min;
  18. int osc6_max;
  19. double omh;
  20. double os;
  21. int best_osc;
  22. int best_done;
  23. };
  24. struct bitfury_device {
  25. struct spi_port *spi;
  26. unsigned char osc6_bits;
  27. unsigned newbuf[17];
  28. unsigned oldbuf[17];
  29. bool oldjob;
  30. int active;
  31. struct work * work;
  32. struct work * owork;
  33. struct work * o2work;
  34. int job_switched;
  35. uint32_t atrvec[20];
  36. struct bitfury_payload payload;
  37. struct bitfury_payload opayload;
  38. struct bitfury_payload o2payload;
  39. struct freq_stat chip_stat;
  40. unsigned int results[16];
  41. int results_n;
  42. time_t stat_ts[BITFURY_STAT_N];
  43. unsigned int stat_counter;
  44. unsigned int future_nonce;
  45. unsigned int old_nonce;
  46. struct timeval timer1;
  47. struct timeval timer2;
  48. struct timeval otimer1;
  49. struct timeval otimer2;
  50. struct timeval predict1;
  51. struct timeval predict2;
  52. struct timeval tv_stat;
  53. unsigned int counter1, counter2;
  54. unsigned int ocounter1, ocounter2;
  55. int rate; //per msec
  56. int osc_slow;
  57. int osc_fast;
  58. int req1_done, req2_done;
  59. double mhz;
  60. double ns;
  61. unsigned slot;
  62. unsigned fasync;
  63. unsigned strange_counter;
  64. bool second_run;
  65. bool force_reinit;
  66. int desync_counter;
  67. int sample_hwe;
  68. int sample_tot;
  69. time_t short_out_t;
  70. time_t long_out_t;
  71. };
  72. extern void libbitfury_sendHashData1(int chip_id, struct bitfury_device *, struct thr_info *);
  73. void work_to_payload(struct bitfury_payload *p, struct work *w);
  74. extern void payload_to_atrvec(uint32_t *atrvec, struct bitfury_payload *);
  75. extern void send_reinit(struct spi_port *, int slot, int chip_n, int n);
  76. extern void send_shutdown(struct spi_port *, int slot, int chip_n);
  77. extern void send_freq(struct spi_port *, int slot, int chip_n, int bits);
  78. extern int libbitfury_detectChips1(struct spi_port *);
  79. extern unsigned bitfury_decnonce(unsigned);
  80. extern bool bitfury_fudge_nonce(const void *midstate, const uint32_t m7, const uint32_t ntime, const uint32_t nbits, uint32_t *nonce_p);
  81. #endif /* __LIBBITFURY_H__ */