libbitfury.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /**
  2. * libbitfury.h - library for Bitfury chip/board
  3. *
  4. * Copyright (c) 2013 bitfury
  5. * Copyright (c) 2013 legkodymov
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8. * of this software and associated documentation files (the "Software"), to deal
  9. * in the Software without restriction, including without limitation the rights
  10. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. * copies of the Software, and to permit persons to whom the Software is
  12. * furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included in
  15. * all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  23. * THE SOFTWARE.
  24. *
  25. **/
  26. #ifndef __LIBBITFURY_H__
  27. #define __LIBBITFURY_H__
  28. #include "miner.h"
  29. #define BITFURY_STAT_N 1024
  30. struct bitfury_payload {
  31. unsigned char midstate[32];
  32. unsigned int junk[8];
  33. unsigned m7;
  34. unsigned ntime;
  35. unsigned nbits;
  36. unsigned nnonce;
  37. };
  38. struct bitfury_device {
  39. unsigned char osc6_bits;
  40. unsigned newbuf[17];
  41. unsigned oldbuf[17];
  42. struct work * work;
  43. struct work * owork;
  44. struct work * o2work;
  45. int job_switched;
  46. struct bitfury_payload payload;
  47. struct bitfury_payload opayload;
  48. struct bitfury_payload o2payload;
  49. unsigned int results[16];
  50. int results_n;
  51. time_t stat_ts[BITFURY_STAT_N];
  52. unsigned int stat_counter;
  53. unsigned int future_nonce;
  54. unsigned int old_nonce;
  55. struct timespec timer1;
  56. struct timespec timer2;
  57. struct timespec otimer1;
  58. struct timespec otimer2;
  59. struct timespec predict1;
  60. struct timespec predict2;
  61. unsigned int counter1, counter2;
  62. unsigned int ocounter1, ocounter2;
  63. int rate; //per msec
  64. int osc_slow;
  65. int osc_fast;
  66. int req1_done, req2_done;
  67. double mhz;
  68. double ns;
  69. unsigned slot;
  70. unsigned fasync;
  71. };
  72. int libbitfury_readHashData(unsigned int *res);
  73. int libbitfury_sendHashData(struct bitfury_device *bf, int chip_n);
  74. void work_to_payload(struct bitfury_payload *p, struct work *w);
  75. struct timespec t_diff(struct timespec start, struct timespec end);
  76. int libbitfury_detectChips(struct bitfury_device *devices);
  77. int libbitfury_shutdownChips(struct bitfury_device *devices, int chip_n);
  78. #endif /* __LIBBITFURY_H__ */