libbitfury.h 2.2 KB

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