|
@@ -155,7 +155,9 @@ static bool opt_nogpu;
|
|
|
|
|
|
|
|
struct string_elist *scan_devices;
|
|
struct string_elist *scan_devices;
|
|
|
bool opt_force_dev_init;
|
|
bool opt_force_dev_init;
|
|
|
-static signed int devices_enabled;
|
|
|
|
|
|
|
+static bool devices_enabled[MAX_DEVICES];
|
|
|
|
|
+static int opt_devs_enabled;
|
|
|
|
|
+static bool opt_display_devs;
|
|
|
static bool opt_removedisabled;
|
|
static bool opt_removedisabled;
|
|
|
int total_devices;
|
|
int total_devices;
|
|
|
struct cgpu_info **devices;
|
|
struct cgpu_info **devices;
|
|
@@ -746,21 +748,52 @@ static char *add_serial(char *arg)
|
|
|
}
|
|
}
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
|
|
+void get_intrange(char *arg, int *val1, int *val2)
|
|
|
|
|
+{
|
|
|
|
|
+ if (sscanf(arg, "%d-%d", val1, val2) == 1)
|
|
|
|
|
+ *val2 = *val1;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
static char *set_devices(char *arg)
|
|
static char *set_devices(char *arg)
|
|
|
{
|
|
{
|
|
|
- int i = strtol(arg, &arg, 0);
|
|
|
|
|
|
|
+ int i, val1 = 0, val2 = 0;
|
|
|
|
|
+ char *nextptr;
|
|
|
|
|
|
|
|
if (*arg) {
|
|
if (*arg) {
|
|
|
if (*arg == '?') {
|
|
if (*arg == '?') {
|
|
|
- devices_enabled = -1;
|
|
|
|
|
|
|
+ opt_display_devs = true;
|
|
|
return NULL;
|
|
return NULL;
|
|
|
}
|
|
}
|
|
|
- return "Invalid device number";
|
|
|
|
|
|
|
+ } else
|
|
|
|
|
+ return "Invalid device parameters";
|
|
|
|
|
+
|
|
|
|
|
+ nextptr = strtok(arg, ",");
|
|
|
|
|
+ if (nextptr == NULL)
|
|
|
|
|
+ return "Invalid parameters for set devices";
|
|
|
|
|
+ get_intrange(nextptr, &val1, &val2);
|
|
|
|
|
+ if (val1 < 0 || val1 > MAX_DEVICES || val2 < 0 || val2 > MAX_DEVICES ||
|
|
|
|
|
+ val1 > val2) {
|
|
|
|
|
+ return "Invalid value passed to set devices";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for (i = val1; i <= val2; i++) {
|
|
|
|
|
+ devices_enabled[i] = true;
|
|
|
|
|
+ opt_devs_enabled++;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ while ((nextptr = strtok(NULL, ",")) != NULL) {
|
|
|
|
|
+ get_intrange(nextptr, &val1, &val2);
|
|
|
|
|
+ if (val1 < 0 || val1 > MAX_DEVICES || val2 < 0 || val2 > MAX_DEVICES ||
|
|
|
|
|
+ val1 > val2) {
|
|
|
|
|
+ return "Invalid value passed to set devices";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for (i = val1; i <= val2; i++) {
|
|
|
|
|
+ devices_enabled[i] = true;
|
|
|
|
|
+ opt_devs_enabled++;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (i < 0 || i >= (int)(sizeof(devices_enabled) * 8) - 1)
|
|
|
|
|
- return "Invalid device number";
|
|
|
|
|
- devices_enabled |= 1 << i;
|
|
|
|
|
return NULL;
|
|
return NULL;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1227,7 +1260,7 @@ static struct opt_table opt_config_table[] = {
|
|
|
"Enable debug logging"),
|
|
"Enable debug logging"),
|
|
|
OPT_WITH_ARG("--device|-d",
|
|
OPT_WITH_ARG("--device|-d",
|
|
|
set_devices, NULL, NULL,
|
|
set_devices, NULL, NULL,
|
|
|
- "Select device to use, (Use repeat -d for multiple devices, default: all)"),
|
|
|
|
|
|
|
+ "Select device to use, one value, range and/or comma separated (e.g. 0-2,4) default: all"),
|
|
|
OPT_WITHOUT_ARG("--disable-gpu|-G",
|
|
OPT_WITHOUT_ARG("--disable-gpu|-G",
|
|
|
opt_set_bool, &opt_nogpu,
|
|
opt_set_bool, &opt_nogpu,
|
|
|
#ifdef HAVE_OPENCL
|
|
#ifdef HAVE_OPENCL
|
|
@@ -5211,7 +5244,7 @@ void write_config(FILE *fcfg)
|
|
|
fprintf(fcfg, ",\n\"socks-proxy\" : \"%s\"", json_escape(opt_socks_proxy));
|
|
fprintf(fcfg, ",\n\"socks-proxy\" : \"%s\"", json_escape(opt_socks_proxy));
|
|
|
|
|
|
|
|
// We can only remove devices or disable them by default, but not both...
|
|
// We can only remove devices or disable them by default, but not both...
|
|
|
- if (!(opt_removedisabled && devices_enabled))
|
|
|
|
|
|
|
+ if (!(opt_removedisabled && opt_devs_enabled))
|
|
|
{
|
|
{
|
|
|
// Don't need to remove any, so we can set defaults here
|
|
// Don't need to remove any, so we can set defaults here
|
|
|
for (i = 0; i < total_devices; ++i)
|
|
for (i = 0; i < total_devices; ++i)
|
|
@@ -5232,13 +5265,12 @@ void write_config(FILE *fcfg)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
- if (devices_enabled) {
|
|
|
|
|
|
|
+ if (opt_devs_enabled) {
|
|
|
// Mark original device params and remove-disabled
|
|
// Mark original device params and remove-disabled
|
|
|
fprintf(fcfg, ",\n\"device\" : [");
|
|
fprintf(fcfg, ",\n\"device\" : [");
|
|
|
bool first = true;
|
|
bool first = true;
|
|
|
- for (i = 0; i < (int)(sizeof(devices_enabled) * 8) - 1; ++i) {
|
|
|
|
|
- if (devices_enabled & (1 << i))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ for (i = 0; i < MAX_DEVICES; i++) {
|
|
|
|
|
+ if (devices_enabled[i]) {
|
|
|
fprintf(fcfg, "%s\n\t%d", first ? "" : ",", i);
|
|
fprintf(fcfg, "%s\n\t%d", first ? "" : ",", i);
|
|
|
first = false;
|
|
first = false;
|
|
|
}
|
|
}
|
|
@@ -8619,7 +8651,7 @@ int main(int argc, char *argv[])
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_CURSES
|
|
#ifdef HAVE_CURSES
|
|
|
- if (opt_realquiet || devices_enabled == -1)
|
|
|
|
|
|
|
+ if (opt_realquiet || opt_display_devs)
|
|
|
use_curses = false;
|
|
use_curses = false;
|
|
|
|
|
|
|
|
if (use_curses)
|
|
if (use_curses)
|
|
@@ -8749,7 +8781,7 @@ int main(int argc, char *argv[])
|
|
|
if (!devices[i]->devtype)
|
|
if (!devices[i]->devtype)
|
|
|
devices[i]->devtype = "PGA";
|
|
devices[i]->devtype = "PGA";
|
|
|
|
|
|
|
|
- if (devices_enabled == -1) {
|
|
|
|
|
|
|
+ if (opt_display_devs) {
|
|
|
applog(LOG_ERR, "Devices detected:");
|
|
applog(LOG_ERR, "Devices detected:");
|
|
|
for (i = 0; i < total_devices; ++i) {
|
|
for (i = 0; i < total_devices; ++i) {
|
|
|
struct cgpu_info *cgpu = devices[i];
|
|
struct cgpu_info *cgpu = devices[i];
|
|
@@ -8762,9 +8794,9 @@ int main(int argc, char *argv[])
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
mining_threads = 0;
|
|
mining_threads = 0;
|
|
|
- if (devices_enabled) {
|
|
|
|
|
- for (i = 0; i < (int)(sizeof(devices_enabled) * 8) - 1; ++i) {
|
|
|
|
|
- if (devices_enabled & (1 << i)) {
|
|
|
|
|
|
|
+ if (opt_devs_enabled) {
|
|
|
|
|
+ for (i = 0; i < MAX_DEVICES; i++) {
|
|
|
|
|
+ if (devices_enabled[i]) {
|
|
|
if (i >= total_devices)
|
|
if (i >= total_devices)
|
|
|
quit (1, "Command line options set a device that doesn't exist");
|
|
quit (1, "Command line options set a device that doesn't exist");
|
|
|
register_device(devices[i]);
|
|
register_device(devices[i]);
|