Browse Source

hashbusteravalon: Klondike-based metadriver

Luke Dashjr 12 years ago
parent
commit
748c3db3ba
5 changed files with 125 additions and 52 deletions
  1. 1 1
      Makefile.am
  2. 1 1
      configure.ac
  3. 55 0
      driver-hashbusteravalon.c
  4. 2 50
      driver-klondike.c
  5. 66 0
      driver-klondike.h

+ 1 - 1
Makefile.am

@@ -243,7 +243,7 @@ bfgminer_SOURCES += driver-knc.c
 endif
 endif
 
 
 if HAS_KLONDIKE
 if HAS_KLONDIKE
-bfgminer_SOURCES += driver-klondike.c
+bfgminer_SOURCES += driver-klondike.c driver-klondike.h driver-hashbusteravalon.c
 endif
 endif
 
 
 if HAS_MODMINER
 if HAS_MODMINER

+ 1 - 1
configure.ac

@@ -583,7 +583,7 @@ PKG_CHECK_MODULES([LIBUSB], [libusb-1.0],[
 ])
 ])
 fi
 fi
 
 
-driverlist="$driverlist klondike"
+driverlist="$driverlist klondike hashbusteravalon/klondike"
 AC_ARG_ENABLE([klondike],
 AC_ARG_ENABLE([klondike],
 	[AC_HELP_STRING([--disable-klondike],[Compile support for Klondike (default enabled)])],
 	[AC_HELP_STRING([--disable-klondike],[Compile support for Klondike (default enabled)])],
 	[klondike=$enableval],
 	[klondike=$enableval],

+ 55 - 0
driver-hashbusteravalon.c

@@ -0,0 +1,55 @@
+/*
+ * Copyright 2014 Luke Dashjr
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 3 of the License, or (at your option)
+ * any later version.  See COPYING for more details.
+ */
+
+#include <stdbool.h>
+#include <stdlib.h>
+
+#include "deviceapi.h"
+#include "driver-klondike.h"
+#include "logging.h"
+#include "lowlevel.h"
+
+BFG_REGISTER_DRIVER(hashbusteravalon_drv)
+
+static
+bool hashbusteravalon_lowl_match(const struct lowlevel_device_info * const info)
+{
+	if (!lowlevel_match_id(info, &lowl_usb, 0xfa05, 0x0001))
+		return false;
+	return (info->manufacturer && strstr(info->manufacturer, "HashBuster"));
+}
+
+static
+bool hashbusteravalon_lowl_probe(const struct lowlevel_device_info * const info)
+{
+	struct klondike_info * const klninfo = malloc(sizeof(*klninfo));
+	if (unlikely(!klninfo))
+		applogr(false, LOG_ERR, "%s: Failed to malloc klninfo", __func__);
+	
+	*klninfo = (struct klondike_info){
+		.clock = 2425,
+		.max_work_count = 0x20,
+		.old_work_ms = 30000,
+	};
+	
+	return klondike_lowl_probe_custom(info, &hashbusteravalon_drv, klninfo);
+}
+
+static void hashbusteravalon_drv_init()
+{
+	hashbusteravalon_drv = klondike_drv;
+	hashbusteravalon_drv.dname = "hashbusteravalon";
+	hashbusteravalon_drv.name = "HBA";
+	hashbusteravalon_drv.lowl_match = hashbusteravalon_lowl_match;
+	hashbusteravalon_drv.lowl_probe = hashbusteravalon_lowl_probe;
+}
+
+struct device_drv hashbusteravalon_drv = {
+	.drv_init = hashbusteravalon_drv_init,
+};

+ 2 - 50
driver-klondike.c

@@ -1,4 +1,5 @@
 /*
 /*
+ * Copyright 2014 Luke Dashjr
  * Copyright 2013 Andrew Smith
  * Copyright 2013 Andrew Smith
  * Copyright 2013 Con Kolivas
  * Copyright 2013 Con Kolivas
  * Copyright 2013 Chris Savery
  * Copyright 2013 Chris Savery
@@ -28,6 +29,7 @@
 
 
 #include "compat.h"
 #include "compat.h"
 #include "deviceapi.h"
 #include "deviceapi.h"
+#include "driver-klondike.h"
 #include "lowlevel.h"
 #include "lowlevel.h"
 #include "lowl-usb.h"
 #include "lowl-usb.h"
 #include "miner.h"
 #include "miner.h"
@@ -207,55 +209,6 @@ typedef struct jobque {
 	int late_update_sequential;
 	int late_update_sequential;
 } JOBQUE;
 } JOBQUE;
 
 
-struct klondike_info {
-	pthread_rwlock_t stat_lock;
-	struct thr_info replies_thr;
-	cglock_t klist_lock;
-	KLIST *used;
-	KLIST *free;
-	int kline_count;
-	int used_count;
-	int block_seq;
-	KLIST *status;
-	DEVINFO *devinfo;
-	KLIST *cfg;
-	JOBQUE *jobque;
-	int noncecount;
-	uint64_t hashcount;
-	uint64_t errorcount;
-	uint64_t noisecount;
-	int incorrect_slave_sequential;
-	int16_t nonce_offset;
-
-	// us Delay from USB reply to being processed
-	double delay_count;
-	double delay_total;
-	double delay_min;
-	double delay_max;
-
-	struct timeval tv_last_nonce_received;
-
-	// Time from recieving one nonce to the next
-	double nonce_count;
-	double nonce_total;
-	double nonce_min;
-	double nonce_max;
-
-	int wque_size;
-	int wque_cleared;
-
-	int clock;
-	bool initialised;
-	
-	struct libusb_device_handle *usbdev_handle;
-	
-	// TODO:
-	bool usbinfo_nodev;
-	
-	int max_work_count;
-	int old_work_ms;
-};
-
 static KLIST *new_klist_set(struct cgpu_info *klncgpu)
 static KLIST *new_klist_set(struct cgpu_info *klncgpu)
 {
 {
 	struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data);
 	struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data);
@@ -875,7 +828,6 @@ bool klondike_lowl_match(const struct lowlevel_device_info * const info)
 	return (info->manufacturer && strstr(info->manufacturer, "Klondike"));
 	return (info->manufacturer && strstr(info->manufacturer, "Klondike"));
 }
 }
 
 
-static
 bool klondike_lowl_probe_custom(const struct lowlevel_device_info * const info, struct device_drv * const drv, struct klondike_info * const klninfo)
 bool klondike_lowl_probe_custom(const struct lowlevel_device_info * const info, struct device_drv * const drv, struct klondike_info * const klninfo)
 {
 {
 	if (unlikely(info->lowl != &lowl_usb))
 	if (unlikely(info->lowl != &lowl_usb))

+ 66 - 0
driver-klondike.h

@@ -0,0 +1,66 @@
+#ifndef BFG_DRIVER_KLONDIKE_H
+#define BFG_DRIVER_KLONDIKE_H
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <sys/time.h>
+
+#include <pthread.h>
+
+#include "lowlevel.h"
+#include "miner.h"
+
+struct klondike_info {
+	pthread_rwlock_t stat_lock;
+	struct thr_info replies_thr;
+	cglock_t klist_lock;
+	struct klist *used;
+	struct klist *free;
+	int kline_count;
+	int used_count;
+	int block_seq;
+	struct klist *status;
+	struct device_info *devinfo;
+	struct klist *cfg;
+	struct jobque *jobque;
+	int noncecount;
+	uint64_t hashcount;
+	uint64_t errorcount;
+	uint64_t noisecount;
+	int incorrect_slave_sequential;
+	int16_t nonce_offset;
+
+	// us Delay from USB reply to being processed
+	double delay_count;
+	double delay_total;
+	double delay_min;
+	double delay_max;
+
+	struct timeval tv_last_nonce_received;
+
+	// Time from recieving one nonce to the next
+	double nonce_count;
+	double nonce_total;
+	double nonce_min;
+	double nonce_max;
+
+	int wque_size;
+	int wque_cleared;
+
+	int clock;
+	bool initialised;
+	
+	struct libusb_device_handle *usbdev_handle;
+	
+	// TODO:
+	bool usbinfo_nodev;
+	
+	int max_work_count;
+	int old_work_ms;
+};
+
+extern bool klondike_lowl_probe_custom(const struct lowlevel_device_info * const info, struct device_drv * const drv, struct klondike_info * const klninfo);
+
+extern struct device_drv klondike_drv;
+
+#endif