libbitfury.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef BFG_LIBBITFURY_H
  2. #define BFG_LIBBITFURY_H
  3. #include <stdbool.h>
  4. #include <stdint.h>
  5. #include "lowl-spi.h"
  6. #include "miner.h"
  7. struct work;
  8. #define BITFURY_STAT_N 1024
  9. struct bitfury_payload {
  10. uint8_t midstate[32];
  11. uint32_t junk[8];
  12. uint32_t m7;
  13. uint32_t ntime;
  14. uint32_t nbits;
  15. uint32_t nnonce;
  16. };
  17. struct freq_stat {
  18. double *mh;
  19. double *s;
  20. int osc6_min;
  21. int osc6_max;
  22. double omh;
  23. double os;
  24. int best_osc;
  25. int best_done;
  26. };
  27. struct bitfury_device {
  28. struct spi_port *spi;
  29. uint8_t osc6_bits;
  30. uint32_t newbuf[17];
  31. uint32_t oldbuf[17];
  32. bool oldjob;
  33. int active;
  34. int chipgen;
  35. int chipgen_probe;
  36. uint32_t atrvec[20];
  37. struct bitfury_payload payload;
  38. struct freq_stat chip_stat;
  39. struct timeval timer1;
  40. struct timeval tv_stat;
  41. uint32_t counter1, counter2;
  42. double mhz;
  43. int mhz_last;
  44. int mhz_best;
  45. uint32_t slot;
  46. unsigned fasync;
  47. unsigned strange_counter;
  48. bool force_reinit;
  49. int desync_counter;
  50. int sample_hwe;
  51. int sample_tot;
  52. };
  53. extern void work_to_bitfury_payload(struct bitfury_payload *, struct work *);
  54. extern void bitfury_payload_to_atrvec(uint32_t *atrvec, struct bitfury_payload *);
  55. extern void bitfury_send_reinit(struct spi_port *, int slot, int chip_n, int n);
  56. extern void bitfury_send_shutdown(struct spi_port *, int slot, int chip_n);
  57. extern void bitfury_send_freq(struct spi_port *, int slot, int chip_n, int bits);
  58. extern int libbitfury_detectChips1(struct spi_port *);
  59. extern uint32_t bitfury_decnonce(uint32_t);
  60. extern bool bitfury_fudge_nonce(const void *midstate, const uint32_t m7, const uint32_t ntime, const uint32_t nbits, uint32_t *nonce_p);
  61. #endif /* __LIBBITFURY_H__ */