2010-11-25 09:03:59 +00:00
|
|
|
#ifndef __MINER_H__
|
|
|
|
#define __MINER_H__
|
|
|
|
|
2011-06-24 18:43:37 +00:00
|
|
|
#include "config.h"
|
2011-03-21 02:44:25 +00:00
|
|
|
|
2010-11-25 09:03:59 +00:00
|
|
|
#include <stdbool.h>
|
2010-11-27 06:29:56 +00:00
|
|
|
#include <stdint.h>
|
2010-11-27 06:59:03 +00:00
|
|
|
#include <sys/time.h>
|
2011-03-15 03:36:28 +00:00
|
|
|
#include <pthread.h>
|
2010-11-25 09:03:59 +00:00
|
|
|
#include <jansson.h>
|
2013-09-21 12:49:28 +00:00
|
|
|
#ifdef HAVE_LIBCURL
|
2011-02-10 05:41:44 +00:00
|
|
|
#include <curl/curl.h>
|
2013-09-21 12:49:28 +00:00
|
|
|
#else
|
|
|
|
typedef char CURL;
|
|
|
|
extern char *curly;
|
|
|
|
#define curl_easy_init(curl) (curly)
|
|
|
|
#define curl_easy_cleanup(curl) {}
|
|
|
|
#define curl_global_cleanup() {}
|
|
|
|
#define CURL_GLOBAL_ALL 0
|
|
|
|
#define curl_global_init(X) (0)
|
|
|
|
#endif
|
2013-06-13 03:28:48 +00:00
|
|
|
#include <sched.h>
|
|
|
|
|
2011-08-23 22:06:15 +00:00
|
|
|
#include "elist.h"
|
|
|
|
#include "uthash.h"
|
2012-02-11 18:31:34 +00:00
|
|
|
#include "logging.h"
|
2012-09-24 06:50:04 +00:00
|
|
|
#include "util.h"
|
2013-05-08 11:59:58 +00:00
|
|
|
#include <sys/types.h>
|
2013-05-09 01:39:09 +00:00
|
|
|
#ifndef WIN32
|
|
|
|
# include <sys/socket.h>
|
|
|
|
# include <netdb.h>
|
|
|
|
#endif
|
2011-07-05 09:47:03 +00:00
|
|
|
|
2013-05-30 01:01:29 +00:00
|
|
|
#ifdef USE_USBUTILS
|
|
|
|
#include <semaphore.h>
|
|
|
|
#endif
|
|
|
|
|
2011-07-05 09:47:03 +00:00
|
|
|
#ifdef HAVE_OPENCL
|
2011-06-27 01:31:05 +00:00
|
|
|
#ifdef __APPLE_CC__
|
|
|
|
#include <OpenCL/opencl.h>
|
|
|
|
#else
|
|
|
|
#include <CL/cl.h>
|
|
|
|
#endif
|
2011-07-05 09:47:03 +00:00
|
|
|
#endif /* HAVE_OPENCL */
|
2010-11-25 09:03:59 +00:00
|
|
|
|
2011-03-18 21:24:16 +00:00
|
|
|
#ifdef STDC_HEADERS
|
|
|
|
# include <stdlib.h>
|
|
|
|
# include <stddef.h>
|
|
|
|
#else
|
|
|
|
# ifdef HAVE_STDLIB_H
|
|
|
|
# include <stdlib.h>
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_ALLOCA_H
|
|
|
|
# include <alloca.h>
|
|
|
|
#elif defined __GNUC__
|
2011-07-22 13:43:26 +00:00
|
|
|
# ifndef WIN32
|
|
|
|
# define alloca __builtin_alloca
|
|
|
|
# else
|
|
|
|
# include <malloc.h>
|
|
|
|
# endif
|
2011-03-18 21:24:16 +00:00
|
|
|
#elif defined _AIX
|
|
|
|
# define alloca __alloca
|
|
|
|
#elif defined _MSC_VER
|
|
|
|
# include <malloc.h>
|
|
|
|
# define alloca _alloca
|
|
|
|
#else
|
|
|
|
# ifndef HAVE_ALLOCA
|
|
|
|
# ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
# endif
|
|
|
|
void *alloca (size_t);
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2012-10-04 05:35:28 +00:00
|
|
|
#ifdef __MINGW32__
|
|
|
|
#include <windows.h>
|
|
|
|
#include <io.h>
|
|
|
|
static inline int fsync (int fd)
|
|
|
|
{
|
|
|
|
return (FlushFileBuffers ((HANDLE) _get_osfhandle (fd))) ? 0 : -1;
|
|
|
|
}
|
|
|
|
|
2012-12-14 10:36:42 +00:00
|
|
|
#ifndef EWOULDBLOCK
|
|
|
|
# define EWOULDBLOCK EAGAIN
|
|
|
|
#endif
|
|
|
|
|
2012-10-04 05:35:28 +00:00
|
|
|
#ifndef MSG_DONTWAIT
|
|
|
|
# define MSG_DONTWAIT 0x1000000
|
|
|
|
#endif
|
|
|
|
#endif /* __MINGW32__ */
|
|
|
|
|
2011-09-03 00:53:35 +00:00
|
|
|
#if defined (__linux)
|
|
|
|
#ifndef LINUX
|
|
|
|
#define LINUX
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2012-05-06 10:49:06 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
#ifndef timersub
|
|
|
|
#define timersub(a, b, result) \
|
|
|
|
do { \
|
|
|
|
(result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
|
|
|
|
(result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
|
|
|
|
if ((result)->tv_usec < 0) { \
|
|
|
|
--(result)->tv_sec; \
|
|
|
|
(result)->tv_usec += 1000000; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
#endif
|
|
|
|
#ifndef timeradd
|
|
|
|
# define timeradd(a, b, result) \
|
|
|
|
do { \
|
|
|
|
(result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \
|
|
|
|
(result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \
|
|
|
|
if ((result)->tv_usec >= 1000000) \
|
|
|
|
{ \
|
|
|
|
++(result)->tv_sec; \
|
|
|
|
(result)->tv_usec -= 1000000; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2011-09-03 00:53:35 +00:00
|
|
|
#ifdef HAVE_ADL
|
|
|
|
#include "ADL_SDK/adl_sdk.h"
|
|
|
|
#endif
|
2011-03-18 21:24:16 +00:00
|
|
|
|
2013-08-29 01:10:13 +00:00
|
|
|
#ifdef USE_USBUTILS
|
2012-11-15 23:13:56 +00:00
|
|
|
#include <libusb.h>
|
2012-03-11 00:49:25 +00:00
|
|
|
#endif
|
|
|
|
|
2013-03-05 07:33:43 +00:00
|
|
|
#ifdef USE_USBUTILS
|
2012-12-02 10:48:37 +00:00
|
|
|
#include "usbutils.h"
|
|
|
|
#endif
|
|
|
|
|
2013-04-04 14:59:10 +00:00
|
|
|
#if (!defined(WIN32) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) \
|
|
|
|
|| (defined(WIN32) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)))
|
2013-04-05 03:52:07 +00:00
|
|
|
#ifndef bswap_16
|
|
|
|
#define bswap_16 __builtin_bswap16
|
|
|
|
#define bswap_32 __builtin_bswap32
|
|
|
|
#define bswap_64 __builtin_bswap64
|
|
|
|
#endif
|
2011-02-10 05:52:22 +00:00
|
|
|
#else
|
2011-05-10 18:41:11 +00:00
|
|
|
#if HAVE_BYTESWAP_H
|
2011-02-10 05:52:22 +00:00
|
|
|
#include <byteswap.h>
|
2011-05-10 18:41:11 +00:00
|
|
|
#elif defined(USE_SYS_ENDIAN_H)
|
|
|
|
#include <sys/endian.h>
|
|
|
|
#elif defined(__APPLE__)
|
|
|
|
#include <libkern/OSByteOrder.h>
|
|
|
|
#define bswap_16 OSSwapInt16
|
|
|
|
#define bswap_32 OSSwapInt32
|
|
|
|
#define bswap_64 OSSwapInt64
|
|
|
|
#else
|
|
|
|
#define bswap_16(value) \
|
|
|
|
((((value) & 0xff) << 8) | ((value) >> 8))
|
|
|
|
|
|
|
|
#define bswap_32(value) \
|
|
|
|
(((uint32_t)bswap_16((uint16_t)((value) & 0xffff)) << 16) | \
|
|
|
|
(uint32_t)bswap_16((uint16_t)((value) >> 16)))
|
2011-09-26 23:33:28 +00:00
|
|
|
|
2011-05-10 18:41:11 +00:00
|
|
|
#define bswap_64(value) \
|
|
|
|
(((uint64_t)bswap_32((uint32_t)((value) & 0xffffffff)) \
|
|
|
|
<< 32) | \
|
|
|
|
(uint64_t)bswap_32((uint32_t)((value) >> 32)))
|
2011-02-10 05:52:22 +00:00
|
|
|
#endif
|
2011-05-10 18:41:11 +00:00
|
|
|
#endif /* !defined(__GLXBYTEORDER_H__) */
|
2011-02-10 05:52:22 +00:00
|
|
|
|
2012-10-11 09:46:04 +00:00
|
|
|
/* This assumes htobe32 is a macro in endian.h, and if it doesn't exist, then
|
|
|
|
* htobe64 also won't exist */
|
2011-07-09 00:18:29 +00:00
|
|
|
#ifndef htobe32
|
|
|
|
# if __BYTE_ORDER == __LITTLE_ENDIAN
|
2012-11-06 01:01:07 +00:00
|
|
|
# define htole16(x) (x)
|
|
|
|
# define htole32(x) (x)
|
2013-04-19 01:13:36 +00:00
|
|
|
# define le32toh(x) (x)
|
2011-07-09 00:18:29 +00:00
|
|
|
# define be32toh(x) bswap_32(x)
|
2012-10-12 03:17:29 +00:00
|
|
|
# define be64toh(x) bswap_64(x)
|
2011-07-09 00:18:29 +00:00
|
|
|
# define htobe32(x) bswap_32(x)
|
2012-10-12 00:30:35 +00:00
|
|
|
# define htobe64(x) bswap_64(x)
|
2011-07-09 00:18:29 +00:00
|
|
|
# elif __BYTE_ORDER == __BIG_ENDIAN
|
2012-11-06 01:01:07 +00:00
|
|
|
# define htole16(x) bswap_16(x)
|
|
|
|
# define htole32(x) bswap_32(x)
|
2013-04-19 01:13:36 +00:00
|
|
|
# define le32toh(x) bswap_32(x)
|
2011-07-09 00:18:29 +00:00
|
|
|
# define be32toh(x) (x)
|
2012-10-12 03:17:29 +00:00
|
|
|
# define be64toh(x) (x)
|
2011-07-09 00:18:29 +00:00
|
|
|
# define htobe32(x) (x)
|
2012-10-11 09:46:04 +00:00
|
|
|
# define htobe64(x) (x)
|
2011-07-09 00:18:29 +00:00
|
|
|
#else
|
|
|
|
#error UNKNOWN BYTE ORDER
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2011-02-17 06:22:55 +00:00
|
|
|
#undef unlikely
|
2011-06-09 01:45:06 +00:00
|
|
|
#undef likely
|
|
|
|
#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
|
|
|
|
#define unlikely(expr) (__builtin_expect(!!(expr), 0))
|
|
|
|
#define likely(expr) (__builtin_expect(!!(expr), 1))
|
2011-02-17 06:22:55 +00:00
|
|
|
#else
|
|
|
|
#define unlikely(expr) (expr)
|
2011-06-09 01:45:06 +00:00
|
|
|
#define likely(expr) (expr)
|
2011-02-17 06:22:55 +00:00
|
|
|
#endif
|
2012-02-04 07:19:30 +00:00
|
|
|
#define __maybe_unused __attribute__((unused))
|
2011-02-17 06:22:55 +00:00
|
|
|
|
2012-05-04 23:37:33 +00:00
|
|
|
#define uninitialised_var(x) x = x
|
|
|
|
|
2010-12-07 01:14:58 +00:00
|
|
|
#if defined(__i386__)
|
|
|
|
#define WANT_CRYPTOPP_ASM32
|
|
|
|
#endif
|
|
|
|
|
2010-11-26 20:46:11 +00:00
|
|
|
#ifndef ARRAY_SIZE
|
|
|
|
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
|
|
|
|
#endif
|
|
|
|
|
2012-11-04 21:26:39 +00:00
|
|
|
#ifdef MIPSEB
|
|
|
|
#ifndef roundl
|
|
|
|
#define roundl(x) (long double)((long long)((x==0)?0.0:((x)+((x)>0)?0.5:-0.5)))
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2013-06-05 05:50:30 +00:00
|
|
|
/* No semtimedop on apple so ignore timeout till we implement one */
|
|
|
|
#ifdef __APPLE__
|
|
|
|
#define semtimedop(SEM, SOPS, VAL, TIMEOUT) semop(SEM, SOPS, VAL)
|
|
|
|
#endif
|
|
|
|
|
2013-03-16 23:15:24 +00:00
|
|
|
#define MIN(x, y) ((x) > (y) ? (y) : (x))
|
|
|
|
#define MAX(x, y) ((x) > (y) ? (x) : (y))
|
|
|
|
|
2013-09-28 05:14:28 +00:00
|
|
|
/* Put avalon last to make it the last device it tries to detect to prevent it
|
2013-09-29 02:28:43 +00:00
|
|
|
* trying to claim same chip but different devices. Adding a device here will
|
|
|
|
* update all macros in the code that use the *_PARSE_COMMANDS macros for each
|
|
|
|
* listed driver. */
|
2013-09-29 03:54:16 +00:00
|
|
|
#define FPGA_PARSE_COMMANDS(DRIVER_ADD_COMMAND) \
|
2013-09-28 00:25:48 +00:00
|
|
|
DRIVER_ADD_COMMAND(bitforce) \
|
|
|
|
DRIVER_ADD_COMMAND(icarus) \
|
2013-10-04 02:00:41 +00:00
|
|
|
DRIVER_ADD_COMMAND(modminer)
|
2013-09-29 02:28:43 +00:00
|
|
|
|
2013-09-29 03:54:16 +00:00
|
|
|
#define ASIC_PARSE_COMMANDS(DRIVER_ADD_COMMAND) \
|
2013-09-29 02:28:43 +00:00
|
|
|
DRIVER_ADD_COMMAND(bflsc) \
|
|
|
|
DRIVER_ADD_COMMAND(bitfury) \
|
2013-10-03 13:19:18 +00:00
|
|
|
DRIVER_ADD_COMMAND(avalon) \
|
|
|
|
DRIVER_ADD_COMMAND(klondike)
|
2013-09-28 00:25:48 +00:00
|
|
|
|
2013-09-29 03:54:16 +00:00
|
|
|
#define DRIVER_PARSE_COMMANDS(DRIVER_ADD_COMMAND) \
|
2013-09-29 02:28:43 +00:00
|
|
|
DRIVER_ADD_COMMAND(opencl) \
|
2013-09-29 03:54:16 +00:00
|
|
|
FPGA_PARSE_COMMANDS(DRIVER_ADD_COMMAND) \
|
|
|
|
ASIC_PARSE_COMMANDS(DRIVER_ADD_COMMAND)
|
|
|
|
|
|
|
|
#define DRIVER_ENUM(X) DRIVER_##X,
|
|
|
|
#define DRIVER_PROTOTYPE(X) struct device_drv X##_drv;
|
2013-09-29 02:28:43 +00:00
|
|
|
|
2013-09-28 00:25:48 +00:00
|
|
|
/* Create drv_driver enum from DRIVER_PARSE_COMMANDS macro */
|
2013-01-05 12:47:26 +00:00
|
|
|
enum drv_driver {
|
2013-09-29 03:54:16 +00:00
|
|
|
DRIVER_PARSE_COMMANDS(DRIVER_ENUM)
|
2013-03-10 23:58:28 +00:00
|
|
|
DRIVER_MAX
|
2013-01-05 12:47:26 +00:00
|
|
|
};
|
|
|
|
|
2013-09-28 01:45:58 +00:00
|
|
|
/* Use DRIVER_PARSE_COMMANDS to generate extern device_drv prototypes */
|
2013-09-29 03:54:16 +00:00
|
|
|
DRIVER_PARSE_COMMANDS(DRIVER_PROTOTYPE)
|
2013-09-28 01:45:58 +00:00
|
|
|
|
2011-07-29 15:23:17 +00:00
|
|
|
enum alive {
|
|
|
|
LIFE_WELL,
|
|
|
|
LIFE_SICK,
|
|
|
|
LIFE_DEAD,
|
2012-07-11 20:29:06 +00:00
|
|
|
LIFE_NOSTART,
|
|
|
|
LIFE_INIT,
|
2011-07-29 15:23:17 +00:00
|
|
|
};
|
|
|
|
|
2012-01-22 07:24:55 +00:00
|
|
|
|
|
|
|
enum pool_strategy {
|
|
|
|
POOL_FAILOVER,
|
|
|
|
POOL_ROUNDROBIN,
|
|
|
|
POOL_ROTATE,
|
|
|
|
POOL_LOADBALANCE,
|
2012-08-18 05:27:53 +00:00
|
|
|
POOL_BALANCE,
|
2012-01-22 07:24:55 +00:00
|
|
|
};
|
|
|
|
|
2012-08-18 05:27:53 +00:00
|
|
|
#define TOP_STRATEGY (POOL_BALANCE)
|
2012-01-22 07:24:55 +00:00
|
|
|
|
|
|
|
struct strategies {
|
|
|
|
const char *s;
|
|
|
|
};
|
|
|
|
|
2012-01-24 14:19:58 +00:00
|
|
|
struct cgpu_info;
|
2012-01-22 07:24:55 +00:00
|
|
|
|
2011-09-03 00:53:35 +00:00
|
|
|
#ifdef HAVE_ADL
|
|
|
|
struct gpu_adl {
|
|
|
|
ADLTemperature lpTemperature;
|
|
|
|
int iAdapterIndex;
|
|
|
|
int lpAdapterID;
|
2012-01-26 12:27:10 +00:00
|
|
|
int iBusNumber;
|
|
|
|
char strAdapterName[256];
|
2011-09-06 23:17:51 +00:00
|
|
|
|
2011-09-03 00:53:35 +00:00
|
|
|
ADLPMActivity lpActivity;
|
|
|
|
ADLODParameters lpOdParameters;
|
2011-09-03 12:30:11 +00:00
|
|
|
ADLODPerformanceLevels *DefPerfLev;
|
2011-09-03 00:53:35 +00:00
|
|
|
ADLFanSpeedInfo lpFanSpeedInfo;
|
|
|
|
ADLFanSpeedValue lpFanSpeedValue;
|
2011-09-03 12:30:11 +00:00
|
|
|
ADLFanSpeedValue DefFanSpeedValue;
|
2011-09-06 23:17:51 +00:00
|
|
|
|
2011-09-03 00:53:35 +00:00
|
|
|
int iEngineClock;
|
|
|
|
int iMemoryClock;
|
|
|
|
int iVddc;
|
2011-09-04 12:56:19 +00:00
|
|
|
int iPercentage;
|
2011-09-03 05:33:53 +00:00
|
|
|
|
|
|
|
bool autofan;
|
|
|
|
bool autoengine;
|
2011-09-07 00:00:10 +00:00
|
|
|
bool managed; /* Were the values ever changed on this card */
|
2011-09-06 23:17:51 +00:00
|
|
|
|
2012-02-18 11:29:12 +00:00
|
|
|
int lastengine;
|
2011-09-23 00:45:43 +00:00
|
|
|
int lasttemp;
|
2011-09-11 01:25:28 +00:00
|
|
|
int targetfan;
|
2011-09-03 05:33:53 +00:00
|
|
|
int targettemp;
|
|
|
|
int overtemp;
|
|
|
|
int minspeed;
|
|
|
|
int maxspeed;
|
2012-01-24 14:19:58 +00:00
|
|
|
|
|
|
|
int gpu;
|
|
|
|
bool has_fanspeed;
|
|
|
|
struct gpu_adl *twin;
|
2011-09-03 00:53:35 +00:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2013-07-06 09:15:59 +00:00
|
|
|
extern void blank_get_statline_before(char *buf, size_t bufsiz, struct cgpu_info __maybe_unused *cgpu);
|
2013-02-09 08:27:57 +00:00
|
|
|
|
2012-06-30 05:58:31 +00:00
|
|
|
struct api_data;
|
2012-01-06 00:26:01 +00:00
|
|
|
struct thr_info;
|
2012-01-07 07:56:27 +00:00
|
|
|
struct work;
|
2012-01-06 00:26:01 +00:00
|
|
|
|
2013-01-05 12:47:26 +00:00
|
|
|
struct device_drv {
|
2013-02-03 11:51:05 +00:00
|
|
|
enum drv_driver drv_id;
|
2013-01-05 12:47:26 +00:00
|
|
|
|
2012-12-04 10:52:41 +00:00
|
|
|
char *dname;
|
|
|
|
char *name;
|
2012-01-06 00:26:01 +00:00
|
|
|
|
2013-01-05 12:47:26 +00:00
|
|
|
// DRV-global functions
|
2013-09-28 05:11:06 +00:00
|
|
|
void (*drv_detect)(bool);
|
2012-01-06 00:26:01 +00:00
|
|
|
|
|
|
|
// Device-specific functions
|
2012-12-04 10:52:41 +00:00
|
|
|
void (*reinit_device)(struct cgpu_info *);
|
2013-07-06 09:15:59 +00:00
|
|
|
void (*get_statline_before)(char *, size_t, struct cgpu_info *);
|
|
|
|
void (*get_statline)(char *, size_t, struct cgpu_info *);
|
2012-12-04 10:52:41 +00:00
|
|
|
struct api_data *(*get_api_stats)(struct cgpu_info *);
|
|
|
|
bool (*get_stats)(struct cgpu_info *);
|
|
|
|
void (*identify_device)(struct cgpu_info *); // e.g. to flash a led
|
2012-12-18 23:43:27 +00:00
|
|
|
char *(*set_device)(struct cgpu_info *, char *option, char *setting, char *replybuf);
|
2012-01-06 00:26:01 +00:00
|
|
|
|
|
|
|
// Thread-specific functions
|
2012-12-04 10:52:41 +00:00
|
|
|
bool (*thread_prepare)(struct thr_info *);
|
|
|
|
uint64_t (*can_limit_work)(struct thr_info *);
|
|
|
|
bool (*thread_init)(struct thr_info *);
|
|
|
|
bool (*prepare_work)(struct thr_info *, struct work *);
|
2013-02-16 03:09:44 +00:00
|
|
|
|
|
|
|
/* Which hash work loop this driver uses. */
|
|
|
|
void (*hash_work)(struct thr_info *);
|
|
|
|
/* Two variants depending on whether the device divides work up into
|
|
|
|
* small pieces or works with whole work items and may or may not have
|
|
|
|
* a queue of its own. */
|
2012-12-04 10:52:41 +00:00
|
|
|
int64_t (*scanhash)(struct thr_info *, struct work *, int64_t);
|
2013-02-16 00:54:05 +00:00
|
|
|
int64_t (*scanwork)(struct thr_info *);
|
2013-02-16 03:09:44 +00:00
|
|
|
|
|
|
|
/* Used to extract work from the hash table of queued work and tell
|
|
|
|
* the main loop that it should not add any further work to the table.
|
|
|
|
*/
|
2013-02-16 01:14:13 +00:00
|
|
|
bool (*queue_full)(struct cgpu_info *);
|
2013-02-16 01:38:53 +00:00
|
|
|
void (*flush_work)(struct cgpu_info *);
|
2013-02-16 01:14:13 +00:00
|
|
|
|
2012-12-04 10:52:41 +00:00
|
|
|
void (*hw_error)(struct thr_info *);
|
|
|
|
void (*thread_shutdown)(struct thr_info *);
|
|
|
|
void (*thread_enable)(struct thr_info *);
|
2013-01-06 10:00:38 +00:00
|
|
|
|
|
|
|
// Does it need to be free()d?
|
|
|
|
bool copy;
|
2013-03-16 23:15:24 +00:00
|
|
|
|
|
|
|
/* Highest target diff the device supports */
|
|
|
|
double max_diff;
|
2013-05-11 10:29:48 +00:00
|
|
|
double working_diff;
|
2012-01-06 00:26:01 +00:00
|
|
|
};
|
|
|
|
|
2013-01-06 10:00:38 +00:00
|
|
|
extern struct device_drv *copy_drv(struct device_drv*);
|
|
|
|
|
2012-02-19 09:19:47 +00:00
|
|
|
enum dev_enable {
|
|
|
|
DEV_ENABLED,
|
|
|
|
DEV_DISABLED,
|
|
|
|
DEV_RECOVER,
|
|
|
|
};
|
|
|
|
|
2012-02-22 08:38:01 +00:00
|
|
|
enum cl_kernels {
|
|
|
|
KL_NONE,
|
|
|
|
KL_POCLBM,
|
|
|
|
KL_PHATK,
|
|
|
|
KL_DIAKGCN,
|
|
|
|
KL_DIABLO,
|
2012-07-13 04:44:52 +00:00
|
|
|
KL_SCRYPT,
|
2012-02-22 08:38:01 +00:00
|
|
|
};
|
|
|
|
|
2012-03-22 14:50:45 +00:00
|
|
|
enum dev_reason {
|
|
|
|
REASON_THREAD_FAIL_INIT,
|
|
|
|
REASON_THREAD_ZERO_HASH,
|
|
|
|
REASON_THREAD_FAIL_QUEUE,
|
|
|
|
REASON_DEV_SICK_IDLE_60,
|
|
|
|
REASON_DEV_DEAD_IDLE_600,
|
|
|
|
REASON_DEV_NOSTART,
|
|
|
|
REASON_DEV_OVER_HEAT,
|
|
|
|
REASON_DEV_THERMAL_CUTOFF,
|
2012-07-03 03:14:30 +00:00
|
|
|
REASON_DEV_COMMS_ERROR,
|
2012-09-03 16:26:17 +00:00
|
|
|
REASON_DEV_THROTTLE,
|
2012-03-22 14:50:45 +00:00
|
|
|
};
|
|
|
|
|
2012-03-22 16:17:20 +00:00
|
|
|
#define REASON_NONE "None"
|
|
|
|
#define REASON_THREAD_FAIL_INIT_STR "Thread failed to init"
|
|
|
|
#define REASON_THREAD_ZERO_HASH_STR "Thread got zero hashes"
|
|
|
|
#define REASON_THREAD_FAIL_QUEUE_STR "Thread failed to queue work"
|
|
|
|
#define REASON_DEV_SICK_IDLE_60_STR "Device idle for 60s"
|
|
|
|
#define REASON_DEV_DEAD_IDLE_600_STR "Device dead - idle for 600s"
|
|
|
|
#define REASON_DEV_NOSTART_STR "Device failed to start"
|
|
|
|
#define REASON_DEV_OVER_HEAT_STR "Device over heated"
|
|
|
|
#define REASON_DEV_THERMAL_CUTOFF_STR "Device reached thermal cutoff"
|
2012-07-03 03:14:30 +00:00
|
|
|
#define REASON_DEV_COMMS_ERROR_STR "Device comms error"
|
2012-09-03 16:26:17 +00:00
|
|
|
#define REASON_DEV_THROTTLE_STR "Device throttle"
|
2012-03-22 16:17:20 +00:00
|
|
|
#define REASON_UNKNOWN_STR "Unknown reason - code bug"
|
|
|
|
|
2012-05-05 05:04:15 +00:00
|
|
|
#define MIN_SEC_UNSET 99999999
|
|
|
|
|
|
|
|
struct cgminer_stats {
|
|
|
|
uint32_t getwork_calls;
|
|
|
|
struct timeval getwork_wait;
|
|
|
|
struct timeval getwork_wait_max;
|
|
|
|
struct timeval getwork_wait_min;
|
|
|
|
};
|
|
|
|
|
2012-06-10 01:19:21 +00:00
|
|
|
// Just the actual network getworks to the pool
|
|
|
|
struct cgminer_pool_stats {
|
|
|
|
uint32_t getwork_calls;
|
|
|
|
uint32_t getwork_attempts;
|
|
|
|
struct timeval getwork_wait;
|
|
|
|
struct timeval getwork_wait_max;
|
|
|
|
struct timeval getwork_wait_min;
|
2012-06-24 03:20:17 +00:00
|
|
|
double getwork_wait_rolling;
|
2012-08-23 09:20:12 +00:00
|
|
|
bool hadrolltime;
|
|
|
|
bool canroll;
|
|
|
|
bool hadexpire;
|
|
|
|
uint32_t rolltime;
|
2012-09-24 01:34:50 +00:00
|
|
|
double min_diff;
|
|
|
|
double max_diff;
|
|
|
|
double last_diff;
|
|
|
|
uint32_t min_diff_count;
|
|
|
|
uint32_t max_diff_count;
|
2012-12-12 13:56:10 +00:00
|
|
|
uint64_t times_sent;
|
|
|
|
uint64_t bytes_sent;
|
2013-01-14 14:13:00 +00:00
|
|
|
uint64_t net_bytes_sent;
|
2012-12-12 13:56:10 +00:00
|
|
|
uint64_t times_received;
|
|
|
|
uint64_t bytes_received;
|
2013-01-14 14:13:00 +00:00
|
|
|
uint64_t net_bytes_received;
|
2012-06-10 01:19:21 +00:00
|
|
|
};
|
|
|
|
|
2011-06-29 00:12:00 +00:00
|
|
|
struct cgpu_info {
|
2012-01-06 00:26:01 +00:00
|
|
|
int cgminer_id;
|
2013-01-05 12:47:26 +00:00
|
|
|
struct device_drv *drv;
|
2012-01-06 00:26:01 +00:00
|
|
|
int device_id;
|
2012-03-19 01:06:47 +00:00
|
|
|
char *name;
|
2012-01-09 00:56:15 +00:00
|
|
|
char *device_path;
|
2013-05-19 16:52:07 +00:00
|
|
|
void *device_data;
|
2013-03-05 07:33:43 +00:00
|
|
|
#ifdef USE_USBUTILS
|
2013-10-04 02:00:41 +00:00
|
|
|
struct cg_usb_device *usbdev;
|
2013-04-05 03:52:07 +00:00
|
|
|
#endif
|
|
|
|
#ifdef USE_AVALON
|
|
|
|
struct work **works;
|
2013-04-05 15:25:48 +00:00
|
|
|
int work_array;
|
2013-04-05 03:52:07 +00:00
|
|
|
int queued;
|
2013-04-15 10:30:02 +00:00
|
|
|
int results;
|
2012-12-31 12:46:03 +00:00
|
|
|
#endif
|
2013-03-05 07:33:43 +00:00
|
|
|
#ifdef USE_USBUTILS
|
2013-01-22 10:46:21 +00:00
|
|
|
struct cg_usb_info usbinfo;
|
2012-12-31 12:46:03 +00:00
|
|
|
#endif
|
|
|
|
#ifdef USE_MODMINER
|
2012-12-02 10:48:37 +00:00
|
|
|
char fpgaid;
|
|
|
|
unsigned char clock;
|
|
|
|
pthread_mutex_t *modminer_mutex;
|
|
|
|
#endif
|
2012-06-13 19:26:03 +00:00
|
|
|
#ifdef USE_BITFORCE
|
2012-07-09 06:25:02 +00:00
|
|
|
struct timeval work_start_tv;
|
2012-06-13 19:26:03 +00:00
|
|
|
unsigned int wait_ms;
|
|
|
|
unsigned int sleep_ms;
|
2012-07-11 21:46:09 +00:00
|
|
|
double avg_wait_f;
|
|
|
|
unsigned int avg_wait_d;
|
2012-07-04 14:40:01 +00:00
|
|
|
uint32_t nonces;
|
2012-07-04 07:31:02 +00:00
|
|
|
bool nonce_range;
|
2012-08-15 00:54:38 +00:00
|
|
|
bool polling;
|
2012-09-04 02:52:11 +00:00
|
|
|
bool flash_led;
|
2013-04-26 02:00:44 +00:00
|
|
|
#endif /* USE_BITFORCE */
|
|
|
|
#if defined(USE_BITFORCE) || defined(USE_BFLSC)
|
2012-12-02 10:48:37 +00:00
|
|
|
pthread_mutex_t device_mutex;
|
2013-04-26 02:00:44 +00:00
|
|
|
#endif /* USE_BITFORCE || USE_BFLSC */
|
2012-02-19 09:19:47 +00:00
|
|
|
enum dev_enable deven;
|
2011-06-29 00:12:00 +00:00
|
|
|
int accepted;
|
|
|
|
int rejected;
|
|
|
|
int hw_errors;
|
2011-07-26 01:58:45 +00:00
|
|
|
double rolling;
|
2011-07-05 12:04:54 +00:00
|
|
|
double total_mhashes;
|
2011-07-11 03:41:31 +00:00
|
|
|
double utility;
|
2011-07-29 15:23:17 +00:00
|
|
|
enum alive status;
|
2011-08-15 12:21:17 +00:00
|
|
|
char init[40];
|
2011-08-18 10:17:10 +00:00
|
|
|
struct timeval last_message_tv;
|
2011-09-03 00:53:35 +00:00
|
|
|
|
2012-01-06 00:26:01 +00:00
|
|
|
int threads;
|
2012-06-12 16:31:17 +00:00
|
|
|
struct thr_info **thr;
|
2012-01-06 00:26:01 +00:00
|
|
|
|
2012-08-30 13:22:37 +00:00
|
|
|
int64_t max_hashes;
|
2012-02-22 05:54:06 +00:00
|
|
|
|
2012-06-17 03:24:40 +00:00
|
|
|
const char *kname;
|
|
|
|
#ifdef HAVE_OPENCL
|
2012-04-23 07:40:47 +00:00
|
|
|
bool mapped;
|
2012-01-27 14:56:12 +00:00
|
|
|
int virtual_gpu;
|
2012-04-23 07:40:47 +00:00
|
|
|
int virtual_adl;
|
2011-09-26 05:24:20 +00:00
|
|
|
int intensity;
|
2012-02-14 21:51:59 +00:00
|
|
|
bool dynamic;
|
2012-07-23 07:41:31 +00:00
|
|
|
|
2012-02-22 05:54:06 +00:00
|
|
|
cl_uint vwidth;
|
|
|
|
size_t work_size;
|
2012-02-22 08:38:01 +00:00
|
|
|
enum cl_kernels kernel;
|
2012-07-23 07:41:31 +00:00
|
|
|
cl_ulong max_alloc;
|
2012-06-25 03:31:52 +00:00
|
|
|
|
2012-07-21 07:31:06 +00:00
|
|
|
#ifdef USE_SCRYPT
|
2012-08-05 05:32:44 +00:00
|
|
|
int opt_lg, lookup_gap;
|
2012-10-06 23:00:02 +00:00
|
|
|
size_t opt_tc, thread_concurrency;
|
2012-10-06 23:21:20 +00:00
|
|
|
size_t shaders;
|
2012-07-21 07:31:06 +00:00
|
|
|
#endif
|
2012-08-14 23:38:45 +00:00
|
|
|
struct timeval tv_gpustart;
|
2012-10-14 01:07:27 +00:00
|
|
|
int intervals;
|
2012-02-22 14:27:36 +00:00
|
|
|
#endif
|
2012-01-24 19:34:17 +00:00
|
|
|
|
2012-08-22 00:07:20 +00:00
|
|
|
bool new_work;
|
|
|
|
|
2012-01-24 19:34:17 +00:00
|
|
|
float temp;
|
|
|
|
int cutofftemp;
|
|
|
|
|
2011-09-03 00:53:35 +00:00
|
|
|
#ifdef HAVE_ADL
|
|
|
|
bool has_adl;
|
|
|
|
struct gpu_adl adl;
|
2012-01-24 14:19:58 +00:00
|
|
|
|
2011-09-04 11:55:06 +00:00
|
|
|
int gpu_engine;
|
2011-09-08 03:04:39 +00:00
|
|
|
int min_engine;
|
2011-09-04 12:25:31 +00:00
|
|
|
int gpu_fan;
|
2011-09-08 03:04:39 +00:00
|
|
|
int min_fan;
|
2011-09-04 12:01:58 +00:00
|
|
|
int gpu_memclock;
|
2011-10-23 09:50:52 +00:00
|
|
|
int gpu_memdiff;
|
2011-09-04 13:23:31 +00:00
|
|
|
int gpu_powertune;
|
2011-09-04 12:08:42 +00:00
|
|
|
float gpu_vddc;
|
2011-09-03 00:53:35 +00:00
|
|
|
#endif
|
2012-09-01 13:51:51 +00:00
|
|
|
int diff1;
|
2012-09-18 14:54:55 +00:00
|
|
|
double diff_accepted;
|
|
|
|
double diff_rejected;
|
2012-02-04 06:49:49 +00:00
|
|
|
int last_share_pool;
|
|
|
|
time_t last_share_pool_time;
|
2012-09-18 15:14:43 +00:00
|
|
|
double last_share_diff;
|
2013-03-03 08:33:20 +00:00
|
|
|
time_t last_device_valid_work;
|
2012-03-22 14:50:45 +00:00
|
|
|
|
|
|
|
time_t device_last_well;
|
|
|
|
time_t device_last_not_well;
|
|
|
|
enum dev_reason device_not_well_reason;
|
|
|
|
int thread_fail_init_count;
|
|
|
|
int thread_zero_hash_count;
|
|
|
|
int thread_fail_queue_count;
|
|
|
|
int dev_sick_idle_60_count;
|
|
|
|
int dev_dead_idle_600_count;
|
|
|
|
int dev_nostart_count;
|
|
|
|
int dev_over_heat_count; // It's a warning but worth knowing
|
|
|
|
int dev_thermal_cutoff_count;
|
2012-07-03 03:14:30 +00:00
|
|
|
int dev_comms_error_count;
|
2012-09-03 16:26:17 +00:00
|
|
|
int dev_throttle_count;
|
2012-05-05 05:04:15 +00:00
|
|
|
|
|
|
|
struct cgminer_stats cgminer_stats;
|
2013-02-16 01:14:13 +00:00
|
|
|
|
|
|
|
pthread_rwlock_t qlock;
|
|
|
|
struct work *queued_work;
|
2013-04-06 02:01:42 +00:00
|
|
|
unsigned int queued_count;
|
2013-05-28 13:33:32 +00:00
|
|
|
|
|
|
|
bool shutdown;
|
2013-06-13 15:09:50 +00:00
|
|
|
|
|
|
|
struct timeval dev_start_tv;
|
2011-06-29 00:12:00 +00:00
|
|
|
};
|
|
|
|
|
2012-03-19 00:09:03 +00:00
|
|
|
extern bool add_cgpu(struct cgpu_info*);
|
|
|
|
|
2011-08-23 22:06:15 +00:00
|
|
|
struct thread_q {
|
|
|
|
struct list_head q;
|
|
|
|
|
|
|
|
bool frozen;
|
|
|
|
|
|
|
|
pthread_mutex_t mutex;
|
|
|
|
pthread_cond_t cond;
|
|
|
|
};
|
|
|
|
|
2011-03-18 06:53:13 +00:00
|
|
|
struct thr_info {
|
|
|
|
int id;
|
2012-02-05 11:33:58 +00:00
|
|
|
int device_thread;
|
2012-06-18 05:51:09 +00:00
|
|
|
bool primary_thread;
|
2012-02-05 11:33:58 +00:00
|
|
|
|
2011-09-15 01:45:24 +00:00
|
|
|
pthread_t pth;
|
2013-06-09 02:20:04 +00:00
|
|
|
cgsem_t sem;
|
2011-03-18 06:53:13 +00:00
|
|
|
struct thread_q *q;
|
2011-06-29 00:12:00 +00:00
|
|
|
struct cgpu_info *cgpu;
|
2012-01-07 07:56:27 +00:00
|
|
|
void *cgpu_data;
|
2011-07-13 02:05:04 +00:00
|
|
|
struct timeval last;
|
2011-08-20 13:03:49 +00:00
|
|
|
struct timeval sick;
|
|
|
|
|
2011-09-01 03:19:51 +00:00
|
|
|
bool pause;
|
2011-07-19 23:31:45 +00:00
|
|
|
bool getwork;
|
2011-07-26 01:58:45 +00:00
|
|
|
double rolling;
|
2012-07-06 02:39:32 +00:00
|
|
|
|
|
|
|
bool work_restart;
|
2011-03-18 06:53:13 +00:00
|
|
|
};
|
|
|
|
|
2012-01-09 00:56:15 +00:00
|
|
|
struct string_elist {
|
|
|
|
char *string;
|
|
|
|
bool free_me;
|
|
|
|
|
|
|
|
struct list_head list;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline void string_elist_add(const char *s, struct list_head *head)
|
|
|
|
{
|
|
|
|
struct string_elist *n;
|
|
|
|
|
|
|
|
n = calloc(1, sizeof(*n));
|
|
|
|
n->string = strdup(s);
|
|
|
|
n->free_me = true;
|
|
|
|
list_add_tail(&n->list, head);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void string_elist_del(struct string_elist *item)
|
|
|
|
{
|
|
|
|
if (item->free_me)
|
|
|
|
free(item->string);
|
|
|
|
list_del(&item->list);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-27 04:37:58 +00:00
|
|
|
static inline uint32_t swab32(uint32_t v)
|
|
|
|
{
|
2011-02-10 05:52:22 +00:00
|
|
|
return bswap_32(v);
|
2010-12-27 04:37:58 +00:00
|
|
|
}
|
|
|
|
|
2011-02-02 23:47:04 +00:00
|
|
|
static inline void swap256(void *dest_p, const void *src_p)
|
|
|
|
{
|
|
|
|
uint32_t *dest = dest_p;
|
|
|
|
const uint32_t *src = src_p;
|
|
|
|
|
|
|
|
dest[0] = src[7];
|
|
|
|
dest[1] = src[6];
|
|
|
|
dest[2] = src[5];
|
|
|
|
dest[3] = src[4];
|
|
|
|
dest[4] = src[3];
|
|
|
|
dest[5] = src[2];
|
|
|
|
dest[6] = src[1];
|
|
|
|
dest[7] = src[0];
|
|
|
|
}
|
|
|
|
|
2012-10-02 14:35:08 +00:00
|
|
|
static inline void swab256(void *dest_p, const void *src_p)
|
|
|
|
{
|
|
|
|
uint32_t *dest = dest_p;
|
|
|
|
const uint32_t *src = src_p;
|
|
|
|
|
|
|
|
dest[0] = swab32(src[7]);
|
|
|
|
dest[1] = swab32(src[6]);
|
|
|
|
dest[2] = swab32(src[5]);
|
|
|
|
dest[3] = swab32(src[4]);
|
|
|
|
dest[4] = swab32(src[3]);
|
|
|
|
dest[5] = swab32(src[2]);
|
|
|
|
dest[6] = swab32(src[1]);
|
|
|
|
dest[7] = swab32(src[0]);
|
|
|
|
}
|
|
|
|
|
2012-11-05 04:57:47 +00:00
|
|
|
static inline void flip32(void *dest_p, const void *src_p)
|
|
|
|
{
|
|
|
|
uint32_t *dest = dest_p;
|
|
|
|
const uint32_t *src = src_p;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
dest[i] = swab32(src[i]);
|
|
|
|
}
|
|
|
|
|
2013-04-21 23:23:13 +00:00
|
|
|
static inline void flip64(void *dest_p, const void *src_p)
|
|
|
|
{
|
|
|
|
uint32_t *dest = dest_p;
|
|
|
|
const uint32_t *src = src_p;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
dest[i] = swab32(src[i]);
|
|
|
|
}
|
|
|
|
|
2012-11-05 03:56:57 +00:00
|
|
|
static inline void flip80(void *dest_p, const void *src_p)
|
2012-11-05 03:02:43 +00:00
|
|
|
{
|
|
|
|
uint32_t *dest = dest_p;
|
|
|
|
const uint32_t *src = src_p;
|
|
|
|
int i;
|
|
|
|
|
2012-11-05 03:56:57 +00:00
|
|
|
for (i = 0; i < 20; i++)
|
2012-11-05 03:02:43 +00:00
|
|
|
dest[i] = swab32(src[i]);
|
|
|
|
}
|
|
|
|
|
2013-04-21 23:28:06 +00:00
|
|
|
static inline void flip128(void *dest_p, const void *src_p)
|
|
|
|
{
|
|
|
|
uint32_t *dest = dest_p;
|
|
|
|
const uint32_t *src = src_p;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 32; i++)
|
|
|
|
dest[i] = swab32(src[i]);
|
|
|
|
}
|
|
|
|
|
2013-04-21 23:35:48 +00:00
|
|
|
/* For flipping to the correct endianness if necessary */
|
|
|
|
#if defined(__BIG_ENDIAN__) || defined(MIPSEB)
|
|
|
|
static inline void endian_flip32(void *dest_p, const void *src_p)
|
|
|
|
{
|
|
|
|
flip32(dest_p, src_p);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void endian_flip128(void *dest_p, const void *src_p)
|
|
|
|
{
|
|
|
|
flip128(dest_p, src_p);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static inline void
|
|
|
|
endian_flip32(void __maybe_unused *dest_p, const void __maybe_unused *src_p)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
endian_flip128(void __maybe_unused *dest_p, const void __maybe_unused *src_p)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-06-15 12:03:56 +00:00
|
|
|
extern void _quit(int status);
|
2011-07-27 00:31:44 +00:00
|
|
|
|
2013-08-11 22:54:11 +00:00
|
|
|
#define mutex_lock(_lock) _mutex_lock(_lock, __FILE__, __func__, __LINE__)
|
|
|
|
#define mutex_unlock_noyield(_lock) _mutex_unlock_noyield(_lock, __FILE__, __func__, __LINE__)
|
|
|
|
#define wr_lock(_lock) _wr_lock(_lock, __FILE__, __func__, __LINE__)
|
|
|
|
#define rd_lock(_lock) _rd_lock(_lock, __FILE__, __func__, __LINE__)
|
|
|
|
#define rw_unlock(_lock) _rw_unlock(_lock, __FILE__, __func__, __LINE__)
|
|
|
|
#define mutex_init(_lock) _mutex_init(_lock, __FILE__, __func__, __LINE__)
|
|
|
|
#define rwlock_init(_lock) _rwlock_init(_lock, __FILE__, __func__, __LINE__)
|
|
|
|
|
|
|
|
static inline void _mutex_lock(pthread_mutex_t *lock, const char *file, const char *func, const int line)
|
2011-07-27 00:31:44 +00:00
|
|
|
{
|
|
|
|
if (unlikely(pthread_mutex_lock(lock)))
|
2013-08-11 22:54:11 +00:00
|
|
|
quitfrom(1, file, func, line, "WTF MUTEX ERROR ON LOCK! errno=%d", errno);
|
2011-07-27 00:31:44 +00:00
|
|
|
}
|
|
|
|
|
2013-08-11 22:54:11 +00:00
|
|
|
static inline void _mutex_unlock_noyield(pthread_mutex_t *lock, const char *file, const char *func, const int line)
|
2011-07-27 00:31:44 +00:00
|
|
|
{
|
|
|
|
if (unlikely(pthread_mutex_unlock(lock)))
|
2013-08-11 22:54:11 +00:00
|
|
|
quitfrom(1, file, func, line, "WTF MUTEX ERROR ON UNLOCK! errno=%d", errno);
|
2013-06-15 02:35:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void mutex_unlock(pthread_mutex_t *lock)
|
|
|
|
{
|
|
|
|
mutex_unlock_noyield(lock);
|
2013-06-13 03:28:48 +00:00
|
|
|
sched_yield();
|
2011-07-27 00:31:44 +00:00
|
|
|
}
|
|
|
|
|
2012-08-02 23:26:43 +00:00
|
|
|
static inline int mutex_trylock(pthread_mutex_t *lock)
|
|
|
|
{
|
|
|
|
return pthread_mutex_trylock(lock);
|
|
|
|
}
|
|
|
|
|
2013-08-11 22:54:11 +00:00
|
|
|
static inline void _wr_lock(pthread_rwlock_t *lock, const char *file, const char *func, const int line)
|
2011-08-24 11:50:04 +00:00
|
|
|
{
|
|
|
|
if (unlikely(pthread_rwlock_wrlock(lock)))
|
2013-08-11 22:54:11 +00:00
|
|
|
quitfrom(1, file, func, line, "WTF WRLOCK ERROR ON LOCK! errno=%d", errno);
|
2011-08-24 11:50:04 +00:00
|
|
|
}
|
|
|
|
|
2013-08-11 22:54:11 +00:00
|
|
|
static inline void _rd_lock(pthread_rwlock_t *lock, const char *file, const char *func, const int line)
|
2011-08-24 11:50:04 +00:00
|
|
|
{
|
|
|
|
if (unlikely(pthread_rwlock_rdlock(lock)))
|
2013-08-11 22:54:11 +00:00
|
|
|
quitfrom(1, file, func, line, "WTF RDLOCK ERROR ON LOCK! errno=%d", errno);
|
2011-08-24 11:50:04 +00:00
|
|
|
}
|
|
|
|
|
2013-08-11 22:54:11 +00:00
|
|
|
static inline void _rw_unlock(pthread_rwlock_t *lock, const char *file, const char *func, const int line)
|
2011-08-24 11:50:04 +00:00
|
|
|
{
|
|
|
|
if (unlikely(pthread_rwlock_unlock(lock)))
|
2013-08-11 22:54:11 +00:00
|
|
|
quitfrom(1, file, func, line, "WTF RWLOCK ERROR ON UNLOCK! errno=%d", errno);
|
2013-08-11 14:11:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void rd_unlock_noyield(pthread_rwlock_t *lock)
|
|
|
|
{
|
|
|
|
rw_unlock(lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void wr_unlock_noyield(pthread_rwlock_t *lock)
|
|
|
|
{
|
|
|
|
rw_unlock(lock);
|
2011-08-24 11:50:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void rd_unlock(pthread_rwlock_t *lock)
|
|
|
|
{
|
|
|
|
rw_unlock(lock);
|
2013-08-11 14:11:49 +00:00
|
|
|
sched_yield();
|
2011-08-24 11:50:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void wr_unlock(pthread_rwlock_t *lock)
|
|
|
|
{
|
|
|
|
rw_unlock(lock);
|
2013-08-11 14:11:49 +00:00
|
|
|
sched_yield();
|
2011-08-24 11:50:04 +00:00
|
|
|
}
|
|
|
|
|
2013-08-11 22:54:11 +00:00
|
|
|
static inline void _mutex_init(pthread_mutex_t *lock, const char *file, const char *func, const int line)
|
2012-01-20 03:47:17 +00:00
|
|
|
{
|
|
|
|
if (unlikely(pthread_mutex_init(lock, NULL)))
|
2013-08-11 22:54:11 +00:00
|
|
|
quitfrom(1, file, func, line, "Failed to pthread_mutex_init errno=%d", errno);
|
2012-01-20 03:47:17 +00:00
|
|
|
}
|
|
|
|
|
2013-08-11 22:54:11 +00:00
|
|
|
static inline void _rwlock_init(pthread_rwlock_t *lock, const char *file, const char *func, const int line)
|
2012-01-20 03:47:17 +00:00
|
|
|
{
|
|
|
|
if (unlikely(pthread_rwlock_init(lock, NULL)))
|
2013-08-11 22:54:11 +00:00
|
|
|
quitfrom(1, file, func, line, "Failed to pthread_rwlock_init errno=%d", errno);
|
2012-01-20 03:47:17 +00:00
|
|
|
}
|
|
|
|
|
2013-03-11 02:23:51 +00:00
|
|
|
static inline void cglock_init(cglock_t *lock)
|
|
|
|
{
|
|
|
|
mutex_init(&lock->mutex);
|
|
|
|
rwlock_init(&lock->rwlock);
|
|
|
|
}
|
|
|
|
|
2013-09-29 05:14:06 +00:00
|
|
|
/* Read lock variant of cglock. Cannot be promoted. */
|
2013-03-11 02:23:51 +00:00
|
|
|
static inline void cg_rlock(cglock_t *lock)
|
|
|
|
{
|
|
|
|
mutex_lock(&lock->mutex);
|
|
|
|
rd_lock(&lock->rwlock);
|
2013-06-15 02:35:16 +00:00
|
|
|
mutex_unlock_noyield(&lock->mutex);
|
2013-03-11 02:23:51 +00:00
|
|
|
}
|
|
|
|
|
2013-09-29 05:14:06 +00:00
|
|
|
/* Intermediate variant of cglock - behaves as a read lock but can be promoted
|
|
|
|
* to a write lock or demoted to read lock. */
|
2013-03-12 11:40:23 +00:00
|
|
|
static inline void cg_ilock(cglock_t *lock)
|
|
|
|
{
|
|
|
|
mutex_lock(&lock->mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Upgrade intermediate variant to a write lock */
|
|
|
|
static inline void cg_ulock(cglock_t *lock)
|
|
|
|
{
|
|
|
|
wr_lock(&lock->rwlock);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write lock variant of cglock */
|
2013-03-11 02:23:51 +00:00
|
|
|
static inline void cg_wlock(cglock_t *lock)
|
|
|
|
{
|
|
|
|
mutex_lock(&lock->mutex);
|
|
|
|
wr_lock(&lock->rwlock);
|
2013-03-12 11:40:23 +00:00
|
|
|
}
|
|
|
|
|
2013-08-11 14:11:49 +00:00
|
|
|
/* Downgrade write variant to a read lock */
|
|
|
|
static inline void cg_dwlock(cglock_t *lock)
|
|
|
|
{
|
|
|
|
wr_unlock_noyield(&lock->rwlock);
|
|
|
|
rd_lock(&lock->rwlock);
|
|
|
|
mutex_unlock_noyield(&lock->mutex);
|
|
|
|
}
|
|
|
|
|
2013-09-29 05:14:06 +00:00
|
|
|
/* Demote a write variant to an intermediate variant */
|
|
|
|
static inline void cg_dwilock(cglock_t *lock)
|
|
|
|
{
|
|
|
|
wr_unlock(&lock->rwlock);
|
|
|
|
}
|
|
|
|
|
2013-03-12 11:40:23 +00:00
|
|
|
/* Downgrade intermediate variant to a read lock */
|
|
|
|
static inline void cg_dlock(cglock_t *lock)
|
|
|
|
{
|
|
|
|
rd_lock(&lock->rwlock);
|
2013-06-15 11:33:12 +00:00
|
|
|
mutex_unlock_noyield(&lock->mutex);
|
2013-03-11 02:23:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void cg_runlock(cglock_t *lock)
|
|
|
|
{
|
|
|
|
rd_unlock(&lock->rwlock);
|
|
|
|
}
|
|
|
|
|
2013-10-07 13:01:26 +00:00
|
|
|
/* This drops the read lock and grabs a write lock. It does NOT protect data
|
|
|
|
* between the two locks! */
|
|
|
|
static inline void cg_ruwlock(cglock_t *lock)
|
|
|
|
{
|
|
|
|
rd_unlock_noyield(&lock->rwlock);
|
|
|
|
cg_wlock(lock);
|
|
|
|
}
|
|
|
|
|
2013-03-11 02:23:51 +00:00
|
|
|
static inline void cg_wunlock(cglock_t *lock)
|
|
|
|
{
|
2013-09-29 05:16:25 +00:00
|
|
|
wr_unlock_noyield(&lock->rwlock);
|
2013-03-12 11:40:23 +00:00
|
|
|
mutex_unlock(&lock->mutex);
|
2013-03-11 02:23:51 +00:00
|
|
|
}
|
|
|
|
|
2011-07-19 01:45:58 +00:00
|
|
|
struct pool;
|
|
|
|
|
2013-08-21 23:27:49 +00:00
|
|
|
#define API_MCAST_CODE "FTW"
|
|
|
|
#define API_MCAST_ADDR "224.0.0.75"
|
|
|
|
|
2010-11-25 09:03:59 +00:00
|
|
|
extern bool opt_protocol;
|
2012-08-20 06:07:20 +00:00
|
|
|
extern bool have_longpoll;
|
2011-08-25 04:42:03 +00:00
|
|
|
extern char *opt_kernel_path;
|
2012-01-21 22:36:21 +00:00
|
|
|
extern char *opt_socks_proxy;
|
2011-09-06 00:11:34 +00:00
|
|
|
extern char *cgminer_path;
|
2012-08-14 02:54:27 +00:00
|
|
|
extern bool opt_fail_only;
|
2011-09-03 05:46:57 +00:00
|
|
|
extern bool opt_autofan;
|
2011-09-03 12:30:11 +00:00
|
|
|
extern bool opt_autoengine;
|
2011-09-21 11:45:24 +00:00
|
|
|
extern bool use_curses;
|
2012-02-08 08:06:24 +00:00
|
|
|
extern char *opt_api_allow;
|
2013-08-21 23:27:49 +00:00
|
|
|
extern bool opt_api_mcast;
|
|
|
|
extern char *opt_api_mcast_addr;
|
|
|
|
extern char *opt_api_mcast_code;
|
2013-08-31 14:23:26 +00:00
|
|
|
extern char *opt_api_mcast_des;
|
2013-08-21 23:27:49 +00:00
|
|
|
extern int opt_api_mcast_port;
|
2012-06-27 11:28:18 +00:00
|
|
|
extern char *opt_api_groups;
|
2011-12-03 13:24:26 +00:00
|
|
|
extern char *opt_api_description;
|
2011-11-23 11:22:10 +00:00
|
|
|
extern int opt_api_port;
|
|
|
|
extern bool opt_api_listen;
|
2011-12-03 13:24:26 +00:00
|
|
|
extern bool opt_api_network;
|
2012-01-20 04:36:42 +00:00
|
|
|
extern bool opt_delaynet;
|
2012-02-19 09:19:47 +00:00
|
|
|
extern bool opt_restart;
|
2013-09-28 05:11:06 +00:00
|
|
|
extern bool opt_nogpu;
|
2012-08-01 12:50:30 +00:00
|
|
|
extern char *opt_icarus_options;
|
2012-05-16 12:25:21 +00:00
|
|
|
extern char *opt_icarus_timing;
|
2012-09-15 04:04:57 +00:00
|
|
|
extern bool opt_worktime;
|
2013-04-05 03:52:07 +00:00
|
|
|
#ifdef USE_AVALON
|
|
|
|
extern char *opt_avalon_options;
|
|
|
|
#endif
|
2013-10-03 13:19:18 +00:00
|
|
|
#ifdef USE_KLONDIKE
|
|
|
|
extern char *opt_klondike_options;
|
|
|
|
#endif
|
2013-03-10 23:58:28 +00:00
|
|
|
#ifdef USE_USBUTILS
|
|
|
|
extern char *opt_usb_select;
|
2012-12-02 10:48:37 +00:00
|
|
|
extern int opt_usbdump;
|
2013-03-14 13:02:17 +00:00
|
|
|
extern bool opt_usb_list_all;
|
2013-06-06 03:08:00 +00:00
|
|
|
extern cgsem_t usb_resource_sem;
|
2012-12-02 10:48:37 +00:00
|
|
|
#endif
|
2012-07-06 06:54:00 +00:00
|
|
|
#ifdef USE_BITFORCE
|
|
|
|
extern bool opt_bfl_noncerange;
|
|
|
|
#endif
|
2012-09-29 06:10:13 +00:00
|
|
|
extern int swork_id;
|
2012-01-20 04:36:42 +00:00
|
|
|
|
|
|
|
extern pthread_rwlock_t netacc_lock;
|
2011-09-03 05:46:57 +00:00
|
|
|
|
2010-11-27 06:29:56 +00:00
|
|
|
extern const uint32_t sha256_init_state[];
|
2013-09-21 12:49:28 +00:00
|
|
|
#ifdef HAVE_LIBCURL
|
2011-02-10 05:41:44 +00:00
|
|
|
extern json_t *json_rpc_call(CURL *curl, const char *url, const char *userpass,
|
2012-06-23 13:43:22 +00:00
|
|
|
const char *rpc_req, bool, bool, int *,
|
2012-01-30 04:09:58 +00:00
|
|
|
struct pool *pool, bool);
|
2013-09-21 12:49:28 +00:00
|
|
|
#endif
|
|
|
|
extern const char *proxytype(proxytypes_t proxytype);
|
2012-09-11 21:44:00 +00:00
|
|
|
extern char *get_proxy(char *url, struct pool *pool);
|
2011-03-15 03:17:34 +00:00
|
|
|
extern char *bin2hex(const unsigned char *p, size_t len);
|
2010-11-25 09:03:59 +00:00
|
|
|
extern bool hex2bin(unsigned char *p, const char *hexstr, size_t len);
|
|
|
|
|
2012-07-06 02:39:32 +00:00
|
|
|
typedef bool (*sha256_func)(struct thr_info*, const unsigned char *pmidstate,
|
2011-10-09 01:22:00 +00:00
|
|
|
unsigned char *pdata,
|
|
|
|
unsigned char *phash1, unsigned char *phash,
|
|
|
|
const unsigned char *ptarget,
|
2012-01-17 21:29:01 +00:00
|
|
|
uint32_t max_nonce,
|
|
|
|
uint32_t *last_nonce,
|
|
|
|
uint32_t nonce);
|
2011-10-09 01:22:00 +00:00
|
|
|
|
2011-02-03 05:46:55 +00:00
|
|
|
extern bool fulltest(const unsigned char *hash, const unsigned char *target);
|
2011-02-02 23:47:04 +00:00
|
|
|
|
2012-09-12 13:26:43 +00:00
|
|
|
extern int opt_queue;
|
2011-03-18 06:53:13 +00:00
|
|
|
extern int opt_scantime;
|
2012-09-12 13:26:43 +00:00
|
|
|
extern int opt_expiry;
|
2011-03-15 03:17:34 +00:00
|
|
|
|
2013-03-10 23:58:28 +00:00
|
|
|
#ifdef USE_USBUTILS
|
2012-12-02 10:48:37 +00:00
|
|
|
extern pthread_mutex_t cgusb_lock;
|
2013-05-27 13:30:18 +00:00
|
|
|
extern pthread_mutex_t cgusbres_lock;
|
2013-06-14 15:02:27 +00:00
|
|
|
extern cglock_t cgusb_fd_lock;
|
2012-12-02 10:48:37 +00:00
|
|
|
#endif
|
|
|
|
|
2013-03-12 11:07:06 +00:00
|
|
|
extern cglock_t control_lock;
|
2012-12-03 00:36:15 +00:00
|
|
|
extern pthread_mutex_t hash_lock;
|
2012-07-23 20:22:01 +00:00
|
|
|
extern pthread_mutex_t console_lock;
|
2013-03-12 11:17:08 +00:00
|
|
|
extern cglock_t ch_lock;
|
2013-03-04 11:46:34 +00:00
|
|
|
extern pthread_rwlock_t mining_thr_lock;
|
|
|
|
extern pthread_rwlock_t devices_lock;
|
2012-07-23 20:22:01 +00:00
|
|
|
|
2012-07-02 00:54:20 +00:00
|
|
|
extern pthread_mutex_t restart_lock;
|
|
|
|
extern pthread_cond_t restart_cond;
|
|
|
|
|
2013-02-15 12:05:29 +00:00
|
|
|
extern void clear_stratum_shares(struct pool *pool);
|
2013-05-11 09:51:43 +00:00
|
|
|
extern void set_target(unsigned char *dest_target, double diff);
|
2013-08-19 05:58:22 +00:00
|
|
|
extern int restart_wait(struct thr_info *thr, unsigned int mstime);
|
2012-02-03 23:18:29 +00:00
|
|
|
|
2011-11-23 05:25:13 +00:00
|
|
|
extern void kill_work(void);
|
|
|
|
|
2011-11-24 01:59:30 +00:00
|
|
|
extern void reinit_device(struct cgpu_info *cgpu);
|
|
|
|
|
2011-12-03 13:24:26 +00:00
|
|
|
#ifdef HAVE_ADL
|
|
|
|
extern bool gpu_stats(int gpu, float *temp, int *engineclock, int *memclock, float *vddc, int *activity, int *fanspeed, int *fanpercent, int *powertune);
|
2012-01-22 07:24:55 +00:00
|
|
|
extern int set_fanspeed(int gpu, int iFanSpeed);
|
|
|
|
extern int set_vddc(int gpu, float fVddc);
|
|
|
|
extern int set_engineclock(int gpu, int iEngineClock);
|
|
|
|
extern int set_memoryclock(int gpu, int iMemoryClock);
|
2011-12-03 13:24:26 +00:00
|
|
|
#endif
|
2011-11-29 00:07:27 +00:00
|
|
|
|
2012-02-21 09:03:13 +00:00
|
|
|
extern void api(int thr_id);
|
2011-11-23 03:35:49 +00:00
|
|
|
|
2012-02-23 05:10:17 +00:00
|
|
|
extern struct pool *current_pool(void);
|
2012-07-29 03:15:39 +00:00
|
|
|
extern int enabled_pools;
|
2013-06-03 01:09:36 +00:00
|
|
|
extern void get_intrange(char *arg, int *val1, int *val2);
|
2012-09-26 23:06:56 +00:00
|
|
|
extern bool detect_stratum(struct pool *pool, char *url);
|
2013-01-10 00:08:12 +00:00
|
|
|
extern void print_summary(void);
|
2013-09-13 03:51:15 +00:00
|
|
|
extern void adjust_quota_gcd(void);
|
2012-09-26 23:06:56 +00:00
|
|
|
extern struct pool *add_pool(void);
|
2013-03-14 11:34:53 +00:00
|
|
|
extern bool add_pool_details(struct pool *pool, bool live, char *url, char *user, char *pass);
|
2012-02-23 02:58:33 +00:00
|
|
|
|
2011-09-08 04:44:14 +00:00
|
|
|
#define MAX_GPUDEVICES 16
|
2013-06-03 01:09:36 +00:00
|
|
|
#define MAX_DEVICES 4096
|
2011-09-08 04:44:14 +00:00
|
|
|
|
2013-08-09 05:12:57 +00:00
|
|
|
#define MIN_SHA_INTENSITY -10
|
|
|
|
#define MIN_SHA_INTENSITY_STR "-10"
|
|
|
|
#define MAX_SHA_INTENSITY 14
|
|
|
|
#define MAX_SHA_INTENSITY_STR "14"
|
|
|
|
#define MIN_SCRYPT_INTENSITY 8
|
|
|
|
#define MIN_SCRYPT_INTENSITY_STR "8"
|
|
|
|
#define MAX_SCRYPT_INTENSITY 20
|
|
|
|
#define MAX_SCRYPT_INTENSITY_STR "20"
|
2012-07-21 14:49:47 +00:00
|
|
|
#ifdef USE_SCRYPT
|
2013-08-09 05:12:57 +00:00
|
|
|
#define MIN_INTENSITY (opt_scrypt ? MIN_SCRYPT_INTENSITY : MIN_SHA_INTENSITY)
|
|
|
|
#define MIN_INTENSITY_STR (opt_scrypt ? MIN_SCRYPT_INTENSITY_STR : MIN_SHA_INTENSITY_STR)
|
|
|
|
#define MAX_INTENSITY (opt_scrypt ? MAX_SCRYPT_INTENSITY : MAX_SHA_INTENSITY)
|
|
|
|
#define MAX_INTENSITY_STR (opt_scrypt ? MAX_SCRYPT_INTENSITY_STR : MAX_SHA_INTENSITY_STR)
|
2013-08-11 05:10:27 +00:00
|
|
|
#define MAX_GPU_INTENSITY MAX_SCRYPT_INTENSITY
|
2012-07-21 14:49:47 +00:00
|
|
|
#else
|
2013-08-09 05:12:57 +00:00
|
|
|
#define MIN_INTENSITY MIN_SHA_INTENSITY
|
|
|
|
#define MIN_INTENSITY_STR MIN_SHA_INTENSITY_STR
|
|
|
|
#define MAX_INTENSITY MAX_SHA_INTENSITY
|
|
|
|
#define MAX_INTENSITY_STR MAX_SHA_INTENSITY_STR
|
2013-08-11 05:10:27 +00:00
|
|
|
#define MAX_GPU_INTENSITY MAX_SHA_INTENSITY
|
2012-07-21 14:49:47 +00:00
|
|
|
#endif
|
2012-01-26 03:00:52 +00:00
|
|
|
|
2013-02-01 22:51:47 +00:00
|
|
|
extern bool hotplug_mode;
|
2013-03-04 06:26:11 +00:00
|
|
|
extern int hotplug_time;
|
2012-01-09 00:56:15 +00:00
|
|
|
extern struct list_head scan_devices;
|
2011-11-24 09:41:31 +00:00
|
|
|
extern int nDevs;
|
|
|
|
extern int num_processors;
|
2011-06-28 23:22:21 +00:00
|
|
|
extern int hw_errors;
|
2011-03-18 21:24:16 +00:00
|
|
|
extern bool use_syslog;
|
2012-07-23 19:56:03 +00:00
|
|
|
extern bool opt_quiet;
|
2013-01-29 12:44:09 +00:00
|
|
|
extern struct thr_info *control_thr;
|
|
|
|
extern struct thr_info **mining_thr;
|
2011-09-08 04:44:14 +00:00
|
|
|
extern struct cgpu_info gpus[MAX_GPUDEVICES];
|
2011-11-23 03:35:49 +00:00
|
|
|
extern int gpu_threads;
|
2012-07-13 09:02:43 +00:00
|
|
|
#ifdef USE_SCRYPT
|
|
|
|
extern bool opt_scrypt;
|
|
|
|
#else
|
|
|
|
#define opt_scrypt (0)
|
|
|
|
#endif
|
2011-11-23 03:35:49 +00:00
|
|
|
extern double total_secs;
|
|
|
|
extern int mining_threads;
|
2012-01-06 00:26:01 +00:00
|
|
|
extern int total_devices;
|
2013-06-14 15:28:00 +00:00
|
|
|
extern int zombie_devs;
|
2012-06-25 06:59:29 +00:00
|
|
|
extern struct cgpu_info **devices;
|
2011-11-23 03:35:49 +00:00
|
|
|
extern int total_pools;
|
2012-06-25 07:06:26 +00:00
|
|
|
extern struct pool **pools;
|
2012-01-22 07:24:55 +00:00
|
|
|
extern struct strategies strategies[];
|
|
|
|
extern enum pool_strategy pool_strategy;
|
|
|
|
extern int opt_rotate_period;
|
2011-11-23 06:01:45 +00:00
|
|
|
extern double total_mhashes_done;
|
|
|
|
extern unsigned int new_blocks;
|
|
|
|
extern unsigned int found_blocks;
|
2012-08-19 05:09:45 +00:00
|
|
|
extern int total_accepted, total_rejected, total_diff1;;
|
2011-11-23 06:01:45 +00:00
|
|
|
extern int total_getworks, total_stale, total_discarded;
|
2012-09-18 14:54:55 +00:00
|
|
|
extern double total_diff_accepted, total_diff_rejected, total_diff_stale;
|
2011-11-23 06:01:45 +00:00
|
|
|
extern unsigned int local_work;
|
|
|
|
extern unsigned int total_go, total_ro;
|
2012-01-24 19:34:17 +00:00
|
|
|
extern const int opt_cutofftemp;
|
2011-11-24 01:59:30 +00:00
|
|
|
extern int opt_log_interval;
|
2012-06-28 00:43:52 +00:00
|
|
|
extern unsigned long long global_hashrate;
|
2012-08-20 06:07:20 +00:00
|
|
|
extern char *current_fullhash;
|
2013-03-06 20:40:05 +00:00
|
|
|
extern double current_diff;
|
2012-12-03 12:08:11 +00:00
|
|
|
extern uint64_t best_diff;
|
2012-08-20 06:07:20 +00:00
|
|
|
extern struct timeval block_timeval;
|
2013-08-12 18:57:04 +00:00
|
|
|
extern char *workpadding;
|
2011-06-27 01:31:05 +00:00
|
|
|
|
2011-07-05 09:47:03 +00:00
|
|
|
#ifdef HAVE_OPENCL
|
2011-06-27 01:31:05 +00:00
|
|
|
typedef struct {
|
2011-07-23 04:17:25 +00:00
|
|
|
cl_uint ctx_a; cl_uint ctx_b; cl_uint ctx_c; cl_uint ctx_d;
|
|
|
|
cl_uint ctx_e; cl_uint ctx_f; cl_uint ctx_g; cl_uint ctx_h;
|
|
|
|
cl_uint cty_a; cl_uint cty_b; cl_uint cty_c; cl_uint cty_d;
|
|
|
|
cl_uint cty_e; cl_uint cty_f; cl_uint cty_g; cl_uint cty_h;
|
|
|
|
cl_uint merkle; cl_uint ntime; cl_uint nbits; cl_uint nonce;
|
2011-06-27 01:31:05 +00:00
|
|
|
cl_uint fW0; cl_uint fW1; cl_uint fW2; cl_uint fW3; cl_uint fW15;
|
|
|
|
cl_uint fW01r; cl_uint fcty_e; cl_uint fcty_e2;
|
2011-06-28 11:11:04 +00:00
|
|
|
cl_uint W16; cl_uint W17; cl_uint W2;
|
|
|
|
cl_uint PreVal4; cl_uint T1;
|
2011-07-23 04:17:25 +00:00
|
|
|
cl_uint C1addK5; cl_uint D1A; cl_uint W2A; cl_uint W17_2;
|
|
|
|
cl_uint PreVal4addT1; cl_uint T1substate0;
|
2011-08-17 03:19:46 +00:00
|
|
|
cl_uint PreVal4_2;
|
|
|
|
cl_uint PreVal0;
|
|
|
|
cl_uint PreW18;
|
|
|
|
cl_uint PreW19;
|
|
|
|
cl_uint PreW31;
|
|
|
|
cl_uint PreW32;
|
2012-02-08 04:40:10 +00:00
|
|
|
|
|
|
|
/* For diakgcn */
|
|
|
|
cl_uint B1addK6, PreVal0addK7, W16addK16, W17addK17;
|
2012-02-11 10:42:02 +00:00
|
|
|
cl_uint zeroA, zeroB;
|
2012-02-18 04:17:50 +00:00
|
|
|
cl_uint oneA, twoA, threeA, fourA, fiveA, sixA, sevenA;
|
2012-07-13 10:28:36 +00:00
|
|
|
#ifdef USE_SCRYPT
|
2012-07-16 03:14:21 +00:00
|
|
|
struct work *work;
|
2012-07-13 10:28:36 +00:00
|
|
|
#endif
|
2011-06-27 01:31:05 +00:00
|
|
|
} dev_blk_ctx;
|
2011-07-05 09:47:03 +00:00
|
|
|
#else
|
|
|
|
typedef struct {
|
|
|
|
uint32_t nonce;
|
|
|
|
} dev_blk_ctx;
|
|
|
|
#endif
|
2011-06-27 01:31:05 +00:00
|
|
|
|
2012-05-01 09:59:37 +00:00
|
|
|
struct curl_ent {
|
|
|
|
CURL *curl;
|
|
|
|
struct list_head node;
|
2012-05-02 00:12:07 +00:00
|
|
|
struct timeval tv;
|
2012-05-01 09:59:37 +00:00
|
|
|
};
|
|
|
|
|
2012-08-05 05:43:27 +00:00
|
|
|
/* Disabled needs to be the lowest enum as a freshly calloced value will then
|
|
|
|
* equal disabled */
|
2012-05-04 10:10:38 +00:00
|
|
|
enum pool_enable {
|
|
|
|
POOL_DISABLED,
|
2012-08-05 05:43:27 +00:00
|
|
|
POOL_ENABLED,
|
2012-05-04 10:10:38 +00:00
|
|
|
POOL_REJECTING,
|
|
|
|
};
|
|
|
|
|
2012-09-27 03:26:09 +00:00
|
|
|
struct stratum_work {
|
|
|
|
char *job_id;
|
|
|
|
char *prev_hash;
|
2013-08-12 01:36:28 +00:00
|
|
|
unsigned char **merkle_bin;
|
2012-09-27 03:26:09 +00:00
|
|
|
char *bbversion;
|
|
|
|
char *nbit;
|
|
|
|
char *ntime;
|
|
|
|
bool clean;
|
|
|
|
|
2013-02-04 00:19:12 +00:00
|
|
|
size_t cb_len;
|
2013-02-04 00:06:05 +00:00
|
|
|
size_t header_len;
|
2012-09-28 15:48:01 +00:00
|
|
|
int merkles;
|
2012-11-14 22:18:58 +00:00
|
|
|
double diff;
|
2012-09-27 03:26:09 +00:00
|
|
|
};
|
|
|
|
|
2012-12-29 00:29:59 +00:00
|
|
|
#define RBUFSIZE 8192
|
|
|
|
#define RECVSIZE (RBUFSIZE - 4)
|
2012-10-04 13:18:33 +00:00
|
|
|
|
2011-07-18 14:09:45 +00:00
|
|
|
struct pool {
|
2011-07-20 00:24:25 +00:00
|
|
|
int pool_no;
|
2011-07-22 01:46:26 +00:00
|
|
|
int prio;
|
2011-07-18 14:09:45 +00:00
|
|
|
int accepted, rejected;
|
2012-05-03 05:35:13 +00:00
|
|
|
int seq_rejects;
|
2012-09-23 22:30:07 +00:00
|
|
|
int seq_getfails;
|
2012-05-06 06:22:18 +00:00
|
|
|
int solved;
|
2012-08-18 05:27:53 +00:00
|
|
|
int diff1;
|
2012-12-25 12:14:21 +00:00
|
|
|
char diff[8];
|
2013-09-07 01:33:07 +00:00
|
|
|
int quota;
|
2013-09-13 03:51:15 +00:00
|
|
|
int quota_gcd;
|
2013-09-07 02:12:24 +00:00
|
|
|
int quota_used;
|
2012-04-27 01:58:47 +00:00
|
|
|
|
2012-09-18 14:54:55 +00:00
|
|
|
double diff_accepted;
|
|
|
|
double diff_rejected;
|
|
|
|
double diff_stale;
|
|
|
|
|
2011-07-18 14:09:45 +00:00
|
|
|
bool submit_fail;
|
2011-07-19 23:31:45 +00:00
|
|
|
bool idle;
|
2011-08-23 01:40:48 +00:00
|
|
|
bool lagging;
|
2011-07-19 03:01:08 +00:00
|
|
|
bool probed;
|
2012-05-04 10:10:38 +00:00
|
|
|
enum pool_enable enabled;
|
2012-02-06 07:12:22 +00:00
|
|
|
bool submit_old;
|
2012-04-27 01:58:47 +00:00
|
|
|
bool removed;
|
2012-04-27 03:11:19 +00:00
|
|
|
bool lp_started;
|
2011-08-17 02:43:39 +00:00
|
|
|
|
|
|
|
char *hdr_path;
|
2012-02-19 10:28:23 +00:00
|
|
|
char *lp_url;
|
2011-08-17 02:43:39 +00:00
|
|
|
|
2011-07-18 14:09:45 +00:00
|
|
|
unsigned int getwork_requested;
|
|
|
|
unsigned int stale_shares;
|
|
|
|
unsigned int discarded_work;
|
2011-09-02 00:37:00 +00:00
|
|
|
unsigned int getfail_occasions;
|
2011-07-18 14:09:45 +00:00
|
|
|
unsigned int remotefail_occasions;
|
2011-07-20 03:07:41 +00:00
|
|
|
struct timeval tv_idle;
|
2011-07-18 14:09:45 +00:00
|
|
|
|
2012-08-18 05:27:53 +00:00
|
|
|
double utility;
|
|
|
|
int last_shares, shares;
|
|
|
|
|
2012-11-01 02:06:34 +00:00
|
|
|
char *rpc_req;
|
2011-07-18 14:09:45 +00:00
|
|
|
char *rpc_url;
|
|
|
|
char *rpc_userpass;
|
|
|
|
char *rpc_user, *rpc_pass;
|
2013-09-21 12:49:28 +00:00
|
|
|
proxytypes_t rpc_proxytype;
|
2012-09-11 21:44:00 +00:00
|
|
|
char *rpc_proxy;
|
2011-07-18 23:54:50 +00:00
|
|
|
|
|
|
|
pthread_mutex_t pool_lock;
|
2013-03-12 11:31:45 +00:00
|
|
|
cglock_t data_lock;
|
2012-04-26 13:29:21 +00:00
|
|
|
|
|
|
|
struct thread_q *submit_q;
|
|
|
|
struct thread_q *getwork_q;
|
|
|
|
|
2012-04-27 01:58:47 +00:00
|
|
|
pthread_t longpoll_thread;
|
2013-03-09 00:33:50 +00:00
|
|
|
pthread_t test_thread;
|
|
|
|
bool testing;
|
2012-05-01 09:59:37 +00:00
|
|
|
|
2012-05-02 23:24:25 +00:00
|
|
|
int curls;
|
2012-05-02 22:56:42 +00:00
|
|
|
pthread_cond_t cr_cond;
|
2012-05-01 09:59:37 +00:00
|
|
|
struct list_head curlring;
|
2012-05-03 14:13:42 +00:00
|
|
|
|
|
|
|
time_t last_share_time;
|
2012-09-18 15:14:43 +00:00
|
|
|
double last_share_diff;
|
2013-01-02 10:51:09 +00:00
|
|
|
uint64_t best_diff;
|
2012-05-05 05:04:15 +00:00
|
|
|
|
|
|
|
struct cgminer_stats cgminer_stats;
|
2012-06-10 01:19:21 +00:00
|
|
|
struct cgminer_pool_stats cgminer_pool_stats;
|
2012-09-24 06:50:04 +00:00
|
|
|
|
2012-09-26 06:49:51 +00:00
|
|
|
/* Stratum variables */
|
2012-09-29 04:16:16 +00:00
|
|
|
char *stratum_url;
|
2012-10-05 02:37:29 +00:00
|
|
|
char *stratum_port;
|
2013-05-08 11:59:58 +00:00
|
|
|
struct addrinfo stratum_hints;
|
2012-09-24 06:50:04 +00:00
|
|
|
SOCKETTYPE sock;
|
2012-12-29 00:29:59 +00:00
|
|
|
char *sockbuf;
|
|
|
|
size_t sockbuf_size;
|
2012-10-01 14:00:55 +00:00
|
|
|
char *sockaddr_url; /* stripped url used for sockaddr */
|
2013-09-05 13:14:53 +00:00
|
|
|
char *sockaddr_proxy_url;
|
|
|
|
char *sockaddr_proxy_port;
|
|
|
|
|
2012-09-26 06:49:51 +00:00
|
|
|
char *nonce1;
|
2013-08-11 04:06:17 +00:00
|
|
|
unsigned char *nonce1bin;
|
2013-02-04 00:19:12 +00:00
|
|
|
size_t n1_len;
|
2012-09-28 16:16:22 +00:00
|
|
|
uint32_t nonce2;
|
2012-09-28 15:03:23 +00:00
|
|
|
int n2size;
|
2013-02-15 03:46:30 +00:00
|
|
|
char *sessionid;
|
2012-09-26 23:06:56 +00:00
|
|
|
bool has_stratum;
|
|
|
|
bool stratum_active;
|
2013-03-08 04:18:10 +00:00
|
|
|
bool stratum_init;
|
2012-12-28 22:45:40 +00:00
|
|
|
bool stratum_notify;
|
2012-09-27 03:26:09 +00:00
|
|
|
struct stratum_work swork;
|
2013-05-19 01:25:45 +00:00
|
|
|
pthread_t stratum_sthread;
|
|
|
|
pthread_t stratum_rthread;
|
2012-10-05 02:37:29 +00:00
|
|
|
pthread_mutex_t stratum_lock;
|
2013-05-19 01:25:45 +00:00
|
|
|
struct thread_q *stratum_q;
|
2013-03-06 03:34:17 +00:00
|
|
|
int sshares; /* stratum shares submitted waiting on response */
|
2012-11-01 02:53:12 +00:00
|
|
|
|
|
|
|
/* GBT variables */
|
|
|
|
bool has_gbt;
|
2013-03-12 11:44:41 +00:00
|
|
|
cglock_t gbt_lock;
|
2012-11-04 04:28:13 +00:00
|
|
|
unsigned char previousblockhash[32];
|
|
|
|
unsigned char gbt_target[32];
|
2012-11-01 05:56:54 +00:00
|
|
|
char *coinbasetxn;
|
|
|
|
char *longpollid;
|
2012-11-18 10:48:44 +00:00
|
|
|
char *gbt_workid;
|
2012-11-01 05:56:54 +00:00
|
|
|
int gbt_expires;
|
|
|
|
uint32_t gbt_version;
|
|
|
|
uint32_t curtime;
|
2012-11-04 04:28:13 +00:00
|
|
|
uint32_t gbt_bits;
|
2012-11-03 02:27:41 +00:00
|
|
|
unsigned char *txn_hashes;
|
|
|
|
int gbt_txns;
|
2012-11-03 08:45:37 +00:00
|
|
|
int coinbase_len;
|
2013-08-11 15:15:22 +00:00
|
|
|
|
2013-08-12 00:49:38 +00:00
|
|
|
/* Shared by both stratum & GBT */
|
2013-08-12 00:58:43 +00:00
|
|
|
unsigned char *coinbase;
|
2013-08-12 00:49:38 +00:00
|
|
|
int nonce2_offset;
|
2013-08-12 19:49:32 +00:00
|
|
|
unsigned char header_bin[128];
|
|
|
|
int merkle_offset;
|
2013-08-12 00:58:43 +00:00
|
|
|
|
2012-11-07 12:28:49 +00:00
|
|
|
struct timeval tv_lastwork;
|
2011-07-18 14:09:45 +00:00
|
|
|
};
|
|
|
|
|
2012-09-15 21:57:43 +00:00
|
|
|
#define GETWORK_MODE_TESTPOOL 'T'
|
|
|
|
#define GETWORK_MODE_POOL 'P'
|
|
|
|
#define GETWORK_MODE_LP 'L'
|
|
|
|
#define GETWORK_MODE_BENCHMARK 'B'
|
2012-09-29 03:07:00 +00:00
|
|
|
#define GETWORK_MODE_STRATUM 'S'
|
2012-11-03 14:07:01 +00:00
|
|
|
#define GETWORK_MODE_GBT 'G'
|
2012-09-15 21:57:43 +00:00
|
|
|
|
2011-06-27 01:31:05 +00:00
|
|
|
struct work {
|
|
|
|
unsigned char data[128];
|
|
|
|
unsigned char midstate[32];
|
|
|
|
unsigned char target[32];
|
|
|
|
unsigned char hash[32];
|
|
|
|
|
2013-05-11 10:29:48 +00:00
|
|
|
#ifdef USE_SCRYPT
|
|
|
|
unsigned char device_target[32];
|
|
|
|
#endif
|
2013-04-08 11:26:10 +00:00
|
|
|
double device_diff;
|
|
|
|
uint64_t share_diff;
|
2013-09-26 11:14:14 +00:00
|
|
|
unsigned char hash2[32];
|
2013-03-16 23:15:24 +00:00
|
|
|
|
2011-07-22 10:06:06 +00:00
|
|
|
int rolls;
|
|
|
|
|
2011-07-18 14:09:45 +00:00
|
|
|
dev_blk_ctx blk;
|
2011-06-28 23:22:21 +00:00
|
|
|
|
2011-07-29 01:11:42 +00:00
|
|
|
struct thr_info *thr;
|
2011-07-18 14:09:45 +00:00
|
|
|
int thr_id;
|
|
|
|
struct pool *pool;
|
2011-07-26 10:48:05 +00:00
|
|
|
struct timeval tv_staged;
|
2012-05-30 22:41:56 +00:00
|
|
|
|
2011-08-14 03:57:58 +00:00
|
|
|
bool mined;
|
2011-07-26 10:48:05 +00:00
|
|
|
bool clone;
|
|
|
|
bool cloned;
|
2012-06-23 13:43:22 +00:00
|
|
|
int rolltime;
|
2012-02-19 11:15:55 +00:00
|
|
|
bool longpoll;
|
2012-05-30 22:41:56 +00:00
|
|
|
bool stale;
|
2012-06-14 05:42:43 +00:00
|
|
|
bool mandatory;
|
|
|
|
bool block;
|
2012-08-15 23:19:45 +00:00
|
|
|
bool queued;
|
2012-09-29 05:02:23 +00:00
|
|
|
|
2012-09-29 03:07:00 +00:00
|
|
|
bool stratum;
|
2012-11-23 23:47:20 +00:00
|
|
|
char *job_id;
|
2013-08-12 20:09:42 +00:00
|
|
|
uint32_t nonce2;
|
|
|
|
size_t nonce2_len;
|
2012-11-23 23:47:20 +00:00
|
|
|
char *ntime;
|
2012-11-14 22:18:58 +00:00
|
|
|
double sdiff;
|
2013-02-22 01:55:01 +00:00
|
|
|
char *nonce1;
|
2011-08-23 22:06:15 +00:00
|
|
|
|
2012-11-01 03:05:25 +00:00
|
|
|
bool gbt;
|
2013-08-12 01:40:17 +00:00
|
|
|
char *coinbase;
|
2012-11-04 07:01:09 +00:00
|
|
|
int gbt_txns;
|
2012-11-01 03:05:25 +00:00
|
|
|
|
2011-11-01 04:19:26 +00:00
|
|
|
unsigned int work_block;
|
2011-08-23 22:06:15 +00:00
|
|
|
int id;
|
2012-09-18 01:19:57 +00:00
|
|
|
UT_hash_handle hh;
|
|
|
|
|
|
|
|
double work_difficulty;
|
2012-04-25 01:46:48 +00:00
|
|
|
|
2013-04-01 22:50:05 +00:00
|
|
|
// Allow devices to identify work if multiple sub-devices
|
|
|
|
int subid;
|
|
|
|
// Allow devices to flag work for their own purposes
|
|
|
|
bool devflag;
|
|
|
|
|
2012-09-15 21:57:43 +00:00
|
|
|
struct timeval tv_getwork;
|
|
|
|
struct timeval tv_getwork_reply;
|
|
|
|
struct timeval tv_cloned;
|
|
|
|
struct timeval tv_work_start;
|
|
|
|
struct timeval tv_work_found;
|
|
|
|
char getwork_mode;
|
2011-06-27 01:31:05 +00:00
|
|
|
};
|
|
|
|
|
2012-06-13 16:57:37 +00:00
|
|
|
#ifdef USE_MODMINER
|
|
|
|
struct modminer_fpga_state {
|
|
|
|
bool work_running;
|
|
|
|
struct work running_work;
|
|
|
|
struct timeval tv_workstart;
|
|
|
|
uint32_t hashes;
|
|
|
|
|
|
|
|
char next_work_cmd[46];
|
2012-12-02 10:48:37 +00:00
|
|
|
char fpgaid;
|
2012-06-13 16:57:37 +00:00
|
|
|
|
2012-12-02 10:48:37 +00:00
|
|
|
bool overheated;
|
|
|
|
bool new_work;
|
2012-06-13 16:57:37 +00:00
|
|
|
|
2012-10-16 22:56:42 +00:00
|
|
|
uint32_t shares;
|
|
|
|
uint32_t shares_last_hw;
|
|
|
|
uint32_t hw_errors;
|
|
|
|
uint32_t shares_to_good;
|
2012-12-17 02:21:24 +00:00
|
|
|
uint32_t timeout_fail;
|
2012-12-17 02:20:10 +00:00
|
|
|
uint32_t success_more;
|
2012-10-16 22:56:42 +00:00
|
|
|
struct timeval last_changed;
|
2012-12-12 06:01:28 +00:00
|
|
|
struct timeval last_nonce;
|
|
|
|
struct timeval first_work;
|
|
|
|
bool death_stage_one;
|
|
|
|
bool tried_two_byte_temp;
|
|
|
|
bool one_byte_temp;
|
2012-06-13 16:57:37 +00:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2013-07-06 09:15:59 +00:00
|
|
|
#define TAILBUFSIZ 64
|
|
|
|
|
|
|
|
#define tailsprintf(buf, bufsiz, fmt, ...) do { \
|
|
|
|
char tmp13[TAILBUFSIZ]; \
|
|
|
|
size_t len13, buflen = strlen(buf); \
|
|
|
|
snprintf(tmp13, sizeof(tmp13), fmt, ##__VA_ARGS__); \
|
|
|
|
len13 = strlen(tmp13); \
|
|
|
|
if ((buflen + len13) >= bufsiz) \
|
|
|
|
quit(1, "tailsprintf buffer overflow in %s %s line %d", __FILE__, __func__, __LINE__); \
|
|
|
|
strcat(buf, tmp13); \
|
|
|
|
} while (0)
|
|
|
|
|
2013-07-06 10:17:17 +00:00
|
|
|
extern void get_datestamp(char *, size_t, struct timeval *);
|
2013-04-18 04:47:46 +00:00
|
|
|
extern void inc_hw_errors(struct thr_info *thr);
|
2013-09-25 05:30:54 +00:00
|
|
|
extern bool test_nonce(struct work *work, uint32_t nonce);
|
2013-09-26 11:20:59 +00:00
|
|
|
extern void submit_tested_work(struct thr_info *thr, struct work *work);
|
2013-05-26 10:59:40 +00:00
|
|
|
extern bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce);
|
2013-10-04 11:39:42 +00:00
|
|
|
extern bool submit_noffset_nonce(struct thr_info *thr, struct work *work, uint32_t nonce,
|
|
|
|
int noffset);
|
2013-02-18 03:14:10 +00:00
|
|
|
extern struct work *get_queued(struct cgpu_info *cgpu);
|
2013-04-01 02:10:15 +00:00
|
|
|
extern struct work *__find_work_bymidstate(struct work *que, char *midstate, size_t midstatelen, char *data, int offset, size_t datalen);
|
2013-03-31 13:38:19 +00:00
|
|
|
extern struct work *find_queued_work_bymidstate(struct cgpu_info *cgpu, char *midstate, size_t midstatelen, char *data, int offset, size_t datalen);
|
2013-08-14 12:59:57 +00:00
|
|
|
extern struct work *clone_queued_work_bymidstate(struct cgpu_info *cgpu, char *midstate, size_t midstatelen, char *data, int offset, size_t datalen);
|
2013-02-16 01:28:50 +00:00
|
|
|
extern void work_completed(struct cgpu_info *cgpu, struct work *work);
|
2013-08-27 10:29:47 +00:00
|
|
|
extern struct work *take_queued_work_bymidstate(struct cgpu_info *cgpu, char *midstate, size_t midstatelen, char *data, int offset, size_t datalen);
|
2013-02-16 03:09:44 +00:00
|
|
|
extern void hash_queued_work(struct thr_info *mythr);
|
2013-06-15 12:03:56 +00:00
|
|
|
extern void _wlog(const char *str);
|
|
|
|
extern void _wlogprint(const char *str);
|
2011-09-03 03:02:21 +00:00
|
|
|
extern int curses_int(const char *query);
|
|
|
|
extern char *curses_input(const char *query);
|
2011-07-14 12:16:06 +00:00
|
|
|
extern void kill_work(void);
|
2012-01-22 07:24:55 +00:00
|
|
|
extern void switch_pools(struct pool *selected);
|
2013-03-09 04:12:41 +00:00
|
|
|
extern void discard_work(struct work *work);
|
2012-04-20 17:15:41 +00:00
|
|
|
extern void remove_pool(struct pool *pool);
|
2012-01-22 07:24:55 +00:00
|
|
|
extern void write_config(FILE *fcfg);
|
2013-01-10 00:08:12 +00:00
|
|
|
extern void zero_bestshare(void);
|
|
|
|
extern void zero_stats(void);
|
2012-05-31 13:18:55 +00:00
|
|
|
extern void default_save_file(char *filename);
|
2013-06-15 12:03:56 +00:00
|
|
|
extern bool log_curses_only(int prio, const char *datetime, const char *str);
|
2011-09-17 03:23:58 +00:00
|
|
|
extern void clear_logwin(void);
|
2013-05-19 11:28:53 +00:00
|
|
|
extern void logwin_update(void);
|
2012-02-20 22:20:31 +00:00
|
|
|
extern bool pool_tclear(struct pool *pool, bool *var);
|
2011-03-15 03:17:34 +00:00
|
|
|
extern struct thread_q *tq_new(void);
|
|
|
|
extern void tq_free(struct thread_q *tq);
|
|
|
|
extern bool tq_push(struct thread_q *tq, void *data);
|
|
|
|
extern void *tq_pop(struct thread_q *tq, const struct timespec *abstime);
|
|
|
|
extern void tq_freeze(struct thread_q *tq);
|
|
|
|
extern void tq_thaw(struct thread_q *tq);
|
2011-07-14 12:16:06 +00:00
|
|
|
extern bool successful_connect;
|
2011-09-03 00:53:35 +00:00
|
|
|
extern void adl(void);
|
2012-04-14 07:38:31 +00:00
|
|
|
extern void app_restart(void);
|
2012-11-23 23:47:20 +00:00
|
|
|
extern void clean_work(struct work *work);
|
|
|
|
extern void free_work(struct work *work);
|
|
|
|
extern struct work *copy_work(struct work *base_work);
|
2013-02-03 12:41:41 +00:00
|
|
|
extern struct thr_info *get_thread(int thr_id);
|
2013-02-07 15:12:09 +00:00
|
|
|
extern struct cgpu_info *get_devices(int id);
|
2011-03-15 03:17:34 +00:00
|
|
|
|
2012-06-29 16:49:01 +00:00
|
|
|
enum api_data_type {
|
|
|
|
API_ESCAPE,
|
|
|
|
API_STRING,
|
2012-06-30 02:44:57 +00:00
|
|
|
API_CONST,
|
2012-06-29 16:49:01 +00:00
|
|
|
API_INT,
|
|
|
|
API_UINT,
|
2012-06-30 02:44:57 +00:00
|
|
|
API_UINT32,
|
2012-06-29 16:49:01 +00:00
|
|
|
API_UINT64,
|
|
|
|
API_DOUBLE,
|
2012-06-30 13:41:22 +00:00
|
|
|
API_ELAPSED,
|
2012-06-29 16:49:01 +00:00
|
|
|
API_BOOL,
|
|
|
|
API_TIMEVAL,
|
|
|
|
API_TIME,
|
|
|
|
API_MHS,
|
|
|
|
API_MHTOTAL,
|
|
|
|
API_TEMP,
|
|
|
|
API_UTILITY,
|
2012-06-30 02:44:57 +00:00
|
|
|
API_FREQ,
|
2012-06-29 16:49:01 +00:00
|
|
|
API_VOLTS,
|
2012-09-18 14:54:55 +00:00
|
|
|
API_HS,
|
2013-08-14 00:42:52 +00:00
|
|
|
API_DIFF,
|
|
|
|
API_PERCENT
|
2012-06-29 16:49:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct api_data {
|
|
|
|
enum api_data_type type;
|
|
|
|
char *name;
|
|
|
|
void *data;
|
|
|
|
bool data_was_malloc;
|
|
|
|
struct api_data *prev;
|
|
|
|
struct api_data *next;
|
|
|
|
};
|
|
|
|
|
2012-06-30 02:44:57 +00:00
|
|
|
extern struct api_data *api_add_escape(struct api_data *root, char *name, char *data, bool copy_data);
|
|
|
|
extern struct api_data *api_add_string(struct api_data *root, char *name, char *data, bool copy_data);
|
|
|
|
extern struct api_data *api_add_const(struct api_data *root, char *name, const char *data, bool copy_data);
|
|
|
|
extern struct api_data *api_add_int(struct api_data *root, char *name, int *data, bool copy_data);
|
|
|
|
extern struct api_data *api_add_uint(struct api_data *root, char *name, unsigned int *data, bool copy_data);
|
|
|
|
extern struct api_data *api_add_uint32(struct api_data *root, char *name, uint32_t *data, bool copy_data);
|
|
|
|
extern struct api_data *api_add_uint64(struct api_data *root, char *name, uint64_t *data, bool copy_data);
|
|
|
|
extern struct api_data *api_add_double(struct api_data *root, char *name, double *data, bool copy_data);
|
2012-06-30 13:41:22 +00:00
|
|
|
extern struct api_data *api_add_elapsed(struct api_data *root, char *name, double *data, bool copy_data);
|
2012-06-30 02:44:57 +00:00
|
|
|
extern struct api_data *api_add_bool(struct api_data *root, char *name, bool *data, bool copy_data);
|
|
|
|
extern struct api_data *api_add_timeval(struct api_data *root, char *name, struct timeval *data, bool copy_data);
|
|
|
|
extern struct api_data *api_add_time(struct api_data *root, char *name, time_t *data, bool copy_data);
|
|
|
|
extern struct api_data *api_add_mhs(struct api_data *root, char *name, double *data, bool copy_data);
|
|
|
|
extern struct api_data *api_add_mhstotal(struct api_data *root, char *name, double *data, bool copy_data);
|
|
|
|
extern struct api_data *api_add_temp(struct api_data *root, char *name, float *data, bool copy_data);
|
|
|
|
extern struct api_data *api_add_utility(struct api_data *root, char *name, double *data, bool copy_data);
|
|
|
|
extern struct api_data *api_add_freq(struct api_data *root, char *name, double *data, bool copy_data);
|
|
|
|
extern struct api_data *api_add_volts(struct api_data *root, char *name, float *data, bool copy_data);
|
|
|
|
extern struct api_data *api_add_hs(struct api_data *root, char *name, double *data, bool copy_data);
|
2012-09-18 14:54:55 +00:00
|
|
|
extern struct api_data *api_add_diff(struct api_data *root, char *name, double *data, bool copy_data);
|
2013-08-21 10:46:07 +00:00
|
|
|
extern struct api_data *api_add_percent(struct api_data *root, char *name, double *data, bool copy_data);
|
2012-06-29 16:49:01 +00:00
|
|
|
|
2010-11-25 09:03:59 +00:00
|
|
|
#endif /* __MINER_H__ */
|