File: deviceapi.h

package info (click to toggle)
bfgminer 4.7.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,116 kB
  • ctags: 9,129
  • sloc: ansic: 62,470; lisp: 5,221; sh: 4,572; php: 2,645; asm: 667; makefile: 427; python: 85; ruby: 23
file content (119 lines) | stat: -rw-r--r-- 4,506 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#ifndef BFG_DEVICEAPI_H
#define BFG_DEVICEAPI_H

#include <stdbool.h>
#include <stdint.h>
#include <sys/time.h>

#include <uthash.h>

#include "miner.h"

struct driver_registration;
struct driver_registration {
	const struct device_drv *drv;
	
	UT_hash_handle hh;   // hash & order by dname
	UT_hash_handle hh2;  // hash by name, order by priority
	struct driver_registration *next;  // DO NOT USE
};

extern struct driver_registration *_bfg_drvreg1;
extern struct driver_registration *_bfg_drvreg2;
extern void bfg_devapi_init();

#define BFG_FIND_DRV_BY_DNAME(reg, name, namelen)  \
	HASH_FIND(hh , _bfg_drvreg1, name, namelen, reg)
#define BFG_FIND_DRV_BY_NAME(reg, name, namelen)  \
	HASH_FIND(hh2, _bfg_drvreg2, name, namelen, reg)
#define BFG_FOREACH_DRIVER_BY_DNAME(reg, tmp)  \
	HASH_ITER(hh , _bfg_drvreg1, reg, tmp)
#define BFG_FOREACH_DRIVER_BY_PRIORITY(reg, tmp)  \
	HASH_ITER(hh2, _bfg_drvreg2, reg, tmp)

extern void _bfg_register_driver(const struct device_drv *);
#define BFG_REGISTER_DRIVER(drv)                \
	struct device_drv drv;                      \
	__attribute__((constructor))                \
	static void __bfg_register_drv_ ## drv() {  \
		_bfg_register_driver(&drv);             \
	}                                           \
// END BFG_REGISTER_DRIVER

extern bool bfg_need_detect_rescan;

extern void request_work(struct thr_info *);
extern struct work *get_work(struct thr_info *);
extern bool hashes_done(struct thr_info *, int64_t hashes, struct timeval *tvp_hashes, uint32_t *max_nonce);
extern bool hashes_done2(struct thr_info *, int64_t hashes, uint32_t *max_nonce);
extern void mt_disable_start(struct thr_info *);
extern void mt_disable_finish(struct thr_info *);
extern void mt_disable(struct thr_info *);  // blocks until reenabled

extern int restart_wait(struct thr_info *, unsigned int ms);
extern void minerloop_scanhash(struct thr_info *);

extern void mt_disable_start__async(struct thr_info *);
extern bool do_job_prepare(struct thr_info *, struct timeval *tvp_now);
extern void job_prepare_complete(struct thr_info *);
extern void do_get_results(struct thr_info *, bool proceed_with_new_job);
extern void job_results_fetched(struct thr_info *);
extern void do_job_start(struct thr_info *);
extern void mt_job_transition(struct thr_info *);
extern void job_start_complete(struct thr_info *);
extern void job_start_abort(struct thr_info *, bool failure);
extern bool do_process_results(struct thr_info *, struct timeval *tvp_now, struct work *, bool stopping);
extern void minerloop_async(struct thr_info *);

extern void minerloop_queue(struct thr_info *);

// Establishes a simple way for external threads to directly communicate with device
extern void cgpu_setup_control_requests(struct cgpu_info *);
extern void cgpu_request_control(struct cgpu_info *);
extern void cgpu_release_control(struct cgpu_info *);

extern void *miner_thread(void *);

extern void add_cgpu_live(void*);
extern bool add_cgpu_slave(struct cgpu_info *, struct cgpu_info *master);

enum bfg_set_device_replytype {
	SDR_AUTO,
	SDR_OK,
	SDR_ERR,
	SDR_HELP,
	SDR_UNKNOWN,
	SDR_NOSUPP,
};
typedef const char *(*bfg_set_device_func_t)(struct cgpu_info *proc, const char *optname, const char *newvalue, char *replybuf, enum bfg_set_device_replytype *out_success);
struct bfg_set_device_definition {
	const char *optname;
	bfg_set_device_func_t func;
	const char *description;
};
extern const char *proc_set_device(struct cgpu_info *proc, char *optname, char *newvalue, char *replybuf, enum bfg_set_device_replytype *out_success);

typedef bool(*detectone_func_t)(const char*);
typedef int(*autoscan_func_t)();

enum generic_detect_flags {
	GDF_REQUIRE_DNAME = 2,
	GDF_DEFAULT_NOAUTO = 4,
};

extern int _serial_detect(struct device_drv *api, detectone_func_t, autoscan_func_t, int flags);
#define noserial_detect_manual(api, autoscan)  \
	_serial_detect(api, NULL     , autoscan, 4)
#define generic_detect(drv, detectone, autoscan, flags)  _serial_detect(drv, detectone, autoscan, flags)

extern FILE *open_bitstream(const char *dname, const char *filename);

extern void close_device_fd(struct thr_info *);

#define for_each_managed_proc(procvar, dev)  \
	for (struct cgpu_info *procvar = dev; procvar; procvar = procvar->next_proc)
#define for_each_logical_proc(procvar, dev)  \
	for (struct cgpu_info *procvar = dev; procvar && procvar->device == (dev); procvar = procvar->next_proc)
extern struct cgpu_info *device_proc_by_id(const struct cgpu_info *dev, int procid);

#endif