miner.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  1. #ifndef __MINER_H__
  2. #define __MINER_H__
  3. #include "config.h"
  4. #include <stdbool.h>
  5. #include <stdint.h>
  6. #include <sys/time.h>
  7. #include <pthread.h>
  8. #include <jansson.h>
  9. #include <curl/curl.h>
  10. #include "elist.h"
  11. #include "uthash.h"
  12. #ifdef HAVE_OPENCL
  13. #ifdef __APPLE_CC__
  14. #include <OpenCL/opencl.h>
  15. #else
  16. #include <CL/cl.h>
  17. #endif
  18. #endif /* HAVE_OPENCL */
  19. #ifdef STDC_HEADERS
  20. # include <stdlib.h>
  21. # include <stddef.h>
  22. #else
  23. # ifdef HAVE_STDLIB_H
  24. # include <stdlib.h>
  25. # endif
  26. #endif
  27. #ifdef HAVE_ALLOCA_H
  28. # include <alloca.h>
  29. #elif defined __GNUC__
  30. # ifndef WIN32
  31. # define alloca __builtin_alloca
  32. # else
  33. # include <malloc.h>
  34. # endif
  35. #elif defined _AIX
  36. # define alloca __alloca
  37. #elif defined _MSC_VER
  38. # include <malloc.h>
  39. # define alloca _alloca
  40. #else
  41. # ifndef HAVE_ALLOCA
  42. # ifdef __cplusplus
  43. extern "C"
  44. # endif
  45. void *alloca (size_t);
  46. # endif
  47. #endif
  48. #if defined (__linux)
  49. #ifndef LINUX
  50. #define LINUX
  51. #endif
  52. #endif
  53. #ifdef HAVE_ADL
  54. #include "ADL_SDK/adl_sdk.h"
  55. #endif
  56. #ifdef __SSE2__
  57. #define WANT_SSE2_4WAY 1
  58. #endif
  59. #ifdef __ALTIVEC__
  60. #define WANT_ALTIVEC_4WAY 1
  61. #endif
  62. #if defined(__i386__) && defined(HAS_YASM) && defined(__SSE2__)
  63. #define WANT_X8632_SSE2 1
  64. #endif
  65. #if (defined(__i386__) || defined(__x86_64__)) && !defined(__APPLE__)
  66. #define WANT_VIA_PADLOCK 1
  67. #endif
  68. #if defined(__x86_64__) && defined(HAS_YASM)
  69. #define WANT_X8664_SSE2 1
  70. #endif
  71. #if defined(__x86_64__) && defined(HAS_YASM)
  72. #define WANT_X8664_SSE4 1
  73. #endif
  74. #if !defined(WIN32) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
  75. #define bswap_16 __builtin_bswap16
  76. #define bswap_32 __builtin_bswap32
  77. #define bswap_64 __builtin_bswap64
  78. #else
  79. #if HAVE_BYTESWAP_H
  80. #include <byteswap.h>
  81. #elif defined(USE_SYS_ENDIAN_H)
  82. #include <sys/endian.h>
  83. #elif defined(__APPLE__)
  84. #include <libkern/OSByteOrder.h>
  85. #define bswap_16 OSSwapInt16
  86. #define bswap_32 OSSwapInt32
  87. #define bswap_64 OSSwapInt64
  88. #else
  89. #define bswap_16(value) \
  90. ((((value) & 0xff) << 8) | ((value) >> 8))
  91. #define bswap_32(value) \
  92. (((uint32_t)bswap_16((uint16_t)((value) & 0xffff)) << 16) | \
  93. (uint32_t)bswap_16((uint16_t)((value) >> 16)))
  94. #define bswap_64(value) \
  95. (((uint64_t)bswap_32((uint32_t)((value) & 0xffffffff)) \
  96. << 32) | \
  97. (uint64_t)bswap_32((uint32_t)((value) >> 32)))
  98. #endif
  99. #endif /* !defined(__GLXBYTEORDER_H__) */
  100. /* This assumes htobe32 is a macro in endian.h */
  101. #ifndef htobe32
  102. # if __BYTE_ORDER == __LITTLE_ENDIAN
  103. # define be32toh(x) bswap_32(x)
  104. # define htobe32(x) bswap_32(x)
  105. # elif __BYTE_ORDER == __BIG_ENDIAN
  106. # define be32toh(x) (x)
  107. # define htobe32(x) (x)
  108. #else
  109. #error UNKNOWN BYTE ORDER
  110. #endif
  111. #endif
  112. #ifdef HAVE_SYSLOG_H
  113. #include <syslog.h>
  114. #else
  115. enum {
  116. LOG_ERR,
  117. LOG_WARNING,
  118. LOG_NOTICE,
  119. LOG_INFO,
  120. LOG_DEBUG,
  121. };
  122. #endif
  123. #undef unlikely
  124. #undef likely
  125. #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
  126. #define unlikely(expr) (__builtin_expect(!!(expr), 0))
  127. #define likely(expr) (__builtin_expect(!!(expr), 1))
  128. #else
  129. #define unlikely(expr) (expr)
  130. #define likely(expr) (expr)
  131. #endif
  132. #define __maybe_unused __attribute__((unused))
  133. #if defined(__i386__)
  134. #define WANT_CRYPTOPP_ASM32
  135. #endif
  136. #ifndef ARRAY_SIZE
  137. #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
  138. #endif
  139. enum sha256_algos {
  140. ALGO_C, /* plain C */
  141. ALGO_4WAY, /* parallel SSE2 */
  142. ALGO_VIA, /* VIA padlock */
  143. ALGO_CRYPTOPP, /* Crypto++ (C) */
  144. ALGO_CRYPTOPP_ASM32, /* Crypto++ 32-bit assembly */
  145. ALGO_SSE2_32, /* SSE2 for x86_32 */
  146. ALGO_SSE2_64, /* SSE2 for x86_64 */
  147. ALGO_SSE4_64, /* SSE4 for x86_64 */
  148. ALGO_ALTIVEC_4WAY, /* parallel Altivec */
  149. };
  150. enum alive {
  151. LIFE_WELL,
  152. LIFE_SICK,
  153. LIFE_DEAD,
  154. LIFE_NOSTART
  155. };
  156. enum pool_strategy {
  157. POOL_FAILOVER,
  158. POOL_ROUNDROBIN,
  159. POOL_ROTATE,
  160. POOL_LOADBALANCE,
  161. };
  162. #define TOP_STRATEGY (POOL_LOADBALANCE)
  163. struct strategies {
  164. const char *s;
  165. };
  166. struct cgpu_info;
  167. #ifdef HAVE_ADL
  168. struct gpu_adl {
  169. ADLTemperature lpTemperature;
  170. int iAdapterIndex;
  171. int lpAdapterID;
  172. int iBusNumber;
  173. char strAdapterName[256];
  174. ADLPMActivity lpActivity;
  175. ADLODParameters lpOdParameters;
  176. ADLODPerformanceLevels *DefPerfLev;
  177. ADLFanSpeedInfo lpFanSpeedInfo;
  178. ADLFanSpeedValue lpFanSpeedValue;
  179. ADLFanSpeedValue DefFanSpeedValue;
  180. int iEngineClock;
  181. int iMemoryClock;
  182. int iVddc;
  183. int iPercentage;
  184. bool autofan;
  185. bool autoengine;
  186. bool managed; /* Were the values ever changed on this card */
  187. int lasttemp;
  188. int targetfan;
  189. int targettemp;
  190. int overtemp;
  191. int cutofftemp;
  192. int minspeed;
  193. int maxspeed;
  194. int gpu;
  195. bool has_fanspeed;
  196. struct gpu_adl *twin;
  197. };
  198. #endif
  199. struct thr_info;
  200. struct work;
  201. struct device_api {
  202. char*name;
  203. // API-global functions
  204. void (*api_detect)();
  205. // Device-specific functions
  206. void (*reinit_device)(struct cgpu_info*);
  207. void (*get_statline_before)(char*, struct cgpu_info*);
  208. void (*get_statline)(char*, struct cgpu_info*);
  209. // Thread-specific functions
  210. bool (*thread_prepare)(struct thr_info*);
  211. uint64_t (*can_limit_work)(struct thr_info*);
  212. bool (*thread_init)(struct thr_info*);
  213. void (*free_work)(struct thr_info*, struct work*);
  214. bool (*prepare_work)(struct thr_info*, struct work*);
  215. uint64_t (*scanhash)(struct thr_info*, struct work*, uint64_t);
  216. void (*thread_shutdown)(struct thr_info*);
  217. };
  218. struct cgpu_info {
  219. int cgminer_id;
  220. struct device_api *api;
  221. int device_id;
  222. char *device_path;
  223. FILE *device_file;
  224. int device_fd;
  225. bool enabled;
  226. int accepted;
  227. int rejected;
  228. int hw_errors;
  229. double rolling;
  230. double total_mhashes;
  231. double utility;
  232. enum alive status;
  233. char init[40];
  234. struct timeval last_message_tv;
  235. int threads;
  236. struct thr_info *thread;
  237. int virtual_gpu;
  238. bool dynamic;
  239. int intensity;
  240. #ifdef HAVE_ADL
  241. bool has_adl;
  242. struct gpu_adl adl;
  243. int gpu_engine;
  244. int min_engine;
  245. int gpu_fan;
  246. int min_fan;
  247. int gpu_memclock;
  248. int gpu_memdiff;
  249. int gpu_powertune;
  250. float gpu_vddc;
  251. #endif
  252. int last_share_pool;
  253. time_t last_share_pool_time;
  254. };
  255. #ifndef WIN32
  256. #define PTH(thr) ((thr)->pth)
  257. #else
  258. #define PTH(thr) ((thr)->pth.p)
  259. static inline void nanosleep(struct timespec *rgtp, void *__unused)
  260. {
  261. Sleep(rgtp->tv_nsec / 1000000);
  262. }
  263. #endif
  264. struct thread_q {
  265. struct list_head q;
  266. bool frozen;
  267. pthread_mutex_t mutex;
  268. pthread_cond_t cond;
  269. };
  270. struct thr_info {
  271. int id;
  272. int device_thread;
  273. pthread_t pth;
  274. struct thread_q *q;
  275. struct cgpu_info *cgpu;
  276. void *cgpu_data;
  277. struct timeval last;
  278. struct timeval sick;
  279. bool pause;
  280. bool getwork;
  281. double rolling;
  282. };
  283. extern int thr_info_create(struct thr_info *thr, pthread_attr_t *attr, void *(*start) (void *), void *arg);
  284. extern void thr_info_cancel(struct thr_info *thr);
  285. struct string_elist {
  286. char *string;
  287. bool free_me;
  288. struct list_head list;
  289. };
  290. static inline void string_elist_add(const char *s, struct list_head *head)
  291. {
  292. struct string_elist *n;
  293. n = calloc(1, sizeof(*n));
  294. n->string = strdup(s);
  295. n->free_me = true;
  296. list_add_tail(&n->list, head);
  297. }
  298. static inline void string_elist_del(struct string_elist *item)
  299. {
  300. if (item->free_me)
  301. free(item->string);
  302. list_del(&item->list);
  303. }
  304. static inline uint32_t swab32(uint32_t v)
  305. {
  306. return bswap_32(v);
  307. }
  308. static inline void swap256(void *dest_p, const void *src_p)
  309. {
  310. uint32_t *dest = dest_p;
  311. const uint32_t *src = src_p;
  312. dest[0] = src[7];
  313. dest[1] = src[6];
  314. dest[2] = src[5];
  315. dest[3] = src[4];
  316. dest[4] = src[3];
  317. dest[5] = src[2];
  318. dest[6] = src[1];
  319. dest[7] = src[0];
  320. }
  321. extern void quit(int status, const char *format, ...);
  322. static inline void mutex_lock(pthread_mutex_t *lock)
  323. {
  324. if (unlikely(pthread_mutex_lock(lock)))
  325. quit(1, "WTF MUTEX ERROR ON LOCK!");
  326. }
  327. static inline void mutex_unlock(pthread_mutex_t *lock)
  328. {
  329. if (unlikely(pthread_mutex_unlock(lock)))
  330. quit(1, "WTF MUTEX ERROR ON UNLOCK!");
  331. }
  332. static inline void wr_lock(pthread_rwlock_t *lock)
  333. {
  334. if (unlikely(pthread_rwlock_wrlock(lock)))
  335. quit(1, "WTF WRLOCK ERROR ON LOCK!");
  336. }
  337. static inline void rd_lock(pthread_rwlock_t *lock)
  338. {
  339. if (unlikely(pthread_rwlock_rdlock(lock)))
  340. quit(1, "WTF RDLOCK ERROR ON LOCK!");
  341. }
  342. static inline void rw_unlock(pthread_rwlock_t *lock)
  343. {
  344. if (unlikely(pthread_rwlock_unlock(lock)))
  345. quit(1, "WTF RWLOCK ERROR ON UNLOCK!");
  346. }
  347. static inline void rd_unlock(pthread_rwlock_t *lock)
  348. {
  349. rw_unlock(lock);
  350. }
  351. static inline void wr_unlock(pthread_rwlock_t *lock)
  352. {
  353. rw_unlock(lock);
  354. }
  355. static inline void mutex_init(pthread_mutex_t *lock)
  356. {
  357. if (unlikely(pthread_mutex_init(lock, NULL)))
  358. quit(1, "Failed to pthread_mutex_init");
  359. }
  360. static inline void rwlock_init(pthread_rwlock_t *lock)
  361. {
  362. if (unlikely(pthread_rwlock_init(lock, NULL)))
  363. quit(1, "Failed to pthread_rwlock_init");
  364. }
  365. struct pool;
  366. extern bool opt_debug;
  367. extern bool opt_protocol;
  368. extern bool opt_log_output;
  369. extern char *opt_kernel_path;
  370. extern char *opt_socks_proxy;
  371. extern char *cgminer_path;
  372. extern bool opt_autofan;
  373. extern bool opt_autoengine;
  374. extern bool use_curses;
  375. extern char *opt_api_description;
  376. extern int opt_api_port;
  377. extern bool opt_api_listen;
  378. extern bool opt_api_network;
  379. extern bool opt_delaynet;
  380. extern pthread_rwlock_t netacc_lock;
  381. extern const uint32_t sha256_init_state[];
  382. extern json_t *json_rpc_call(CURL *curl, const char *url, const char *userpass,
  383. const char *rpc_req, bool, bool, bool *,
  384. struct pool *pool, bool);
  385. extern char *bin2hex(const unsigned char *p, size_t len);
  386. extern bool hex2bin(unsigned char *p, const char *hexstr, size_t len);
  387. typedef bool (*sha256_func)(int thr_id, const unsigned char *pmidstate,
  388. unsigned char *pdata,
  389. unsigned char *phash1, unsigned char *phash,
  390. const unsigned char *ptarget,
  391. uint32_t max_nonce,
  392. uint32_t *last_nonce,
  393. uint32_t nonce);
  394. extern bool ScanHash_4WaySSE2(int, const unsigned char *pmidstate,
  395. unsigned char *pdata, unsigned char *phash1, unsigned char *phash,
  396. const unsigned char *ptarget,
  397. uint32_t max_nonce, uint32_t *last_nonce, uint32_t nonce);
  398. extern bool ScanHash_altivec_4way(int thr_id, const unsigned char *pmidstate,
  399. unsigned char *pdata,
  400. unsigned char *phash1, unsigned char *phash,
  401. const unsigned char *ptarget,
  402. uint32_t max_nonce, uint32_t *last_nonce, uint32_t nonce);
  403. extern bool scanhash_via(int, const unsigned char *pmidstate,
  404. unsigned char *pdata,
  405. unsigned char *phash1, unsigned char *phash,
  406. const unsigned char *target,
  407. uint32_t max_nonce, uint32_t *last_nonce, uint32_t n);
  408. extern bool scanhash_c(int, const unsigned char *midstate, unsigned char *data,
  409. unsigned char *hash1, unsigned char *hash,
  410. const unsigned char *target,
  411. uint32_t max_nonce, uint32_t *last_nonce, uint32_t n);
  412. extern bool scanhash_cryptopp(int, const unsigned char *midstate,unsigned char *data,
  413. unsigned char *hash1, unsigned char *hash,
  414. const unsigned char *target,
  415. uint32_t max_nonce, uint32_t *last_nonce, uint32_t n);
  416. extern bool scanhash_asm32(int, const unsigned char *midstate,unsigned char *data,
  417. unsigned char *hash1, unsigned char *hash,
  418. const unsigned char *target,
  419. uint32_t max_nonce, uint32_t *last_nonce, uint32_t nonce);
  420. extern bool scanhash_sse2_64(int, const unsigned char *pmidstate, unsigned char *pdata,
  421. unsigned char *phash1, unsigned char *phash,
  422. const unsigned char *ptarget,
  423. uint32_t max_nonce, uint32_t *last_nonce,
  424. uint32_t nonce);
  425. extern bool scanhash_sse4_64(int, const unsigned char *pmidstate, unsigned char *pdata,
  426. unsigned char *phash1, unsigned char *phash,
  427. const unsigned char *ptarget,
  428. uint32_t max_nonce, uint32_t *last_nonce,
  429. uint32_t nonce);
  430. extern bool scanhash_sse2_32(int, const unsigned char *pmidstate, unsigned char *pdata,
  431. unsigned char *phash1, unsigned char *phash,
  432. const unsigned char *ptarget,
  433. uint32_t max_nonce, uint32_t *last_nonce,
  434. uint32_t nonce);
  435. extern int
  436. timeval_subtract (struct timeval *result, struct timeval *x, struct timeval *y);
  437. extern bool fulltest(const unsigned char *hash, const unsigned char *target);
  438. extern int opt_scantime;
  439. struct work_restart {
  440. volatile unsigned long restart;
  441. char padding[128 - sizeof(unsigned long)];
  442. };
  443. extern void thread_reportin(struct thr_info *thr);
  444. extern void kill_work(void);
  445. extern void reinit_device(struct cgpu_info *cgpu);
  446. #ifdef HAVE_ADL
  447. extern float gpu_temp(int gpu);
  448. extern int gpu_fanspeed(int gpu);
  449. extern int gpu_fanpercent(int gpu);
  450. extern bool gpu_stats(int gpu, float *temp, int *engineclock, int *memclock, float *vddc, int *activity, int *fanspeed, int *fanpercent, int *powertune);
  451. extern int set_fanspeed(int gpu, int iFanSpeed);
  452. extern int set_vddc(int gpu, float fVddc);
  453. extern int set_engineclock(int gpu, int iEngineClock);
  454. extern int set_memoryclock(int gpu, int iMemoryClock);
  455. #endif
  456. extern void api(void);
  457. #define MAX_GPUDEVICES 16
  458. #define MAX_DEVICES 32
  459. #define MAX_POOLS (32)
  460. #define MIN_INTENSITY -10
  461. #define _MIN_INTENSITY_STR "-10"
  462. #define MAX_INTENSITY 14
  463. #define _MAX_INTENSITY_STR "14"
  464. extern struct list_head scan_devices;
  465. extern int nDevs;
  466. extern int opt_n_threads;
  467. extern int num_processors;
  468. extern int hw_errors;
  469. extern bool use_syslog;
  470. extern struct thr_info *thr_info;
  471. extern int longpoll_thr_id;
  472. extern struct work_restart *work_restart;
  473. extern struct cgpu_info gpus[MAX_GPUDEVICES];
  474. extern int gpu_threads;
  475. extern double total_secs;
  476. extern int mining_threads;
  477. extern struct cgpu_info *cpus;
  478. extern int total_devices;
  479. extern struct cgpu_info *devices[];
  480. extern int total_pools;
  481. extern struct pool *pools[MAX_POOLS];
  482. extern const char *algo_names[];
  483. extern enum sha256_algos opt_algo;
  484. extern struct strategies strategies[];
  485. extern enum pool_strategy pool_strategy;
  486. extern int opt_rotate_period;
  487. extern double total_mhashes_done;
  488. extern unsigned int new_blocks;
  489. extern unsigned int found_blocks;
  490. extern int total_accepted, total_rejected;
  491. extern int total_getworks, total_stale, total_discarded;
  492. extern unsigned int local_work;
  493. extern unsigned int total_go, total_ro;
  494. extern int opt_log_interval;
  495. #ifdef HAVE_OPENCL
  496. typedef struct {
  497. cl_uint ctx_a; cl_uint ctx_b; cl_uint ctx_c; cl_uint ctx_d;
  498. cl_uint ctx_e; cl_uint ctx_f; cl_uint ctx_g; cl_uint ctx_h;
  499. cl_uint cty_a; cl_uint cty_b; cl_uint cty_c; cl_uint cty_d;
  500. cl_uint cty_e; cl_uint cty_f; cl_uint cty_g; cl_uint cty_h;
  501. cl_uint merkle; cl_uint ntime; cl_uint nbits; cl_uint nonce;
  502. cl_uint fW0; cl_uint fW1; cl_uint fW2; cl_uint fW3; cl_uint fW15;
  503. cl_uint fW01r; cl_uint fcty_e; cl_uint fcty_e2;
  504. cl_uint W16; cl_uint W17; cl_uint W2;
  505. cl_uint PreVal4; cl_uint T1;
  506. cl_uint C1addK5; cl_uint D1A; cl_uint W2A; cl_uint W17_2;
  507. cl_uint PreVal4addT1; cl_uint T1substate0;
  508. cl_uint PreVal4_2;
  509. cl_uint PreVal0;
  510. cl_uint PreW18;
  511. cl_uint PreW19;
  512. cl_uint PreW31;
  513. cl_uint PreW32;
  514. /* For diakgcn */
  515. cl_uint B1addK6, PreVal0addK7, W16addK16, W17addK17;
  516. cl_uint A0, B0;
  517. } dev_blk_ctx;
  518. #else
  519. typedef struct {
  520. uint32_t nonce;
  521. } dev_blk_ctx;
  522. #endif
  523. struct pool {
  524. int pool_no;
  525. int prio;
  526. int accepted, rejected;
  527. bool submit_fail;
  528. bool idle;
  529. bool lagging;
  530. bool probed;
  531. bool enabled;
  532. bool submit_old;
  533. char *hdr_path;
  534. unsigned int getwork_requested;
  535. unsigned int stale_shares;
  536. unsigned int discarded_work;
  537. unsigned int getfail_occasions;
  538. unsigned int remotefail_occasions;
  539. struct timeval tv_idle;
  540. char *rpc_url;
  541. char *rpc_userpass;
  542. char *rpc_user, *rpc_pass;
  543. pthread_mutex_t pool_lock;
  544. };
  545. struct work {
  546. unsigned char data[128];
  547. unsigned char hash1[64];
  548. unsigned char midstate[32];
  549. unsigned char target[32];
  550. unsigned char hash[32];
  551. int rolls;
  552. uint32_t output[1];
  553. uint32_t valid;
  554. dev_blk_ctx blk;
  555. struct thr_info *thr;
  556. int thr_id;
  557. struct pool *pool;
  558. struct timeval tv_staged;
  559. bool mined;
  560. bool clone;
  561. bool cloned;
  562. bool rolltime;
  563. unsigned int work_block;
  564. int id;
  565. UT_hash_handle hh;
  566. };
  567. enum cl_kernels {
  568. KL_NONE,
  569. KL_POCLBM,
  570. KL_PHATK,
  571. KL_DIAKGCN,
  572. };
  573. extern void get_datestamp(char *, struct timeval *);
  574. bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce);
  575. extern void wlogprint(const char *f, ...);
  576. extern int curses_int(const char *query);
  577. extern char *curses_input(const char *query);
  578. extern void kill_work(void);
  579. extern void switch_pools(struct pool *selected);
  580. extern void write_config(FILE *fcfg);
  581. extern void log_curses(int prio, const char *f, va_list ap);
  582. extern void clear_logwin(void);
  583. extern void vapplog(int prio, const char *fmt, va_list ap);
  584. extern void applog(int prio, const char *fmt, ...);
  585. extern struct thread_q *tq_new(void);
  586. extern void tq_free(struct thread_q *tq);
  587. extern bool tq_push(struct thread_q *tq, void *data);
  588. extern void *tq_pop(struct thread_q *tq, const struct timespec *abstime);
  589. extern void tq_freeze(struct thread_q *tq);
  590. extern void tq_thaw(struct thread_q *tq);
  591. extern bool successful_connect;
  592. extern enum cl_kernels chosen_kernel;
  593. extern void adl(void);
  594. #endif /* __MINER_H__ */