summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorRobin Getz <robin.getz@analog.com>2009-12-21 18:40:44 -0500
committerWolfgang Denk <wd@denx.de>2010-01-18 00:24:21 +0100
commit16035bcd8c81c3c59dddfb54f48e8059a623b13c (patch)
tree3ce5c99500ed65ece855006abea4d4cb7b1c4175 /common
parentcbb0cab1d929839d1cf170b54b1fef05896433ea (diff)
downloadu-boot-imx-16035bcd8c81c3c59dddfb54f48e8059a623b13c.zip
u-boot-imx-16035bcd8c81c3c59dddfb54f48e8059a623b13c.tar.gz
u-boot-imx-16035bcd8c81c3c59dddfb54f48e8059a623b13c.tar.bz2
kgdb: update mem2hex/hex2mem funcs
Convert the funcs to do the conversion inline so that we can do the copy all at once with memcpy. This let's us push out an weird arch-specific issue with accessing different regions of memory to the memcpy function like the MMRs on Blackfin systems, and it should be a bit faster. Signed-off-by: Robin Getz <robin.getz@analog.com> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'common')
-rw-r--r--common/kgdb.c43
1 files changed, 32 insertions, 11 deletions
diff --git a/common/kgdb.c b/common/kgdb.c
index 862f368..0531452 100644
--- a/common/kgdb.c
+++ b/common/kgdb.c
@@ -132,11 +132,20 @@ hex(unsigned char ch)
static unsigned char *
mem2hex(char *mem, char *buf, int count)
{
+ char *tmp;
unsigned char ch;
+ /*
+ * We use the upper half of buf as an intermediate buffer for the
+ * raw memory copy. Hex conversion will work against this one.
+ */
+ tmp = buf + count;
longjmp_on_fault = 1;
+
+ memcpy(tmp, mem, count);
+
while (count-- > 0) {
- ch = *mem++;
+ ch = *tmp++;
*buf++ = hexchars[ch >> 4];
*buf++ = hexchars[ch & 0xf];
}
@@ -151,21 +160,33 @@ mem2hex(char *mem, char *buf, int count)
static char *
hex2mem(char *buf, char *mem, int count)
{
- int i, hexValue;
- unsigned char ch;
- char *mem_start = mem;
+ int hexValue;
+ char *tmp_raw, *tmp_hex;
+
+ /*
+ * We use the upper half of buf as an intermediate buffer for the
+ * raw memory that is converted from hex.
+ */
+ tmp_raw = buf + count * 2;
+ tmp_hex = tmp_raw - 1;
longjmp_on_fault = 1;
- for (i=0; i<count; i++) {
- if ((hexValue = hex(*buf++)) < 0)
+ while (tmp_hex >= buf) {
+ tmp_raw--;
+ hexValue = hex(*tmp_hex--);
+ if (hexValue < 0)
kgdb_error(KGDBERR_NOTHEXDIG);
- ch = hexValue << 4;
- if ((hexValue = hex(*buf++)) < 0)
+ *tmp_raw = hexValue;
+ hexValue = hex(*tmp_hex--);
+ if (hexValue < 0)
kgdb_error(KGDBERR_NOTHEXDIG);
- ch |= hexValue;
- *mem++ = ch;
+ *tmp_raw |= hexValue << 4;
+
}
- kgdb_flush_cache_range((void *)mem_start, (void *)(mem - 1));
+
+ memcpy(mem, tmp_raw, count);
+
+ kgdb_flush_cache_range((void *)mem, (void *)(mem+count));
longjmp_on_fault = 0;
return buf;