diff options
author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2008-07-26 18:04:59 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2008-07-26 18:04:59 -0400 |
commit | d9ecdb282c91952796b7542c4f57fd6de6948d7b (patch) | |
tree | fd4de7923968afa7d2981fb037e2255fc2cfa1e1 /arch/cris/arch-v10/kernel/kgdb.c | |
parent | 4ef584ba84125b67c17b5aded38e7783cd8cdef0 (diff) | |
parent | 1d1f8b377c48e5aeddaea52eba74cc0539f088cd (diff) |
Merge branch 'for_rmk_13' of git://git.mnementh.co.uk/linux-2.6-im
Diffstat (limited to 'arch/cris/arch-v10/kernel/kgdb.c')
-rw-r--r-- | arch/cris/arch-v10/kernel/kgdb.c | 79 |
1 files changed, 24 insertions, 55 deletions
diff --git a/arch/cris/arch-v10/kernel/kgdb.c b/arch/cris/arch-v10/kernel/kgdb.c index a3ca55150745..6fea45f2e40c 100644 --- a/arch/cris/arch-v10/kernel/kgdb.c +++ b/arch/cris/arch-v10/kernel/kgdb.c | |||
@@ -278,14 +278,6 @@ void putDebugChar (int val); | |||
278 | 278 | ||
279 | void enableDebugIRQ (void); | 279 | void enableDebugIRQ (void); |
280 | 280 | ||
281 | /* Returns the character equivalent of a nibble, bit 7, 6, 5, and 4 of a byte, | ||
282 | represented by int x. */ | ||
283 | static char highhex (int x); | ||
284 | |||
285 | /* Returns the character equivalent of a nibble, bit 3, 2, 1, and 0 of a byte, | ||
286 | represented by int x. */ | ||
287 | static char lowhex (int x); | ||
288 | |||
289 | /* Returns the integer equivalent of a hexadecimal character. */ | 281 | /* Returns the integer equivalent of a hexadecimal character. */ |
290 | static int hex (char ch); | 282 | static int hex (char ch); |
291 | 283 | ||
@@ -356,9 +348,6 @@ extern unsigned char executing_task; | |||
356 | /* Run-length encoding maximum length. Send 64 at most. */ | 348 | /* Run-length encoding maximum length. Send 64 at most. */ |
357 | #define RUNLENMAX 64 | 349 | #define RUNLENMAX 64 |
358 | 350 | ||
359 | /* Definition of all valid hexadecimal characters */ | ||
360 | static const char hexchars[] = "0123456789abcdef"; | ||
361 | |||
362 | /* The inbound/outbound buffers used in packet I/O */ | 351 | /* The inbound/outbound buffers used in packet I/O */ |
363 | static char remcomInBuffer[BUFMAX]; | 352 | static char remcomInBuffer[BUFMAX]; |
364 | static char remcomOutBuffer[BUFMAX]; | 353 | static char remcomOutBuffer[BUFMAX]; |
@@ -499,8 +488,8 @@ gdb_cris_strtol (const char *s, char **endptr, int base) | |||
499 | char *sd; | 488 | char *sd; |
500 | int x = 0; | 489 | int x = 0; |
501 | 490 | ||
502 | for (s1 = (char*)s; (sd = gdb_cris_memchr(hexchars, *s1, base)) != NULL; ++s1) | 491 | for (s1 = (char*)s; (sd = gdb_cris_memchr(hex_asc, *s1, base)) != NULL; ++s1) |
503 | x = x * base + (sd - hexchars); | 492 | x = x * base + (sd - hex_asc); |
504 | 493 | ||
505 | if (endptr) | 494 | if (endptr) |
506 | { | 495 | { |
@@ -670,22 +659,6 @@ read_register (char regno, unsigned int *valptr) | |||
670 | } | 659 | } |
671 | 660 | ||
672 | /********************************** Packet I/O ******************************/ | 661 | /********************************** Packet I/O ******************************/ |
673 | /* Returns the character equivalent of a nibble, bit 7, 6, 5, and 4 of a byte, | ||
674 | represented by int x. */ | ||
675 | static inline char | ||
676 | highhex(int x) | ||
677 | { | ||
678 | return hexchars[(x >> 4) & 0xf]; | ||
679 | } | ||
680 | |||
681 | /* Returns the character equivalent of a nibble, bit 3, 2, 1, and 0 of a byte, | ||
682 | represented by int x. */ | ||
683 | static inline char | ||
684 | lowhex(int x) | ||
685 | { | ||
686 | return hexchars[x & 0xf]; | ||
687 | } | ||
688 | |||
689 | /* Returns the integer equivalent of a hexadecimal character. */ | 662 | /* Returns the integer equivalent of a hexadecimal character. */ |
690 | static int | 663 | static int |
691 | hex (char ch) | 664 | hex (char ch) |
@@ -721,8 +694,7 @@ mem2hex(char *buf, unsigned char *mem, int count) | |||
721 | /* Valid mem address. */ | 694 | /* Valid mem address. */ |
722 | for (i = 0; i < count; i++) { | 695 | for (i = 0; i < count; i++) { |
723 | ch = *mem++; | 696 | ch = *mem++; |
724 | *buf++ = highhex (ch); | 697 | buf = pack_hex_byte(buf, ch); |
725 | *buf++ = lowhex (ch); | ||
726 | } | 698 | } |
727 | } | 699 | } |
728 | 700 | ||
@@ -857,9 +829,9 @@ putpacket(char *buffer) | |||
857 | src++; | 829 | src++; |
858 | } | 830 | } |
859 | } | 831 | } |
860 | putDebugChar ('#'); | 832 | putDebugChar('#'); |
861 | putDebugChar (highhex (checksum)); | 833 | putDebugChar(hex_asc_hi(checksum)); |
862 | putDebugChar (lowhex (checksum)); | 834 | putDebugChar(hex_asc_lo(checksum)); |
863 | } while(kgdb_started && (getDebugChar() != '+')); | 835 | } while(kgdb_started && (getDebugChar() != '+')); |
864 | } | 836 | } |
865 | 837 | ||
@@ -895,9 +867,8 @@ stub_is_stopped(int sigval) | |||
895 | 867 | ||
896 | /* Send trap type (converted to signal) */ | 868 | /* Send trap type (converted to signal) */ |
897 | 869 | ||
898 | *ptr++ = 'T'; | 870 | *ptr++ = 'T'; |
899 | *ptr++ = highhex (sigval); | 871 | ptr = pack_hex_byte(ptr, sigval); |
900 | *ptr++ = lowhex (sigval); | ||
901 | 872 | ||
902 | /* Send register contents. We probably only need to send the | 873 | /* Send register contents. We probably only need to send the |
903 | * PC, frame pointer and stack pointer here. Other registers will be | 874 | * PC, frame pointer and stack pointer here. Other registers will be |
@@ -910,9 +881,7 @@ stub_is_stopped(int sigval) | |||
910 | status = read_register (regno, ®_cont); | 881 | status = read_register (regno, ®_cont); |
911 | 882 | ||
912 | if (status == SUCCESS) { | 883 | if (status == SUCCESS) { |
913 | 884 | ptr = pack_hex_byte(ptr, regno); | |
914 | *ptr++ = highhex (regno); | ||
915 | *ptr++ = lowhex (regno); | ||
916 | *ptr++ = ':'; | 885 | *ptr++ = ':'; |
917 | 886 | ||
918 | ptr = mem2hex(ptr, (unsigned char *)®_cont, | 887 | ptr = mem2hex(ptr, (unsigned char *)®_cont, |
@@ -937,8 +906,8 @@ stub_is_stopped(int sigval) | |||
937 | /* Store thread:r...; with the executing task TID. */ | 906 | /* Store thread:r...; with the executing task TID. */ |
938 | gdb_cris_strcpy (&remcomOutBuffer[pos], "thread:"); | 907 | gdb_cris_strcpy (&remcomOutBuffer[pos], "thread:"); |
939 | pos += gdb_cris_strlen ("thread:"); | 908 | pos += gdb_cris_strlen ("thread:"); |
940 | remcomOutBuffer[pos++] = highhex (executing_task); | 909 | remcomOutBuffer[pos++] = hex_asc_hi(executing_task); |
941 | remcomOutBuffer[pos++] = lowhex (executing_task); | 910 | remcomOutBuffer[pos++] = hex_asc_lo(executing_task); |
942 | gdb_cris_strcpy (&remcomOutBuffer[pos], ";"); | 911 | gdb_cris_strcpy (&remcomOutBuffer[pos], ";"); |
943 | #endif | 912 | #endif |
944 | 913 | ||
@@ -1126,8 +1095,8 @@ handle_exception (int sigval) | |||
1126 | Success: SAA, where AA is the signal number. | 1095 | Success: SAA, where AA is the signal number. |
1127 | Failure: void. */ | 1096 | Failure: void. */ |
1128 | remcomOutBuffer[0] = 'S'; | 1097 | remcomOutBuffer[0] = 'S'; |
1129 | remcomOutBuffer[1] = highhex (sigval); | 1098 | remcomOutBuffer[1] = hex_asc_hi(sigval); |
1130 | remcomOutBuffer[2] = lowhex (sigval); | 1099 | remcomOutBuffer[2] = hex_asc_lo(sigval); |
1131 | remcomOutBuffer[3] = 0; | 1100 | remcomOutBuffer[3] = 0; |
1132 | break; | 1101 | break; |
1133 | 1102 | ||
@@ -1224,23 +1193,23 @@ handle_exception (int sigval) | |||
1224 | case 'C': | 1193 | case 'C': |
1225 | /* Identify the remote current thread. */ | 1194 | /* Identify the remote current thread. */ |
1226 | gdb_cris_strcpy (&remcomOutBuffer[0], "QC"); | 1195 | gdb_cris_strcpy (&remcomOutBuffer[0], "QC"); |
1227 | remcomOutBuffer[2] = highhex (current_thread_c); | 1196 | remcomOutBuffer[2] = hex_asc_hi(current_thread_c); |
1228 | remcomOutBuffer[3] = lowhex (current_thread_c); | 1197 | remcomOutBuffer[3] = hex_asc_lo(current_thread_c); |
1229 | remcomOutBuffer[4] = '\0'; | 1198 | remcomOutBuffer[4] = '\0'; |
1230 | break; | 1199 | break; |
1231 | case 'L': | 1200 | case 'L': |
1232 | gdb_cris_strcpy (&remcomOutBuffer[0], "QM"); | 1201 | gdb_cris_strcpy (&remcomOutBuffer[0], "QM"); |
1233 | /* Reply with number of threads. */ | 1202 | /* Reply with number of threads. */ |
1234 | if (os_is_started()) { | 1203 | if (os_is_started()) { |
1235 | remcomOutBuffer[2] = highhex (number_of_tasks); | 1204 | remcomOutBuffer[2] = hex_asc_hi(number_of_tasks); |
1236 | remcomOutBuffer[3] = lowhex (number_of_tasks); | 1205 | remcomOutBuffer[3] = hex_asc_lo(number_of_tasks); |
1237 | } | 1206 | } |
1238 | else { | 1207 | else { |
1239 | remcomOutBuffer[2] = highhex (0); | 1208 | remcomOutBuffer[2] = hex_asc_hi(0); |
1240 | remcomOutBuffer[3] = lowhex (1); | 1209 | remcomOutBuffer[3] = hex_asc_lo(1); |
1241 | } | 1210 | } |
1242 | /* Done with the reply. */ | 1211 | /* Done with the reply. */ |
1243 | remcomOutBuffer[4] = lowhex (1); | 1212 | remcomOutBuffer[4] = hex_asc_lo(1); |
1244 | pos = 5; | 1213 | pos = 5; |
1245 | /* Expects the argument thread id. */ | 1214 | /* Expects the argument thread id. */ |
1246 | for (; pos < (5 + HEXCHARS_IN_THREAD_ID); pos++) | 1215 | for (; pos < (5 + HEXCHARS_IN_THREAD_ID); pos++) |
@@ -1251,16 +1220,16 @@ handle_exception (int sigval) | |||
1251 | for (thread_id = 0; thread_id < number_of_tasks; thread_id++) { | 1220 | for (thread_id = 0; thread_id < number_of_tasks; thread_id++) { |
1252 | nextpos = pos + HEXCHARS_IN_THREAD_ID - 1; | 1221 | nextpos = pos + HEXCHARS_IN_THREAD_ID - 1; |
1253 | for (; pos < nextpos; pos ++) | 1222 | for (; pos < nextpos; pos ++) |
1254 | remcomOutBuffer[pos] = lowhex (0); | 1223 | remcomOutBuffer[pos] = hex_asc_lo(0); |
1255 | remcomOutBuffer[pos++] = lowhex (thread_id); | 1224 | remcomOutBuffer[pos++] = hex_asc_lo(thread_id); |
1256 | } | 1225 | } |
1257 | } | 1226 | } |
1258 | else { | 1227 | else { |
1259 | /* Store the thread identifier of the boot task. */ | 1228 | /* Store the thread identifier of the boot task. */ |
1260 | nextpos = pos + HEXCHARS_IN_THREAD_ID - 1; | 1229 | nextpos = pos + HEXCHARS_IN_THREAD_ID - 1; |
1261 | for (; pos < nextpos; pos ++) | 1230 | for (; pos < nextpos; pos ++) |
1262 | remcomOutBuffer[pos] = lowhex (0); | 1231 | remcomOutBuffer[pos] = hex_asc_lo(0); |
1263 | remcomOutBuffer[pos++] = lowhex (current_thread_c); | 1232 | remcomOutBuffer[pos++] = hex_asc_lo(current_thread_c); |
1264 | } | 1233 | } |
1265 | remcomOutBuffer[pos] = '\0'; | 1234 | remcomOutBuffer[pos] = '\0'; |
1266 | break; | 1235 | break; |