Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sh: Bring kgdb back from the dead.

This code has suffered quite a bit of bitrot, do some basic
tidying to get it to a reasonably functional state again.
This gets the basic support and the console working again.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>

authored by

Paul Mundt and committed by
Paul Mundt
fa5da2f7 15700770

+101 -369
+7 -8
arch/sh/Kconfig.debug
··· 77 77 on the VM subsystem for higher order allocations. This option 78 78 will also use IRQ stacks to compensate for the reduced stackspace. 79 79 80 - config KGDB 80 + config SH_KGDB 81 81 bool "Include KGDB kernel debugger" 82 82 select FRAME_POINTER 83 + select DEBUG_INFO 83 84 help 84 85 Include in-kernel hooks for kgdb, the Linux kernel source level 85 86 debugger. See <http://kgdb.sourceforge.net/> for more information. 86 87 Unless you are intending to debug the kernel, say N here. 87 88 88 89 menu "KGDB configuration options" 89 - depends on KGDB 90 + depends on SH_KGDB 90 91 91 92 config MORE_COMPILE_OPTIONS 92 93 bool "Add any additional compile options" ··· 110 109 111 110 config SH_KGDB_CONSOLE 112 111 bool "Console messages through GDB" 112 + depends on !SERIAL_SH_SCI_CONSOLE 113 + select SERIAL_CORE_CONSOLE 113 114 default n 114 115 115 116 config KGDB_SYSRQ 116 117 bool "Allow SysRq 'G' to enter KGDB" 117 118 default y 118 - 119 - config KGDB_KERNEL_ASSERTS 120 - bool "Include KGDB kernel assertions" 121 - default n 122 119 123 120 comment "Serial port setup" 124 121 ··· 130 131 131 132 choice 132 133 prompt "Parity" 133 - depends on KGDB 134 + depends on SH_KGDB 134 135 default KGDB_DEFPARITY_N 135 136 136 137 config KGDB_DEFPARITY_N ··· 146 147 147 148 choice 148 149 prompt "Data bits" 149 - depends on KGDB 150 + depends on SH_KGDB 150 151 default KGDB_DEFBITS_8 151 152 152 153 config KGDB_DEFBITS_8
-1
arch/sh/Makefile
··· 47 47 cflags-y += $(call as-option,-Wa$(comma)-isa=$(isa-y),) -ffreestanding 48 48 49 49 cflags-$(CONFIG_SH_DSP) += -Wa,-dsp 50 - cflags-$(CONFIG_SH_KGDB) += -g 51 50 52 51 cflags-$(CONFIG_MORE_COMPILE_OPTIONS) += \ 53 52 $(shell echo $(CONFIG_COMPILE_OPTIONS) | sed -e 's/"//g')
-148
arch/sh/boards/se/7751/setup.c
··· 14 14 #include <asm/se7751.h> 15 15 #include <asm/io.h> 16 16 17 - void init_7751se_IRQ(void); 18 - 19 - #ifdef CONFIG_SH_KGDB 20 - #include <asm/kgdb.h> 21 - static int kgdb_uart_setup(void); 22 - static struct kgdb_sermap kgdb_uart_sermap = 23 - { "ttyS", 0, kgdb_uart_setup, NULL }; 24 - #endif 25 - 26 - /* 27 - * Initialize the board 28 - */ 29 - static void __init sh7751se_setup(char **cmdline_p) 30 - { 31 - /* Call init_smsc() replacement to set up SuperIO. */ 32 - /* XXX: RTC setting comes here */ 33 - #ifdef CONFIG_SH_KGDB 34 - kgdb_register_sermap(&kgdb_uart_sermap); 35 - #endif 36 - } 37 - 38 - /********************************************************************* 39 - * Currently a hack (e.g. does not interact well w/serial.c, lots of * 40 - * hardcoded stuff) but may be useful if SCI/F needs debugging. * 41 - * Mostly copied from x86 code (see files asm-i386/kgdb_local.h and * 42 - * arch/i386/lib/kgdb_serial.c). * 43 - *********************************************************************/ 44 - 45 - #ifdef CONFIG_SH_KGDB 46 - #include <linux/types.h> 47 - #include <linux/serial.h> 48 - #include <linux/serialP.h> 49 - #include <linux/serial_reg.h> 50 - 51 - #define COM1_PORT 0x3f8 /* Base I/O address */ 52 - #define COM1_IRQ 4 /* IRQ not used yet */ 53 - #define COM2_PORT 0x2f8 /* Base I/O address */ 54 - #define COM2_IRQ 3 /* IRQ not used yet */ 55 - 56 - #define SB_CLOCK 1843200 /* Serial baud clock */ 57 - #define SB_BASE (SB_CLOCK/16) 58 - #define SB_MCR UART_MCR_OUT2 | UART_MCR_DTR | UART_MCR_RTS 59 - 60 - struct uart_port { 61 - int base; 62 - }; 63 - #define UART_NPORTS 2 64 - struct uart_port uart_ports[] = { 65 - { COM1_PORT }, 66 - { COM2_PORT }, 67 - }; 68 - struct uart_port *kgdb_uart_port; 69 - 70 - #define UART_IN(reg) inb_p(kgdb_uart_port->base + reg) 71 - #define UART_OUT(reg,v) outb_p((v), kgdb_uart_port->base + reg) 72 - 73 - /* Basic read/write functions for the UART */ 74 - #define UART_LSR_RXCERR (UART_LSR_BI | UART_LSR_FE | UART_LSR_PE) 75 - static int kgdb_uart_getchar(void) 76 - { 77 - int lsr; 78 - int c = -1; 79 - 80 - while (c == -1) { 81 - lsr = UART_IN(UART_LSR); 82 - if (lsr & UART_LSR_DR) 83 - c = UART_IN(UART_RX); 84 - if ((lsr & UART_LSR_RXCERR)) 85 - c = -1; 86 - } 87 - return c; 88 - } 89 - 90 - static void kgdb_uart_putchar(int c) 91 - { 92 - while ((UART_IN(UART_LSR) & UART_LSR_THRE) == 0) 93 - ; 94 - UART_OUT(UART_TX, c); 95 - } 96 - 97 - /* 98 - * Initialize UART to configured/requested values. 99 - * (But we don't interrupts yet, or interact w/serial.c) 100 - */ 101 - static int kgdb_uart_setup(void) 102 - { 103 - int port; 104 - int lcr = 0; 105 - int bdiv = 0; 106 - 107 - if (kgdb_portnum >= UART_NPORTS) { 108 - KGDB_PRINTK("uart port %d invalid.\n", kgdb_portnum); 109 - return -1; 110 - } 111 - 112 - kgdb_uart_port = &uart_ports[kgdb_portnum]; 113 - 114 - /* Init sequence from gdb_hook_interrupt */ 115 - UART_IN(UART_RX); 116 - UART_OUT(UART_IER, 0); 117 - 118 - UART_IN(UART_RX); /* Serial driver comments say */ 119 - UART_IN(UART_IIR); /* this clears interrupt regs */ 120 - UART_IN(UART_MSR); 121 - 122 - /* Figure basic LCR values */ 123 - switch (kgdb_bits) { 124 - case '7': 125 - lcr |= UART_LCR_WLEN7; 126 - break; 127 - default: case '8': 128 - lcr |= UART_LCR_WLEN8; 129 - break; 130 - } 131 - switch (kgdb_parity) { 132 - case 'O': 133 - lcr |= UART_LCR_PARITY; 134 - break; 135 - case 'E': 136 - lcr |= (UART_LCR_PARITY | UART_LCR_EPAR); 137 - break; 138 - default: break; 139 - } 140 - 141 - /* Figure the baud rate divisor */ 142 - bdiv = (SB_BASE/kgdb_baud); 143 - 144 - /* Set the baud rate and LCR values */ 145 - UART_OUT(UART_LCR, (lcr | UART_LCR_DLAB)); 146 - UART_OUT(UART_DLL, (bdiv & 0xff)); 147 - UART_OUT(UART_DLM, ((bdiv >> 8) & 0xff)); 148 - UART_OUT(UART_LCR, lcr); 149 - 150 - /* Set the MCR */ 151 - UART_OUT(UART_MCR, SB_MCR); 152 - 153 - /* Turn off FIFOs for now */ 154 - UART_OUT(UART_FCR, 0); 155 - 156 - /* Setup complete: initialize function pointers */ 157 - kgdb_getchar = kgdb_uart_getchar; 158 - kgdb_putchar = kgdb_uart_putchar; 159 - 160 - return 0; 161 - } 162 - #endif /* CONFIG_SH_KGDB */ 163 - 164 17 static unsigned char heartbeat_bit_pos[] = { 8, 9, 10, 11, 12, 13, 14, 15 }; 165 18 166 19 static struct resource heartbeat_resources[] = { ··· 50 197 */ 51 198 struct sh_machine_vector mv_7751se __initmv = { 52 199 .mv_name = "7751 SolutionEngine", 53 - .mv_setup = sh7751se_setup, 54 200 .mv_nr_irqs = 72, 55 201 56 202 .mv_inb = sh7751se_inb,
+54 -52
arch/sh/kernel/kgdb_stub.c
··· 6 6 * David Grothe <dave@gcom.com>, Tigran Aivazian <tigran@sco.com>, 7 7 * Amit S. Kale <akale@veritas.com>, William Gatliff <bgat@open-widgets.com>, 8 8 * Ben Lee, Steve Chamberlain and Benoit Miller <fulg@iname.com>. 9 - * 9 + * 10 10 * This version by Henry Bell <henry.bell@st.com> 11 11 * Minor modifications by Jeremy Siegel <jsiegel@mvista.com> 12 - * 13 - * Contains low-level support for remote debug using GDB. 12 + * 13 + * Contains low-level support for remote debug using GDB. 14 14 * 15 15 * To enable debugger support, two things need to happen. A call to 16 16 * set_debug_traps() is necessary in order to allow any breakpoints ··· 48 48 * k kill (Detach GDB) 49 49 * 50 50 * d Toggle debug flag 51 - * D Detach GDB 51 + * D Detach GDB 52 52 * 53 53 * Hct Set thread t for operations, OK or ENN 54 54 * c = 'c' (step, cont), c = 'g' (other ··· 58 58 * qfThreadInfo Get list of current threads (first) m<id> 59 59 * qsThreadInfo " " " " " (subsequent) 60 60 * qOffsets Get section offsets Text=x;Data=y;Bss=z 61 - * 61 + * 62 62 * TXX Find if thread XX is alive OK or ENN 63 63 * ? What was the last sigval ? SNN (signal NN) 64 64 * O Output to GDB console ··· 74 74 * '$' or '#'. If <data> starts with two characters followed by 75 75 * ':', then the existing stubs interpret this as a sequence number. 76 76 * 77 - * CSUM1 and CSUM2 are ascii hex representation of an 8-bit 77 + * CSUM1 and CSUM2 are ascii hex representation of an 8-bit 78 78 * checksum of <data>, the most significant nibble is sent first. 79 79 * the hex digits 0-9,a-f are used. 80 80 * ··· 86 86 * Responses can be run-length encoded to save space. A '*' means that 87 87 * the next character is an ASCII encoding giving a repeat count which 88 88 * stands for that many repititions of the character preceding the '*'. 89 - * The encoding is n+29, yielding a printable character where n >=3 90 - * (which is where RLE starts to win). Don't use an n > 126. 89 + * The encoding is n+29, yielding a printable character where n >=3 90 + * (which is where RLE starts to win). Don't use an n > 126. 91 91 * 92 92 * So "0* " means the same as "0000". 93 93 */ ··· 100 100 #include <linux/delay.h> 101 101 #include <linux/linkage.h> 102 102 #include <linux/init.h> 103 - 104 - #ifdef CONFIG_SH_KGDB_CONSOLE 105 103 #include <linux/console.h> 106 - #endif 107 - 104 + #include <linux/sysrq.h> 108 105 #include <asm/system.h> 106 + #include <asm/cacheflush.h> 109 107 #include <asm/current.h> 110 108 #include <asm/signal.h> 111 109 #include <asm/pgtable.h> ··· 151 153 char in_nmi; /* Set during NMI to prevent reentry */ 152 154 int kgdb_nofault; /* Boolean to ignore bus errs (i.e. in GDB) */ 153 155 int kgdb_enabled = 1; /* Default to enabled, cmdline can disable */ 154 - int kgdb_halt; 155 156 156 157 /* Exposed for user access */ 157 158 struct task_struct *kgdb_current; ··· 325 328 } 326 329 327 330 /* Copy the binary array pointed to by buf into mem. Fix $, #, 328 - and 0x7d escaped with 0x7d. Return a pointer to the character 331 + and 0x7d escaped with 0x7d. Return a pointer to the character 329 332 after the last byte written. */ 330 333 static char *ebin_to_mem(const char *buf, char *mem, int count) 331 334 { ··· 449 452 /* Ack successful transfer */ 450 453 put_debug_char('+'); 451 454 452 - /* If a sequence char is present, reply 455 + /* If a sequence char is present, reply 453 456 the sequence ID */ 454 457 if (buffer[2] == ':') { 455 458 put_debug_char(buffer[0]); ··· 756 759 return (short *) addr; 757 760 } 758 761 759 - /* Set up a single-step. Replace the instruction immediately after the 762 + /* Set up a single-step. Replace the instruction immediately after the 760 763 current instruction (i.e. next in the expected flow of control) with a 761 764 trap instruction, so that returning will cause only a single instruction 762 765 to be executed. Note that this model is slightly broken for instructions ··· 999 1002 char *ptr; 1000 1003 1001 1004 switch (in_buffer[1]) { 1002 - 1003 - /* To select which thread for gG etc messages, i.e. supported */ 1005 + /* To select which thread for gG etc messages, i.e. supported */ 1004 1006 case 'g': 1005 - 1006 1007 ptr = &in_buffer[2]; 1007 1008 hex_to_int(&ptr, &threadid); 1008 1009 thread = get_thread(threadid); ··· 1168 1173 } 1169 1174 #endif /* CONFIG_KGDB_THREAD */ 1170 1175 1176 + #ifdef CONFIG_SH_KGDB_CONSOLE 1171 1177 /* 1172 1178 * Bring up the ports.. 1173 1179 */ ··· 1181 1185 1182 1186 return 0; 1183 1187 } 1188 + #else 1189 + #define kgdb_serial_setup() 0 1190 + #endif 1184 1191 1185 1192 /* The command loop, read and act on requests */ 1186 1193 static void kgdb_command_loop(const int excep_code, const int trapa_value) ··· 1192 1193 1193 1194 if (excep_code == NMI_VEC) { 1194 1195 #ifndef CONFIG_KGDB_NMI 1195 - KGDB_PRINTK("Ignoring unexpected NMI?\n"); 1196 + printk(KERN_NOTICE "KGDB: Ignoring unexpected NMI?\n"); 1196 1197 return; 1197 1198 #else /* CONFIG_KGDB_NMI */ 1198 1199 if (!kgdb_enabled) { ··· 1215 1216 /* Enter GDB mode (e.g. after detach) */ 1216 1217 if (!kgdb_in_gdb_mode) { 1217 1218 /* Do serial setup, notify user, issue preemptive ack */ 1218 - kgdb_serial_setup(); 1219 - KGDB_PRINTK("Waiting for GDB (on %s%d at %d baud)\n", 1220 - (kgdb_porttype ? kgdb_porttype->name : ""), 1221 - kgdb_portnum, kgdb_baud); 1219 + printk(KERN_NOTICE "KGDB: Waiting for GDB\n"); 1222 1220 kgdb_in_gdb_mode = 1; 1223 1221 put_debug_char('+'); 1224 1222 } ··· 1229 1233 will later be replaced by its original one. Do NOT do this for 1230 1234 trap 0xff, since that indicates a compiled-in breakpoint which 1231 1235 will not be replaced (and we would retake the trap forever) */ 1232 - if ((excep_code == TRAP_VEC) && (trapa_value != (0xff << 2))) { 1236 + if ((excep_code == TRAP_VEC) && (trapa_value != (0x3c << 2))) 1233 1237 trap_registers.pc -= 2; 1234 - } 1235 1238 1236 1239 /* Undo any stepping we may have done */ 1237 1240 undo_single_step(); 1238 1241 1239 1242 while (1) { 1240 - 1241 1243 out_buffer[0] = 0; 1242 1244 get_packet(in_buffer, BUFMAX); 1243 1245 1244 1246 /* Examine first char of buffer to see what we need to do */ 1245 1247 switch (in_buffer[0]) { 1246 - 1247 1248 case '?': /* Send which signal we've received */ 1248 1249 send_signal_msg(sigval); 1249 1250 break; ··· 1316 1323 } 1317 1324 1318 1325 /* There has been an exception, most likely a breakpoint. */ 1319 - asmlinkage void kgdb_handle_exception(unsigned long r4, unsigned long r5, 1320 - unsigned long r6, unsigned long r7, 1321 - struct pt_regs __regs) 1326 + static void handle_exception(struct pt_regs *regs) 1322 1327 { 1323 - struct pt_regs *regs = RELOC_HIDE(&__regs, 0); 1324 1328 int excep_code, vbr_val; 1325 1329 int count; 1326 1330 int trapa_value = ctrl_inl(TRA); ··· 1345 1355 kgdb_trapa_val = trapa_value; 1346 1356 1347 1357 /* Act on the exception */ 1348 - kgdb_command_loop(excep_code >> 5, trapa_value); 1358 + kgdb_command_loop(excep_code, trapa_value); 1349 1359 1350 1360 kgdb_current = NULL; 1351 1361 ··· 1363 1373 asm("ldc %0, vbr": :"r"(vbr_val)); 1364 1374 } 1365 1375 1366 - /* Trigger a breakpoint by function */ 1367 - void breakpoint(void) 1376 + asmlinkage void kgdb_handle_exception(unsigned long r4, unsigned long r5, 1377 + unsigned long r6, unsigned long r7, 1378 + struct pt_regs __regs) 1368 1379 { 1369 - if (!kgdb_enabled) { 1370 - kgdb_enabled = 1; 1371 - kgdb_init(); 1372 - } 1373 - BREAKPOINT(); 1380 + struct pt_regs *regs = RELOC_HIDE(&__regs, 0); 1381 + handle_exception(regs); 1374 1382 } 1375 1383 1376 1384 /* Initialise the KGDB data structures and serial configuration */ ··· 1383 1395 kgdb_in_gdb_mode = 0; 1384 1396 1385 1397 if (kgdb_serial_setup() != 0) { 1386 - KGDB_PRINTK("serial setup error\n"); 1398 + printk(KERN_NOTICE "KGDB: serial setup error\n"); 1387 1399 return -1; 1388 1400 } 1389 1401 1390 1402 /* Init ptr to exception handler */ 1391 - kgdb_debug_hook = kgdb_handle_exception; 1403 + kgdb_debug_hook = handle_exception; 1392 1404 kgdb_bus_err_hook = kgdb_handle_bus_error; 1393 1405 1394 1406 /* Enter kgdb now if requested, or just report init done */ 1395 - if (kgdb_halt) { 1396 - kgdb_in_gdb_mode = 1; 1397 - put_debug_char('+'); 1398 - breakpoint(); 1399 - } 1400 - else 1401 - { 1402 - KGDB_PRINTK("stub is initialized.\n"); 1403 - } 1407 + printk(KERN_NOTICE "KGDB: stub is initialized.\n"); 1404 1408 1405 1409 return 0; 1406 1410 } ··· 1417 1437 1418 1438 /* Calculate how many this time */ 1419 1439 wcount = (count > MAXOUT) ? MAXOUT : count; 1420 - 1440 + 1421 1441 /* Pack in hex chars */ 1422 1442 for (i = 0; i < wcount; i++) 1423 1443 bufptr = pack_hex_byte(bufptr, s[i]); ··· 1446 1466 1447 1467 kgdb_msg_write(s, count); 1448 1468 } 1469 + #endif 1470 + 1471 + #ifdef CONFIG_KGDB_SYSRQ 1472 + static void sysrq_handle_gdb(int key, struct tty_struct *tty) 1473 + { 1474 + printk("Entering GDB stub\n"); 1475 + breakpoint(); 1476 + } 1477 + 1478 + static struct sysrq_key_op sysrq_gdb_op = { 1479 + .handler = sysrq_handle_gdb, 1480 + .help_msg = "Gdb", 1481 + .action_msg = "GDB", 1482 + }; 1483 + 1484 + static int gdb_register_sysrq(void) 1485 + { 1486 + printk("Registering GDB sysrq handler\n"); 1487 + register_sysrq_key('g', &sysrq_gdb_op); 1488 + return 0; 1489 + } 1490 + module_init(gdb_register_sysrq); 1449 1491 #endif
+1 -93
arch/sh/kernel/setup.c
··· 25 25 #include <asm/setup.h> 26 26 #include <asm/clock.h> 27 27 28 - #ifdef CONFIG_SH_KGDB 29 - #include <asm/kgdb.h> 30 - static int kgdb_parse_options(char *options); 31 - #endif 32 28 extern void * __rd_start, * __rd_end; 29 + 33 30 /* 34 31 * Machine setup.. 35 32 */ ··· 496 499 .show = show_cpuinfo, 497 500 }; 498 501 #endif /* CONFIG_PROC_FS */ 499 - 500 - #ifdef CONFIG_SH_KGDB 501 - /* 502 - * Parse command-line kgdb options. By default KGDB is enabled, 503 - * entered on error (or other action) using default serial info. 504 - * The command-line option can include a serial port specification 505 - * and an action to override default or configured behavior. 506 - */ 507 - struct kgdb_sermap kgdb_sci_sermap = 508 - { "ttySC", 5, kgdb_sci_setup, NULL }; 509 - 510 - struct kgdb_sermap *kgdb_serlist = &kgdb_sci_sermap; 511 - struct kgdb_sermap *kgdb_porttype = &kgdb_sci_sermap; 512 - 513 - void kgdb_register_sermap(struct kgdb_sermap *map) 514 - { 515 - struct kgdb_sermap *last; 516 - 517 - for (last = kgdb_serlist; last->next; last = last->next) 518 - ; 519 - last->next = map; 520 - if (!map->namelen) { 521 - map->namelen = strlen(map->name); 522 - } 523 - } 524 - 525 - static int __init kgdb_parse_options(char *options) 526 - { 527 - char c; 528 - int baud; 529 - 530 - /* Check for port spec (or use default) */ 531 - 532 - /* Determine port type and instance */ 533 - if (!memcmp(options, "tty", 3)) { 534 - struct kgdb_sermap *map = kgdb_serlist; 535 - 536 - while (map && memcmp(options, map->name, map->namelen)) 537 - map = map->next; 538 - 539 - if (!map) { 540 - KGDB_PRINTK("unknown port spec in %s\n", options); 541 - return -1; 542 - } 543 - 544 - kgdb_porttype = map; 545 - kgdb_serial_setup = map->setup_fn; 546 - kgdb_portnum = options[map->namelen] - '0'; 547 - options += map->namelen + 1; 548 - 549 - options = (*options == ',') ? options+1 : options; 550 - 551 - /* Read optional parameters (baud/parity/bits) */ 552 - baud = simple_strtoul(options, &options, 10); 553 - if (baud != 0) { 554 - kgdb_baud = baud; 555 - 556 - c = toupper(*options); 557 - if (c == 'E' || c == 'O' || c == 'N') { 558 - kgdb_parity = c; 559 - options++; 560 - } 561 - 562 - c = *options; 563 - if (c == '7' || c == '8') { 564 - kgdb_bits = c; 565 - options++; 566 - } 567 - options = (*options == ',') ? options+1 : options; 568 - } 569 - } 570 - 571 - /* Check for action specification */ 572 - if (!memcmp(options, "halt", 4)) { 573 - kgdb_halt = 1; 574 - options += 4; 575 - } else if (!memcmp(options, "disabled", 8)) { 576 - kgdb_enabled = 0; 577 - options += 8; 578 - } 579 - 580 - if (*options) { 581 - KGDB_PRINTK("ignored unknown options: %s\n", options); 582 - return 0; 583 - } 584 - return 1; 585 - } 586 - __setup("kgdb=", kgdb_parse_options); 587 - #endif /* CONFIG_SH_KGDB */
+33 -20
drivers/serial/sh-sci.c
··· 46 46 #endif 47 47 48 48 #if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64) 49 + #include <linux/ctype.h> 49 50 #include <asm/clock.h> 50 51 #include <asm/sh_bios.h> 51 52 #include <asm/kgdb.h> ··· 164 163 usegdb |= sh_bios_in_gdb_mode(); 165 164 #endif 166 165 #ifdef CONFIG_SH_KGDB 167 - usegdb |= (kgdb_in_gdb_mode && (port == kgdb_sci_port)); 166 + usegdb |= (kgdb_in_gdb_mode && (sci_port == kgdb_sci_port)); 168 167 #endif 169 168 170 169 if (usegdb) { ··· 205 204 int c; 206 205 207 206 /* Keep trying to read a character, this could be neater */ 208 - while ((c = get_char(kgdb_sci_port)) < 0) 207 + while ((c = get_char(&kgdb_sci_port->port)) < 0) 209 208 cpu_relax(); 210 209 211 210 return c; ··· 213 212 214 213 static inline void kgdb_sci_putchar(int c) 215 214 { 216 - put_char(kgdb_sci_port, c); 215 + put_char(&kgdb_sci_port->port, c); 217 216 } 218 217 #endif /* CONFIG_SH_KGDB */ 219 218 ··· 739 738 740 739 #ifdef CONFIG_SH_KGDB 741 740 /* Break into the debugger if a break is detected */ 742 - BREAKPOINT(); 741 + breakpoint(); 743 742 #endif 744 743 745 744 sci_out(port, SCxSR, SCxSR_BREAK_CLEAR(port)); ··· 972 971 { 973 972 struct sci_port *s = &sci_ports[port->line]; 974 973 unsigned int status, baud, smr_val; 975 - unsigned long flags; 976 974 int t; 977 975 978 976 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); ··· 989 989 #else 990 990 t = SCBRR_VALUE(baud); 991 991 #endif 992 - } 993 992 break; 993 + } 994 994 } 995 - 996 - spin_lock_irqsave(&port->lock, flags); 997 995 998 996 do { 999 997 status = sci_in(port, SCxSR); ··· 1036 1038 1037 1039 if ((termios->c_cflag & CREAD) != 0) 1038 1040 sci_start_rx(port,0); 1039 - 1040 - spin_unlock_irqrestore(&port->lock, flags); 1041 1041 } 1042 1042 1043 1043 static const char *sci_type(struct uart_port *port) ··· 1216 1220 if (!port->membase || !port->mapbase) 1217 1221 return -ENODEV; 1218 1222 1219 - spin_lock_init(&port->lock); 1220 - 1221 1223 port->type = serial_console_port->type; 1222 1224 1223 1225 if (port->flags & UPF_IOREMAP) ··· 1241 1247 .device = uart_console_device, 1242 1248 .write = serial_console_write, 1243 1249 .setup = serial_console_setup, 1244 - .flags = CON_PRINTBUFFER, 1250 + .flags = CON_PRINTBUFFER, 1245 1251 .index = -1, 1246 1252 .data = &sci_uart_driver, 1247 1253 }; ··· 1286 1292 int parity = 'n'; 1287 1293 int flow = 'n'; 1288 1294 1289 - spin_lock_init(&port->lock); 1290 - 1291 1295 if (co->index != kgdb_portnum) 1292 1296 co->index = kgdb_portnum; 1297 + 1298 + kgdb_sci_port = &sci_ports[co->index]; 1299 + port = &kgdb_sci_port->port; 1300 + 1301 + /* 1302 + * Also need to check port->type, we don't actually have any 1303 + * UPIO_PORT ports, but uart_report_port() handily misreports 1304 + * it anyways if we don't have a port available by the time this is 1305 + * called. 1306 + */ 1307 + if (!port->type) 1308 + return -ENODEV; 1309 + if (!port->membase || !port->mapbase) 1310 + return -ENODEV; 1293 1311 1294 1312 if (options) 1295 1313 uart_parse_options(options, &baud, &parity, &bits, &flow); ··· 1317 1311 1318 1312 #ifdef CONFIG_SH_KGDB_CONSOLE 1319 1313 static struct console kgdb_console = { 1320 - .name = "ttySC", 1321 - .write = kgdb_console_write, 1322 - .setup = kgdb_console_setup, 1323 - .flags = CON_PRINTBUFFER | CON_ENABLED, 1324 - .index = -1, 1314 + .name = "ttySC", 1315 + .device = uart_console_device, 1316 + .write = kgdb_console_write, 1317 + .setup = kgdb_console_setup, 1318 + .flags = CON_PRINTBUFFER, 1319 + .index = -1, 1325 1320 .data = &sci_uart_driver, 1326 1321 }; 1327 1322 ··· 1392 1385 1393 1386 uart_add_one_port(&sci_uart_driver, &sciport->port); 1394 1387 } 1388 + 1389 + #if defined(CONFIG_SH_KGDB) && !defined(CONFIG_SH_KGDB_CONSOLE) 1390 + kgdb_sci_port = &sci_ports[kgdb_portnum]; 1391 + kgdb_getchar = kgdb_sci_getchar; 1392 + kgdb_putchar = kgdb_sci_putchar; 1393 + #endif 1395 1394 1396 1395 #ifdef CONFIG_CPU_FREQ 1397 1396 cpufreq_register_notifier(&sci_nb, CPUFREQ_TRANSITION_NOTIFIER);
+4 -47
include/asm-sh/kgdb.h
··· 17 17 #define __KGDB_H 18 18 19 19 #include <asm/ptrace.h> 20 + #include <asm/cacheflush.h> 20 21 21 22 struct console; 22 23 ··· 46 45 extern int kgdb_baud; 47 46 extern char kgdb_parity; 48 47 extern char kgdb_bits; 49 - extern int kgdb_console_setup(struct console *, char *); 50 48 51 49 /* Init and interface stuff */ 52 50 extern int kgdb_init(void); 53 - extern int (*kgdb_serial_setup)(void); 54 51 extern int (*kgdb_getchar)(void); 55 52 extern void (*kgdb_putchar)(int); 56 53 57 - struct kgdb_sermap { 58 - char *name; 59 - int namelen; 60 - int (*setup_fn)(struct console *, char *); 61 - struct kgdb_sermap *next; 62 - }; 63 - extern void kgdb_register_sermap(struct kgdb_sermap *map); 64 - extern struct kgdb_sermap *kgdb_porttype; 65 - 66 54 /* Trap functions */ 67 - typedef void (kgdb_debug_hook_t)(struct pt_regs *regs); 55 + typedef void (kgdb_debug_hook_t)(struct pt_regs *regs); 68 56 typedef void (kgdb_bus_error_hook_t)(void); 69 57 extern kgdb_debug_hook_t *kgdb_debug_hook; 70 58 extern kgdb_bus_error_hook_t *kgdb_bus_err_hook; 71 59 72 - extern void breakpoint(void); 73 - 74 60 /* Console */ 75 - struct console; 76 61 void kgdb_console_write(struct console *co, const char *s, unsigned count); 77 - void kgdb_console_init(void); 62 + extern int kgdb_console_setup(struct console *, char *); 78 63 79 64 /* Prototypes for jmp fns */ 80 65 #define _JBLEN 9 ··· 68 81 extern void longjmp(jmp_buf __jmpb, int __retval); 69 82 extern int setjmp(jmp_buf __jmpb); 70 83 71 - /* Variadic macro to print our own message to the console */ 72 - #define KGDB_PRINTK(...) printk("KGDB: " __VA_ARGS__) 73 - 74 84 /* Forced breakpoint */ 75 - #define BREAKPOINT() \ 85 + #define breakpoint() \ 76 86 do { \ 77 87 if (kgdb_enabled) \ 78 88 __asm__ __volatile__("trapa #0x3c"); \ ··· 79 95 #if defined(CONFIG_CPU_SH4) 80 96 #define kgdb_flush_icache_range(start, end) \ 81 97 { \ 82 - extern void __flush_purge_region(void *, int); \ 83 98 __flush_purge_region((void*)(start), (int)(end) - (int)(start));\ 84 99 flush_icache_range((start), (end)); \ 85 100 } 86 101 #else 87 102 #define kgdb_flush_icache_range(start, end) do { } while (0) 88 - #endif 89 - 90 - /* Kernel assert macros */ 91 - #ifdef CONFIG_KGDB_KERNEL_ASSERTS 92 - 93 - /* Predefined conditions */ 94 - #define KA_VALID_ERRNO(errno) ((errno) > 0 && (errno) <= EMEDIUMTYPE) 95 - #define KA_VALID_PTR_ERR(ptr) KA_VALID_ERRNO(-PTR_ERR(ptr)) 96 - #define KA_VALID_KPTR(ptr) (!(ptr) || \ 97 - ((void *)(ptr) >= (void *)PAGE_OFFSET && \ 98 - (void *)(ptr) < ERR_PTR(-EMEDIUMTYPE))) 99 - #define KA_VALID_PTRORERR(errptr) \ 100 - (KA_VALID_KPTR(errptr) || KA_VALID_PTR_ERR(errptr)) 101 - #define KA_HELD_GKL() (current->lock_depth >= 0) 102 - 103 - /* The actual assert */ 104 - #define KGDB_ASSERT(condition, message) do { \ 105 - if (!(condition) && (kgdb_enabled)) { \ 106 - KGDB_PRINTK("Assertion failed at %s:%d: %s\n", \ 107 - __FILE__, __LINE__, message);\ 108 - BREAKPOINT(); \ 109 - } \ 110 - } while (0) 111 - #else 112 - #define KGDB_ASSERT(condition, message) 113 103 #endif 114 104 115 105 /* Taken from sh-stub.c of GDB 4.18 */ ··· 100 142 { 101 143 return hexchars[x & 0xf]; 102 144 } 103 - 104 145 #endif
+2
include/asm-sh/se7751.h
··· 65 65 66 66 #define IRQ_79C973 13 67 67 68 + void init_7751se_IRQ(void); 69 + 68 70 #define __IO_PREFIX sh7751se 69 71 #include <asm/io_generic.h> 70 72