libbitfury.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef BFG_LIBBITFURY_H
  2. #define BFG_LIBBITFURY_H
  3. #include <stdbool.h>
  4. #include <stdint.h>
  5. #include "miner.h"
  6. #include "spidevc.h"
  7. struct work;
  8. #define BITFURY_STAT_N 1024
  9. struct bitfury_payload {
  10. unsigned char midstate[32];
  11. unsigned int junk[8];
  12. unsigned m7;
  13. unsigned ntime;
  14. unsigned nbits;
  15. unsigned 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. unsigned char osc6_bits;
  30. unsigned newbuf[17];
  31. unsigned oldbuf[17];
  32. bool oldjob;
  33. int active;
  34. uint32_t atrvec[20];
  35. struct bitfury_payload payload;
  36. struct freq_stat chip_stat;
  37. struct timeval timer1;
  38. struct timeval tv_stat;
  39. unsigned int counter1, counter2;
  40. double mhz;
  41. int mhz_last;
  42. int mhz_best;
  43. unsigned slot;
  44. unsigned fasync;
  45. unsigned strange_counter;
  46. bool force_reinit;
  47. int desync_counter;
  48. int sample_hwe;
  49. int sample_tot;
  50. };
  51. extern void work_to_bitfury_payload(struct bitfury_payload *, struct work *);
  52. extern void bitfury_payload_to_atrvec(uint32_t *atrvec, struct bitfury_payload *);
  53. extern void bitfury_send_reinit(struct spi_port *, int slot, int chip_n, int n);
  54. extern void bitfury_send_shutdown(struct spi_port *, int slot, int chip_n);
  55. extern void bitfury_send_freq(struct spi_port *, int slot, int chip_n, int bits);
  56. extern int libbitfury_detectChips1(struct spi_port *);
  57. extern unsigned bitfury_decnonce(unsigned);
  58. extern bool bitfury_fudge_nonce(const void *midstate, const uint32_t m7, const uint32_t ntime, const uint32_t nbits, uint32_t *nonce_p);
  59. #endif /* __LIBBITFURY_H__ */