libbitfury.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 timespec timer1;
  36. struct timespec timer2;
  37. struct timespec otimer1;
  38. struct timespec otimer2;
  39. struct timespec predict1;
  40. struct timespec 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. time_t short_out_t;
  54. time_t long_out_t;
  55. };
  56. int libbitfury_readHashData(unsigned int *res);
  57. extern void libbitfury_sendHashData1(int chip_id, struct bitfury_device *, struct thr_info *);
  58. void work_to_payload(struct bitfury_payload *p, struct work *w);
  59. extern void payload_to_atrvec(uint32_t *atrvec, struct bitfury_payload *);
  60. struct timespec t_diff(struct timespec start, struct timespec end);
  61. extern void send_reinit(struct spi_port *, int slot, int chip_n, int n);
  62. extern void send_shutdown(struct spi_port *, int slot, int chip_n);
  63. extern void send_freq(struct spi_port *, int slot, int chip_n, int bits);
  64. extern int libbitfury_detectChips1(struct spi_port *);
  65. extern unsigned bitfury_decnonce(unsigned);
  66. #endif /* __LIBBITFURY_H__ */