Browse Source

Merge branch 'master' of github.com:ckolivas/cgminer

nfactor-troky
Con Kolivas 13 years ago
parent
commit
0a7d6222bf
  1. 34
      bitforce.c
  2. 15
      icarus.c

34
bitforce.c

@ -47,8 +47,7 @@ static int BFopen(const char *devpath)
return _open_osfhandle((LONG)hSerial, 0); return _open_osfhandle((LONG)hSerial, 0);
#else #else
int fdDev = open(devpath, O_RDWR | O_CLOEXEC | O_NOCTTY); int fdDev = open(devpath, O_RDWR | O_CLOEXEC | O_NOCTTY);
if (likely(fdDev != -1)) if (likely(fdDev != -1)) {
{
struct termios pattr; struct termios pattr;
tcgetattr(fdDev, &pattr); tcgetattr(fdDev, &pattr);
@ -93,21 +92,18 @@ static bool bitforce_detect_one(const char *devpath)
return false; return false;
int fdDev = BFopen(devpath); int fdDev = BFopen(devpath);
if (unlikely(fdDev == -1)) if (unlikely(fdDev == -1)) {
{
applog(LOG_DEBUG, "BitForce Detect: Failed to open %s", devpath); applog(LOG_DEBUG, "BitForce Detect: Failed to open %s", devpath);
return false; return false;
} }
BFwrite(fdDev, "ZGX", 3); BFwrite(fdDev, "ZGX", 3);
BFgets(pdevbuf, sizeof(pdevbuf), fdDev); BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
if (unlikely(!pdevbuf[0])) if (unlikely(!pdevbuf[0])) {
{
applog(LOG_ERR, "Error reading from BitForce (ZGX)"); applog(LOG_ERR, "Error reading from BitForce (ZGX)");
return 0; return 0;
} }
BFclose(fdDev); BFclose(fdDev);
if (unlikely(!strstr(pdevbuf, "SHA256"))) if (unlikely(!strstr(pdevbuf, "SHA256"))) {
{
applog(LOG_DEBUG, "BitForce Detect: Didn't recognise BitForce on %s", devpath); applog(LOG_DEBUG, "BitForce Detect: Didn't recognise BitForce on %s", devpath);
return false; return false;
} }
@ -158,9 +154,7 @@ static void bitforce_detect()
list_for_each_entry_safe(iter, tmp, &scan_devices, list) { list_for_each_entry_safe(iter, tmp, &scan_devices, list) {
if (!strcmp(iter->string, "auto")) if (!strcmp(iter->string, "auto"))
autoscan = true; autoscan = true;
else else if (bitforce_detect_one(iter->string)) {
if (bitforce_detect_one(iter->string))
{
string_elist_del(iter); string_elist_del(iter);
found = true; found = true;
} }
@ -187,8 +181,7 @@ static bool bitforce_thread_prepare(struct thr_info *thr)
struct timeval now; struct timeval now;
int fdDev = BFopen(bitforce->device_path); int fdDev = BFopen(bitforce->device_path);
if (unlikely(-1 == fdDev)) if (unlikely(-1 == fdDev)) {
{
applog(LOG_ERR, "Failed to open BitForce on %s", bitforce->device_path); applog(LOG_ERR, "Failed to open BitForce on %s", bitforce->device_path);
return false; return false;
} }
@ -219,8 +212,7 @@ static uint64_t bitforce_scanhash(struct thr_info *thr, struct work *work, uint6
applog(LOG_ERR, "Error reading from BitForce (ZDX)"); applog(LOG_ERR, "Error reading from BitForce (ZDX)");
return 0; return 0;
} }
if (unlikely(pdevbuf[0] != 'O' || pdevbuf[1] != 'K')) if (unlikely(pdevbuf[0] != 'O' || pdevbuf[1] != 'K')) {
{
applog(LOG_ERR, "BitForce ZDX reports: %s", pdevbuf); applog(LOG_ERR, "BitForce ZDX reports: %s", pdevbuf);
return 0; return 0;
} }
@ -231,13 +223,11 @@ static uint64_t bitforce_scanhash(struct thr_info *thr, struct work *work, uint6
applog(LOG_DEBUG, "BitForce block data: %s", bin2hex(ob + 8, 44)); applog(LOG_DEBUG, "BitForce block data: %s", bin2hex(ob + 8, 44));
BFgets(pdevbuf, sizeof(pdevbuf), fdDev); BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
if (unlikely(!pdevbuf[0])) if (unlikely(!pdevbuf[0])) {
{
applog(LOG_ERR, "Error reading from BitForce (block data)"); applog(LOG_ERR, "Error reading from BitForce (block data)");
return 0; return 0;
} }
if (unlikely(pdevbuf[0] != 'O' || pdevbuf[1] != 'K')) if (unlikely(pdevbuf[0] != 'O' || pdevbuf[1] != 'K')) {
{
applog(LOG_ERR, "BitForce block data reports: %s", pdevbuf); applog(LOG_ERR, "BitForce block data reports: %s", pdevbuf);
return 0; return 0;
} }
@ -264,8 +254,7 @@ static uint64_t bitforce_scanhash(struct thr_info *thr, struct work *work, uint6
while (1) { while (1) {
BFwrite(fdDev, "ZFX", 3); BFwrite(fdDev, "ZFX", 3);
BFgets(pdevbuf, sizeof(pdevbuf), fdDev); BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
if (unlikely(!pdevbuf[0])) if (unlikely(!pdevbuf[0])) {
{
applog(LOG_ERR, "Error reading from BitForce (ZFX)"); applog(LOG_ERR, "Error reading from BitForce (ZFX)");
return 0; return 0;
} }
@ -278,8 +267,7 @@ static uint64_t bitforce_scanhash(struct thr_info *thr, struct work *work, uint6
work->blk.nonce = 0xffffffff; work->blk.nonce = 0xffffffff;
if (pdevbuf[2] == '-') if (pdevbuf[2] == '-')
return 0xffffffff; return 0xffffffff;
else else if (strncasecmp(pdevbuf, "NONCE-FOUND", 11)) {
if (strncasecmp(pdevbuf, "NONCE-FOUND", 11)) {
applog(LOG_ERR, "BitForce result reports: %s", pdevbuf); applog(LOG_ERR, "BitForce result reports: %s", pdevbuf);
return 0; return 0;
} }

15
icarus.c

@ -108,7 +108,7 @@ static int icarus_open(const char *devpath)
#endif #endif
} }
static void icarus_gets(char *buf, size_t bufLen, int fd) static void icarus_gets(unsigned char *buf, size_t bufLen, int fd)
{ {
ssize_t ret = 0; ssize_t ret = 0;
@ -134,7 +134,7 @@ static void icarus_gets(char *buf, size_t bufLen, int fd)
static void icarus_write(int fd, const void *buf, size_t bufLen) static void icarus_write(int fd, const void *buf, size_t bufLen)
{ {
ssize_t ret; size_t ret;
ret = write(fd, buf, bufLen); ret = write(fd, buf, bufLen);
if (unlikely(ret != bufLen)) if (unlikely(ret != bufLen))
@ -147,14 +147,14 @@ static bool icarus_detect_one(const char *devpath)
{ {
int fd; int fd;
const unsigned char golden_ob[] = const char golden_ob[] =
"2db907f9cb4eb938ded904f4832c4331" "2db907f9cb4eb938ded904f4832c4331"
"0380e3aeb54364057e7fec5157bfc533" "0380e3aeb54364057e7fec5157bfc533"
"00000000000000000000000080000000" "00000000000000000000000080000000"
"00000000a58e091ac342724e7c3dc346"; "00000000a58e091ac342724e7c3dc346";
const unsigned char golden_nonce[] = "063c5e01"; const char golden_nonce[] = "063c5e01";
char ob_bin[64], nonce_bin[4]; unsigned char ob_bin[64], nonce_bin[4];
char *nonce_hex; char *nonce_hex;
if (total_devices == MAX_DEVICES) if (total_devices == MAX_DEVICES)
@ -235,13 +235,13 @@ static bool icarus_prepare(struct thr_info *thr)
} }
static uint64_t icarus_scanhash(struct thr_info *thr, struct work *work, static uint64_t icarus_scanhash(struct thr_info *thr, struct work *work,
uint64_t max_nonce) __maybe_unused uint64_t max_nonce)
{ {
struct cgpu_info *icarus; struct cgpu_info *icarus;
int fd; int fd;
unsigned char ob_bin[64], nonce_bin[4]; unsigned char ob_bin[64], nonce_bin[4];
unsigned char *ob_hex, *nonce_hex; char *ob_hex, *nonce_hex;
uint32_t nonce; uint32_t nonce;
uint32_t hash_count; uint32_t hash_count;
time_t t; time_t t;
@ -307,7 +307,6 @@ static uint64_t icarus_scanhash(struct thr_info *thr, struct work *work,
static void icarus_shutdown(struct thr_info *thr) static void icarus_shutdown(struct thr_info *thr)
{ {
struct cgpu_info *icarus; struct cgpu_info *icarus;
int fd;
if (thr->cgpu) { if (thr->cgpu) {
icarus = thr->cgpu; icarus = thr->cgpu;

Loading…
Cancel
Save