Commit 3105b3aee5fc581b711ab01049d0a206690cd3f9

Con Kolivas 2014-01-05T23:16:39

Add basic nf1_scan function.

diff --git a/driver-bitfury.c b/driver-bitfury.c
index 0384be1..9085e6f 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -973,6 +973,39 @@ static int64_t bxf_scan(struct cgpu_info *bitfury, struct bitfury_info *info)
 	return ret;
 }
 
+static int64_t nf1_scan(struct thr_info *thr, struct cgpu_info *bitfury,
+			struct bitfury_info *info)
+{
+	struct work *work;
+	int64_t ret = 0;
+
+	work = get_queue_work(thr, bitfury, thr->id);
+	if (unlikely(thr->work_restart)) {
+		work_completed(bitfury, work);
+		return 0;
+	}
+	info->work = work;
+	bitfury_work_to_payload(&info->payload, work);
+	libbitfury_sendHashData(bitfury);
+	if (info->job_switched) {
+		int i, j;
+		int *res = info->results;
+		struct work *owork = info->owork;
+
+		i = info->results_n;
+		for (j = i - 1; j >= 0; j--) {
+			if (owork)
+				submit_nonce(thr, owork, bswap_32(res[j]));
+		}
+		if (owork)
+			work_completed(bitfury, owork);
+		info->owork = info->work;
+		info->work = NULL;
+		ret += 0xffffffffull * i;
+	}
+	return ret;
+}
+
 static int64_t bitfury_scanwork(struct thr_info *thr)
 {
 	struct cgpu_info *bitfury = thr->cgpu;
@@ -981,10 +1014,10 @@ static int64_t bitfury_scanwork(struct thr_info *thr)
 	switch(info->ident) {
 		case IDENT_BF1:
 			return bf1_scan(thr, bitfury, info);
-			break;
 		case IDENT_BXF:
 			return bxf_scan(bitfury, info);
-			break;
+		case IDENT_NF1:
+			return nf1_scan(thr, bitfury, info);
 		default:
 			return 0;
 	}
diff --git a/driver-bitfury.h b/driver-bitfury.h
index 7fc8a2f..9c1fa86 100644
--- a/driver-bitfury.h
+++ b/driver-bitfury.h
@@ -85,8 +85,10 @@ struct bitfury_info {
 	unsigned newbuf[20];
 	unsigned oldbuf[20];
 	int job_switched;
-	unsigned int results[16];
+	int results[16];
 	int results_n;
+	struct work *work;
+	struct work *owork;
 };
 
 #endif /* BITFURY_H */
diff --git a/libbitfury.h b/libbitfury.h
index 377b3dd..69adcae 100644
--- a/libbitfury.h
+++ b/libbitfury.h
@@ -14,11 +14,13 @@
 
 void ms3steps(uint32_t *p);
 uint32_t decnonce(uint32_t in);
+void bitfury_work_to_payload(struct bitfury_payload *p, struct work *w);
 void spi_clear_buf(struct bitfury_info *info);
 void spi_add_buf(struct bitfury_info *info, const void *buf, const int sz);
 void spi_add_break(struct bitfury_info *info);
 void spi_add_data(struct bitfury_info *info, uint16_t addr, const void *buf, int len);
 bool spi_reset(struct cgpu_info *bitfury, struct bitfury_info *info);
 bool spi_txrx(struct cgpu_info *bitfury, struct bitfury_info *info);
+void libbitfury_sendHashData(struct cgpu_info *bf);
 
 #endif /* LIBBITFURY_H */