diff options
author | Harvey Harrison <harvey.harrison@gmail.com> | 2008-07-25 22:45:19 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-26 15:00:05 -0400 |
commit | 19caeed6339aec02901e2f4c49d8e1d3d6090559 (patch) | |
tree | 97cf94f185857c99f8e407b22e725145b9e412ad /arch/frv/kernel | |
parent | 42a9a58361d3b65f4a7c2ad280cc1ec9b657e7d2 (diff) |
frv: use the common ascii hex helpers
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/frv/kernel')
-rw-r--r-- | arch/frv/kernel/gdb-stub.c | 88 |
1 files changed, 36 insertions, 52 deletions
diff --git a/arch/frv/kernel/gdb-stub.c b/arch/frv/kernel/gdb-stub.c index 48a0393e7cee..7ca8a6b19ac9 100644 --- a/arch/frv/kernel/gdb-stub.c +++ b/arch/frv/kernel/gdb-stub.c | |||
@@ -182,8 +182,6 @@ extern volatile u32 __attribute__((section(".bss"))) gdbstub_trace_through_excep | |||
182 | static char input_buffer[BUFMAX]; | 182 | static char input_buffer[BUFMAX]; |
183 | static char output_buffer[BUFMAX]; | 183 | static char output_buffer[BUFMAX]; |
184 | 184 | ||
185 | static const char hexchars[] = "0123456789abcdef"; | ||
186 | |||
187 | static const char *regnames[] = { | 185 | static const char *regnames[] = { |
188 | "PSR ", "ISR ", "CCR ", "CCCR", | 186 | "PSR ", "ISR ", "CCR ", "CCCR", |
189 | "LR ", "LCR ", "PC ", "_stt", | 187 | "LR ", "LCR ", "PC ", "_stt", |
@@ -383,8 +381,8 @@ static int gdbstub_send_packet(char *buffer) | |||
383 | } | 381 | } |
384 | 382 | ||
385 | gdbstub_tx_char('#'); | 383 | gdbstub_tx_char('#'); |
386 | gdbstub_tx_char(hexchars[checksum >> 4]); | 384 | gdbstub_tx_char(hex_asc_hi(checksum)); |
387 | gdbstub_tx_char(hexchars[checksum & 0xf]); | 385 | gdbstub_tx_char(hex_asc_lo(checksum)); |
388 | 386 | ||
389 | } while (gdbstub_rx_char(&ch,0), | 387 | } while (gdbstub_rx_char(&ch,0), |
390 | #ifdef GDBSTUB_DEBUG_PROTOCOL | 388 | #ifdef GDBSTUB_DEBUG_PROTOCOL |
@@ -674,8 +672,7 @@ static unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fa | |||
674 | if ((uint32_t)mem&1 && count>=1) { | 672 | if ((uint32_t)mem&1 && count>=1) { |
675 | if (!gdbstub_read_byte(mem,ch)) | 673 | if (!gdbstub_read_byte(mem,ch)) |
676 | return NULL; | 674 | return NULL; |
677 | *buf++ = hexchars[ch[0] >> 4]; | 675 | buf = pack_hex_byte(buf, ch[0]); |
678 | *buf++ = hexchars[ch[0] & 0xf]; | ||
679 | mem++; | 676 | mem++; |
680 | count--; | 677 | count--; |
681 | } | 678 | } |
@@ -683,10 +680,8 @@ static unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fa | |||
683 | if ((uint32_t)mem&3 && count>=2) { | 680 | if ((uint32_t)mem&3 && count>=2) { |
684 | if (!gdbstub_read_word(mem,(uint16_t *)ch)) | 681 | if (!gdbstub_read_word(mem,(uint16_t *)ch)) |
685 | return NULL; | 682 | return NULL; |
686 | *buf++ = hexchars[ch[0] >> 4]; | 683 | buf = pack_hex_byte(buf, ch[0]); |
687 | *buf++ = hexchars[ch[0] & 0xf]; | 684 | buf = pack_hex_byte(buf, ch[1]); |
688 | *buf++ = hexchars[ch[1] >> 4]; | ||
689 | *buf++ = hexchars[ch[1] & 0xf]; | ||
690 | mem += 2; | 685 | mem += 2; |
691 | count -= 2; | 686 | count -= 2; |
692 | } | 687 | } |
@@ -694,14 +689,10 @@ static unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fa | |||
694 | while (count>=4) { | 689 | while (count>=4) { |
695 | if (!gdbstub_read_dword(mem,(uint32_t *)ch)) | 690 | if (!gdbstub_read_dword(mem,(uint32_t *)ch)) |
696 | return NULL; | 691 | return NULL; |
697 | *buf++ = hexchars[ch[0] >> 4]; | 692 | buf = pack_hex_byte(buf, ch[0]); |
698 | *buf++ = hexchars[ch[0] & 0xf]; | 693 | buf = pack_hex_byte(buf, ch[1]); |
699 | *buf++ = hexchars[ch[1] >> 4]; | 694 | buf = pack_hex_byte(buf, ch[2]); |
700 | *buf++ = hexchars[ch[1] & 0xf]; | 695 | buf = pack_hex_byte(buf, ch[3]); |
701 | *buf++ = hexchars[ch[2] >> 4]; | ||
702 | *buf++ = hexchars[ch[2] & 0xf]; | ||
703 | *buf++ = hexchars[ch[3] >> 4]; | ||
704 | *buf++ = hexchars[ch[3] & 0xf]; | ||
705 | mem += 4; | 696 | mem += 4; |
706 | count -= 4; | 697 | count -= 4; |
707 | } | 698 | } |
@@ -709,10 +700,8 @@ static unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fa | |||
709 | if (count>=2) { | 700 | if (count>=2) { |
710 | if (!gdbstub_read_word(mem,(uint16_t *)ch)) | 701 | if (!gdbstub_read_word(mem,(uint16_t *)ch)) |
711 | return NULL; | 702 | return NULL; |
712 | *buf++ = hexchars[ch[0] >> 4]; | 703 | buf = pack_hex_byte(buf, ch[0]); |
713 | *buf++ = hexchars[ch[0] & 0xf]; | 704 | buf = pack_hex_byte(buf, ch[1]); |
714 | *buf++ = hexchars[ch[1] >> 4]; | ||
715 | *buf++ = hexchars[ch[1] & 0xf]; | ||
716 | mem += 2; | 705 | mem += 2; |
717 | count -= 2; | 706 | count -= 2; |
718 | } | 707 | } |
@@ -720,8 +709,7 @@ static unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fa | |||
720 | if (count>=1) { | 709 | if (count>=1) { |
721 | if (!gdbstub_read_byte(mem,ch)) | 710 | if (!gdbstub_read_byte(mem,ch)) |
722 | return NULL; | 711 | return NULL; |
723 | *buf++ = hexchars[ch[0] >> 4]; | 712 | buf = pack_hex_byte(buf, ch[0]); |
724 | *buf++ = hexchars[ch[0] & 0xf]; | ||
725 | } | 713 | } |
726 | 714 | ||
727 | *buf = 0; | 715 | *buf = 0; |
@@ -1471,22 +1459,22 @@ void gdbstub(int sigval) | |||
1471 | *ptr++ = 'O'; | 1459 | *ptr++ = 'O'; |
1472 | ptr = mem2hex(title, ptr, sizeof(title) - 1,0); | 1460 | ptr = mem2hex(title, ptr, sizeof(title) - 1,0); |
1473 | 1461 | ||
1474 | hx = hexchars[(brr & 0xf0000000) >> 28]; | 1462 | hx = hex_asc_hi(brr >> 24); |
1475 | *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; | 1463 | ptr = pack_hex_byte(ptr, hx); |
1476 | hx = hexchars[(brr & 0x0f000000) >> 24]; | 1464 | hx = hex_asc_lo(brr >> 24); |
1477 | *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; | 1465 | ptr = pack_hex_byte(ptr, hx); |
1478 | hx = hexchars[(brr & 0x00f00000) >> 20]; | 1466 | hx = hex_asc_hi(brr >> 16); |
1479 | *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; | 1467 | ptr = pack_hex_byte(ptr, hx); |
1480 | hx = hexchars[(brr & 0x000f0000) >> 16]; | 1468 | hx = hex_asc_lo(brr >> 16); |
1481 | *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; | 1469 | ptr = pack_hex_byte(ptr, hx); |
1482 | hx = hexchars[(brr & 0x0000f000) >> 12]; | 1470 | hx = hex_asc_hi(brr >> 8); |
1483 | *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; | 1471 | ptr = pack_hex_byte(ptr, hx); |
1484 | hx = hexchars[(brr & 0x00000f00) >> 8]; | 1472 | hx = hex_asc_lo(brr >> 8); |
1485 | *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; | 1473 | ptr = pack_hex_byte(ptr, hx); |
1486 | hx = hexchars[(brr & 0x000000f0) >> 4]; | 1474 | hx = hex_asc_hi(brr); |
1487 | *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; | 1475 | ptr = pack_hex_byte(ptr, hx); |
1488 | hx = hexchars[(brr & 0x0000000f)]; | 1476 | hx = hex_asc_lo(brr); |
1489 | *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; | 1477 | ptr = pack_hex_byte(ptr, hx); |
1490 | 1478 | ||
1491 | ptr = mem2hex(crlf, ptr, sizeof(crlf) - 1, 0); | 1479 | ptr = mem2hex(crlf, ptr, sizeof(crlf) - 1, 0); |
1492 | *ptr = 0; | 1480 | *ptr = 0; |
@@ -1500,12 +1488,10 @@ void gdbstub(int sigval) | |||
1500 | 1488 | ||
1501 | /* Send trap type (converted to signal) */ | 1489 | /* Send trap type (converted to signal) */ |
1502 | *ptr++ = 'T'; | 1490 | *ptr++ = 'T'; |
1503 | *ptr++ = hexchars[sigval >> 4]; | 1491 | ptr = pack_hex_byte(ptr, sigval); |
1504 | *ptr++ = hexchars[sigval & 0xf]; | ||
1505 | 1492 | ||
1506 | /* Send Error PC */ | 1493 | /* Send Error PC */ |
1507 | *ptr++ = hexchars[GDB_REG_PC >> 4]; | 1494 | ptr = pack_hex_byte(ptr, GDB_REG_PC); |
1508 | *ptr++ = hexchars[GDB_REG_PC & 0xf]; | ||
1509 | *ptr++ = ':'; | 1495 | *ptr++ = ':'; |
1510 | ptr = mem2hex(&__debug_frame->pc, ptr, 4, 0); | 1496 | ptr = mem2hex(&__debug_frame->pc, ptr, 4, 0); |
1511 | *ptr++ = ';'; | 1497 | *ptr++ = ';'; |
@@ -1513,8 +1499,7 @@ void gdbstub(int sigval) | |||
1513 | /* | 1499 | /* |
1514 | * Send frame pointer | 1500 | * Send frame pointer |
1515 | */ | 1501 | */ |
1516 | *ptr++ = hexchars[GDB_REG_FP >> 4]; | 1502 | ptr = pack_hex_byte(ptr, GDB_REG_FP); |
1517 | *ptr++ = hexchars[GDB_REG_FP & 0xf]; | ||
1518 | *ptr++ = ':'; | 1503 | *ptr++ = ':'; |
1519 | ptr = mem2hex(&__debug_frame->fp, ptr, 4, 0); | 1504 | ptr = mem2hex(&__debug_frame->fp, ptr, 4, 0); |
1520 | *ptr++ = ';'; | 1505 | *ptr++ = ';'; |
@@ -1522,8 +1507,7 @@ void gdbstub(int sigval) | |||
1522 | /* | 1507 | /* |
1523 | * Send stack pointer | 1508 | * Send stack pointer |
1524 | */ | 1509 | */ |
1525 | *ptr++ = hexchars[GDB_REG_SP >> 4]; | 1510 | ptr = pack_hex_byte(ptr, GDB_REG_SP); |
1526 | *ptr++ = hexchars[GDB_REG_SP & 0xf]; | ||
1527 | *ptr++ = ':'; | 1511 | *ptr++ = ':'; |
1528 | ptr = mem2hex(&__debug_frame->sp, ptr, 4, 0); | 1512 | ptr = mem2hex(&__debug_frame->sp, ptr, 4, 0); |
1529 | *ptr++ = ';'; | 1513 | *ptr++ = ';'; |
@@ -1548,8 +1532,8 @@ void gdbstub(int sigval) | |||
1548 | /* request repeat of last signal number */ | 1532 | /* request repeat of last signal number */ |
1549 | case '?': | 1533 | case '?': |
1550 | output_buffer[0] = 'S'; | 1534 | output_buffer[0] = 'S'; |
1551 | output_buffer[1] = hexchars[sigval >> 4]; | 1535 | output_buffer[1] = hex_asc_hi(sigval); |
1552 | output_buffer[2] = hexchars[sigval & 0xf]; | 1536 | output_buffer[2] = hex_asc_lo(sigval); |
1553 | output_buffer[3] = 0; | 1537 | output_buffer[3] = 0; |
1554 | break; | 1538 | break; |
1555 | 1539 | ||
@@ -2059,8 +2043,8 @@ void gdbstub_exit(int status) | |||
2059 | } | 2043 | } |
2060 | 2044 | ||
2061 | gdbstub_tx_char('#'); | 2045 | gdbstub_tx_char('#'); |
2062 | gdbstub_tx_char(hexchars[checksum >> 4]); | 2046 | gdbstub_tx_char(hex_asc_hi(checksum)); |
2063 | gdbstub_tx_char(hexchars[checksum & 0xf]); | 2047 | gdbstub_tx_char(hex_asc_lo(checksum)); |
2064 | 2048 | ||
2065 | /* make sure the output is flushed, or else RedBoot might clobber it */ | 2049 | /* make sure the output is flushed, or else RedBoot might clobber it */ |
2066 | gdbstub_tx_char('-'); | 2050 | gdbstub_tx_char('-'); |