Browse Source

dualminer: Split gc3355_scrypt_prepare_work and gc3355_sha2_prepare_work out of dualminer_job_prepare

Nate Woolls 12 years ago
parent
commit
286ba4de32
3 changed files with 36 additions and 25 deletions
  1. 2 25
      driver-dualminer.c
  2. 29 0
      gc3355.c
  3. 5 0
      gc3355.h

+ 2 - 25
driver-dualminer.c

@@ -261,32 +261,9 @@ bool dualminer_job_prepare(struct thr_info *thr, struct work *work, __maybe_unus
 	memset(state->ob_bin, 0, info->ob_size);
 	memset(state->ob_bin, 0, info->ob_size);
 
 
 	if (opt_scrypt)
 	if (opt_scrypt)
-	{
-		state->ob_bin[0] = 0x55;
-		state->ob_bin[1] = 0xaa;
-		state->ob_bin[2] = 0x1f;
-		state->ob_bin[3] = 0x00;
-		memcpy(state->ob_bin + 4, work->target, 32);
-		memcpy(state->ob_bin + 36, work->midstate, 32);
-		memcpy(state->ob_bin + 68, work->data, 80);
-		state->ob_bin[148] = 0xff;
-		state->ob_bin[149] = 0xff;
-		state->ob_bin[150] = 0xff;
-		state->ob_bin[151] = 0xff;
-	}
+		gc3355_scrypt_prepare_work(state->ob_bin, work);
 	else
 	else
-	{
-		uint8_t temp_bin[64];
-		memset(temp_bin, 0, 64);
-		memcpy(temp_bin, work->midstate, 32);
-		memcpy(temp_bin+52, work->data + 64, 12);
-		state->ob_bin[0] = 0x55;
-		state->ob_bin[1] = 0xaa;
-		state->ob_bin[2] = 0x0f;
-		state->ob_bin[3] = 0x00;
-		memcpy(state->ob_bin + 8, temp_bin, 32);
-		memcpy(state->ob_bin + 40, temp_bin + 52, 12);
-	}
+		gc3355_sha2_prepare_work(state->ob_bin, work, false);
 
 
 	return true;
 	return true;
 }
 }

+ 29 - 0
gc3355.c

@@ -545,3 +545,32 @@ void gc3355_init(int fd, char *sha2_unit, bool is_scrypt_only)
 		}
 		}
 	}
 	}
 }
 }
+
+void gc3355_scrypt_prepare_work(unsigned char cmd[156], struct work *work)
+{
+	cmd[0] = 0x55;
+	cmd[1] = 0xaa;
+	cmd[2] = 0x1f;
+	cmd[3] = 0x00;
+	memcpy(cmd + 4, work->target, 32);
+	memcpy(cmd + 36, work->midstate, 32);
+	memcpy(cmd + 68, work->data, 80);
+	cmd[148] = 0xff;
+	cmd[149] = 0xff;
+	cmd[150] = 0xff;
+	cmd[151] = 0xff;
+}
+
+void gc3355_sha2_prepare_work(unsigned char cmd[52], struct work *work, bool simple)
+{
+	uint8_t temp_bin[64];
+	memset(temp_bin, 0, 64);
+	memcpy(temp_bin, work->midstate, 32);
+	memcpy(temp_bin+52, work->data + 64, 12);
+	cmd[0] = 0x55;
+	cmd[1] = 0xaa;
+	cmd[2] = 0x0f;
+	cmd[3] = 0x00;
+	memcpy(cmd + 8, temp_bin, 32);
+	memcpy(cmd + 40, temp_bin + 52, 12);
+}

+ 5 - 0
gc3355.h

@@ -13,6 +13,8 @@
 
 
 #include <stdbool.h>
 #include <stdbool.h>
 
 
+#include "miner.h"
+
 #define SCRYPT_UNIT_OPEN  0
 #define SCRYPT_UNIT_OPEN  0
 #define SCRYPT_UNIT_CLOSE 1
 #define SCRYPT_UNIT_CLOSE 1
 
 
@@ -54,6 +56,9 @@ void gc3355_open_sha2_unit(int fd, char *opt_sha2_gating);
 extern
 extern
 void gc3355_open_scrypt_unit(int fd, int status);
 void gc3355_open_scrypt_unit(int fd, int status);
 
 
+extern void gc3355_scrypt_prepare_work(unsigned char cmd[156], struct work *);
+extern void gc3355_sha2_prepare_work(unsigned char cmd[52], struct work *, bool simple);
+
 #define gc3355_get_cts_status(fd)  ((get_serial_cts(fd) == BGV_LOW) ? 1 : 0)
 #define gc3355_get_cts_status(fd)  ((get_serial_cts(fd) == BGV_LOW) ? 1 : 0)
 
 
 #endif
 #endif