Merge branch 'master' of github.com:ckolivas/cgminer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
diff --git a/configure.ac b/configure.ac
index 7bfdc23..fa8274e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -288,7 +288,7 @@ else
want_usbutils=false
fi
-if test x$bab$bitfury != xnono; then
+if test x$bitfury != xno; then
want_libbitfury=true
else
want_libbitfury=false
diff --git a/driver-bab.c b/driver-bab.c
index e0b54c6..e09d5f2 100644
--- a/driver-bab.c
+++ b/driver-bab.c
@@ -15,7 +15,6 @@
#include "compat.h"
#include "miner.h"
#include "sha2.h"
-#include "libbitfury.h"
#include "klist.h"
#include <ctype.h>
@@ -521,6 +520,67 @@ struct bab_info {
// Don't send work more often than this
#define BAB_EXPECTED_WORK_DELAY_mS 899
+static void bab_ms3steps(uint32_t *p)
+{
+ uint32_t a, b, c, d, e, f, g, h, new_e, new_a;
+ int i;
+
+ a = p[0];
+ b = p[1];
+ c = p[2];
+ d = p[3];
+ e = p[4];
+ f = p[5];
+ g = p[6];
+ h = p[7];
+ for (i = 0; i < 3; i++) {
+ new_e = p[i+16] + sha256_k[i] + h + CH(e,f,g) + SHA256_F2(e) + d;
+ new_a = p[i+16] + sha256_k[i] + h + CH(e,f,g) + SHA256_F2(e) +
+ SHA256_F1(a) + MAJ(a,b,c);
+ d = c;
+ c = b;
+ b = a;
+ a = new_a;
+ h = g;
+ g = f;
+ f = e;
+ e = new_e;
+ }
+ p[15] = a;
+ p[14] = b;
+ p[13] = c;
+ p[12] = d;
+ p[11] = e;
+ p[10] = f;
+ p[9] = g;
+ p[8] = h;
+}
+
+static uint32_t bab_decnonce(uint32_t in)
+{
+ uint32_t out;
+
+ /* First part load */
+ out = (in & 0xFF) << 24;
+ in >>= 8;
+
+ /* Byte reversal */
+ in = (((in & 0xaaaaaaaa) >> 1) | ((in & 0x55555555) << 1));
+ in = (((in & 0xcccccccc) >> 2) | ((in & 0x33333333) << 2));
+ in = (((in & 0xf0f0f0f0) >> 4) | ((in & 0x0f0f0f0f) << 4));
+
+ out |= (in >> 2) & 0x3FFFFF;
+
+ /* Extraction */
+ if (in & 1)
+ out |= (1 << 23);
+ if (in & 2)
+ out |= (1 << 22);
+
+ out -= 0x800004;
+ return out;
+}
+
static void cleanup_older(struct cgpu_info *babcgpu, int chip, K_ITEM *witem)
{
struct bab_info *babinfo = (struct bab_info *)(babcgpu->device_data);
@@ -1772,7 +1832,7 @@ static K_ITEM *process_nonce(struct thr_info *thr, struct cgpu_info *babcgpu, K_
try_fin = BAB_OFF_OTHER_FIN;
}
- nonce = decnonce(raw_nonce);
+ nonce = bab_decnonce(raw_nonce);
cgtime(&now);
@@ -1998,7 +2058,7 @@ static bool bab_do_work(struct cgpu_info *babcgpu)
memcpy((void *)&(DATAW(witem)->chip_input.merkle7),
(void *)&(DATAW(witem)->work->data[WORK_MERKLE7]), MERKLE_BYTES);
- ms3steps((void *)&(DATAW(witem)->chip_input));
+ bab_ms3steps((void *)&(DATAW(witem)->chip_input));
DATAW(witem)->ci_setup = true;
}