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>
|
2011-02-10 05:41:44 +00:00
|
|
|
#include <curl/curl.h>
|
2011-08-23 22:06:15 +00:00
|
|
|
#include "elist.h"
|
|
|
|
#include "uthash.h"
|
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
|
|
|
|
|
2011-09-03 00:53:35 +00:00
|
|
|
#if defined (__linux)
|
|
|
|
#ifndef LINUX
|
|
|
|
#define LINUX
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_ADL
|
|
|
|
#include "ADL_SDK/adl_sdk.h"
|
|
|
|
#endif
|
2011-03-18 21:24:16 +00:00
|
|
|
|
2010-11-27 05:46:59 +00:00
|
|
|
#ifdef __SSE2__
|
|
|
|
#define WANT_SSE2_4WAY 1
|
|
|
|
#endif
|
|
|
|
|
2011-10-09 01:22:00 +00:00
|
|
|
#ifdef __ALTIVEC__
|
|
|
|
#define WANT_ALTIVEC_4WAY 1
|
|
|
|
#endif
|
|
|
|
|
2011-08-29 00:12:34 +00:00
|
|
|
#if defined(__i386__) && defined(HAS_YASM) && defined(__SSE2__)
|
2011-08-25 01:19:40 +00:00
|
|
|
#define WANT_X8632_SSE2 1
|
|
|
|
#endif
|
|
|
|
|
2011-11-11 08:35:41 +00:00
|
|
|
#if (defined(__i386__) || defined(__x86_64__)) && !defined(__APPLE__)
|
2010-11-27 06:29:56 +00:00
|
|
|
#define WANT_VIA_PADLOCK 1
|
|
|
|
#endif
|
|
|
|
|
2011-07-23 06:19:51 +00:00
|
|
|
#if defined(__x86_64__) && defined(HAS_YASM)
|
2011-03-06 03:22:57 +00:00
|
|
|
#define WANT_X8664_SSE2 1
|
|
|
|
#endif
|
|
|
|
|
2011-07-23 06:19:51 +00:00
|
|
|
#if defined(__x86_64__) && defined(HAS_YASM)
|
2011-07-18 01:27:58 +00:00
|
|
|
#define WANT_X8664_SSE4 1
|
|
|
|
#endif
|
|
|
|
|
2011-07-09 02:39:08 +00:00
|
|
|
#if !defined(WIN32) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
|
2011-09-26 23:33:28 +00:00
|
|
|
#define bswap_16 __builtin_bswap16
|
|
|
|
#define bswap_32 __builtin_bswap32
|
|
|
|
#define bswap_64 __builtin_bswap64
|
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
|
|
|
|
2011-07-09 00:18:29 +00:00
|
|
|
/* This assumes htobe32 is a macro in endian.h */
|
|
|
|
#ifndef htobe32
|
|
|
|
# if __BYTE_ORDER == __LITTLE_ENDIAN
|
|
|
|
# define be32toh(x) bswap_32(x)
|
|
|
|
# define htobe32(x) bswap_32(x)
|
|
|
|
# elif __BYTE_ORDER == __BIG_ENDIAN
|
|
|
|
# define be32toh(x) (x)
|
|
|
|
# define htobe32(x) (x)
|
|
|
|
#else
|
|
|
|
#error UNKNOWN BYTE ORDER
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2011-03-18 21:24:16 +00:00
|
|
|
#ifdef HAVE_SYSLOG_H
|
|
|
|
#include <syslog.h>
|
|
|
|
#else
|
|
|
|
enum {
|
2011-03-21 08:02:13 +00:00
|
|
|
LOG_ERR,
|
|
|
|
LOG_WARNING,
|
2011-09-17 03:23:58 +00:00
|
|
|
LOG_NOTICE,
|
2011-03-18 21:24:16 +00:00
|
|
|
LOG_INFO,
|
2011-03-21 08:02:13 +00:00
|
|
|
LOG_DEBUG,
|
2011-03-18 21:24:16 +00:00
|
|
|
};
|
|
|
|
#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
|
|
|
|
|
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
|
|
|
|
|
2011-11-23 06:01:45 +00:00
|
|
|
enum sha256_algos {
|
|
|
|
ALGO_C, /* plain C */
|
|
|
|
ALGO_4WAY, /* parallel SSE2 */
|
|
|
|
ALGO_VIA, /* VIA padlock */
|
|
|
|
ALGO_CRYPTOPP, /* Crypto++ (C) */
|
|
|
|
ALGO_CRYPTOPP_ASM32, /* Crypto++ 32-bit assembly */
|
|
|
|
ALGO_SSE2_32, /* SSE2 for x86_32 */
|
|
|
|
ALGO_SSE2_64, /* SSE2 for x86_64 */
|
|
|
|
ALGO_SSE4_64, /* SSE4 for x86_64 */
|
|
|
|
ALGO_ALTIVEC_4WAY, /* parallel Altivec */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-07-29 15:23:17 +00:00
|
|
|
enum alive {
|
|
|
|
LIFE_WELL,
|
|
|
|
LIFE_SICK,
|
|
|
|
LIFE_DEAD,
|
2011-09-11 00:48:39 +00:00
|
|
|
LIFE_NOSTART
|
2011-07-29 15:23:17 +00:00
|
|
|
};
|
|
|
|
|
2011-09-03 00:53:35 +00:00
|
|
|
#ifdef HAVE_ADL
|
|
|
|
struct gpu_adl {
|
|
|
|
ADLTemperature lpTemperature;
|
|
|
|
int iAdapterIndex;
|
|
|
|
int lpAdapterID;
|
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
|
|
|
|
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;
|
2011-09-07 00:43:26 +00:00
|
|
|
int cutofftemp;
|
2011-09-03 05:33:53 +00:00
|
|
|
int minspeed;
|
|
|
|
int maxspeed;
|
2011-09-03 00:53:35 +00:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2011-06-29 00:12:00 +00:00
|
|
|
struct cgpu_info {
|
|
|
|
int is_gpu;
|
|
|
|
int cpu_gpu;
|
|
|
|
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
|
|
|
|
2011-09-26 05:24:20 +00:00
|
|
|
bool dynamic;
|
|
|
|
int intensity;
|
2011-09-03 00:53:35 +00:00
|
|
|
#ifdef HAVE_ADL
|
|
|
|
bool has_adl;
|
|
|
|
struct gpu_adl adl;
|
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
|
2011-06-29 00:12:00 +00:00
|
|
|
};
|
|
|
|
|
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;
|
2011-09-15 01:45:24 +00:00
|
|
|
pthread_t pth;
|
2011-03-18 06:53:13 +00:00
|
|
|
struct thread_q *q;
|
2011-06-29 00:12:00 +00:00
|
|
|
struct cgpu_info *cgpu;
|
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;
|
2011-03-18 06:53:13 +00:00
|
|
|
};
|
|
|
|
|
2011-09-15 00:33:23 +00:00
|
|
|
extern int thr_info_create(struct thr_info *thr, pthread_attr_t *attr, void *(*start) (void *), void *arg);
|
|
|
|
extern void thr_info_cancel(struct thr_info *thr);
|
2011-07-22 13:43:26 +00:00
|
|
|
|
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];
|
|
|
|
}
|
|
|
|
|
2011-07-27 00:31:44 +00:00
|
|
|
extern void quit(int status, const char *format, ...);
|
|
|
|
|
|
|
|
static inline void mutex_lock(pthread_mutex_t *lock)
|
|
|
|
{
|
|
|
|
if (unlikely(pthread_mutex_lock(lock)))
|
|
|
|
quit(1, "WTF MUTEX ERROR ON LOCK!");
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void mutex_unlock(pthread_mutex_t *lock)
|
|
|
|
{
|
|
|
|
if (unlikely(pthread_mutex_unlock(lock)))
|
|
|
|
quit(1, "WTF MUTEX ERROR ON UNLOCK!");
|
|
|
|
}
|
|
|
|
|
2011-08-24 11:50:04 +00:00
|
|
|
static inline void wr_lock(pthread_rwlock_t *lock)
|
|
|
|
{
|
|
|
|
if (unlikely(pthread_rwlock_wrlock(lock)))
|
|
|
|
quit(1, "WTF WRLOCK ERROR ON LOCK!");
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void rd_lock(pthread_rwlock_t *lock)
|
|
|
|
{
|
|
|
|
if (unlikely(pthread_rwlock_rdlock(lock)))
|
|
|
|
quit(1, "WTF RDLOCK ERROR ON LOCK!");
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void rw_unlock(pthread_rwlock_t *lock)
|
|
|
|
{
|
|
|
|
if (unlikely(pthread_rwlock_unlock(lock)))
|
|
|
|
quit(1, "WTF RWLOCK ERROR ON UNLOCK!");
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void rd_unlock(pthread_rwlock_t *lock)
|
|
|
|
{
|
|
|
|
rw_unlock(lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void wr_unlock(pthread_rwlock_t *lock)
|
|
|
|
{
|
|
|
|
rw_unlock(lock);
|
|
|
|
}
|
|
|
|
|
2011-07-19 01:45:58 +00:00
|
|
|
struct pool;
|
|
|
|
|
2010-11-27 06:29:56 +00:00
|
|
|
extern bool opt_debug;
|
2010-11-25 09:03:59 +00:00
|
|
|
extern bool opt_protocol;
|
2011-07-05 12:04:54 +00:00
|
|
|
extern bool opt_log_output;
|
2011-08-25 04:42:03 +00:00
|
|
|
extern char *opt_kernel_path;
|
2011-09-06 00:11:34 +00:00
|
|
|
extern char *cgminer_path;
|
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;
|
2011-11-23 11:22:10 +00:00
|
|
|
extern int opt_api_port;
|
|
|
|
extern bool opt_api_listen;
|
2011-09-03 05:46:57 +00:00
|
|
|
|
2010-11-27 06:29:56 +00:00
|
|
|
extern const uint32_t sha256_init_state[];
|
2011-02-10 05:41:44 +00:00
|
|
|
extern json_t *json_rpc_call(CURL *curl, const char *url, const char *userpass,
|
2011-08-13 15:54:47 +00:00
|
|
|
const char *rpc_req, bool, bool, bool *,
|
|
|
|
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);
|
|
|
|
|
2011-03-18 02:02:28 +00:00
|
|
|
extern unsigned int ScanHash_4WaySSE2(int, const unsigned char *pmidstate,
|
2010-11-27 00:04:48 +00:00
|
|
|
unsigned char *pdata, unsigned char *phash1, unsigned char *phash,
|
2011-02-03 05:46:55 +00:00
|
|
|
const unsigned char *ptarget,
|
2011-07-03 09:10:59 +00:00
|
|
|
uint32_t max_nonce, unsigned long *nHashesDone, uint32_t nonce);
|
2011-03-06 03:22:57 +00:00
|
|
|
|
2011-10-09 01:22:00 +00:00
|
|
|
extern unsigned int ScanHash_altivec_4way(int thr_id, const unsigned char *pmidstate,
|
|
|
|
unsigned char *pdata,
|
|
|
|
unsigned char *phash1, unsigned char *phash,
|
|
|
|
const unsigned char *ptarget,
|
|
|
|
uint32_t max_nonce, unsigned long *nHashesDone, uint32_t nonce);
|
|
|
|
|
2011-03-18 02:02:28 +00:00
|
|
|
extern unsigned int scanhash_sse2_amd64(int, const unsigned char *pmidstate,
|
2011-03-06 03:22:57 +00:00
|
|
|
unsigned char *pdata, unsigned char *phash1, unsigned char *phash,
|
|
|
|
const unsigned char *ptarget,
|
|
|
|
uint32_t max_nonce, unsigned long *nHashesDone);
|
2010-11-27 04:12:24 +00:00
|
|
|
|
2011-03-18 02:02:28 +00:00
|
|
|
extern bool scanhash_via(int, unsigned char *data_inout,
|
2011-02-03 05:46:55 +00:00
|
|
|
const unsigned char *target,
|
2011-07-03 09:10:59 +00:00
|
|
|
uint32_t max_nonce, unsigned long *hashes_done, uint32_t n);
|
2010-11-27 09:31:32 +00:00
|
|
|
|
2011-03-18 02:02:28 +00:00
|
|
|
extern bool scanhash_c(int, const unsigned char *midstate, unsigned char *data,
|
2010-11-27 09:31:32 +00:00
|
|
|
unsigned char *hash1, unsigned char *hash,
|
2011-02-03 05:46:55 +00:00
|
|
|
const unsigned char *target,
|
2011-07-03 09:10:59 +00:00
|
|
|
uint32_t max_nonce, unsigned long *hashes_done, uint32_t n);
|
2011-10-09 01:22:00 +00:00
|
|
|
|
2011-03-18 02:02:28 +00:00
|
|
|
extern bool scanhash_cryptopp(int, const unsigned char *midstate,unsigned char *data,
|
2010-11-29 01:16:22 +00:00
|
|
|
unsigned char *hash1, unsigned char *hash,
|
2011-02-03 05:46:55 +00:00
|
|
|
const unsigned char *target,
|
2011-07-03 09:10:59 +00:00
|
|
|
uint32_t max_nonce, unsigned long *hashes_done, uint32_t n);
|
2011-10-09 01:22:00 +00:00
|
|
|
|
2011-03-18 02:02:28 +00:00
|
|
|
extern bool scanhash_asm32(int, const unsigned char *midstate,unsigned char *data,
|
2010-12-07 01:14:58 +00:00
|
|
|
unsigned char *hash1, unsigned char *hash,
|
2011-02-03 05:46:55 +00:00
|
|
|
const unsigned char *target,
|
2011-07-03 14:05:12 +00:00
|
|
|
uint32_t max_nonce, unsigned long *hashes_done, uint32_t nonce);
|
2011-10-09 01:22:00 +00:00
|
|
|
|
2011-03-18 02:02:28 +00:00
|
|
|
extern int scanhash_sse2_64(int, const unsigned char *pmidstate, unsigned char *pdata,
|
2011-03-07 05:23:12 +00:00
|
|
|
unsigned char *phash1, unsigned char *phash,
|
|
|
|
const unsigned char *ptarget,
|
2011-07-03 09:10:59 +00:00
|
|
|
uint32_t max_nonce, unsigned long *nHashesDone,
|
|
|
|
uint32_t nonce);
|
2010-11-27 09:31:32 +00:00
|
|
|
|
2011-07-18 01:27:58 +00:00
|
|
|
extern int scanhash_sse4_64(int, const unsigned char *pmidstate, unsigned char *pdata,
|
|
|
|
unsigned char *phash1, unsigned char *phash,
|
2011-08-25 01:19:40 +00:00
|
|
|
const unsigned char *ptarget,
|
|
|
|
uint32_t max_nonce, unsigned long *nHashesDone,
|
|
|
|
uint32_t nonce);
|
|
|
|
|
|
|
|
extern int scanhash_sse2_32(int, const unsigned char *pmidstate, unsigned char *pdata,
|
|
|
|
unsigned char *phash1, unsigned char *phash,
|
2011-07-18 01:27:58 +00:00
|
|
|
const unsigned char *ptarget,
|
|
|
|
uint32_t max_nonce, unsigned long *nHashesDone,
|
|
|
|
uint32_t nonce);
|
|
|
|
|
2010-11-27 04:12:24 +00:00
|
|
|
extern int
|
|
|
|
timeval_subtract (struct timeval *result, struct timeval *x, struct timeval *y);
|
2010-11-27 00:04:48 +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
|
|
|
|
2011-03-18 06:53:13 +00:00
|
|
|
extern int opt_scantime;
|
2011-03-15 03:17:34 +00:00
|
|
|
|
2011-03-18 02:02:28 +00:00
|
|
|
struct work_restart {
|
|
|
|
volatile unsigned long restart;
|
2011-03-18 03:19:43 +00:00
|
|
|
char padding[128 - sizeof(unsigned long)];
|
2011-03-18 02:02:28 +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-11-29 00:07:27 +00:00
|
|
|
extern float gpu_temp(int gpu);
|
|
|
|
extern int gpu_fanspeed(int gpu);
|
|
|
|
extern int gpu_fanpercent(int gpu);
|
|
|
|
|
2011-11-23 05:25:13 +00:00
|
|
|
extern void api(void);
|
2011-11-23 03:35:49 +00:00
|
|
|
|
2011-09-08 04:44:14 +00:00
|
|
|
|
|
|
|
#define MAX_GPUDEVICES 16
|
2011-11-23 03:35:49 +00:00
|
|
|
#define MAX_POOLS (32)
|
2011-09-08 04:44:14 +00:00
|
|
|
|
2011-11-24 09:41:31 +00:00
|
|
|
extern int nDevs;
|
|
|
|
extern int opt_n_threads;
|
|
|
|
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;
|
2011-03-18 06:53:13 +00:00
|
|
|
extern struct thr_info *thr_info;
|
|
|
|
extern int longpoll_thr_id;
|
2011-03-18 02:02:28 +00:00
|
|
|
extern struct work_restart *work_restart;
|
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;
|
|
|
|
extern double total_secs;
|
|
|
|
extern bool gpu_devices[MAX_GPUDEVICES];
|
|
|
|
extern int mining_threads;
|
|
|
|
extern struct cgpu_info *cpus;
|
|
|
|
extern int total_pools;
|
|
|
|
extern struct pool *pools[MAX_POOLS];
|
2011-11-23 06:01:45 +00:00
|
|
|
extern const char *algo_names[];
|
|
|
|
extern enum sha256_algos opt_algo;
|
|
|
|
extern double total_mhashes_done;
|
|
|
|
extern unsigned int new_blocks;
|
|
|
|
extern unsigned int found_blocks;
|
|
|
|
extern int total_accepted, total_rejected;
|
|
|
|
extern int total_getworks, total_stale, total_discarded;
|
|
|
|
extern unsigned int local_work;
|
|
|
|
extern unsigned int total_go, total_ro;
|
2011-11-24 01:59:30 +00:00
|
|
|
extern int opt_log_interval;
|
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;
|
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
|
|
|
|
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;
|
|
|
|
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;
|
2011-07-21 04:41:12 +00:00
|
|
|
bool enabled;
|
2011-08-17 02:43:39 +00:00
|
|
|
|
|
|
|
char *hdr_path;
|
|
|
|
|
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
|
|
|
|
|
|
|
char *rpc_url;
|
|
|
|
char *rpc_userpass;
|
|
|
|
char *rpc_user, *rpc_pass;
|
2011-07-18 23:54:50 +00:00
|
|
|
|
|
|
|
pthread_mutex_t pool_lock;
|
2011-07-18 14:09:45 +00:00
|
|
|
};
|
|
|
|
|
2011-06-27 01:31:05 +00:00
|
|
|
struct work {
|
|
|
|
unsigned char data[128];
|
|
|
|
unsigned char hash1[64];
|
|
|
|
unsigned char midstate[32];
|
|
|
|
unsigned char target[32];
|
|
|
|
unsigned char hash[32];
|
|
|
|
|
2011-07-22 10:06:06 +00:00
|
|
|
int rolls;
|
|
|
|
|
2011-07-18 14:09:45 +00:00
|
|
|
uint32_t output[1];
|
|
|
|
uint32_t valid;
|
|
|
|
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;
|
2011-08-14 03:57:58 +00:00
|
|
|
bool mined;
|
2011-07-26 10:48:05 +00:00
|
|
|
bool clone;
|
|
|
|
bool cloned;
|
2011-08-13 15:54:47 +00:00
|
|
|
bool rolltime;
|
2011-08-23 22:06:15 +00:00
|
|
|
|
2011-11-01 04:19:26 +00:00
|
|
|
unsigned int work_block;
|
2011-08-23 22:06:15 +00:00
|
|
|
int id;
|
|
|
|
UT_hash_handle hh;
|
2011-06-27 01:31:05 +00:00
|
|
|
};
|
|
|
|
|
2011-07-23 05:15:46 +00:00
|
|
|
enum cl_kernel {
|
|
|
|
KL_NONE,
|
|
|
|
KL_POCLBM,
|
|
|
|
KL_PHATK,
|
|
|
|
};
|
|
|
|
|
2011-06-14 00:32:54 +00:00
|
|
|
bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce);
|
2011-09-03 03:02:21 +00:00
|
|
|
extern void wlogprint(const char *f, ...);
|
|
|
|
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);
|
2011-07-28 00:36:48 +00:00
|
|
|
extern void log_curses(int prio, const char *f, va_list ap);
|
2011-09-17 03:23:58 +00:00
|
|
|
extern void clear_logwin(void);
|
2011-07-06 07:14:36 +00:00
|
|
|
extern void vapplog(int prio, const char *fmt, va_list ap);
|
2011-03-18 21:24:16 +00:00
|
|
|
extern void applog(int prio, const char *fmt, ...);
|
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-07-23 05:15:46 +00:00
|
|
|
extern enum cl_kernel chosen_kernel;
|
2011-09-03 00:53:35 +00:00
|
|
|
extern void adl(void);
|
2011-09-26 08:49:15 +00:00
|
|
|
extern bool get_dondata(char **url, char **userpass);
|
2011-03-15 03:17:34 +00:00
|
|
|
|
2010-11-25 09:03:59 +00:00
|
|
|
#endif /* __MINER_H__ */
|