diff options
Diffstat (limited to 'arch/cris/arch-v32/kernel')
-rw-r--r-- | arch/cris/arch-v32/kernel/kgdb.c | 60 |
1 files changed, 13 insertions, 47 deletions
diff --git a/arch/cris/arch-v32/kernel/kgdb.c b/arch/cris/arch-v32/kernel/kgdb.c index 4e2e2e271efb..8bd5a5bc0dc7 100644 --- a/arch/cris/arch-v32/kernel/kgdb.c +++ b/arch/cris/arch-v32/kernel/kgdb.c | |||
@@ -398,14 +398,6 @@ void putDebugChar(int val) | |||
398 | } | 398 | } |
399 | #endif | 399 | #endif |
400 | 400 | ||
401 | /* Returns the character equivalent of a nibble, bit 7, 6, 5, and 4 of a byte, | ||
402 | represented by int x. */ | ||
403 | static char highhex(int x); | ||
404 | |||
405 | /* Returns the character equivalent of a nibble, bit 3, 2, 1, and 0 of a byte, | ||
406 | represented by int x. */ | ||
407 | static char lowhex(int x); | ||
408 | |||
409 | /* Returns the integer equivalent of a hexadecimal character. */ | 401 | /* Returns the integer equivalent of a hexadecimal character. */ |
410 | static int hex(char ch); | 402 | static int hex(char ch); |
411 | 403 | ||
@@ -464,9 +456,6 @@ void breakpoint(void); | |||
464 | /* Run-length encoding maximum length. Send 64 at most. */ | 456 | /* Run-length encoding maximum length. Send 64 at most. */ |
465 | #define RUNLENMAX 64 | 457 | #define RUNLENMAX 64 |
466 | 458 | ||
467 | /* Definition of all valid hexadecimal characters */ | ||
468 | static const char hexchars[] = "0123456789abcdef"; | ||
469 | |||
470 | /* The inbound/outbound buffers used in packet I/O */ | 459 | /* The inbound/outbound buffers used in packet I/O */ |
471 | static char input_buffer[BUFMAX]; | 460 | static char input_buffer[BUFMAX]; |
472 | static char output_buffer[BUFMAX]; | 461 | static char output_buffer[BUFMAX]; |
@@ -550,8 +539,8 @@ gdb_cris_strtol(const char *s, char **endptr, int base) | |||
550 | char *sd; | 539 | char *sd; |
551 | int x = 0; | 540 | int x = 0; |
552 | 541 | ||
553 | for (s1 = (char*)s; (sd = gdb_cris_memchr(hexchars, *s1, base)) != NULL; ++s1) | 542 | for (s1 = (char*)s; (sd = gdb_cris_memchr(hex_asc, *s1, base)) != NULL; ++s1) |
554 | x = x * base + (sd - hexchars); | 543 | x = x * base + (sd - hex_asc); |
555 | 544 | ||
556 | if (endptr) { | 545 | if (endptr) { |
557 | /* Unconverted suffix is stored in endptr unless endptr is NULL. */ | 546 | /* Unconverted suffix is stored in endptr unless endptr is NULL. */ |
@@ -655,22 +644,6 @@ read_register(char regno, unsigned int *valptr) | |||
655 | } | 644 | } |
656 | 645 | ||
657 | /********************************** Packet I/O ******************************/ | 646 | /********************************** Packet I/O ******************************/ |
658 | /* Returns the character equivalent of a nibble, bit 7, 6, 5, and 4 of a byte, | ||
659 | represented by int x. */ | ||
660 | static inline char | ||
661 | highhex(int x) | ||
662 | { | ||
663 | return hexchars[(x >> 4) & 0xf]; | ||
664 | } | ||
665 | |||
666 | /* Returns the character equivalent of a nibble, bit 3, 2, 1, and 0 of a byte, | ||
667 | represented by int x. */ | ||
668 | static inline char | ||
669 | lowhex(int x) | ||
670 | { | ||
671 | return hexchars[x & 0xf]; | ||
672 | } | ||
673 | |||
674 | /* Returns the integer equivalent of a hexadecimal character. */ | 647 | /* Returns the integer equivalent of a hexadecimal character. */ |
675 | static int | 648 | static int |
676 | hex(char ch) | 649 | hex(char ch) |
@@ -704,8 +677,7 @@ mem2hex(char *buf, unsigned char *mem, int count) | |||
704 | /* Valid mem address. */ | 677 | /* Valid mem address. */ |
705 | for (i = 0; i < count; i++) { | 678 | for (i = 0; i < count; i++) { |
706 | ch = *mem++; | 679 | ch = *mem++; |
707 | *buf++ = highhex (ch); | 680 | buf = pack_hex_byte(buf, ch); |
708 | *buf++ = lowhex (ch); | ||
709 | } | 681 | } |
710 | } | 682 | } |
711 | /* Terminate properly. */ | 683 | /* Terminate properly. */ |
@@ -723,8 +695,7 @@ mem2hex_nbo(char *buf, unsigned char *mem, int count) | |||
723 | mem += count - 1; | 695 | mem += count - 1; |
724 | for (i = 0; i < count; i++) { | 696 | for (i = 0; i < count; i++) { |
725 | ch = *mem--; | 697 | ch = *mem--; |
726 | *buf++ = highhex (ch); | 698 | buf = pack_hex_byte(buf, ch); |
727 | *buf++ = lowhex (ch); | ||
728 | } | 699 | } |
729 | 700 | ||
730 | /* Terminate properly. */ | 701 | /* Terminate properly. */ |
@@ -862,8 +833,8 @@ putpacket(char *buffer) | |||
862 | } | 833 | } |
863 | } | 834 | } |
864 | putDebugChar('#'); | 835 | putDebugChar('#'); |
865 | putDebugChar(highhex (checksum)); | 836 | putDebugChar(hex_asc_hi(checksum)); |
866 | putDebugChar(lowhex (checksum)); | 837 | putDebugChar(hex_asc_lo(checksum)); |
867 | } while(kgdb_started && (getDebugChar() != '+')); | 838 | } while(kgdb_started && (getDebugChar() != '+')); |
868 | } | 839 | } |
869 | 840 | ||
@@ -909,8 +880,7 @@ stub_is_stopped(int sigval) | |||
909 | /* Send trap type (converted to signal) */ | 880 | /* Send trap type (converted to signal) */ |
910 | 881 | ||
911 | *ptr++ = 'T'; | 882 | *ptr++ = 'T'; |
912 | *ptr++ = highhex(sigval); | 883 | ptr = pack_hex_byte(ptr, sigval); |
913 | *ptr++ = lowhex(sigval); | ||
914 | 884 | ||
915 | if (((reg.exs & 0xff00) >> 8) == 0xc) { | 885 | if (((reg.exs & 0xff00) >> 8) == 0xc) { |
916 | 886 | ||
@@ -1018,30 +988,26 @@ stub_is_stopped(int sigval) | |||
1018 | } | 988 | } |
1019 | /* Only send PC, frame and stack pointer. */ | 989 | /* Only send PC, frame and stack pointer. */ |
1020 | read_register(PC, ®_cont); | 990 | read_register(PC, ®_cont); |
1021 | *ptr++ = highhex(PC); | 991 | ptr = pack_hex_byte(PC); |
1022 | *ptr++ = lowhex(PC); | ||
1023 | *ptr++ = ':'; | 992 | *ptr++ = ':'; |
1024 | ptr = mem2hex(ptr, (unsigned char *)®_cont, register_size[PC]); | 993 | ptr = mem2hex(ptr, (unsigned char *)®_cont, register_size[PC]); |
1025 | *ptr++ = ';'; | 994 | *ptr++ = ';'; |
1026 | 995 | ||
1027 | read_register(R8, ®_cont); | 996 | read_register(R8, ®_cont); |
1028 | *ptr++ = highhex(R8); | 997 | ptr = pack_hex_byte(R8); |
1029 | *ptr++ = lowhex(R8); | ||
1030 | *ptr++ = ':'; | 998 | *ptr++ = ':'; |
1031 | ptr = mem2hex(ptr, (unsigned char *)®_cont, register_size[R8]); | 999 | ptr = mem2hex(ptr, (unsigned char *)®_cont, register_size[R8]); |
1032 | *ptr++ = ';'; | 1000 | *ptr++ = ';'; |
1033 | 1001 | ||
1034 | read_register(SP, ®_cont); | 1002 | read_register(SP, ®_cont); |
1035 | *ptr++ = highhex(SP); | 1003 | ptr = pack_hex_byte(SP); |
1036 | *ptr++ = lowhex(SP); | ||
1037 | *ptr++ = ':'; | 1004 | *ptr++ = ':'; |
1038 | ptr = mem2hex(ptr, (unsigned char *)®_cont, register_size[SP]); | 1005 | ptr = mem2hex(ptr, (unsigned char *)®_cont, register_size[SP]); |
1039 | *ptr++ = ';'; | 1006 | *ptr++ = ';'; |
1040 | 1007 | ||
1041 | /* Send ERP as well; this will save us an entire register fetch in some cases. */ | 1008 | /* Send ERP as well; this will save us an entire register fetch in some cases. */ |
1042 | read_register(ERP, ®_cont); | 1009 | read_register(ERP, ®_cont); |
1043 | *ptr++ = highhex(ERP); | 1010 | ptr = pack_hex_byte(ERP); |
1044 | *ptr++ = lowhex(ERP); | ||
1045 | *ptr++ = ':'; | 1011 | *ptr++ = ':'; |
1046 | ptr = mem2hex(ptr, (unsigned char *)®_cont, register_size[ERP]); | 1012 | ptr = mem2hex(ptr, (unsigned char *)®_cont, register_size[ERP]); |
1047 | *ptr++ = ';'; | 1013 | *ptr++ = ';'; |
@@ -1533,8 +1499,8 @@ handle_exception(int sigval) | |||
1533 | Success: SAA, where AA is the signal number. | 1499 | Success: SAA, where AA is the signal number. |
1534 | Failure: void. */ | 1500 | Failure: void. */ |
1535 | output_buffer[0] = 'S'; | 1501 | output_buffer[0] = 'S'; |
1536 | output_buffer[1] = highhex(sigval); | 1502 | output_buffer[1] = hex_asc_hi(sigval); |
1537 | output_buffer[2] = lowhex(sigval); | 1503 | output_buffer[2] = hex_asc_lo(sigval); |
1538 | output_buffer[3] = 0; | 1504 | output_buffer[3] = 0; |
1539 | break; | 1505 | break; |
1540 | 1506 | ||