|
|
@@ -1,5 +1,5 @@
|
|
|
/*
|
|
|
- * Copyright 2012-2014 Luke Dashjr
|
|
|
+ * Copyright 2012-2015 Luke Dashjr
|
|
|
* Copyright 2012 Xiangfu
|
|
|
* Copyright 2014 Nate Woolls
|
|
|
* Copyright 2012 Andrew Smith
|
|
|
@@ -163,14 +163,14 @@ uint32_t icarus_nonce32toh(const struct ICARUS_INFO * const info, const uint32_t
|
|
|
#define icarus_open(devpath, baud) icarus_open2(devpath, baud, false)
|
|
|
|
|
|
static
|
|
|
-void icarus_log_protocol(int fd, const void *buf, size_t bufLen, const char *prefix)
|
|
|
+void icarus_log_protocol(const char * const repr, const void *buf, size_t bufLen, const char *prefix)
|
|
|
{
|
|
|
char hex[(bufLen * 2) + 1];
|
|
|
bin2hex(hex, buf, bufLen);
|
|
|
- applog(LOG_DEBUG, "%s fd=%d: DEVPROTO: %s %s", icarus_drv.dname, fd, prefix, hex);
|
|
|
+ applog(LOG_DEBUG, "%"PRIpreprv": DEVPROTO: %s %s", repr, prefix, hex);
|
|
|
}
|
|
|
|
|
|
-int icarus_gets(unsigned char *buf, int fd, struct timeval *tv_finish, struct thr_info *thr, int read_count, int read_size)
|
|
|
+int icarus_gets(const char * const repr, unsigned char *buf, int fd, struct timeval *tv_finish, struct thr_info *thr, int read_count, int read_size)
|
|
|
{
|
|
|
ssize_t ret = 0;
|
|
|
int rc = 0;
|
|
|
@@ -195,7 +195,7 @@ int icarus_gets(unsigned char *buf, int fd, struct timeval *tv_finish, struct th
|
|
|
{
|
|
|
ev.data.fd = thr->work_restart_notifier[0];
|
|
|
if (-1 == epoll_ctl(epollfd, EPOLL_CTL_ADD, thr->work_restart_notifier[0], &ev))
|
|
|
- applog(LOG_ERR, "%s: Error adding work restart fd to epoll", __func__);
|
|
|
+ applog(LOG_ERR, "%"PRIpreprv": Error adding work restart fd to epoll", repr);
|
|
|
else
|
|
|
{
|
|
|
epoll_timeout *= read_count;
|
|
|
@@ -204,7 +204,7 @@ int icarus_gets(unsigned char *buf, int fd, struct timeval *tv_finish, struct th
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
- applog(LOG_ERR, "%s: Error creating epoll", __func__);
|
|
|
+ applog(LOG_ERR, "%"PRIpreprv": Error creating epoll", repr);
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
@@ -237,7 +237,7 @@ int icarus_gets(unsigned char *buf, int fd, struct timeval *tv_finish, struct th
|
|
|
close(epollfd);
|
|
|
|
|
|
if (opt_dev_protocol && opt_debug)
|
|
|
- icarus_log_protocol(fd, buf, read_size, "RECV");
|
|
|
+ icarus_log_protocol(repr, buf, read_size, "RECV");
|
|
|
|
|
|
return ICA_GETS_OK;
|
|
|
}
|
|
|
@@ -252,7 +252,7 @@ int icarus_gets(unsigned char *buf, int fd, struct timeval *tv_finish, struct th
|
|
|
if (thr && thr->work_restart) {
|
|
|
if (epollfd != -1)
|
|
|
close(epollfd);
|
|
|
- applog(LOG_DEBUG, "%s: Interrupted by work restart", __func__);
|
|
|
+ applog(LOG_DEBUG, "%"PRIpreprv": Interrupted by work restart", repr);
|
|
|
return ICA_GETS_RESTART;
|
|
|
}
|
|
|
|
|
|
@@ -260,20 +260,20 @@ int icarus_gets(unsigned char *buf, int fd, struct timeval *tv_finish, struct th
|
|
|
if (rc >= read_count) {
|
|
|
if (epollfd != -1)
|
|
|
close(epollfd);
|
|
|
- applog(LOG_DEBUG, "%s: No data in %.2f seconds",
|
|
|
- __func__,
|
|
|
+ applog(LOG_DEBUG, "%"PRIpreprv": No data in %.2f seconds",
|
|
|
+ repr,
|
|
|
(float)rc * epoll_timeout / 1000.);
|
|
|
return ICA_GETS_TIMEOUT;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-int icarus_write(int fd, const void *buf, size_t bufLen)
|
|
|
+int icarus_write(const char * const repr, int fd, const void *buf, size_t bufLen)
|
|
|
{
|
|
|
size_t ret;
|
|
|
|
|
|
if (opt_dev_protocol && opt_debug)
|
|
|
- icarus_log_protocol(fd, buf, bufLen, "SEND");
|
|
|
+ icarus_log_protocol(repr, buf, bufLen, "SEND");
|
|
|
|
|
|
if (unlikely(fd == -1))
|
|
|
return 1;
|
|
|
@@ -437,7 +437,6 @@ int icarus_excess_nonce_size(int fd, struct ICARUS_INFO *info)
|
|
|
// Read excess_size from Icarus
|
|
|
struct timeval tv_now;
|
|
|
timer_set_now(&tv_now);
|
|
|
- //icarus_gets(excess_bin, fd, &tv_now, NULL, 1, excess_size);
|
|
|
int bytes_read = read(fd, excess_bin, excess_size);
|
|
|
// Number of bytes that were still available
|
|
|
|
|
|
@@ -463,9 +462,9 @@ int icarus_probe_work_division(const int fd, const char * const repr, struct ICA
|
|
|
"BFGMiner Probe\0\0"
|
|
|
"BFG\0\x64\x61\x01\x1a\xc9\x06\xa9\x51\xfb\x9b\x3c\x73";
|
|
|
|
|
|
- icarus_write(fd, pkt, sizeof(pkt));
|
|
|
+ icarus_write(repr, fd, pkt, sizeof(pkt));
|
|
|
memset(res_bin, 0, sizeof(res_bin));
|
|
|
- if (ICA_GETS_OK == icarus_gets(res_bin, fd, &tv_finish, NULL, info->read_count, info->read_size))
|
|
|
+ if (ICA_GETS_OK == icarus_gets(repr, res_bin, fd, &tv_finish, NULL, info->read_count, info->read_size))
|
|
|
{
|
|
|
memcpy(&res, res_bin, sizeof(res));
|
|
|
res = icarus_nonce32toh(info, res);
|
|
|
@@ -553,14 +552,14 @@ struct cgpu_info *icarus_detect_custom(const char *devpath, struct device_drv *a
|
|
|
if (!info->ignore_golden_nonce)
|
|
|
{
|
|
|
hex2bin(ob_bin, info->golden_ob, sizeof(ob_bin));
|
|
|
- icarus_write(fd, ob_bin, sizeof(ob_bin));
|
|
|
+ icarus_write(devpath, fd, ob_bin, sizeof(ob_bin));
|
|
|
cgtime(&tv_start);
|
|
|
|
|
|
memset(nonce_bin, 0, sizeof(nonce_bin));
|
|
|
// Do not use info->read_size here, instead read exactly ICARUS_NONCE_SIZE
|
|
|
// We will then compare the bytes left in fd with info->read_size to determine
|
|
|
// if this is a valid device
|
|
|
- icarus_gets(nonce_bin, fd, &tv_finish, NULL, info->probe_read_count, ICARUS_NONCE_SIZE);
|
|
|
+ icarus_gets(devpath, nonce_bin, fd, &tv_finish, NULL, info->probe_read_count, ICARUS_NONCE_SIZE);
|
|
|
|
|
|
// How many bytes were left after reading the above nonce
|
|
|
int bytes_left = icarus_excess_nonce_size(fd, info);
|
|
|
@@ -784,7 +783,7 @@ bool icarus_job_start(struct thr_info *thr)
|
|
|
|
|
|
cgtime(&state->tv_workstart);
|
|
|
|
|
|
- ret = icarus_write(fd, ob_bin, info->ob_size);
|
|
|
+ ret = icarus_write(icarus->proc_repr, fd, ob_bin, info->ob_size);
|
|
|
if (ret) {
|
|
|
do_icarus_close(thr);
|
|
|
applog(LOG_ERR, "%"PRIpreprv": Comms error (werr=%d)", icarus->proc_repr, ret);
|
|
|
@@ -848,7 +847,7 @@ void handle_identify(struct thr_info * const thr, int ret, const bool was_first_
|
|
|
|
|
|
// Try to get more nonces (ignoring work restart)
|
|
|
memset(nonce_bin, 0, sizeof(nonce_bin));
|
|
|
- ret = icarus_gets(nonce_bin, fd, &tv_now, NULL, (info->fullnonce - delapsed) * 10, info->read_size);
|
|
|
+ ret = icarus_gets(icarus->proc_repr, nonce_bin, fd, &tv_now, NULL, (info->fullnonce - delapsed) * 10, info->read_size);
|
|
|
if (ret == ICA_GETS_OK)
|
|
|
{
|
|
|
memcpy(&nonce, nonce_bin, sizeof(nonce));
|
|
|
@@ -950,7 +949,7 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
|
|
|
keepwaiting:
|
|
|
/* Icarus will return info->read_size bytes nonces or nothing */
|
|
|
memset(nonce_bin, 0, sizeof(nonce_bin));
|
|
|
- ret = icarus_gets(nonce_bin, fd, &state->tv_workfinish, thr, read_count, info->read_size);
|
|
|
+ ret = icarus_gets(icarus->proc_repr, nonce_bin, fd, &state->tv_workfinish, thr, read_count, info->read_size);
|
|
|
switch (ret) {
|
|
|
case ICA_GETS_RESTART:
|
|
|
// The prepared work is invalid, and the current work is abandoned
|