11
#include <curl/curl.h>
17
#include <OpenCL/opencl.h>
21
#endif /* HAVE_OPENCL */
33
#elif defined __GNUC__
35
# define alloca __builtin_alloca
40
# define alloca __alloca
41
#elif defined _MSC_VER
43
# define alloca _alloca
49
void *alloca (size_t);
60
#include "ADL_SDK/adl_sdk.h"
64
#define WANT_SSE2_4WAY 1
67
#if defined(__i386__) && defined(HAS_YASM) && defined(__SSE2__)
68
#define WANT_X8632_SSE2 1
71
#if defined(__i386__) || defined(__x86_64__)
72
#define WANT_VIA_PADLOCK 1
75
#if defined(__x86_64__) && defined(HAS_YASM)
76
#define WANT_X8664_SSE2 1
79
#if defined(__x86_64__) && defined(HAS_YASM)
80
#define WANT_X8664_SSE4 1
83
#if !defined(WIN32) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
84
#define bswap_16 __builtin_bswap16
85
#define bswap_32 __builtin_bswap32
86
#define bswap_64 __builtin_bswap64
90
#elif defined(USE_SYS_ENDIAN_H)
91
#include <sys/endian.h>
92
#elif defined(__APPLE__)
93
#include <libkern/OSByteOrder.h>
94
#define bswap_16 OSSwapInt16
95
#define bswap_32 OSSwapInt32
96
#define bswap_64 OSSwapInt64
98
#define bswap_16(value) \
99
((((value) & 0xff) << 8) | ((value) >> 8))
101
#define bswap_32(value) \
102
(((uint32_t)bswap_16((uint16_t)((value) & 0xffff)) << 16) | \
103
(uint32_t)bswap_16((uint16_t)((value) >> 16)))
105
#define bswap_64(value) \
106
(((uint64_t)bswap_32((uint32_t)((value) & 0xffffffff)) \
108
(uint64_t)bswap_32((uint32_t)((value) >> 32)))
110
#endif /* !defined(__GLXBYTEORDER_H__) */
112
/* This assumes htobe32 is a macro in endian.h */
114
# if __BYTE_ORDER == __LITTLE_ENDIAN
115
# define be32toh(x) bswap_32(x)
116
# define htobe32(x) bswap_32(x)
117
# elif __BYTE_ORDER == __BIG_ENDIAN
118
# define be32toh(x) (x)
119
# define htobe32(x) (x)
121
#error UNKNOWN BYTE ORDER
139
#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
140
#define unlikely(expr) (__builtin_expect(!!(expr), 0))
141
#define likely(expr) (__builtin_expect(!!(expr), 1))
143
#define unlikely(expr) (expr)
144
#define likely(expr) (expr)
147
#if defined(__i386__)
148
#define WANT_CRYPTOPP_ASM32
152
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
164
ADLTemperature lpTemperature;
168
ADLPMActivity lpActivity;
169
ADLODParameters lpOdParameters;
170
ADLODPerformanceLevels *DefPerfLev;
171
ADLFanSpeedInfo lpFanSpeedInfo;
172
ADLFanSpeedValue lpFanSpeedValue;
173
ADLFanSpeedValue DefFanSpeedValue;
182
bool managed; /* Were the values ever changed on this card */
201
double total_mhashes;
205
struct timeval last_message_tv;
227
pthread_mutex_t mutex;
235
struct cgpu_info *cgpu;
244
extern int thr_info_create(struct thr_info *thr, pthread_attr_t *attr, void *(*start) (void *), void *arg);
245
extern void thr_info_cancel(struct thr_info *thr);
247
static inline uint32_t swab32(uint32_t v)
252
static inline void swap256(void *dest_p, const void *src_p)
254
uint32_t *dest = dest_p;
255
const uint32_t *src = src_p;
267
extern void quit(int status, const char *format, ...);
269
static inline void mutex_lock(pthread_mutex_t *lock)
271
if (unlikely(pthread_mutex_lock(lock)))
272
quit(1, "WTF MUTEX ERROR ON LOCK!");
275
static inline void mutex_unlock(pthread_mutex_t *lock)
277
if (unlikely(pthread_mutex_unlock(lock)))
278
quit(1, "WTF MUTEX ERROR ON UNLOCK!");
281
static inline void wr_lock(pthread_rwlock_t *lock)
283
if (unlikely(pthread_rwlock_wrlock(lock)))
284
quit(1, "WTF WRLOCK ERROR ON LOCK!");
287
static inline void rd_lock(pthread_rwlock_t *lock)
289
if (unlikely(pthread_rwlock_rdlock(lock)))
290
quit(1, "WTF RDLOCK ERROR ON LOCK!");
293
static inline void rw_unlock(pthread_rwlock_t *lock)
295
if (unlikely(pthread_rwlock_unlock(lock)))
296
quit(1, "WTF RWLOCK ERROR ON UNLOCK!");
299
static inline void rd_unlock(pthread_rwlock_t *lock)
304
static inline void wr_unlock(pthread_rwlock_t *lock)
311
extern bool opt_debug;
312
extern bool opt_protocol;
313
extern bool opt_log_output;
314
extern char *opt_kernel_path;
315
extern char *cgminer_path;
316
extern bool opt_autofan;
317
extern bool opt_autoengine;
318
extern bool use_curses;
320
extern const uint32_t sha256_init_state[];
321
extern json_t *json_rpc_call(CURL *curl, const char *url, const char *userpass,
322
const char *rpc_req, bool, bool, bool *,
324
extern char *bin2hex(const unsigned char *p, size_t len);
325
extern bool hex2bin(unsigned char *p, const char *hexstr, size_t len);
327
extern unsigned int ScanHash_4WaySSE2(int, const unsigned char *pmidstate,
328
unsigned char *pdata, unsigned char *phash1, unsigned char *phash,
329
const unsigned char *ptarget,
330
uint32_t max_nonce, unsigned long *nHashesDone, uint32_t nonce);
332
extern unsigned int scanhash_sse2_amd64(int, const unsigned char *pmidstate,
333
unsigned char *pdata, unsigned char *phash1, unsigned char *phash,
334
const unsigned char *ptarget,
335
uint32_t max_nonce, unsigned long *nHashesDone);
337
extern bool scanhash_via(int, unsigned char *data_inout,
338
const unsigned char *target,
339
uint32_t max_nonce, unsigned long *hashes_done, uint32_t n);
341
extern bool scanhash_c(int, const unsigned char *midstate, unsigned char *data,
342
unsigned char *hash1, unsigned char *hash,
343
const unsigned char *target,
344
uint32_t max_nonce, unsigned long *hashes_done, uint32_t n);
345
extern bool scanhash_cryptopp(int, const unsigned char *midstate,unsigned char *data,
346
unsigned char *hash1, unsigned char *hash,
347
const unsigned char *target,
348
uint32_t max_nonce, unsigned long *hashes_done, uint32_t n);
349
extern bool scanhash_asm32(int, const unsigned char *midstate,unsigned char *data,
350
unsigned char *hash1, unsigned char *hash,
351
const unsigned char *target,
352
uint32_t max_nonce, unsigned long *hashes_done, uint32_t nonce);
353
extern int scanhash_sse2_64(int, const unsigned char *pmidstate, unsigned char *pdata,
354
unsigned char *phash1, unsigned char *phash,
355
const unsigned char *ptarget,
356
uint32_t max_nonce, unsigned long *nHashesDone,
359
extern int scanhash_sse4_64(int, const unsigned char *pmidstate, unsigned char *pdata,
360
unsigned char *phash1, unsigned char *phash,
361
const unsigned char *ptarget,
362
uint32_t max_nonce, unsigned long *nHashesDone,
365
extern int scanhash_sse2_32(int, const unsigned char *pmidstate, unsigned char *pdata,
366
unsigned char *phash1, unsigned char *phash,
367
const unsigned char *ptarget,
368
uint32_t max_nonce, unsigned long *nHashesDone,
372
timeval_subtract (struct timeval *result, struct timeval *x, struct timeval *y);
374
extern bool fulltest(const unsigned char *hash, const unsigned char *target);
376
extern int opt_scantime;
378
struct work_restart {
379
volatile unsigned long restart;
380
char padding[128 - sizeof(unsigned long)];
384
#define MAX_GPUDEVICES 16
386
extern int hw_errors;
387
extern bool use_syslog;
388
extern struct thr_info *thr_info;
389
extern int longpoll_thr_id;
390
extern struct work_restart *work_restart;
391
extern struct cgpu_info gpus[MAX_GPUDEVICES];
395
cl_uint ctx_a; cl_uint ctx_b; cl_uint ctx_c; cl_uint ctx_d;
396
cl_uint ctx_e; cl_uint ctx_f; cl_uint ctx_g; cl_uint ctx_h;
397
cl_uint cty_a; cl_uint cty_b; cl_uint cty_c; cl_uint cty_d;
398
cl_uint cty_e; cl_uint cty_f; cl_uint cty_g; cl_uint cty_h;
399
cl_uint merkle; cl_uint ntime; cl_uint nbits; cl_uint nonce;
400
cl_uint fW0; cl_uint fW1; cl_uint fW2; cl_uint fW3; cl_uint fW15;
401
cl_uint fW01r; cl_uint fcty_e; cl_uint fcty_e2;
402
cl_uint W16; cl_uint W17; cl_uint W2;
403
cl_uint PreVal4; cl_uint T1;
404
cl_uint C1addK5; cl_uint D1A; cl_uint W2A; cl_uint W17_2;
405
cl_uint PreVal4addT1; cl_uint T1substate0;
422
int accepted, rejected;
431
unsigned int getwork_requested;
432
unsigned int stale_shares;
433
unsigned int discarded_work;
434
unsigned int getfail_occasions;
435
unsigned int remotefail_occasions;
436
struct timeval tv_idle;
440
char *rpc_user, *rpc_pass;
442
pthread_mutex_t pool_lock;
446
unsigned char data[128];
447
unsigned char hash1[64];
448
unsigned char midstate[32];
449
unsigned char target[32];
450
unsigned char hash[32];
458
struct thr_info *thr;
461
struct timeval tv_staged;
477
bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce);
478
extern void wlogprint(const char *f, ...);
479
extern int curses_int(const char *query);
480
extern char *curses_input(const char *query);
481
extern void kill_work(void);
482
extern void log_curses(int prio, const char *f, va_list ap);
483
extern void clear_logwin(void);
484
extern void vapplog(int prio, const char *fmt, va_list ap);
485
extern void applog(int prio, const char *fmt, ...);
486
extern struct thread_q *tq_new(void);
487
extern void tq_free(struct thread_q *tq);
488
extern bool tq_push(struct thread_q *tq, void *data);
489
extern void *tq_pop(struct thread_q *tq, const struct timespec *abstime);
490
extern void tq_freeze(struct thread_q *tq);
491
extern void tq_thaw(struct thread_q *tq);
492
extern bool successful_connect;
493
extern enum cl_kernel chosen_kernel;
494
extern void adl(void);
495
extern bool get_dondata(char **url, char **userpass);
497
#endif /* __MINER_H__ */