mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-05-06 07:21:33 +00:00
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>
This commit is contained in:
parent
cbb0cab1d9
commit
16035bcd8c
1 changed files with 32 additions and 11 deletions
|
@ -132,11 +132,20 @@ hex(unsigned char ch)
|
||||||
static unsigned char *
|
static unsigned char *
|
||||||
mem2hex(char *mem, char *buf, int count)
|
mem2hex(char *mem, char *buf, int count)
|
||||||
{
|
{
|
||||||
|
char *tmp;
|
||||||
unsigned char ch;
|
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;
|
longjmp_on_fault = 1;
|
||||||
|
|
||||||
|
memcpy(tmp, mem, count);
|
||||||
|
|
||||||
while (count-- > 0) {
|
while (count-- > 0) {
|
||||||
ch = *mem++;
|
ch = *tmp++;
|
||||||
*buf++ = hexchars[ch >> 4];
|
*buf++ = hexchars[ch >> 4];
|
||||||
*buf++ = hexchars[ch & 0xf];
|
*buf++ = hexchars[ch & 0xf];
|
||||||
}
|
}
|
||||||
|
@ -151,21 +160,33 @@ mem2hex(char *mem, char *buf, int count)
|
||||||
static char *
|
static char *
|
||||||
hex2mem(char *buf, char *mem, int count)
|
hex2mem(char *buf, char *mem, int count)
|
||||||
{
|
{
|
||||||
int i, hexValue;
|
int hexValue;
|
||||||
unsigned char ch;
|
char *tmp_raw, *tmp_hex;
|
||||||
char *mem_start = mem;
|
|
||||||
|
/*
|
||||||
|
* 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;
|
longjmp_on_fault = 1;
|
||||||
for (i=0; i<count; i++) {
|
while (tmp_hex >= buf) {
|
||||||
if ((hexValue = hex(*buf++)) < 0)
|
tmp_raw--;
|
||||||
|
hexValue = hex(*tmp_hex--);
|
||||||
|
if (hexValue < 0)
|
||||||
kgdb_error(KGDBERR_NOTHEXDIG);
|
kgdb_error(KGDBERR_NOTHEXDIG);
|
||||||
ch = hexValue << 4;
|
*tmp_raw = hexValue;
|
||||||
if ((hexValue = hex(*buf++)) < 0)
|
hexValue = hex(*tmp_hex--);
|
||||||
|
if (hexValue < 0)
|
||||||
kgdb_error(KGDBERR_NOTHEXDIG);
|
kgdb_error(KGDBERR_NOTHEXDIG);
|
||||||
ch |= hexValue;
|
*tmp_raw |= hexValue << 4;
|
||||||
*mem++ = ch;
|
|
||||||
}
|
}
|
||||||
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;
|
longjmp_on_fault = 0;
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
|
|
Loading…
Add table
Reference in a new issue