Browse Source

change the data to uint8_t, add some test temp code

Xiangfu 13 years ago
parent
commit
b27e26cb12
2 changed files with 21 additions and 17 deletions
  1. 16 12
      driver-avalon.c
  2. 5 5
      driver-avalon.h

+ 16 - 12
driver-avalon.c

@@ -82,15 +82,10 @@ static int avalon_init_task(struct avalon_task *at,
 static inline void avalon_create_task(struct avalon_task *at, struct work *work)
 static inline void avalon_create_task(struct avalon_task *at, struct work *work)
 {
 {
 	memcpy(at->midstate, work->midstate, 32);
 	memcpy(at->midstate, work->midstate, 32);
-	rev((uint8_t *)at->midstate, 32);
+	rev(at->midstate, 32);
 
 
 	memcpy(at->data, work->data + 64, 12);
 	memcpy(at->data, work->data + 64, 12);
-	rev((uint8_t *)at->data, 12);
-
-	if (opt_debug) {
-		applog(LOG_DEBUG, "Avalon: Task + work:");
-		hexdump((uint8_t *)at, sizeof(struct avalon_task));
-	}
+	rev(at->data, 12);
 }
 }
 
 
 static int avalon_send_task(int fd, const struct avalon_task *at)
 static int avalon_send_task(int fd, const struct avalon_task *at)
@@ -177,7 +172,7 @@ static int avalon_get_result(int fd, struct avalon_result *ar,
 	struct cgpu_info *avalon;
 	struct cgpu_info *avalon;
 	struct AVALON_INFO *info;
 	struct AVALON_INFO *info;
 	uint8_t result[AVALON_READ_SIZE];
 	uint8_t result[AVALON_READ_SIZE];
-	int ret, read_count = 10;	/* FIXME: Set to 1s now? */
+	int ret, read_count = 16;	/* FIXME: Set to 1.6s now? */
 
 
 	if (thr) {
 	if (thr) {
 		avalon = thr->cgpu;
 		avalon = thr->cgpu;
@@ -188,6 +183,11 @@ static int avalon_get_result(int fd, struct avalon_result *ar,
 	memset(result, 0, AVALON_READ_SIZE);
 	memset(result, 0, AVALON_READ_SIZE);
 	ret = avalon_gets(fd, result, read_count, thr, tv_finish);
 	ret = avalon_gets(fd, result, read_count, thr, tv_finish);
 
 
+	if (opt_debug) {
+		applog(LOG_DEBUG, "Avalon: get:");
+		hexdump((uint8_t *)result, AVALON_READ_SIZE);
+	}
+
 	if (ret == AVA_GETS_OK)	/* FIXME: maybe some decode/swab here? */
 	if (ret == AVA_GETS_OK)	/* FIXME: maybe some decode/swab here? */
 		memcpy((uint8_t *)ar, result, AVALON_READ_SIZE);
 		memcpy((uint8_t *)ar, result, AVALON_READ_SIZE);
 
 
@@ -197,15 +197,17 @@ static int avalon_get_result(int fd, struct avalon_result *ar,
 static int avalon_decode_nonce(struct work **work, struct avalon_result *ar,
 static int avalon_decode_nonce(struct work **work, struct avalon_result *ar,
 			       uint32_t *nonce)
 			       uint32_t *nonce)
 {
 {
+	uint8_t data[12];
 	int i;
 	int i;
 	*nonce = ar->nonce;
 	*nonce = ar->nonce;
 #if !defined (__BIG_ENDIAN__) && !defined(MIPSEB)
 #if !defined (__BIG_ENDIAN__) && !defined(MIPSEB)
 	*nonce = swab32(*nonce);
 	*nonce = swab32(*nonce);
 #endif
 #endif
 
 
+	memcpy(data, ar->data, 12);
+	rev(data, 12);
 	for (i = 0; i < AVALON_GET_WORK_COUNT; i++) {
 	for (i = 0; i < AVALON_GET_WORK_COUNT; i++) {
-		/* TODO: find the nonce work, return index */
-		if (!memcmp((uint8_t *)(ar->data), work[i]->data + 64, 12))
+		if (!memcmp(data, work[i]->data + 64, 12))
 			break;
 			break;
 	}
 	}
 
 
@@ -213,7 +215,8 @@ static int avalon_decode_nonce(struct work **work, struct avalon_result *ar,
 		return -1;
 		return -1;
 
 
 	i -= 1;
 	i -= 1;
-	return i;
+	/* FIXME:  */
+	return 3;
 }
 }
 
 
 static int avalon_reset(int fd)
 static int avalon_reset(int fd)
@@ -580,7 +583,6 @@ static int64_t avalon_scanhash(struct thr_info *thr, struct work **work,
 	struct avalon_task at;
 	struct avalon_task at;
 	struct avalon_result ar;
 	struct avalon_result ar;
 
 
-	uint8_t nonce_bin[AVALON_READ_SIZE];
 	uint32_t nonce;
 	uint32_t nonce;
 	int64_t hash_count;
 	int64_t hash_count;
 	int i, work_i;
 	int i, work_i;
@@ -684,6 +686,8 @@ static int64_t avalon_scanhash(struct thr_info *thr, struct work **work,
 		hash_count *= info->asic_count;
 		hash_count *= info->asic_count;
 	}
 	}
 
 
+	/* FIXME: */
+	return -1;
 	if (opt_debug || info->do_avalon_timing)
 	if (opt_debug || info->do_avalon_timing)
 		timersub(&tv_finish, &tv_start, &elapsed);
 		timersub(&tv_finish, &tv_start, &elapsed);
 
 

+ 5 - 5
driver-avalon.h

@@ -24,17 +24,17 @@ struct avalon_task {
 	uint32_t pad0_miner_ctrl	:31;
 	uint32_t pad0_miner_ctrl	:31;
 	uint32_t pad1_miner_ctrl;	//Word[2:1]
 	uint32_t pad1_miner_ctrl;	//Word[2:1]
 
 
-	uint32_t midstate[8];
-	uint32_t data[3];
+	uint8_t midstate[32];
+	uint8_t data[12];
 
 
 	// nonce_range: Word[??:14]
 	// nonce_range: Word[??:14]
 } __attribute__((packed));
 } __attribute__((packed));
 
 
 struct avalon_result {
 struct avalon_result {
 	uint32_t nonce;
 	uint32_t nonce;
-	uint32_t data[3];
-	uint32_t midstate[8];
-	uint32_t reserved[2];
+	uint8_t data[12];
+	uint8_t midstate[32];
+	uint8_t reserved[8];
 } __attribute__((packed));
 } __attribute__((packed));
 
 
 struct AVALON_HISTORY {
 struct AVALON_HISTORY {