aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mn10300
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mn10300')
-rw-r--r--arch/mn10300/kernel/gdb-stub.c108
1 files changed, 46 insertions, 62 deletions
diff --git a/arch/mn10300/kernel/gdb-stub.c b/arch/mn10300/kernel/gdb-stub.c
index 21891c71d549..54be6afb5555 100644
--- a/arch/mn10300/kernel/gdb-stub.c
+++ b/arch/mn10300/kernel/gdb-stub.c
@@ -163,8 +163,6 @@ static char input_buffer[BUFMAX];
163static char output_buffer[BUFMAX]; 163static char output_buffer[BUFMAX];
164static char trans_buffer[BUFMAX]; 164static char trans_buffer[BUFMAX];
165 165
166static const char hexchars[] = "0123456789abcdef";
167
168struct gdbstub_bkpt { 166struct gdbstub_bkpt {
169 u8 *addr; /* address of breakpoint */ 167 u8 *addr; /* address of breakpoint */
170 u8 len; /* size of breakpoint */ 168 u8 len; /* size of breakpoint */
@@ -363,8 +361,8 @@ static int putpacket(char *buffer)
363 } 361 }
364 362
365 gdbstub_io_tx_char('#'); 363 gdbstub_io_tx_char('#');
366 gdbstub_io_tx_char(hexchars[checksum >> 4]); 364 gdbstub_io_tx_char(hex_asc_hi(checksum));
367 gdbstub_io_tx_char(hexchars[checksum & 0xf]); 365 gdbstub_io_tx_char(hex_asc_lo(checksum));
368 366
369 } while (gdbstub_io_rx_char(&ch, 0), 367 } while (gdbstub_io_rx_char(&ch, 0),
370 ch == '-' && (gdbstub_io("### GDB Rx NAK\n"), 0), 368 ch == '-' && (gdbstub_io("### GDB Rx NAK\n"), 0),
@@ -822,8 +820,7 @@ unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fault)
822 if ((u32) mem & 1 && count >= 1) { 820 if ((u32) mem & 1 && count >= 1) {
823 if (gdbstub_read_byte(mem, ch) != 0) 821 if (gdbstub_read_byte(mem, ch) != 0)
824 return 0; 822 return 0;
825 *buf++ = hexchars[ch[0] >> 4]; 823 buf = pack_hex_byte(buf, ch[0]);
826 *buf++ = hexchars[ch[0] & 0xf];
827 mem++; 824 mem++;
828 count--; 825 count--;
829 } 826 }
@@ -831,10 +828,8 @@ unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fault)
831 if ((u32) mem & 3 && count >= 2) { 828 if ((u32) mem & 3 && count >= 2) {
832 if (gdbstub_read_word(mem, ch) != 0) 829 if (gdbstub_read_word(mem, ch) != 0)
833 return 0; 830 return 0;
834 *buf++ = hexchars[ch[0] >> 4]; 831 buf = pack_hex_byte(buf, ch[0]);
835 *buf++ = hexchars[ch[0] & 0xf]; 832 buf = pack_hex_byte(buf, ch[1]);
836 *buf++ = hexchars[ch[1] >> 4];
837 *buf++ = hexchars[ch[1] & 0xf];
838 mem += 2; 833 mem += 2;
839 count -= 2; 834 count -= 2;
840 } 835 }
@@ -842,14 +837,10 @@ unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fault)
842 while (count >= 4) { 837 while (count >= 4) {
843 if (gdbstub_read_dword(mem, ch) != 0) 838 if (gdbstub_read_dword(mem, ch) != 0)
844 return 0; 839 return 0;
845 *buf++ = hexchars[ch[0] >> 4]; 840 buf = pack_hex_byte(buf, ch[0]);
846 *buf++ = hexchars[ch[0] & 0xf]; 841 buf = pack_hex_byte(buf, ch[1]);
847 *buf++ = hexchars[ch[1] >> 4]; 842 buf = pack_hex_byte(buf, ch[2]);
848 *buf++ = hexchars[ch[1] & 0xf]; 843 buf = pack_hex_byte(buf, ch[3]);
849 *buf++ = hexchars[ch[2] >> 4];
850 *buf++ = hexchars[ch[2] & 0xf];
851 *buf++ = hexchars[ch[3] >> 4];
852 *buf++ = hexchars[ch[3] & 0xf];
853 mem += 4; 844 mem += 4;
854 count -= 4; 845 count -= 4;
855 } 846 }
@@ -857,10 +848,8 @@ unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fault)
857 if (count >= 2) { 848 if (count >= 2) {
858 if (gdbstub_read_word(mem, ch) != 0) 849 if (gdbstub_read_word(mem, ch) != 0)
859 return 0; 850 return 0;
860 *buf++ = hexchars[ch[0] >> 4]; 851 buf = pack_hex_byte(buf, ch[0]);
861 *buf++ = hexchars[ch[0] & 0xf]; 852 buf = pack_hex_byte(buf, ch[1]);
862 *buf++ = hexchars[ch[1] >> 4];
863 *buf++ = hexchars[ch[1] & 0xf];
864 mem += 2; 853 mem += 2;
865 count -= 2; 854 count -= 2;
866 } 855 }
@@ -868,8 +857,7 @@ unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fault)
868 if (count >= 1) { 857 if (count >= 1) {
869 if (gdbstub_read_byte(mem, ch) != 0) 858 if (gdbstub_read_byte(mem, ch) != 0)
870 return 0; 859 return 0;
871 *buf++ = hexchars[ch[0] >> 4]; 860 buf = pack_hex_byte(buf, ch[0]);
872 *buf++ = hexchars[ch[0] & 0xf];
873 } 861 }
874 862
875 *buf = 0; 863 *buf = 0;
@@ -1304,14 +1292,14 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep)
1304 *ptr++ = 'O'; 1292 *ptr++ = 'O';
1305 ptr = mem2hex(title, ptr, sizeof(title) - 1, 0); 1293 ptr = mem2hex(title, ptr, sizeof(title) - 1, 0);
1306 1294
1307 hx = hexchars[(excep & 0xf000) >> 12]; 1295 hx = hex_asc_hi(excep >> 8);
1308 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1296 ptr = pack_hex_byte(ptr, hx);
1309 hx = hexchars[(excep & 0x0f00) >> 8]; 1297 hx = hex_asc_lo(excep >> 8);
1310 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1298 ptr = pack_hex_byte(ptr, hx);
1311 hx = hexchars[(excep & 0x00f0) >> 4]; 1299 hx = hex_asc_hi(excep);
1312 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1300 ptr = pack_hex_byte(ptr, hx);
1313 hx = hexchars[(excep & 0x000f)]; 1301 hx = hex_asc_lo(excep);
1314 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1302 ptr = pack_hex_byte(ptr, hx);
1315 1303
1316 ptr = mem2hex(crlf, ptr, sizeof(crlf) - 1, 0); 1304 ptr = mem2hex(crlf, ptr, sizeof(crlf) - 1, 0);
1317 *ptr = 0; 1305 *ptr = 0;
@@ -1322,22 +1310,22 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep)
1322 *ptr++ = 'O'; 1310 *ptr++ = 'O';
1323 ptr = mem2hex(tbcberr, ptr, sizeof(tbcberr) - 1, 0); 1311 ptr = mem2hex(tbcberr, ptr, sizeof(tbcberr) - 1, 0);
1324 1312
1325 hx = hexchars[(bcberr & 0xf0000000) >> 28]; 1313 hx = hex_asc_hi(bcberr >> 24);
1326 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1314 ptr = pack_hex_byte(ptr, hx);
1327 hx = hexchars[(bcberr & 0x0f000000) >> 24]; 1315 hx = hex_asc_lo(bcberr >> 24);
1328 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1316 ptr = pack_hex_byte(ptr, hx);
1329 hx = hexchars[(bcberr & 0x00f00000) >> 20]; 1317 hx = hex_asc_hi(bcberr >> 16);
1330 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1318 ptr = pack_hex_byte(ptr, hx);
1331 hx = hexchars[(bcberr & 0x000f0000) >> 16]; 1319 hx = hex_asc_lo(bcberr >> 16);
1332 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1320 ptr = pack_hex_byte(ptr, hx);
1333 hx = hexchars[(bcberr & 0x0000f000) >> 12]; 1321 hx = hex_asc_hi(bcberr >> 8);
1334 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1322 ptr = pack_hex_byte(ptr, hx);
1335 hx = hexchars[(bcberr & 0x00000f00) >> 8]; 1323 hx = hex_asc_lo(bcberr >> 8);
1336 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1324 ptr = pack_hex_byte(ptr, hx);
1337 hx = hexchars[(bcberr & 0x000000f0) >> 4]; 1325 hx = hex_asc_hi(bcberr);
1338 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1326 ptr = pack_hex_byte(ptr, hx);
1339 hx = hexchars[(bcberr & 0x0000000f)]; 1327 hx = hex_asc_lo(bcberr);
1340 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1328 ptr = pack_hex_byte(ptr, hx);
1341 1329
1342 ptr = mem2hex(crlf, ptr, sizeof(crlf) - 1, 0); 1330 ptr = mem2hex(crlf, ptr, sizeof(crlf) - 1, 0);
1343 *ptr = 0; 1331 *ptr = 0;
@@ -1353,14 +1341,12 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep)
1353 * Send trap type (converted to signal) 1341 * Send trap type (converted to signal)
1354 */ 1342 */
1355 *ptr++ = 'T'; 1343 *ptr++ = 'T';
1356 *ptr++ = hexchars[sigval >> 4]; 1344 ptr = pack_hex_byte(ptr, sigval);
1357 *ptr++ = hexchars[sigval & 0xf];
1358 1345
1359 /* 1346 /*
1360 * Send Error PC 1347 * Send Error PC
1361 */ 1348 */
1362 *ptr++ = hexchars[GDB_REGID_PC >> 4]; 1349 ptr = pack_hex_byte(ptr, GDB_REGID_PC);
1363 *ptr++ = hexchars[GDB_REGID_PC & 0xf];
1364 *ptr++ = ':'; 1350 *ptr++ = ':';
1365 ptr = mem2hex(&regs->pc, ptr, 4, 0); 1351 ptr = mem2hex(&regs->pc, ptr, 4, 0);
1366 *ptr++ = ';'; 1352 *ptr++ = ';';
@@ -1368,8 +1354,7 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep)
1368 /* 1354 /*
1369 * Send frame pointer 1355 * Send frame pointer
1370 */ 1356 */
1371 *ptr++ = hexchars[GDB_REGID_FP >> 4]; 1357 ptr = pack_hex_byte(ptr, GDB_REGID_FP);
1372 *ptr++ = hexchars[GDB_REGID_FP & 0xf];
1373 *ptr++ = ':'; 1358 *ptr++ = ':';
1374 ptr = mem2hex(&regs->a3, ptr, 4, 0); 1359 ptr = mem2hex(&regs->a3, ptr, 4, 0);
1375 *ptr++ = ';'; 1360 *ptr++ = ';';
@@ -1378,8 +1363,7 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep)
1378 * Send stack pointer 1363 * Send stack pointer
1379 */ 1364 */
1380 ssp = (unsigned long) (regs + 1); 1365 ssp = (unsigned long) (regs + 1);
1381 *ptr++ = hexchars[GDB_REGID_SP >> 4]; 1366 ptr = pack_hex_byte(ptr, GDB_REGID_SP);
1382 *ptr++ = hexchars[GDB_REGID_SP & 0xf];
1383 *ptr++ = ':'; 1367 *ptr++ = ':';
1384 ptr = mem2hex(&ssp, ptr, 4, 0); 1368 ptr = mem2hex(&ssp, ptr, 4, 0);
1385 *ptr++ = ';'; 1369 *ptr++ = ';';
@@ -1399,8 +1383,8 @@ packet_waiting:
1399 /* request repeat of last signal number */ 1383 /* request repeat of last signal number */
1400 case '?': 1384 case '?':
1401 output_buffer[0] = 'S'; 1385 output_buffer[0] = 'S';
1402 output_buffer[1] = hexchars[sigval >> 4]; 1386 output_buffer[1] = hex_asc_hi(sigval);
1403 output_buffer[2] = hexchars[sigval & 0xf]; 1387 output_buffer[2] = hex_asc_lo(sigval);
1404 output_buffer[3] = 0; 1388 output_buffer[3] = 0;
1405 break; 1389 break;
1406 1390
@@ -1838,8 +1822,8 @@ void gdbstub_exit(int status)
1838 1822
1839 gdbstub_busy = 1; 1823 gdbstub_busy = 1;
1840 output_buffer[0] = 'W'; 1824 output_buffer[0] = 'W';
1841 output_buffer[1] = hexchars[(status >> 4) & 0x0F]; 1825 output_buffer[1] = hex_asc_hi(status);
1842 output_buffer[2] = hexchars[status & 0x0F]; 1826 output_buffer[2] = hex_asc_lo(status);
1843 output_buffer[3] = 0; 1827 output_buffer[3] = 0;
1844 1828
1845 gdbstub_io_tx_char('$'); 1829 gdbstub_io_tx_char('$');
@@ -1853,8 +1837,8 @@ void gdbstub_exit(int status)
1853 } 1837 }
1854 1838
1855 gdbstub_io_tx_char('#'); 1839 gdbstub_io_tx_char('#');
1856 gdbstub_io_tx_char(hexchars[checksum >> 4]); 1840 gdbstub_io_tx_char(hex_asc_hi(checksum));
1857 gdbstub_io_tx_char(hexchars[checksum & 0xf]); 1841 gdbstub_io_tx_char(hex_asc_lo(checksum));
1858 1842
1859 /* make sure the output is flushed, or else RedBoot might clobber it */ 1843 /* make sure the output is flushed, or else RedBoot might clobber it */
1860 gdbstub_io_tx_flush(); 1844 gdbstub_io_tx_flush();