1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-02-05 03:24:26 +00:00

add license headers and some cleanup

This commit is contained in:
nelisky 2012-03-11 16:58:50 +00:00
parent bd3dc6d904
commit 0902f21a04
3 changed files with 72 additions and 40 deletions

View File

@ -1,3 +1,25 @@
/**
* libztex.c - Ztex 1.15x fpga board support library
*
* Copyright (c) 2012 nelisky.btc@gmail.com
*
* This work is based upon the Java SDK provided by ztex which is
* Copyright (C) 2009-2011 ZTEX GmbH.
* http://www.ztex.de
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see http://www.gnu.org/licenses/.
**/
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include "miner.h" #include "miner.h"
@ -340,8 +362,6 @@ int libztex_scanDevices (struct libztex_dev_list*** devs_p) {
devs[pos] = malloc(sizeof(struct libztex_dev_list)); devs[pos] = malloc(sizeof(struct libztex_dev_list));
devs[pos]->dev = ztex; devs[pos]->dev = ztex;
devs[pos]->next = NULL; devs[pos]->next = NULL;
//libusb_open(list[usbdevices[i]], &devs[i]->hndl);
//libusb_close(devs[cnt]->dev->hndl);
if (pos > 0) { if (pos > 0) {
devs[pos]->next = devs[pos]; devs[pos]->next = devs[pos];
} }

View File

@ -1,3 +1,24 @@
/**
* libztex.h - headers for Ztex 1.15x fpga board support library
*
* Copyright (c) 2012 nelisky.btc@gmail.com
*
* This work is based upon the Java SDK provided by ztex which is
* Copyright (C) 2009-2011 ZTEX GmbH.
* http://www.ztex.de
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see http://www.gnu.org/licenses/.
**/
#ifndef __LIBZTEX_H__ #ifndef __LIBZTEX_H__
#define __LIBZTEX_H__ #define __LIBZTEX_H__

67
ztex.c
View File

@ -1,34 +1,37 @@
//#include <limits.h> /**
//#include <pthread.h> * ztex.c - cgminer worker for Ztex 1.15x fpga board
//#include <stdio.h> *
//#include <sys/time.h> * Copyright (c) 2012 nelisky.btc@gmail.com
//#include <sys/types.h> *
//#include <dirent.h> * This work is based upon the Java SDK provided by ztex which is
//#include <unistd.h> * Copyright (C) 2009-2011 ZTEX GmbH.
//#ifndef WIN32 * http://www.ztex.de
// #include <termios.h> *
// #include <sys/stat.h> * This work is based upon the icarus.c worker which is
// #include <fcntl.h> * Copyright 2012 Luke Dashjr
// #ifndef O_CLOEXEC * Copyright 2012 Xiangfu <xiangfu@openmobilefree.com>
// #define O_CLOEXEC 0 *
// #endif * This program is free software; you can redistribute it and/or modify
//#else * it under the terms of the GNU General Public License version 2 as
// #include <windows.h> * published by the Free Software Foundation.
// #include <io.h> *
//#endif * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
//#include "elist.h" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see http://www.gnu.org/licenses/.
**/
#include <unistd.h> #include <unistd.h>
#include "miner.h" #include "miner.h"
#include "libztex.h" #include "libztex.h"
//#include <libusb.h>
#define GOLDEN_BACKLOG 5 #define GOLDEN_BACKLOG 5
struct device_api ztex_api; struct device_api ztex_api;
static void ztex_detect() static void ztex_detect()
{ {
int cnt; int cnt;
@ -46,7 +49,6 @@ static void ztex_detect()
ztex->api = &ztex_api; ztex->api = &ztex_api;
ztex->device_id = total_devices; ztex->device_id = total_devices;
ztex->device = ztex_devices[i]->dev; ztex->device = ztex_devices[i]->dev;
//ztex->device_path = strdup(devpath);
ztex->threads = 1; ztex->threads = 1;
devices[total_devices++] = ztex; devices[total_devices++] = ztex;
@ -91,17 +93,13 @@ static uint64_t ztex_scanhash(struct thr_info *thr, struct work *work,
memcpy(sendbuf+12, work->midstate, 32); memcpy(sendbuf+12, work->midstate, 32);
memset(backlog, 0, sizeof(backlog)); memset(backlog, 0, sizeof(backlog));
libztex_sendHashData(ztex, sendbuf); libztex_sendHashData(ztex, sendbuf);
//applog(LOG_WARNING, "sent hashdata"); applog(LOG_DEBUG, "sent hashdata");
//hdata = malloc(sizeof(struct libztex_hash_data*)*ztex->numNonces);
for (i=0; i<ztex->numNonces; i++) { for (i=0; i<ztex->numNonces; i++) {
//hdata[i] = malloc(sizeof(struct libztex_hash_data));
lastnonce[i] = 0; lastnonce[i] = 0;
} }
//sleep(1.00);
overflow = false; overflow = false;
while (!(overflow || work_restart[thr->id].restart)) { while (!(overflow || work_restart[thr->id].restart)) {
//sleep(0.5);
libztex_readHashData(ztex, &hdata[0]); libztex_readHashData(ztex, &hdata[0]);
for (i=0; i<ztex->numNonces; i++) { for (i=0; i<ztex->numNonces; i++) {
@ -132,22 +130,14 @@ static uint64_t ztex_scanhash(struct thr_info *thr, struct work *work,
#endif #endif
work->blk.nonce = 0xffffffff; work->blk.nonce = 0xffffffff;
rv = submit_nonce(thr, work, nonce); rv = submit_nonce(thr, work, nonce);
applog(LOG_WARNING, "submitted %0.8X %d", nonce, rv); applog(LOG_DEBUG, "submitted %0.8X %d", nonce, rv);
} }
} }
//
// //applog(LOG_WARNING, "%0.8X %0.8X %d", hdata[i]->nonce, hdata[i]->goldenNonce, work_restart[thr->id].restart);
} }
} }
//for (i=0; i<ztex->numNonces; i++) { applog(LOG_DEBUG, "exit %0.8X", noncecnt);
// free(hdata[i]);
// }
// free(hdata);
applog(LOG_WARNING, "exit %0.8X", noncecnt);
return noncecnt; return noncecnt;
} }
@ -166,3 +156,4 @@ struct device_api ztex_api = {
.scanhash = ztex_scanhash, .scanhash = ztex_scanhash,
.thread_shutdown = ztex_shutdown, .thread_shutdown = ztex_shutdown,
}; };