driver-blockerupter.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #ifndef _BLOCKERUPTER_H
  2. #define _BLOCKERUPTER_H
  3. /*
  4. WIN32 Build
  5. 1. Install mxe (check tutorial on http://mxe.cc)
  6. 2. After install mxe
  7. export PATH={PATH_TO_MXE}/usr/bin:$PATH
  8. autoreconf -fi
  9. ./configure --host=i686-pc-mingw32 --enable-blockerupter --without-curses CFLAGS=-DCURL_STATICLIB
  10. make
  11. 3. Before starting cgminer
  12. install WinUSB driver for detected CP2102x device with Zadig (Some users might need to reboot)
  13. */
  14. #include "miner.h"
  15. #include "util.h"
  16. #define BET_MAXBOARDS 32
  17. #define BET_MAXASICS 48
  18. #define BET_BAUD 460800
  19. #define BET_CLOCK_MAX 29
  20. #define BET_CLOCK_DEFAULT 23
  21. #define BET_DIFF_DEFAULT 64
  22. #define BET_ROLLING_DEFAULT 5
  23. extern int opt_bet_clk;
  24. #define BET_WORK_FIFO 128
  25. #define BET_NONCE_FIX 4
  26. #define SEND_OK 0
  27. #define SEND_FAIL 1
  28. #define READ_OK 0
  29. #define READ_FAIL 1
  30. // Global Commands
  31. // resets all mega88, recv nothing
  32. #define C_RES (0 << 5)
  33. // stop jobs on all boards, set nTime rolling to (BoardID+1)*30, recv nothing
  34. #define C_LPO (1 << 5)
  35. // set clock for all boards, clock = (BoardID+1)*5, recv nothing
  36. #define C_GCK (2 << 5)
  37. // set difficulty bits for all boards with last 2bits from BoardID, recv nothing
  38. #define C_DIF (3 << 5)
  39. // Board Specific Commands (CMD|BoardID)
  40. // Send midstate(32 bytes), remaining block header(12 bytes), extranonce2(4 bytes) and job index(1 byte) to board
  41. // Recv 0x58
  42. #define C_JOB (4 << 5)
  43. // Recv current status of board
  44. #define C_ASK (5 << 5)
  45. // Recv (max_asics) bytes of chip test result, (max asics) bytes of clocks, 1 byte of diff bits, 1 byte of max nTime rolling, 1 byte of firmware version. Total (max asics)*2+3 bytes
  46. #define C_TRS (6 << 5)
  47. // answers on C_ASK|BoardID
  48. // Idle, waiting for new job
  49. #define A_WAL 0x56
  50. // Mining but no nonce yet
  51. #define A_NO 0xa6
  52. // Found nonce, followed with midstate(32 bytes), remaining block header(12 bytes), extranonce2(4 bytes), nonce(4 bytes), job index(1 byte), chip index(1 byte). Total 54 bytes.
  53. #define A_YES 0x5A
  54. // answer on C_JOB|BoardID
  55. #define A_GET 0x58
  56. #pragma pack(1)
  57. typedef struct asic_info {
  58. int bad;
  59. int accepted;
  60. int nonces;
  61. int hashes;
  62. double hwe;
  63. } asic_info;
  64. #pragma pack(1)
  65. typedef struct board_info {
  66. int bad;
  67. int job_count;
  68. int nonces;
  69. int accepted;
  70. int hashes;
  71. double hashrate;
  72. double hwe;
  73. struct asic_info asics[BET_MAXASICS];
  74. } board_info;
  75. #pragma pack(1)
  76. typedef struct blockerupter_info {
  77. struct pool pool;
  78. uint8_t found;
  79. int clock;
  80. int nonces;
  81. int diff;
  82. int rolling;
  83. int accepted;
  84. int hashes;
  85. double hashrate;
  86. double expected;
  87. double eff;
  88. uint8_t work_idx;
  89. struct work works[BET_WORK_FIFO];
  90. uint8_t boards[BET_MAXBOARDS];
  91. board_info b_info[BET_MAXBOARDS];
  92. struct timeval start_time;
  93. struct timeval last_job;
  94. } blockerupter_info;
  95. #pragma pack(1)
  96. typedef struct blockerupter_response {
  97. uint8_t midstate[32];
  98. uint8_t merkle[4];
  99. uint8_t ntime[4];
  100. uint8_t diff[4];
  101. uint8_t exnonc2[4];
  102. uint8_t nonce[4];
  103. uint8_t work_idx;
  104. uint8_t chip;
  105. } blockerupter_response;
  106. #define BET_RESP_SZ (sizeof(blockerupter_response))
  107. #endif