Browse Source

bitfury: Abstract out payload_to_atrvec

Luke Dashjr 12 years ago
parent
commit
44659caef9
3 changed files with 12 additions and 6 deletions
  1. 1 0
      driver-littlefury.c
  2. 9 6
      libbitfury.c
  3. 2 0
      libbitfury.h

+ 1 - 0
driver-littlefury.c

@@ -384,6 +384,7 @@ bool littlefury_job_prepare(struct thr_info *thr, struct work *work, __maybe_unu
 {
 {
 	struct bitfury_device * const bitfury = thr->cgpu->device_data;
 	struct bitfury_device * const bitfury = thr->cgpu->device_data;
 	work_to_payload(&bitfury->payload, thr->next_work);
 	work_to_payload(&bitfury->payload, thr->next_work);
+	payload_to_atrvec(bitfury->atrvec, &bitfury->payload);
 	return true;
 	return true;
 }
 }
 
 

+ 9 - 6
libbitfury.c

@@ -261,6 +261,13 @@ void work_to_payload(struct bitfury_payload *p, struct work *w) {
 	applog(LOG_INFO, "INFO merkle[7]: %08x, ntime: %08x, nbits: %08x", p->m7, p->ntime, p->nbits);
 	applog(LOG_INFO, "INFO merkle[7]: %08x, ntime: %08x, nbits: %08x", p->m7, p->ntime, p->nbits);
 }
 }
 
 
+void payload_to_atrvec(uint32_t *atrvec, struct bitfury_payload *p)
+{
+	/* Programming next value */
+	memcpy(atrvec, p, 20*4);
+	ms3_compute(atrvec);
+}
+
 void libbitfury_sendHashData1(struct bitfury_device *d, bool want_results)
 void libbitfury_sendHashData1(struct bitfury_device *d, bool want_results)
 {
 {
 	struct spi_port *port = d->spi;
 	struct spi_port *port = d->spi;
@@ -269,16 +276,11 @@ void libbitfury_sendHashData1(struct bitfury_device *d, bool want_results)
 	unsigned *oldbuf = d->oldbuf;
 	unsigned *oldbuf = d->oldbuf;
 	struct bitfury_payload *p = &(d->payload);
 	struct bitfury_payload *p = &(d->payload);
 	struct bitfury_payload *op = &(d->opayload);
 	struct bitfury_payload *op = &(d->opayload);
-	unsigned atrvec[20];
-	
-	/* Programming next value */
-	memcpy(atrvec, p, 20*4);
-	ms3_compute(atrvec);
 	
 	
 	spi_clear_buf(port);
 	spi_clear_buf(port);
 	spi_emit_break(port);
 	spi_emit_break(port);
 	spi_emit_fasync(port, chip);
 	spi_emit_fasync(port, chip);
-	spi_emit_data(port, 0x3000, &atrvec[0], 19*4);
+	spi_emit_data(port, 0x3000, &d->atrvec[0], 19*4);
 	spi_txrx(port);
 	spi_txrx(port);
 	
 	
 	memcpy(newbuf, spi_getrxbuf(port)+4 + chip, 17*4);
 	memcpy(newbuf, spi_getrxbuf(port)+4 + chip, 17*4);
@@ -321,6 +323,7 @@ void libbitfury_sendHashData(struct bitfury_device *bf, int chip_n) {
 	for (chip = 0; chip < chip_n; chip++) {
 	for (chip = 0; chip < chip_n; chip++) {
 		struct bitfury_device *d = bf + chip;
 		struct bitfury_device *d = bf + chip;
 		d->chip = chip;
 		d->chip = chip;
+		payload_to_atrvec(d->atrvec, &d->payload);
 		libbitfury_sendHashData1(d, second_run);
 		libbitfury_sendHashData1(d, second_run);
 	}
 	}
 	second_run = true;
 	second_run = true;

+ 2 - 0
libbitfury.h

@@ -24,6 +24,7 @@ struct bitfury_device {
 	struct work * work;
 	struct work * work;
 	struct work * owork;
 	struct work * owork;
 	int job_switched;
 	int job_switched;
+	uint32_t atrvec[20];
 	struct bitfury_payload payload;
 	struct bitfury_payload payload;
 	struct bitfury_payload opayload;
 	struct bitfury_payload opayload;
 	unsigned int results[16];
 	unsigned int results[16];
@@ -34,5 +35,6 @@ int libbitfury_readHashData(unsigned int *res);
 extern void libbitfury_sendHashData1(struct bitfury_device *d, bool want_results);
 extern void libbitfury_sendHashData1(struct bitfury_device *d, bool want_results);
 void libbitfury_sendHashData(struct bitfury_device *bf, int chip_n);
 void libbitfury_sendHashData(struct bitfury_device *bf, int chip_n);
 void work_to_payload(struct bitfury_payload *p, struct work *w);
 void work_to_payload(struct bitfury_payload *p, struct work *w);
+extern void payload_to_atrvec(uint32_t *atrvec, struct bitfury_payload *);
 
 
 #endif /* __LIBBITFURY_H__ */
 #endif /* __LIBBITFURY_H__ */