Browse Source

avalon: Drop custom hexdump logging

Conflicted with symbols in knc-asic submodule
Luke Dashjr 11 years ago
parent
commit
3d9f06f506
5 changed files with 10 additions and 92 deletions
  1. 1 1
      Makefile.am
  2. 9 6
      driver-avalon.c
  3. 0 82
      hexdump.c
  4. 0 2
      logging.h
  5. 0 1
      tm_i2c.c

+ 1 - 1
Makefile.am

@@ -267,7 +267,7 @@ bfgminer_SOURCES += driver-zeusminer.c
 endif
 endif
 
 
 if HAS_AVALON
 if HAS_AVALON
-bfgminer_SOURCES += driver-avalon.c driver-avalon.h hexdump.c
+bfgminer_SOURCES += driver-avalon.c driver-avalon.h
 endif
 endif
 
 
 if USE_AVALONMM
 if USE_AVALONMM

+ 9 - 6
driver-avalon.c

@@ -200,8 +200,9 @@ static int avalon_send_task(int fd, const struct avalon_task *at,
 	if (at->reset)
 	if (at->reset)
 		nr_len = 1;
 		nr_len = 1;
 	if (opt_debug) {
 	if (opt_debug) {
-		applog(LOG_DEBUG, "Avalon: Sent(%u):", (unsigned int)nr_len);
-		hexdump((uint8_t *)buf, nr_len);
+		char x[(nr_len * 2) + 1];
+		bin2hex(x, buf, nr_len);
+		applog(LOG_DEBUG, "Avalon: Sent(%u): %s", (unsigned int)nr_len, x);
 	}
 	}
 	ret = write(fd, buf, nr_len);
 	ret = write(fd, buf, nr_len);
 	if (unlikely(ret != nr_len))
 	if (unlikely(ret != nr_len))
@@ -290,8 +291,9 @@ static int avalon_get_result(int fd, struct avalon_result *ar,
 
 
 	if (ret == AVA_GETS_OK) {
 	if (ret == AVA_GETS_OK) {
 		if (opt_debug) {
 		if (opt_debug) {
-			applog(LOG_DEBUG, "Avalon: get:");
-			hexdump((uint8_t *)result, AVALON_READ_SIZE);
+			char x[(AVALON_READ_SIZE * 2) + 1];
+			bin2hex(x, result, AVALON_READ_SIZE);
+			applog(LOG_DEBUG, "Avalon: get: %s", x);
 		}
 		}
 		memcpy((uint8_t *)ar, result, AVALON_READ_SIZE);
 		memcpy((uint8_t *)ar, result, AVALON_READ_SIZE);
 	}
 	}
@@ -334,8 +336,9 @@ static void avalon_get_reset(int fd, struct avalon_result *ar)
 	ret = avalon_gets(fd, (uint8_t*)ar, read_count, NULL, NULL);
 	ret = avalon_gets(fd, (uint8_t*)ar, read_count, NULL, NULL);
 	
 	
 	if (ret == AVA_GETS_OK && opt_debug) {
 	if (ret == AVA_GETS_OK && opt_debug) {
-		applog(LOG_DEBUG, "Avalon: get:");
-		hexdump((uint8_t *)ar, AVALON_READ_SIZE);
+		char x[(AVALON_READ_SIZE * 2) + 1];
+		bin2hex(x, ar, AVALON_READ_SIZE);
+		applog(LOG_DEBUG, "Avalon: get: %s", x);
 	}
 	}
 }
 }
 
 

+ 0 - 82
hexdump.c

@@ -1,82 +0,0 @@
-/*
- * hexdump implementation without depenecies to *printf()
- * output is equal to 'hexdump -C'
- * should be compatible to 64bit architectures
- *
- * Copyright 2009 Daniel Mack
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-
-#include "logging.h"
-
-#define hex_print(p) applog(LOG_DEBUG, "%s", p)
-
-static char nibble[] = {
-	'0', '1', '2', '3', '4', '5', '6', '7',
-	'8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
-
-#define BYTES_PER_LINE 0x10
-
-void hexdump(const void *vp, unsigned int len)
-{
-	const unsigned char *p = vp;
-	unsigned int i, addr;
-	unsigned int wordlen = sizeof(void*);
-	unsigned char v, line[BYTES_PER_LINE * 5];
-
-	for (addr = 0; addr < len; addr += BYTES_PER_LINE) {
-		/* clear line */
-		for (i = 0; i < sizeof(line); i++) {
-			if (i == wordlen * 2 + 52 ||
-			    i == wordlen * 2 + 69) {
-			    	line[i] = '|';
-				continue;
-			}
-
-			if (i == wordlen * 2 + 70) {
-				line[i] = '\0';
-				continue;
-			}
-
-			line[i] = ' ';
-		}
-
-		/* print address */
-		for (i = 0; i < wordlen * 2; i++) {
-			v = addr >> ((wordlen * 2 - i - 1) * 4);
-			line[i] = nibble[v & 0xf];
-		}
-
-		/* dump content */
-		for (i = 0; i < BYTES_PER_LINE; i++) {
-			int pos = (wordlen * 2) + 3 + (i / 8);
-
-			if (addr + i >= len)
-				break;
-
-			v = p[addr + i];
-			line[pos + (i * 3) + 0] = nibble[v >> 4];
-			line[pos + (i * 3) + 1] = nibble[v & 0xf];
-
-			/* character printable? */
-			line[(wordlen * 2) + 53 + i] =
-				(v >= ' ' && v <= '~') ? v : '.';
-		}
-
-		hex_print(line);
-	}
-}

+ 0 - 2
logging.h

@@ -173,6 +173,4 @@ extern void _bfg_clean_up(bool);
 
 
 #endif
 #endif
 
 
-extern void hexdump(const void *, unsigned int len);
-
 #endif /* __LOGGING_H__ */
 #endif /* __LOGGING_H__ */

+ 0 - 1
tm_i2c.c

@@ -96,7 +96,6 @@ unsigned int tm_i2c_req(int fd, unsigned char addr, unsigned char cmd, unsigned
 		return -1;
 		return -1;
 	}
 	}
 
 
-	//hexdump(buf, 10);
 	ret = (tm->data_msb << 8) + tm->data_lsb;
 	ret = (tm->data_msb << 8) + tm->data_lsb;
 	if (tm->cmd == cmd) return ret;
 	if (tm->cmd == cmd) return ret;
 	return 0;
 	return 0;