Revert "Style police" This reverts commit 1c56d49500631ed91a8432beaf12ad8dbdb3da17. Accidental breakage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599
diff --git a/driver-icarus.c b/driver-icarus.c
index d51a96d..635531c 100644
--- a/driver-icarus.c
+++ b/driver-icarus.c
@@ -316,11 +316,12 @@ typedef enum {
NONCE_GET_TASK_CMD,
} NONCE_COMMAND;
-typedef struct NONCE_DATA {
- int chip_no ;
- unsigned int task_no ;
- unsigned char work_state;
- int cmd_value;
+typedef struct NONCE_DATA
+{
+int chip_no ;
+unsigned int task_no ;
+unsigned char work_state;
+int cmd_value;
}NONCE_DATA;
@@ -331,21 +332,23 @@ typedef enum {
ROCKMINER_MAX
} ROCKMINER_PRODUCT_T;
-typedef struct ROCKMINER_CHIP_INFO {
- unsigned char freq;
- int error_cnt;
- time_t last_received_task_complete_time;
+typedef struct ROCKMINER_CHIP_INFO
+{
+unsigned char freq;
+int error_cnt;
+time_t last_received_task_complete_time;
}ROCKMINER_CHIP_INFO;
-typedef struct ROCKMINER_DEVICE_INFO {
- unsigned char detect_chip_no;
- unsigned char chip_max;
- unsigned char product_id;
- float min_frq;
- float def_frq;
- float max_frq;
- ROCKMINER_CHIP_INFO chip[MAX_CHIP_NUM];
- time_t dev_detect_time;
+typedef struct ROCKMINER_DEVICE_INFO
+{
+unsigned char detect_chip_no;
+unsigned char chip_max;
+unsigned char product_id;
+float min_frq;
+float def_frq;
+float max_frq;
+ROCKMINER_CHIP_INFO chip[MAX_CHIP_NUM];
+time_t dev_detect_time;
}ROCKMINER_DEVICE_INFO;
ROCKMINER_DEVICE_INFO rmdev[MAX_DEVICE_NUM];
@@ -1036,10 +1039,10 @@ static bool set_anu_freq(struct cgpu_info *icarus, struct ICARUS_INFO *info)
static void rock_init_last_received_task_complete_time(uint32_t dev_id)
{
int i;
-
- if (opt_rock_freq < rmdev[dev_id].min_frq || (opt_rock_freq > rmdev[dev_id].max_frq))
- opt_rock_freq =rmdev[dev_id].def_frq;
- for (i = 0; i < MAX_CHIP_NUM; ++i) {
+ if(opt_rock_freq<rmdev[dev_id].min_frq||(opt_rock_freq>rmdev[dev_id].max_frq))
+ opt_rock_freq =rmdev[dev_id].def_frq;
+ for (i = 0; i < MAX_CHIP_NUM; ++i)
+ {
rmdev[dev_id].chip[i].last_received_task_complete_time = time(NULL);
rmdev[dev_id].chip[i].freq = opt_rock_freq/10 - 1;
rmdev[dev_id].chip[i].error_cnt= 0;
@@ -1047,48 +1050,48 @@ static void rock_init_last_received_task_complete_time(uint32_t dev_id)
rmdev[dev_id].dev_detect_time = time(NULL);
}
-static struct work *g_work[MAX_DEVICE_NUM][MAX_CHIP_NUM][MAX_WORK_BUFFER_SIZE];
+struct work *g_work[MAX_DEVICE_NUM][MAX_CHIP_NUM][MAX_WORK_BUFFER_SIZE];
-static void clear_chip_busy(int device_id)
+void clear_chip_busy(int device_id)
{
- memset(&(g_work[device_id][0]), 0, (sizeof(g_work) / MAX_DEVICE_NUM));
+ memset(&(g_work[device_id][0]), 0, (sizeof(g_work)/MAX_DEVICE_NUM));
}
-static void rock_print_work_data(struct ICARUS_WORK *p_workdata)
+void rock_print_work_data(struct ICARUS_WORK *p_workdata)
{
char *ob_hex = NULL;
-
opt_debug = ROCKMINER_PRINT_DEBUG;
if (opt_debug) {
ob_hex = bin2hex((void *)(p_workdata), sizeof(*p_workdata));
applog(LOG_WARNING, "sent %s", ob_hex);
free(ob_hex);
- rev((void *)(&(p_workdata->midstate)), ICARUS_MIDSTATE_SIZE);
- rev((void *)(&(p_workdata->work)), ICARUS_WORK_SIZE);
- ob_hex = bin2hex((void *)(p_workdata), sizeof(*p_workdata));
- applog(LOG_WARNING, "revert sent %s", ob_hex);
- free(ob_hex);
+
+ rev((void *)(&(p_workdata->midstate)), ICARUS_MIDSTATE_SIZE);
+ rev((void *)(&(p_workdata->work)), ICARUS_WORK_SIZE);
+ ob_hex = bin2hex((void *)(p_workdata), sizeof(*p_workdata));
+ applog(LOG_WARNING, "revert sent %s", ob_hex);
+ free(ob_hex);
}
}
bool icarus_get_device_id(struct cgpu_info *cgpu);
-// Block 171874 nonce = (0xa2870100) = 0x000187a2
-// N.B. golden_ob MUST take less time to calculate
-// than the timeout set in icarus_open()
-// This one takes ~0.53ms on Rev3 Icarus
-static const char golden_ob[] =
- "4679ba4ec99876bf4bfe086082b40025"
- "4df6c356451471139a3afa71e48f544a"
- "00000000000000000000000000000000"
- "aa1ff05587320b1a1426674f2fa722ce";
-
static struct cgpu_info *icarus_detect_one(struct libusb_device *dev, struct usb_find_devices *found)
{
int this_option_offset = ++option_offset;
struct ICARUS_INFO *info;
struct timeval tv_start, tv_finish;
+ // Block 171874 nonce = (0xa2870100) = 0x000187a2
+ // N.B. golden_ob MUST take less time to calculate
+ // than the timeout set in icarus_open()
+ // This one takes ~0.53ms on Rev3 Icarus
+ const char golden_ob[] =
+ "4679ba4ec99876bf4bfe086082b40025"
+ "4df6c356451471139a3afa71e48f544a"
+ "00000000000000000000000000000000"
+ "0000000087320b1a1426674f2fa722ce";
+
const char golden_nonce[] = "000187a2";
const uint32_t golden_nonce_val = 0x000187a2;
unsigned char nonce_bin[ICARUS_READ_SIZE];
@@ -1368,6 +1371,16 @@ static struct cgpu_info *rock_detect_one(struct libusb_device *dev, struct usb_f
int opt_debug = ROCKMINER_PRINT_DEBUG;
char *ob_hex = NULL;
+ // Block 171874 nonce = (0xa2870100) = 0x000187a2
+ // N.B. golden_ob MUST take less time to calculate
+ // than the timeout set in icarus_open()
+ // This one takes ~0.53ms on Rev3 Icarus
+ const char golden_ob[] =
+ "4679ba4ec99876bf4bfe086082b40025"
+ "4df6c356451471139a3afa71e48f544a"
+ "00000000000000000000000000000000"
+ "aa1ff05587320b1a1426674f2fa722ce";
+
const char golden_nonce[] = "000187a2";
const uint32_t golden_nonce_val = 0x000187a2;
unsigned char nonce_bin[ROCK_READ_SIZE];
@@ -1434,55 +1447,62 @@ static struct cgpu_info *rock_detect_one(struct libusb_device *dev, struct usb_f
workdata.unused[ICARUS_UNUSED_SIZE - 3] = opt_rock_freq/10 - 1;
workdata.unused[ICARUS_UNUSED_SIZE - 2] = (MAX_TRIES-1-tries);
rmdev[dev_id].detect_chip_no ++;
- if(rmdev[dev_id].detect_chip_no >=MAX_TRIES )
- rmdev[dev_id].detect_chip_no = 0;
+ if(rmdev[dev_id].detect_chip_no >=MAX_TRIES )
+ rmdev[dev_id].detect_chip_no = 0;
//g_detect_chip_no[dev_id] = (g_detect_chip_no[dev_id] + 1) & MAX_CHIP_NUM;
err = usb_write_ii(icarus, info->intinfo,
(char *)(&workdata), sizeof(workdata), &amount, C_SENDWORK);
rock_print_work_data(&workdata);
if (err != LIBUSB_SUCCESS || amount != sizeof(workdata))
- continue;
+ continue;
memset(nonce_bin, 0, sizeof(nonce_bin));
ret = icarus_get_nonce(icarus, nonce_bin, &tv_start, &tv_finish, NULL, 100);
#if ROCKMINER_PRINT_DEBUG
applog(LOG_WARNING, "Rockminer nonce_bin: %02X, %02X, %02X, %02X, %02X, %02X, %02X, %02X", nonce_bin[0], nonce_bin[1], nonce_bin[2], nonce_bin[3], nonce_bin[4], nonce_bin[5], nonce_bin[6], nonce_bin[7]);
#endif
- if (ret != ICA_NONCE_OK) {
+ if (ret != ICA_NONCE_OK)
+ {
#if ROCKMINER_PRINT_DEBUG
- applog(LOG_WARNING, "detect_one get_gold_nonce error, tries = %d.\r\n", tries);
+ applog(LOG_WARNING, "detect_one get_gold_nonce error, tries = %d.\r\n", tries);
#endif
continue;
}
//device max chip
- if((nonce_bin[NONCE_CHIP_NO_OFFSET]&RM_PRODUCT_MASK) == RM_PRODUCT_T1) {
+ if((nonce_bin[NONCE_CHIP_NO_OFFSET]&RM_PRODUCT_MASK)==RM_PRODUCT_T1)
+ {
rmdev[dev_id].product_id = ROCKMINER_T1;
rmdev[dev_id].chip_max = 24;
rmdev[dev_id].min_frq = 200;
rmdev[dev_id].def_frq = 280;
rmdev[dev_id].max_frq = 320;
- } else {
+ }
+ else
+ {
rmdev[dev_id].product_id= ROCKMINER_RBOX;
rmdev[dev_id].chip_max = 4;
rmdev[dev_id].min_frq = 200;
rmdev[dev_id].def_frq = 270;
rmdev[dev_id].max_frq = 290;
}
- nonce_data.chip_no = nonce_bin[NONCE_CHIP_NO_OFFSET] & RM_CHIP_MASK;
+ nonce_data.chip_no = nonce_bin[NONCE_CHIP_NO_OFFSET]&RM_CHIP_MASK;
if (nonce_data.chip_no >= rmdev[dev_id].chip_max)
+ {
nonce_data.chip_no = 0;
+ }
- nonce_data.cmd_value = nonce_bin[NONCE_TASK_CMD_OFFSET] & RM_CMD_MASK;
- if (nonce_data.cmd_value == NONCE_TASK_COMPLETE_CMD) {
+ nonce_data.cmd_value = nonce_bin[NONCE_TASK_CMD_OFFSET]&RM_CMD_MASK;
+ if (nonce_data.cmd_value == NONCE_TASK_COMPLETE_CMD)
+ {
#if ROCKMINER_PRINT_DEBUG
applog(LOG_WARNING, "complete g_detect_chip_no: %d", rmdev[dev_id].detect_chip_no);
#endif
- workdata.unused[ICARUS_UNUSED_SIZE - 3] = opt_rock_freq / 10 - 1;
- workdata.unused[ICARUS_UNUSED_SIZE - 2] = rmdev[dev_id].detect_chip_no;
+ workdata.unused[ICARUS_UNUSED_SIZE - 3] = opt_rock_freq/10 - 1;
+ workdata.unused[ICARUS_UNUSED_SIZE - 2] = rmdev[dev_id].detect_chip_no;
rmdev[dev_id].detect_chip_no ++;
- if(rmdev[dev_id].detect_chip_no >= MAX_TRIES)
+ if(rmdev[dev_id].detect_chip_no>=MAX_TRIES)
rmdev[dev_id].detect_chip_no = 0;
err = usb_write_ii(icarus, info->intinfo,
@@ -1502,7 +1522,8 @@ static struct cgpu_info *rock_detect_one(struct libusb_device *dev, struct usb_f
applog(LOG_WARNING, "Rockminer nonce: %08X", nonce);
#endif
correction_times = 0;
- while(correction_times < NONCE_CORRECTION_TIMES) {
+ while(correction_times<NONCE_CORRECTION_TIMES)
+ {
nonce_hex = bin2hex(nonce_bin, 4);
if (golden_nonce_val == nonce + correction_value[correction_times]) {
clear_chip_busy(dev_id);
@@ -1521,21 +1542,25 @@ static struct cgpu_info *rock_detect_one(struct libusb_device *dev, struct usb_f
icarus->device_path, nonce_hex, golden_nonce);
}
- if (nonce == 0)
+ if(nonce == 0)
+ {
break;
+ }
}
free(nonce_hex);
correction_times++;
}
#if ROCKMINER_PRINT_DEBUG
- if(correction_times > 0 ) {
+ if(correction_times > 0 )
+ {
if (correction_times < NONCE_CORRECTION_TIMES)
- applog(LOG_WARNING, "Rockminer correction the Golden nonce success %s%d[%d]=%d",icarus->drv->name, icarus->device_id,chip_no,correction_times);
+ applog(LOG_WARNING, "Rockminer correction the Golden nonce success %s%d[%d]=%d",icarus->drv->name, icarus->device_id,chip_no,correction_times);
else
- applog(LOG_WARNING, "Rockminer correction the Golden nonce fail %s%d[%d]=%d",icarus->drv->name, icarus->device_id,chip_no,correction_times);
+ applog(LOG_WARNING, "Rockminer correction the Golden nonce fail %s%d[%d]=%d",icarus->drv->name, icarus->device_id,chip_no,correction_times);
}
#endif
+
}
if (!ok)
@@ -1638,12 +1663,17 @@ void rock_send_task(unsigned char chip_no, unsigned int current_task_id, struct
applog(LOG_WARNING, "thr_info id:%d, device_thread:%d, icarus cgminer_id: %d, device_id: %d.", thr->id, thr->device_thread, icarus->cgminer_id, icarus->device_id);
applog(LOG_WARNING, "::::::::::::::g_work[%d][%d][%d] = 0x%x", dev_id, chip_no, current_task_id, (int)g_work[dev_id][chip_no][current_task_id]);
#endif
- if (g_work[dev_id][chip_no][current_task_id] == NULL) {
+ if (g_work[dev_id][chip_no][current_task_id] == NULL)
+ {
work = get_work(thr, thr->id);
if (work == NULL)
+ {
return;
+ }
g_work[dev_id][chip_no][current_task_id] = work;
- } else {
+ }
+ else
+ {
work = g_work[dev_id][chip_no][current_task_id];
#if ROCKMINER_PRINT_DEBUG
applog(LOG_WARNING, "::resend work");
@@ -1659,8 +1689,10 @@ void rock_send_task(unsigned char chip_no, unsigned int current_task_id, struct
memcpy(&(workdata.midstate), work->midstate, ICARUS_MIDSTATE_SIZE);
memcpy(&(workdata.work), work->data + ICARUS_WORK_DATA_OFFSET, ICARUS_WORK_SIZE);
workdata.unused[ICARUS_UNUSED_SIZE - 4] = 0xaa;
- if ((rmdev[dev_id].chip[chip_no].freq > (rmdev[dev_id].max_frq / 10 - 1)) || (rmdev[dev_id].chip[chip_no].freq < (rmdev[dev_id].min_frq / 10 - 1)))
+ if((rmdev[dev_id].chip[chip_no].freq>(rmdev[dev_id].max_frq/10-1))||(rmdev[dev_id].chip[chip_no].freq<(rmdev[dev_id].min_frq/10-1)))
+ {
rock_init_last_received_task_complete_time(dev_id);
+ }
workdata.unused[ICARUS_UNUSED_SIZE - 3] = rmdev[dev_id].chip[chip_no].freq; //icarus->freq/10 - 1; ;
workdata.unused[ICARUS_UNUSED_SIZE - 2] = chip_no ;
workdata.unused[ICARUS_UNUSED_SIZE - 1] = 0x55;
@@ -1673,9 +1705,18 @@ void rock_send_task(unsigned char chip_no, unsigned int current_task_id, struct
free(ob_hex);
}
+#ifndef ROCKMINER
+ rev((void *)(&(workdata.midstate)), ICARUS_MIDSTATE_SIZE);
+ rev((void *)(&(workdata.work)), ICARUS_WORK_SIZE);
+
+ if (info->speed_next_work || info->flash_next_work)
+ //cmr2_commands(icarus);
+#endif
+
// We only want results for the work we are about to send
usb_buffer_clear(icarus);
+
err = usb_write_ii(icarus, info->intinfo, (char *)(&workdata), sizeof(workdata), &amount, C_SENDWORK);
if (err < 0 || amount != sizeof(workdata)) {
@@ -1684,7 +1725,8 @@ void rock_send_task(unsigned char chip_no, unsigned int current_task_id, struct
dev_error(icarus, REASON_DEV_COMMS_ERROR);
icarus_initialise(icarus, info->baud);
- if(g_work[dev_id][chip_no][current_task_id]) {
+ if(g_work[dev_id][chip_no][current_task_id])
+ {
free_work(g_work[dev_id][chip_no][current_task_id]);
g_work[dev_id][chip_no][current_task_id] = NULL;
}
@@ -1699,12 +1741,12 @@ void rock_send_task(unsigned char chip_no, unsigned int current_task_id, struct
icarus->drv->name, icarus->device_id, ob_hex);
free(ob_hex);
- rev((void *)(&(workdata.midstate)), ICARUS_MIDSTATE_SIZE);
- rev((void *)(&(workdata.work)), ICARUS_WORK_SIZE);
- ob_hex = bin2hex((void *)(&workdata), sizeof(workdata));
- applog(LOG_WARNING, "%s%d: revert sent %s",
- icarus->drv->name, icarus->device_id, ob_hex);
- free(ob_hex);
+ rev((void *)(&(workdata.midstate)), ICARUS_MIDSTATE_SIZE);
+ rev((void *)(&(workdata.work)), ICARUS_WORK_SIZE);
+ ob_hex = bin2hex((void *)(&workdata), sizeof(workdata));
+ applog(LOG_WARNING, "%s%d: revert sent %s",
+ icarus->drv->name, icarus->device_id, ob_hex);
+ free(ob_hex);
}
return;
@@ -2015,9 +2057,11 @@ static int64_t rock_scanwork(struct thr_info *thr)
elapsed.tv_sec = elapsed.tv_usec = 0;
- for (chip_no = 0; chip_no < rmdev[dev_id].chip_max; chip_no++) {
+ for (chip_no = 0; chip_no < rmdev[dev_id].chip_max; chip_no++)
+ {
recv_time = time(NULL);
- if (recv_time > rmdev[dev_id].chip[chip_no].last_received_task_complete_time + 1) {
+ if (recv_time > rmdev[dev_id].chip[chip_no].last_received_task_complete_time + 1)
+ {
#if NONCE_TEST
applog(LOG_WARNING, ":::chip_no error = %d nonce timeout", chip_no);
#endif
@@ -2027,30 +2071,34 @@ static int64_t rock_scanwork(struct thr_info *thr)
}
}
+ /* Icarus will return 4 bytes (ICARUS_READ_SIZE) nonces or nothing */
memset(nonce_bin, 0, sizeof(nonce_bin));
ret = icarus_get_nonce(icarus, nonce_bin, &tv_start, &tv_finish, thr, 3000);//info->read_time);
#if ROCKMINER_PRINT_DEBUG
applog(LOG_WARNING, "Rockminer nonce_bin: ret = %d. %02X, %02X, %02X, %02X, %02X, %02X, %02X, %02X", ret, nonce_bin[0], nonce_bin[1], nonce_bin[2], nonce_bin[3], nonce_bin[4], nonce_bin[5], nonce_bin[6], nonce_bin[7]);
#endif
- if((nonce_bin[NONCE_CHIP_NO_OFFSET]&RM_PRODUCT_MASK)==RM_PRODUCT_T1) {
- rmdev[dev_id].product_id = ROCKMINER_T1;
- rmdev[dev_id].chip_max = 24;
- rmdev[dev_id].min_frq = 200;
- rmdev[dev_id].def_frq = 280;
- rmdev[dev_id].max_frq = 320;
- } else {
- rmdev[dev_id].product_id= ROCKMINER_RBOX;
- rmdev[dev_id].chip_max = 4;
- rmdev[dev_id].min_frq = 200;
- rmdev[dev_id].def_frq = 270;
- rmdev[dev_id].max_frq = 290;
- }
- nonce_data.chip_no = nonce_bin[NONCE_CHIP_NO_OFFSET] & RM_CHIP_MASK;
- if(nonce_data.chip_no >= rmdev[dev_id].chip_max)
- nonce_data.chip_no = 0;
- nonce_data.task_no = nonce_bin[NONCE_TASK_NO_OFFSET] >= 2 ? 0: nonce_bin[NONCE_TASK_NO_OFFSET];
- nonce_data.cmd_value = nonce_bin[NONCE_TASK_CMD_OFFSET] & RM_CMD_MASK;
- nonce_data.work_state = nonce_bin[NONCE_TASK_CMD_OFFSET] & RM_STATUS_MASK;
+ if((nonce_bin[NONCE_CHIP_NO_OFFSET]&RM_PRODUCT_MASK)==RM_PRODUCT_T1)
+ {
+ rmdev[dev_id].product_id = ROCKMINER_T1;
+ rmdev[dev_id].chip_max = 24;
+ rmdev[dev_id].min_frq = 200;
+ rmdev[dev_id].def_frq = 280;
+ rmdev[dev_id].max_frq = 320;
+ }
+ else
+ {
+ rmdev[dev_id].product_id= ROCKMINER_RBOX;
+ rmdev[dev_id].chip_max = 4;
+ rmdev[dev_id].min_frq = 200;
+ rmdev[dev_id].def_frq = 270;
+ rmdev[dev_id].max_frq = 290;
+ }
+ nonce_data.chip_no = nonce_bin[NONCE_CHIP_NO_OFFSET]&RM_CHIP_MASK;
+ if(nonce_data.chip_no>=rmdev[dev_id].chip_max)
+ nonce_data.chip_no=0;
+ nonce_data.task_no = nonce_bin[NONCE_TASK_NO_OFFSET]>=2?0:nonce_bin[NONCE_TASK_NO_OFFSET];
+ nonce_data.cmd_value = nonce_bin[NONCE_TASK_CMD_OFFSET]&RM_CMD_MASK;
+ nonce_data.work_state = nonce_bin[NONCE_TASK_CMD_OFFSET]&RM_STATUS_MASK;
#if ROCKMINER_PRINT_DEBUG
if(nonce_data.work_state == 2)
applog(LOG_WARNING, "Temperature of Device is too hign to work!");
@@ -2060,25 +2108,30 @@ static int64_t rock_scanwork(struct thr_info *thr)
if (icarus->temp == 128)
icarus->temp = 0;
- if (nonce_data.cmd_value == NONCE_TASK_COMPLETE_CMD) {
+ if (nonce_data.cmd_value == NONCE_TASK_COMPLETE_CMD)
+ {
rmdev[dev_id].chip[nonce_data.chip_no].last_received_task_complete_time = time(NULL);
- if (g_work[dev_id][nonce_data.chip_no][nonce_data.task_no]) {
+ if (g_work[dev_id][nonce_data.chip_no][nonce_data.task_no])
+ {
free_work(g_work[dev_id][nonce_data.chip_no][nonce_data.task_no]);
g_work[dev_id][nonce_data.chip_no][nonce_data.task_no] = NULL;
}
#ifdef NONCE_TEST// ROCKMINER_PRINT_DEBUG
chip_work_conunts[nonce_data.chip_no] ++;
#endif
+
goto out;
}
- if (nonce_data.cmd_value == NONCE_GET_TASK_CMD) {
+ if (nonce_data.cmd_value == NONCE_GET_TASK_CMD)
+ {
rock_send_task(nonce_data.chip_no, nonce_data.task_no, thr);
goto out;
}
- if (ret == ICA_NONCE_TIMEOUT) {
+ if (ret == ICA_NONCE_TIMEOUT)
+ {
#if ROCKMINER_PRINT_DEBUG
applog(LOG_WARNING, "chip_no = %d nonce timeout, ret = %d", nonce_data.chip_no, ret);
#endif
@@ -2091,7 +2144,9 @@ static int64_t rock_scanwork(struct thr_info *thr)
work = g_work[dev_id][nonce_data.chip_no][nonce_data.task_no];
if (work == NULL)
+ {
goto out;
+ }
if (ret == ICA_NONCE_ERROR)
goto out;
@@ -2130,78 +2185,97 @@ static int64_t rock_scanwork(struct thr_info *thr)
#endif
recv_time = time(NULL);
- if ((recv_time-rmdev[dev_id].dev_detect_time ) >= 60) {//device_chip_max[device_id]
+ if((recv_time-rmdev[dev_id].dev_detect_time )>=60)//device_chip_max[device_id]
+ {
unsigned char i;
-
rmdev[dev_id].dev_detect_time = recv_time;
#ifdef NONCE_TEST// ROCKMINER_PRINT_DEBUG
applog(LOG_WARNING, "AMU%d Freq: %d0MHz/ %d0MHz/ %d0MHz/ %d0MHz ",dev_id,rmdev[dev_id].chip[0].freq+1,rmdev[dev_id].chip[1].freq+1,rmdev[dev_id].chip[2].freq+1,rmdev[dev_id].chip[3].freq+1);
#endif
- for (i = 0; i < rmdev[dev_id].chip_max; i ++) {
+ for (i = 0; i < rmdev[dev_id].chip_max; i ++)
+ {
#ifdef NONCE_TEST// ROCKMINER_PRINT_DEBUG
- applog(LOG_WARNING, "AMU%d Chip[%d] nonce=%d/%d/%d,freq:%d0MHz, ",dev_id,i,rmdev[dev_id].chip[i].error_cnt,chip_nonce_conunts[i],chip_work_conunts[i],rmdev[dev_id].chip[i].freq+1);
- chip_nonce_conunts[i] = 0;
- chip_work_conunts[i] = 0;
+ applog(LOG_WARNING, "AMU%d Chip[%d] nonce=%d/%d/%d,freq:%d0MHz, ",dev_id,i,rmdev[dev_id].chip[i].error_cnt,chip_nonce_conunts[i],chip_work_conunts[i],rmdev[dev_id].chip[i].freq+1);
+ chip_nonce_conunts[i] = 0;
+ chip_work_conunts[i] = 0;
#endif
- if (rmdev[dev_id].chip[i].error_cnt>=12) {
- if (rmdev[dev_id].chip[i].freq>rmdev[dev_id].min_frq) { //200Mhz
- rmdev[dev_id].chip[i].freq --;
+ if(rmdev[dev_id].chip[i].error_cnt>=12)
+ {
+ if(rmdev[dev_id].chip[i].freq>rmdev[dev_id].min_frq) //200Mhz
+ {
+ rmdev[dev_id].chip[i].freq --;
#ifdef NONCE_TEST
- applog(LOG_WARNING, "AMU%d Chip[%d]=%d SUB FREQ TO %d0MHz,DEF(%fMHz) ",dev_id,i,rmdev[dev_id].chip[i].error_cnt,rmdev[dev_id].chip[i].freq+1,opt_rock_freq);
+ applog(LOG_WARNING, "AMU%d Chip[%d]=%d SUB FREQ TO %d0MHz,DEF(%fMHz) ",dev_id,i,rmdev[dev_id].chip[i].error_cnt,rmdev[dev_id].chip[i].freq+1,opt_rock_freq);
#endif
}
- } else if(rmdev[dev_id].chip[i].error_cnt <= 1) {
- if(rmdev[dev_id].chip[i].freq<(rmdev[dev_id].def_frq/10-1)) {
- rmdev[dev_id].chip[i].freq ++;
+ }
+ else if(rmdev[dev_id].chip[i].error_cnt<=1)
+ {
+ if(rmdev[dev_id].chip[i].freq<(rmdev[dev_id].def_frq/10-1))
+ {
+ rmdev[dev_id].chip[i].freq ++;
#ifdef NONCE_TEST
- applog(LOG_WARNING, "AMU%d Chip[%d]=%d ADD FREQ TO %d0MHz,DEF(%fMHz) ",dev_id,i,rmdev[dev_id].chip[i].error_cnt,rmdev[dev_id].chip[i].freq+1,opt_rock_freq);
+ applog(LOG_WARNING, "AMU%d Chip[%d]=%d ADD FREQ TO %d0MHz,DEF(%fMHz) ",dev_id,i,rmdev[dev_id].chip[i].error_cnt,rmdev[dev_id].chip[i].freq+1,opt_rock_freq);
#endif
}
}
- rmdev[dev_id].chip[i].error_cnt = 0;
+ rmdev[dev_id].chip[i].error_cnt = 0;
}
#ifdef NONCE_TEST// ROCKMINER_PRINT_DEBUG
- device_nonce_corr_ok[dev_id] = 0;
- device_nonce_corr_fail[dev_id] = 0;
- device_nonce_corr_fail_2[dev_id] = 0;
- device_nonce_conunts[dev_id] = 0;
+ device_nonce_corr_ok[dev_id] = 0;
+ device_nonce_corr_fail[dev_id] = 0;
+ device_nonce_corr_fail_2[dev_id] = 0;
+ device_nonce_conunts[dev_id] = 0;
#endif
+
}
correction_times = 0;
- while (correction_times < NONCE_CORRECTION_TIMES) {
- if (submit_nonce(thr, work, nonce + correction_value[correction_times])) {
+ while(correction_times<NONCE_CORRECTION_TIMES)
+ {
+ if (submit_nonce(thr, work, nonce + correction_value[correction_times]))
+ {
hash_count++;
info->failing = false;
#if ROCKMINER_PRINT_DEBUG
applog(LOG_WARNING, "Rockminer nonce :::OK:::\r\n");
#endif
break;
- } else {
+ }
+ else
+ {
#if ROCKMINER_PRINT_DEBUG
applog(LOG_WARNING, "Rockminer nonce error times = %d\r\n", correction_times);
#endif
- if (nonce == 0)
+ if(nonce == 0)
+ {
break;
+ }
}
correction_times++;
}
- if (correction_times > 0 ) {
- /* FIXME: Where is this i supposed to come from? Comment out instead */
- //rmdev[dev_id].chip[i].error_cnt ++;
- if (correction_times < NONCE_CORRECTION_TIMES) {
+ if(correction_times > 0 )
+ {
+
+ /* FIXME: Where is this i supposed to come from? Comment out instead */
+ //rmdev[dev_id].chip[i].error_cnt ++;
+ if (correction_times < NONCE_CORRECTION_TIMES)
+ {
#ifdef NONCE_TEST// ROCKMINER_PRINT_DEBUG
device_nonce_corr_ok[dev_id] ++;
- //applog(LOG_WARNING, "Rockminer correction the nonce success %s%d[%d]=%d",icarus->drv->name, icarus->dev_id,chip_no,correction_times);
+ //applog(LOG_WARNING, "Rockminer correction the nonce success %s%d[%d]=%d",icarus->drv->name, icarus->dev_id,chip_no,correction_times);
#endif
- } else {
+ }
+ else
+ {
#ifdef NONCE_TEST// ROCKMINER_PRINT_DEBUG
- device_nonce_corr_fail[dev_id] ++;
+ device_nonce_corr_fail[dev_id] ++;
#endif
- //applog(LOG_WARNING, "Rockminer correction the nonce fail ---------%s%d[%d]=%d",icarus->drv->name, icarus->dev_id,chip_no,correction_times);
- }
+ //applog(LOG_WARNING, "Rockminer correction the nonce fail ---------%s%d[%d]=%d",icarus->drv->name, icarus->dev_id,chip_no,correction_times);
+ }
+
}
hash_count = (hash_count * info->nonce_mask);