libbitfury.h 2.0 KB

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