1 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/Documentation/DocBook/Makefile linux-2.6.18-53.1.14.kgdb/Documentation/DocBook/Makefile
2 --- linux-2.6.18-53.1.14/Documentation/DocBook/Makefile 2008-03-06 05:54:50.000000000 +0300
3 +++ linux-2.6.18-53.1.14.kgdb/Documentation/DocBook/Makefile 2008-06-10 15:37:25.000000000 +0400
4 @@ -11,7 +11,7 @@ DOCBOOKS := wanbook.xml z8530book.xml mc
5 procfs-guide.xml writing_usb_driver.xml \
6 kernel-api.xml journal-api.xml lsm.xml utrace.xml usb.xml \
7 gadget.xml libata.xml mtdnand.xml librs.xml rapidio.xml \
9 + genericirq.xml kgdb.xml
12 # The build process is as follows (targets):
13 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/Documentation/DocBook/kgdb.tmpl linux-2.6.18-53.1.14.kgdb/Documentation/DocBook/kgdb.tmpl
14 --- linux-2.6.18-53.1.14/Documentation/DocBook/kgdb.tmpl 1970-01-01 03:00:00.000000000 +0300
15 +++ linux-2.6.18-53.1.14.kgdb/Documentation/DocBook/kgdb.tmpl 2008-06-10 15:38:50.000000000 +0400
17 +<?xml version="1.0" encoding="UTF-8"?>
18 +<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
19 + "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []>
21 +<book id="kgdbInternals">
23 + <title>KGDB Internals</title>
27 + <firstname>Tom</firstname>
28 + <surname>Rini</surname>
31 + <email>trini@kernel.crashing.org</email>
39 + <firstname>Amit S.</firstname>
40 + <surname>Kale</surname>
43 + <email>amitkale@linsyssoft.com</email>
50 + <year>2004-2005</year>
51 + <holder>MontaVista Software, Inc.</holder>
55 + <holder>Amit S. Kale</holder>
60 + This file is licensed under the terms of the GNU General Public License
61 + version 2. This program is licensed "as is" without any warranty of any
62 + kind, whether express or implied.
69 + <chapter id="Introduction">
70 + <title>Introduction</title>
72 + kgdb is a source level debugger for linux kernel. It is used along
73 + with gdb to debug a linux kernel. Kernel developers can debug a kernel
74 + similar to application programs with the use of kgdb. It makes it
75 + possible to place breakpoints in kernel code, step through the code
76 + and observe variables.
79 + Two machines are required for using kgdb. One of these machines is a
80 + development machine and the other is a test machine. The machines are
81 + typically connected through a serial line, a null-modem cable which
82 + connects their serial ports. It is also possible however, to use an
83 + ethernet connection between the machines. The kernel to be debugged
84 + runs on the test machine. gdb runs on the development machine. The
85 + serial line or ethernet connection is used by gdb to communicate to
86 + the kernel being debugged.
89 + <chapter id="CompilingAKernel">
90 + <title>Compiling a kernel</title>
92 + To enable <symbol>CONFIG_KGDB</symbol>, look under the "Kernel debugging"
93 + and then select "KGDB: kernel debugging with remote gdb".
96 + The first choice for I/O is <symbol>CONFIG_KGDB_ONLY_MODULES</symbol>.
97 + This means that you will only be able to use KGDB after loading a
98 + kernel module that defines how you want to be able to talk with
99 + KGDB. There are two other choices (more on some architectures) that
100 + can be enabled as modules later, if not picked here.
102 + <para>The first of these is <symbol>CONFIG_KGDB_8250_NOMODULE</symbol>.
103 + This has sub-options such as <symbol>CONFIG_KGDB_SIMPLE_SERIAL</symbol>
104 + which toggles choosing the serial port by ttyS number or by specifying
105 + a port and IRQ number.
108 + The second of these choices on most systems for I/O is
109 + <symbol>CONFIG_KGDBOE</symbol>. This requires that the machine to be
110 + debugged has an ethernet card which supports the netpoll API, such as
111 + the cards supported by <symbol>CONFIG_E100</symbol>. There are no
112 + sub-options for this, but a kernel command line option is required.
115 + <chapter id="BootingTheKernel">
116 + <title>Booting the kernel</title>
118 + The Kernel command line option <constant>kgdbwait</constant> makes kgdb
119 + wait for gdb connection during booting of a kernel. If the
120 + <symbol>CONFIG_KGDB_8250</symbol> driver is used (or if applicable,
121 + another serial driver) this breakpoint will happen very early on, before
122 + console output. If you wish to change serial port information and you
123 + have enabled both <symbol>CONFIG_KGDB_8250</symbol> and
124 + <symbol>CONFIG_KGDB_SIMPLE_SERIAL</symbol> then you must pass the option
125 + <constant>kgdb8250=<io or mmio>,<address>,<baud
126 + rate>,<irq></constant> before <constant>kgdbwait</constant>.
127 + The values <constant>io</constant> or <constant>mmio</constant> refer to
128 + if the address being passed next needs to be memory mapped
129 + (<constant>mmio</constant>) or not. The <constant>address</constant> must
130 + be passed in hex and is the hardware address and will be remapped if
131 + passed as <constant>mmio</constant>. The value
132 + <constant>baud rate</constant> and <constant>irq</constant> are base-10.
133 + The supported values for <constant>baud rate</constant> are
134 + <constant>9600</constant>, <constant>19200</constant>,
135 + <constant>38400</constant>, <constant>57600</constant>, and
136 + <constant>115200</constant>.
139 + To have KGDB stop the kernel and wait, with the compiled values for the
140 + serial driver, pass in: <constant>kgdbwait</constant>.
143 + To specify the values of the SH SCI(F) serial port at boot:
144 + <constant>kgdbsci=0,115200</constant>.
147 + To specify the values of the serial port at boot:
148 + <constant>kgdb8250=io,3f8,115200,3</constant>.
149 + On IA64 this could also be:
150 + <constant>kgdb8250=mmio,0xff5e0000,115200,74</constant>
151 + And to have KGDB also stop the kernel and wait for GDB to connect, pass in
152 + <constant>kgdbwait</constant> after this arguement.
155 + To configure the <symbol>CONFIG_KGDBOE</symbol> driver, pass in
156 + <constant>kgdboe=[src-port]@<src-ip>/[dev],[tgt-port]@<tgt-ip>/[tgt-macaddr]</constant>
159 + <listitem><para>src-port (optional): source for UDP packets (defaults to <constant>6443</constant>)</para></listitem>
160 + <listitem><para>src-ip: source IP to use (interface address)</para></listitem>
161 + <listitem><para>dev (optional): network interface (<constant>eth0</constant>)</para></listitem>
162 + <listitem><para>tgt-port (optional): port GDB will use (defaults to <constant>6442</constant>)</para></listitem>
163 + <listitem><para>tgt-ip: IP address GDB will be connecting from</para></listitem>
164 + <listitem><para>tgt-macaddr (optional): ethernet MAC address for logging agent (default is broadcast)</para></listitem>
168 + The <symbol>CONFIG_KGDBOE</symbol> driver can be reconfigured at run
169 + time, if <symbol>CONFIG_SYSFS</symbol> and
170 + <symbol>CONFIG_MODULES</symbol> by echo'ing a new config string to
171 + <constant>/sys/module/kgdboe/parameter/kgdboe</constant>. The
172 + driver can be unconfigured with the special string
173 + <constant>not_configured</constant>.
176 + <chapter id="ConnectingGDB">
177 + <title>Connecting gdb</title>
179 + If you have used any of the methods to have KGDB stop and create
180 + an initial breakpoint described in the previous chapter, kgdb prints
181 + the message "Waiting for connection from remote gdb..." on the console
182 + and waits for connection from gdb. At this point you connect gdb to kgdb.
189 + (gdb) set remotebaud 115200
190 + (gdb) target remote /dev/ttyS0
193 + Example (ethernet):
197 + (gdb) target remote udp:192.168.2.2:6443
200 + Once connected, you can debug a kernel the way you would debug an
201 + application program.
204 + <chapter id="ArchitectureNotes">
205 + <title>Architecture specific notes</title>
207 + SuperH: The NMI switch found on some boards can be used to trigger an
208 + initial breakpoint. Subsequent triggers do nothing. If console
209 + is enabled on the SCI(F) serial port, and that is the port being used
210 + for KGDB, then you must trigger a breakpoint via sysrq, NMI, or
211 + some other method prior to connecting, or echo a control-c to the
212 + serial port. Also, to use the SCI(F) port for KGDB, the
213 + <symbol>CONFIG_SERIAL_SH_SCI</symbol> driver must be enabled.
216 + <chapter id="CommonBackEndReq">
217 + <title>The common backend (required)</title>
219 + There are a few flags which must be set on every architecture in
220 + their <asm/kgdb.h> file. These are:
224 + NUMREGBYTES: The size in bytes of all of the registers, so
225 + that we can ensure they will all fit into a packet.
228 + BUFMAX: The size in bytes of the buffer GDB will read into.
229 + This must be larger than NUMREGBYTES.
232 + CACHE_FLUSH_IS_SAFE: Set to one if it always safe to call
233 + flush_cache_range or flush_icache_range. On some architectures,
234 + these functions may not be safe to call on SMP since we keep other
235 + CPUs in a holding pattern.
241 + There are also the following functions for the common backend,
242 + found in kernel/kgdb.c that must be supplied by the
243 + architecture-specific backend. No weak version of these is provided.
245 +!Iinclude/linux/kgdb.h
247 + <chapter id="CommonBackEndOpt">
248 + <title>The common backend (optional)</title>
250 + These functions are part of the common backend, found in kernel/kgdb.c
251 + and are optionally implemented. Some functions (with _hw_ in the name)
252 + end up being required on arches which use hardware breakpoints.
256 + <chapter id="DriverSpecificFunctions">
257 + <title>Driver-Specific Functions</title>
259 + Some of the I/O drivers have additional functions that can be
260 + called, that are specific to the driver. Calls from other places
261 + to these functions must be wrapped in #ifdefs for the driver in
264 +!Idrivers/serial/8250_kgdb.c
267 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/MAINTAINERS linux-2.6.18-53.1.14.kgdb/MAINTAINERS
268 --- linux-2.6.18-53.1.14/MAINTAINERS 2008-03-06 05:54:49.000000000 +0300
269 +++ linux-2.6.18-53.1.14.kgdb/MAINTAINERS 2008-06-10 15:37:25.000000000 +0400
270 @@ -1715,6 +1715,15 @@ L: linux-kernel@vger.kernel.org
277 +M: trini@kernel.crashing.org
278 +M: amitkale@linsyssoft.com
279 +W: http://sourceforge.net/projects/kgdb
280 +L: kgdb-bugreport@lists.sourceforge.net
284 P: Prasanna S Panchamukhi
285 M: prasanna@in.ibm.com
286 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/Makefile linux-2.6.18-53.1.14.kgdb/Makefile
287 --- linux-2.6.18-53.1.14/Makefile 2008-03-06 05:55:00.000000000 +0300
288 +++ linux-2.6.18-53.1.14.kgdb/Makefile 2008-06-10 15:39:01.000000000 +0400
289 @@ -992,6 +992,7 @@ MRPROPER_DIRS += include/config include
290 MRPROPER_FILES += .config .config.old include/asm .version .old_version \
291 include/linux/autoconf.h include/linux/version.h \
292 include/linux/utsrelease.h \
293 + include/linux/dwarf2-defs.h \
294 Module.symvers tags TAGS cscope*
296 # clean - Delete most, but leave enough to build external modules
297 @@ -1422,7 +1423,11 @@ clean := -f $(if $(KBUILD_SRC),$(srctree
298 endif # skip-makefile
302 +include/linux/dwarf2-defs.h: $(srctree)/include/linux/dwarf2.h $(srctree)/scripts/dwarfh.awk
303 + mkdir -p include/linux/
304 + awk -f $(srctree)/scripts/dwarfh.awk $(srctree)/include/linux/dwarf2.h > include/linux/dwarf2-defs.h
306 +FORCE: include/linux/dwarf2-defs.h
309 # Declare the contents of the .PHONY variable as phony. We keep that
310 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/arm/kernel/Makefile linux-2.6.18-53.1.14.kgdb/arch/arm/kernel/Makefile
311 --- linux-2.6.18-53.1.14/arch/arm/kernel/Makefile 2006-09-20 07:42:06.000000000 +0400
312 +++ linux-2.6.18-53.1.14.kgdb/arch/arm/kernel/Makefile 2008-06-10 15:38:56.000000000 +0400
313 @@ -20,6 +20,7 @@ obj-$(CONFIG_ISA_DMA) += dma-isa.o
314 obj-$(CONFIG_PCI) += bios32.o isa.o
315 obj-$(CONFIG_SMP) += smp.o
316 obj-$(CONFIG_OABI_COMPAT) += sys_oabi-compat.o
317 +obj-$(CONFIG_KGDB) += kgdb.o kgdb-jmp.o
319 obj-$(CONFIG_CRUNCH) += crunch.o crunch-bits.o
320 AFLAGS_crunch-bits.o := -Wa,-mcpu=ep9312
321 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/arm/kernel/entry-armv.S linux-2.6.18-53.1.14.kgdb/arch/arm/kernel/entry-armv.S
322 --- linux-2.6.18-53.1.14/arch/arm/kernel/entry-armv.S 2006-09-20 07:42:06.000000000 +0400
323 +++ linux-2.6.18-53.1.14.kgdb/arch/arm/kernel/entry-armv.S 2008-06-10 15:39:01.000000000 +0400
325 * it to save wrong values... Be aware!
328 +#include <asm/kgdb.h>
329 #include <asm/memory.h>
330 #include <asm/glue.h>
331 #include <asm/vfpmacros.h>
332 @@ -232,6 +233,7 @@ svc_preempt:
333 beq preempt_return @ go again
336 + CFI_END_FRAME(__irq_svc)
340 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/arm/kernel/kgdb-jmp.S linux-2.6.18-53.1.14.kgdb/arch/arm/kernel/kgdb-jmp.S
341 --- linux-2.6.18-53.1.14/arch/arm/kernel/kgdb-jmp.S 1970-01-01 03:00:00.000000000 +0300
342 +++ linux-2.6.18-53.1.14.kgdb/arch/arm/kernel/kgdb-jmp.S 2008-06-10 15:38:56.000000000 +0400
345 + * arch/arm/kernel/kgdb-jmp.S
347 + * Trivial setjmp and longjmp procedures to support bus error recovery
348 + * which may occur during kgdb memory read/write operations.
350 + * Author: MontaVista Software, Inc. <source@mvista.com>
351 + * source@mvista.com
353 + * 2002-2005 (c) MontaVista Software, Inc. This file is licensed under the
354 + * terms of the GNU General Public License version 2. This program as licensed
355 + * "as is" without any warranty of any kind, whether express or implied.
357 +#include <linux/linkage.h>
359 +ENTRY (kgdb_fault_setjmp)
360 + /* Save registers */
369 +ENTRY (kgdb_fault_longjmp)
370 + /* Restore registers */
376 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/arm/kernel/kgdb.c linux-2.6.18-53.1.14.kgdb/arch/arm/kernel/kgdb.c
377 --- linux-2.6.18-53.1.14/arch/arm/kernel/kgdb.c 1970-01-01 03:00:00.000000000 +0300
378 +++ linux-2.6.18-53.1.14.kgdb/arch/arm/kernel/kgdb.c 2008-06-10 15:38:56.000000000 +0400
381 + * arch/arm/kernel/kgdb.c
385 + * Copyright (c) 2002-2004 MontaVista Software, Inc
387 + * Authors: George Davis <davis_g@mvista.com>
388 + * Deepak Saxena <dsaxena@plexity.net>
390 +#include <linux/config.h>
391 +#include <linux/types.h>
392 +#include <linux/kernel.h>
393 +#include <linux/signal.h>
394 +#include <linux/sched.h>
395 +#include <linux/mm.h>
396 +#include <linux/spinlock.h>
397 +#include <linux/personality.h>
398 +#include <linux/ptrace.h>
399 +#include <linux/elf.h>
400 +#include <linux/interrupt.h>
401 +#include <linux/init.h>
402 +#include <linux/kgdb.h>
404 +#include <asm/atomic.h>
406 +#include <asm/pgtable.h>
407 +#include <asm/system.h>
408 +#include <asm/uaccess.h>
409 +#include <asm/unistd.h>
410 +#include <asm/ptrace.h>
411 +#include <asm/traps.h>
413 +/* Make a local copy of the registers passed into the handler (bletch) */
414 +void regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *kernel_regs)
418 + /* Initialize all to zero (??) */
419 + for (regno = 0; regno < GDB_MAX_REGS; regno++)
420 + gdb_regs[regno] = 0;
422 + gdb_regs[_R0] = kernel_regs->ARM_r0;
423 + gdb_regs[_R1] = kernel_regs->ARM_r1;
424 + gdb_regs[_R2] = kernel_regs->ARM_r2;
425 + gdb_regs[_R3] = kernel_regs->ARM_r3;
426 + gdb_regs[_R4] = kernel_regs->ARM_r4;
427 + gdb_regs[_R5] = kernel_regs->ARM_r5;
428 + gdb_regs[_R6] = kernel_regs->ARM_r6;
429 + gdb_regs[_R7] = kernel_regs->ARM_r7;
430 + gdb_regs[_R8] = kernel_regs->ARM_r8;
431 + gdb_regs[_R9] = kernel_regs->ARM_r9;
432 + gdb_regs[_R10] = kernel_regs->ARM_r10;
433 + gdb_regs[_FP] = kernel_regs->ARM_fp;
434 + gdb_regs[_IP] = kernel_regs->ARM_ip;
435 + gdb_regs[_SP] = kernel_regs->ARM_sp;
436 + gdb_regs[_LR] = kernel_regs->ARM_lr;
437 + gdb_regs[_PC] = kernel_regs->ARM_pc;
438 + gdb_regs[_CPSR] = kernel_regs->ARM_cpsr;
441 +/* Copy local gdb registers back to kgdb regs, for later copy to kernel */
442 +void gdb_regs_to_regs(unsigned long *gdb_regs, struct pt_regs *kernel_regs)
444 + kernel_regs->ARM_r0 = gdb_regs[_R0];
445 + kernel_regs->ARM_r1 = gdb_regs[_R1];
446 + kernel_regs->ARM_r2 = gdb_regs[_R2];
447 + kernel_regs->ARM_r3 = gdb_regs[_R3];
448 + kernel_regs->ARM_r4 = gdb_regs[_R4];
449 + kernel_regs->ARM_r5 = gdb_regs[_R5];
450 + kernel_regs->ARM_r6 = gdb_regs[_R6];
451 + kernel_regs->ARM_r7 = gdb_regs[_R7];
452 + kernel_regs->ARM_r8 = gdb_regs[_R8];
453 + kernel_regs->ARM_r9 = gdb_regs[_R9];
454 + kernel_regs->ARM_r10 = gdb_regs[_R10];
455 + kernel_regs->ARM_fp = gdb_regs[_FP];
456 + kernel_regs->ARM_ip = gdb_regs[_IP];
457 + kernel_regs->ARM_sp = gdb_regs[_SP];
458 + kernel_regs->ARM_lr = gdb_regs[_LR];
459 + kernel_regs->ARM_pc = gdb_regs[_PC];
460 + kernel_regs->ARM_cpsr = gdb_regs[GDB_MAX_REGS - 1];
463 +static inline struct pt_regs *kgdb_get_user_regs(struct task_struct *task)
465 + return (struct pt_regs *)
466 + ((unsigned long)task->thread_info + THREAD_SIZE -
467 + 8 - sizeof(struct pt_regs));
470 +void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs,
471 + struct task_struct *task)
474 + struct pt_regs *thread_regs;
476 + /* Just making sure... */
480 + /* Initialize to zero */
481 + for (regno = 0; regno < GDB_MAX_REGS; regno++)
482 + gdb_regs[regno] = 0;
484 + /* Otherwise, we have only some registers from switch_to() */
485 + thread_regs = kgdb_get_user_regs(task);
486 + gdb_regs[_R0] = thread_regs->ARM_r0; /* Not really valid? */
487 + gdb_regs[_R1] = thread_regs->ARM_r1; /* " " */
488 + gdb_regs[_R2] = thread_regs->ARM_r2; /* " " */
489 + gdb_regs[_R3] = thread_regs->ARM_r3; /* " " */
490 + gdb_regs[_R4] = thread_regs->ARM_r4;
491 + gdb_regs[_R5] = thread_regs->ARM_r5;
492 + gdb_regs[_R6] = thread_regs->ARM_r6;
493 + gdb_regs[_R7] = thread_regs->ARM_r7;
494 + gdb_regs[_R8] = thread_regs->ARM_r8;
495 + gdb_regs[_R9] = thread_regs->ARM_r9;
496 + gdb_regs[_R10] = thread_regs->ARM_r10;
497 + gdb_regs[_FP] = thread_regs->ARM_fp;
498 + gdb_regs[_IP] = thread_regs->ARM_ip;
499 + gdb_regs[_SP] = thread_regs->ARM_sp;
500 + gdb_regs[_LR] = thread_regs->ARM_lr;
501 + gdb_regs[_PC] = thread_regs->ARM_pc;
502 + gdb_regs[_CPSR] = thread_regs->ARM_cpsr;
505 +static int compiled_break;
507 +int kgdb_arch_handle_exception(int exception_vector, int signo,
508 + int err_code, char *remcom_in_buffer,
509 + char *remcom_out_buffer,
510 + struct pt_regs *linux_regs)
515 + switch (remcom_in_buffer[0]) {
517 + kgdb_contthread = NULL;
520 + * Try to read optional parameter, pc unchanged if no parm.
521 + * If this was a compiled breakpoint, we need to move
522 + * to the next instruction or we will just breakpoint
523 + * over and over again.
525 + ptr = &remcom_in_buffer[1];
526 + if (kgdb_hex2long(&ptr, &addr)) {
527 + linux_regs->ARM_pc = addr;
528 + } else if (compiled_break == 1) {
529 + linux_regs->ARM_pc += 4;
532 + compiled_break = 0;
540 +static int kgdb_brk_fn(struct pt_regs *regs, unsigned int instr)
542 + kgdb_handle_exception(1, SIGTRAP, 0, regs);
547 +static int kgdb_compiled_brk_fn(struct pt_regs *regs, unsigned int instr)
549 + compiled_break = 1;
550 + kgdb_handle_exception(1, SIGTRAP, 0, regs);
555 +static struct undef_hook kgdb_brkpt_hook = {
556 + .instr_mask = 0xffffffff,
557 + .instr_val = KGDB_BREAKINST,
561 +static struct undef_hook kgdb_compiled_brkpt_hook = {
562 + .instr_mask = 0xffffffff,
563 + .instr_val = KGDB_COMPILED_BREAK,
564 + .fn = kgdb_compiled_brk_fn
568 + * Register our undef instruction hooks with ARM undef core.
569 + * We regsiter a hook specifically looking for the KGB break inst
570 + * and we handle the normal undef case within the do_undefinstr
573 +int kgdb_arch_init(void)
575 + register_undef_hook(&kgdb_brkpt_hook);
576 + register_undef_hook(&kgdb_compiled_brkpt_hook);
581 +struct kgdb_arch arch_kgdb_ops = {
583 + .gdb_bpt_instr = {0xfe, 0xde, 0xff, 0xe7}
585 + .gdb_bpt_instr = {0xe7, 0xff, 0xde, 0xfe}
588 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/arm/kernel/setup.c linux-2.6.18-53.1.14.kgdb/arch/arm/kernel/setup.c
589 --- linux-2.6.18-53.1.14/arch/arm/kernel/setup.c 2006-09-20 07:42:06.000000000 +0400
590 +++ linux-2.6.18-53.1.14.kgdb/arch/arm/kernel/setup.c 2008-06-10 15:38:56.000000000 +0400
591 @@ -829,6 +829,11 @@ void __init setup_arch(char **cmdline_p)
592 conswitchp = &dummy_con;
596 +#if defined(CONFIG_KGDB)
597 + extern void __init early_trap_init(void);
603 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/arm/kernel/traps.c linux-2.6.18-53.1.14.kgdb/arch/arm/kernel/traps.c
604 --- linux-2.6.18-53.1.14/arch/arm/kernel/traps.c 2006-09-20 07:42:06.000000000 +0400
605 +++ linux-2.6.18-53.1.14.kgdb/arch/arm/kernel/traps.c 2008-06-10 15:38:56.000000000 +0400
606 @@ -278,6 +278,7 @@ asmlinkage void do_undefinstr(struct pt_
608 struct undef_hook *hook;
614 @@ -287,12 +288,15 @@ asmlinkage void do_undefinstr(struct pt_
616 regs->ARM_pc -= correction;
620 pc = (void __user *)instruction_pointer(regs);
621 if (thumb_mode(regs)) {
622 get_user(instr, (u16 __user *)pc);
624 get_user(instr, (u32 __user *)pc);
628 spin_lock_irq(&undef_lock);
629 list_for_each_entry(hook, &undef_hook, node) {
630 @@ -684,6 +688,13 @@ EXPORT_SYMBOL(abort);
632 void __init trap_init(void)
634 +#if defined(CONFIG_KGDB)
638 +void __init early_trap_init(void)
641 unsigned long vectors = CONFIG_VECTORS_BASE;
642 extern char __stubs_start[], __stubs_end[];
643 extern char __vectors_start[], __vectors_end[];
644 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/arm/mach-ixp2000/core.c linux-2.6.18-53.1.14.kgdb/arch/arm/mach-ixp2000/core.c
645 --- linux-2.6.18-53.1.14/arch/arm/mach-ixp2000/core.c 2006-09-20 07:42:06.000000000 +0400
646 +++ linux-2.6.18-53.1.14.kgdb/arch/arm/mach-ixp2000/core.c 2008-06-10 15:38:56.000000000 +0400
648 #include <asm/system.h>
649 #include <asm/tlbflush.h>
650 #include <asm/pgtable.h>
651 +#include <asm/kgdb.h>
653 #include <asm/mach/map.h>
654 #include <asm/mach/time.h>
655 @@ -184,6 +185,9 @@ static struct platform_device ixp2000_se
656 void __init ixp2000_uart_init(void)
658 platform_device_register(&ixp2000_serial_device);
659 +#ifdef CONFIG_KGDB_8250
660 + kgdb8250_add_port(0, &ixp2000_serial_port);
665 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/arm/mach-ixp2000/ixdp2x01.c linux-2.6.18-53.1.14.kgdb/arch/arm/mach-ixp2000/ixdp2x01.c
666 --- linux-2.6.18-53.1.14/arch/arm/mach-ixp2000/ixdp2x01.c 2006-09-20 07:42:06.000000000 +0400
667 +++ linux-2.6.18-53.1.14.kgdb/arch/arm/mach-ixp2000/ixdp2x01.c 2008-06-10 15:38:56.000000000 +0400
669 #include <asm/system.h>
670 #include <asm/hardware.h>
671 #include <asm/mach-types.h>
672 +#include <asm/kgdb.h>
674 #include <asm/mach/pci.h>
675 #include <asm/mach/map.h>
676 @@ -413,6 +414,11 @@ static void __init ixdp2x01_init_machine
677 platform_add_devices(ixdp2x01_devices, ARRAY_SIZE(ixdp2x01_devices));
679 ixdp2x01_uart_init();
681 +#ifdef CONFIG_KGDB_8250
682 + kgdb8250_add_port(0, &ixdp425_serial_ports[0]);
683 + kgdb8250_add_port(1, &ixdp425_serial_ports[1]);
688 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/arm/mach-ixp4xx/coyote-setup.c linux-2.6.18-53.1.14.kgdb/arch/arm/mach-ixp4xx/coyote-setup.c
689 --- linux-2.6.18-53.1.14/arch/arm/mach-ixp4xx/coyote-setup.c 2006-09-20 07:42:06.000000000 +0400
690 +++ linux-2.6.18-53.1.14.kgdb/arch/arm/mach-ixp4xx/coyote-setup.c 2008-06-10 15:38:56.000000000 +0400
691 @@ -96,6 +96,10 @@ static void __init coyote_init(void)
694 platform_add_devices(coyote_devices, ARRAY_SIZE(coyote_devices));
696 +#ifdef CONFIG_KGDB_8250
697 + kgdb8250_add_port(0, &coyote_serial_port);
701 #ifdef CONFIG_ARCH_ADI_COYOTE
702 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/arm/mach-ixp4xx/ixdp425-setup.c linux-2.6.18-53.1.14.kgdb/arch/arm/mach-ixp4xx/ixdp425-setup.c
703 --- linux-2.6.18-53.1.14/arch/arm/mach-ixp4xx/ixdp425-setup.c 2006-09-20 07:42:06.000000000 +0400
704 +++ linux-2.6.18-53.1.14.kgdb/arch/arm/mach-ixp4xx/ixdp425-setup.c 2008-06-10 15:38:56.000000000 +0400
707 #include <asm/mach/arch.h>
708 #include <asm/mach/flash.h>
709 +#include <asm/kgdb.h>
711 static struct flash_platform_data ixdp425_flash_data = {
712 .map_name = "cfi_probe",
713 @@ -76,7 +77,8 @@ static struct plat_serial8250_port ixdp4
714 .mapbase = IXP4XX_UART1_BASE_PHYS,
715 .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
716 .irq = IRQ_IXP4XX_UART1,
717 - .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
718 + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
722 .uartclk = IXP4XX_UART_XTAL,
723 @@ -85,7 +87,8 @@ static struct plat_serial8250_port ixdp4
724 .mapbase = IXP4XX_UART2_BASE_PHYS,
725 .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
726 .irq = IRQ_IXP4XX_UART2,
727 - .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
728 + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
732 .uartclk = IXP4XX_UART_XTAL,
733 @@ -116,6 +119,11 @@ static void __init ixdp425_init(void)
734 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
736 platform_add_devices(ixdp425_devices, ARRAY_SIZE(ixdp425_devices));
738 +#ifdef CONFIG_KGDB_8250
739 + kgdb8250_add_port(0, &ixdp425_serial_ports[0]);
740 + kgdb8250_add_port(1, &ixdp425_serial_ports[1]);
744 #ifdef CONFIG_ARCH_IXDP425
745 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/arm/mach-omap1/serial.c linux-2.6.18-53.1.14.kgdb/arch/arm/mach-omap1/serial.c
746 --- linux-2.6.18-53.1.14/arch/arm/mach-omap1/serial.c 2006-09-20 07:42:06.000000000 +0400
747 +++ linux-2.6.18-53.1.14.kgdb/arch/arm/mach-omap1/serial.c 2008-06-10 15:38:56.000000000 +0400
749 #include <linux/delay.h>
750 #include <linux/serial.h>
751 #include <linux/tty.h>
752 +#include <linux/kgdb.h>
753 #include <linux/serial_8250.h>
754 #include <linux/serial_reg.h>
755 #include <linux/clk.h>
756 @@ -199,6 +200,9 @@ void __init omap_serial_init(void)
759 omap_serial_reset(&serial_platform_data[i]);
760 +#ifdef CONFIG_KGDB_8250
761 + kgdb8250_add_platform_port(i, &serial_platform_data[i]);
766 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/arm/mach-pxa/Makefile linux-2.6.18-53.1.14.kgdb/arch/arm/mach-pxa/Makefile
767 --- linux-2.6.18-53.1.14/arch/arm/mach-pxa/Makefile 2006-09-20 07:42:06.000000000 +0400
768 +++ linux-2.6.18-53.1.14.kgdb/arch/arm/mach-pxa/Makefile 2008-06-10 15:38:56.000000000 +0400
769 @@ -31,6 +31,7 @@ obj-$(CONFIG_LEDS) += $(led-y)
771 obj-$(CONFIG_PM) += pm.o sleep.o
772 obj-$(CONFIG_PXA_SSP) += ssp.o
773 +obj-$(CONFIG_KGDB_PXA_SERIAL) += kgdb-serial.o
775 ifeq ($(CONFIG_PXA27x),y)
776 obj-$(CONFIG_PM) += standby.o
777 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/arm/mach-pxa/kgdb-serial.c linux-2.6.18-53.1.14.kgdb/arch/arm/mach-pxa/kgdb-serial.c
778 --- linux-2.6.18-53.1.14/arch/arm/mach-pxa/kgdb-serial.c 1970-01-01 03:00:00.000000000 +0300
779 +++ linux-2.6.18-53.1.14.kgdb/arch/arm/mach-pxa/kgdb-serial.c 2008-06-10 15:38:56.000000000 +0400
782 + * linux/arch/arm/mach-pxa/kgdb-serial.c
784 + * Provides low level kgdb serial support hooks for PXA2xx boards
786 + * Author: Nicolas Pitre
787 + * Copyright: (C) 2002-2005 MontaVista Software Inc.
789 + * This program is free software; you can redistribute it and/or modify
790 + * it under the terms of the GNU General Public License version 2 as
791 + * published by the Free Software Foundation.
794 +#include <linux/config.h>
795 +#include <linux/serial_reg.h>
796 +#include <linux/kgdb.h>
797 +#include <asm/processor.h>
798 +#include <asm/hardware.h>
799 +#include <asm/arch/pxa-regs.h>
801 +#if defined(CONFIG_KGDB_PXA_FFUART)
804 +#define CKEN_UART CKEN6_FFUART
805 +#define GPIO_RX_MD GPIO34_FFRXD_MD
806 +#define GPIO_TX_MD GPIO39_FFTXD_MD
808 +#elif defined(CONFIG_KGDB_PXA_BTUART)
811 +#define CKEN_UART CKEN7_BTUART
812 +#define GPIO_RX_MD GPIO42_BTRXD_MD
813 +#define GPIO_TX_MD GPIO43_BTTXD_MD
815 +#elif defined(CONFIG_KGDB_PXA_STUART)
818 +#define CKEN_UART CKEN5_STUART
819 +#define GPIO_RX_MD GPIO46_STRXD_MD
820 +#define GPIO_TX_MD GPIO47_STTXD_MD
824 +#define UART_BAUDRATE (CONFIG_KGDB_BAUDRATE)
826 +static volatile unsigned long *port = (unsigned long *)&UART;
828 +static int kgdb_serial_init(void)
830 + pxa_set_cken(CKEN_UART, 1);
831 + pxa_gpio_mode(GPIO_RX_MD);
832 + pxa_gpio_mode(GPIO_TX_MD);
834 + port[UART_IER] = 0;
835 + port[UART_LCR] = LCR_DLAB;
836 + port[UART_DLL] = ((921600 / UART_BAUDRATE) & 0xff);
837 + port[UART_DLM] = ((921600 / UART_BAUDRATE) >> 8);
838 + port[UART_LCR] = LCR_WLS1 | LCR_WLS0;
839 + port[UART_MCR] = 0;
840 + port[UART_IER] = IER_UUE;
841 + port[UART_FCR] = FCR_ITL_16;
846 +static void kgdb_serial_putchar(int c)
848 + if (!(CKEN & CKEN_UART) || port[UART_IER] != IER_UUE)
849 + kgdb_serial_init();
850 + while (!(port[UART_LSR] & LSR_TDRQ))
855 +static void kgdb_serial_flush(void)
857 + if ((CKEN & CKEN_UART) && (port[UART_IER] & IER_UUE))
858 + while (!(port[UART_LSR] & LSR_TEMT))
862 +static int kgdb_serial_getchar(void)
865 + if (!(CKEN & CKEN_UART) || port[UART_IER] != IER_UUE)
866 + kgdb_serial_init();
867 + while (!(port[UART_LSR] & UART_LSR_DR))
873 +struct kgdb_io kgdb_io_ops = {
874 + .init = kgdb_serial_init,
875 + .write_char = kgdb_serial_putchar,
876 + .flush = kgdb_serial_flush,
877 + .read_char = kgdb_serial_getchar,
879 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/arm/mach-versatile/kgdb_serial.c linux-2.6.18-53.1.14.kgdb/arch/arm/mach-versatile/kgdb_serial.c
880 --- linux-2.6.18-53.1.14/arch/arm/mach-versatile/kgdb_serial.c 1970-01-01 03:00:00.000000000 +0300
881 +++ linux-2.6.18-53.1.14.kgdb/arch/arm/mach-versatile/kgdb_serial.c 2008-06-10 15:38:56.000000000 +0400
884 + * arch/arm/mach-versatile/kgdb_serial.c
886 + * Author: Manish Lachwani, mlachwani@mvista.com
888 + * 2005 (c) MontaVista Software, Inc. This file is licensed under
889 + * the terms of the GNU General Public License version 2. This program
890 + * is licensed "as is" without any warranty of any kind, whether express
893 + * Support for KGDB on ARM Versatile.
895 +#include <linux/config.h>
896 +#include <linux/serial_reg.h>
897 +#include <linux/kgdb.h>
899 +#include <asm/processor.h>
900 +#include <asm/hardware.h>
901 +#include <asm/hardware/amba_serial.h>
902 +#include <asm/arch-versatile/hardware.h>
904 +#define ARM_BAUD_38400 23
906 + * Functions that will be used later
908 +#define UART_GET_INT_STATUS(p) readb((p) + UART010_IIR)
909 +#define UART_GET_MIS(p) readw((p) + UART011_MIS)
910 +#define UART_PUT_ICR(p, c) writel((c), (p) + UART010_ICR)
911 +#define UART_GET_FR(p) readb((p) + UART01x_FR)
912 +#define UART_GET_CHAR(p) readb((p) + UART01x_DR)
913 +#define UART_PUT_CHAR(p, c) writel((c), (p) + UART01x_DR)
914 +#define UART_GET_RSR(p) readb((p) + UART01x_RSR)
915 +#define UART_GET_CR(p) readb((p) + UART010_CR)
916 +#define UART_PUT_CR(p,c) writel((c), (p) + UART010_CR)
917 +#define UART_GET_LCRL(p) readb((p) + UART010_LCRL)
918 +#define UART_PUT_LCRL(p,c) writel((c), (p) + UART010_LCRL)
919 +#define UART_GET_LCRM(p) readb((p) + UART010_LCRM)
920 +#define UART_PUT_LCRM(p,c) writel((c), (p) + UART010_LCRM)
921 +#define UART_GET_LCRH(p) readb((p) + UART010_LCRH)
922 +#define UART_PUT_LCRH(p,c) writel((c), (p) + UART010_LCRH)
923 +#define UART_RX_DATA(s) (((s) & UART01x_FR_RXFE) == 0)
924 +#define UART_TX_READY(s) (((s) & UART01x_FR_TXFF) == 0)
925 +#define UART_TX_EMPTY(p) ((UART_GET_FR(p) & UART01x_FR_TMSK) == 0)
930 +static int kgdb_irq = 12;
931 +static volatile unsigned char *port = NULL;
933 +static int kgdb_serial_init(void)
935 + int rate = ARM_BAUD_38400;
937 + port = IO_ADDRESS(0x101F1000);
938 + UART_PUT_CR(port, 0);
940 + /* Set baud rate */
941 + UART_PUT_LCRM(port, ((rate & 0xf00) >> 8));
942 + UART_PUT_LCRL(port, (rate & 0xff));
943 + UART_PUT_LCRH(port, UART01x_LCRH_WLEN_8 | UART01x_LCRH_FEN);
944 + UART_PUT_CR(port, UART01x_CR_UARTEN);
949 +static void kgdb_serial_putchar(int ch)
951 + unsigned int status;
954 + status = UART_GET_FR(port);
955 + } while (!UART_TX_READY(status));
957 + UART_PUT_CHAR(port, ch);
960 +static int kgdb_serial_getchar(void)
962 + unsigned int status;
966 + status = UART_GET_FR(port);
967 + } while (!UART_RX_DATA(status));
968 + ch = UART_GET_CHAR(port);
972 +static struct uart_port kgdb_amba_port = {
975 + .iotype = UPIO_MEM,
976 + .membase = (unsigned char *)IO_ADDRESS(0x101F1000),
979 +static irqreturn_t kgdb_interrupt(int irq, void *dev_id, struct pt_regs *regs)
981 + int status = UART_GET_MIS(port);
983 + if (irq != kgdb_irq)
989 + return IRQ_HANDLED;
992 +static void __init kgdb_hookup_irq(void)
994 + request_irq(kgdb_irq, kgdb_interrupt, SA_SHIRQ, "GDB-stub",
998 +struct kgdb_io kgdb_io_ops = {
999 + .init = kgdb_serial_init,
1000 + .write_char = kgdb_serial_putchar,
1001 + .read_char = kgdb_serial_getchar,
1002 + .late_init = kgdb_hookup_irq,
1004 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/arm/mm/extable.c linux-2.6.18-53.1.14.kgdb/arch/arm/mm/extable.c
1005 --- linux-2.6.18-53.1.14/arch/arm/mm/extable.c 2006-09-20 07:42:06.000000000 +0400
1006 +++ linux-2.6.18-53.1.14.kgdb/arch/arm/mm/extable.c 2008-06-10 15:38:56.000000000 +0400
1008 * linux/arch/arm/mm/extable.c
1010 #include <linux/module.h>
1011 +#include <linux/kgdb.h>
1012 #include <asm/uaccess.h>
1014 int fixup_exception(struct pt_regs *regs)
1015 @@ -11,6 +12,12 @@ int fixup_exception(struct pt_regs *regs
1016 fixup = search_exception_tables(instruction_pointer(regs));
1018 regs->ARM_pc = fixup->fixup;
1020 + if (atomic_read(&debugger_active) && kgdb_may_fault)
1021 + /* Restore our previous state. */
1022 + kgdb_fault_longjmp(kgdb_fault_jmp_regs);
1023 + /* Not reached. */
1026 return fixup != NULL;
1028 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/i386/kernel/Makefile linux-2.6.18-53.1.14.kgdb/arch/i386/kernel/Makefile
1029 --- linux-2.6.18-53.1.14/arch/i386/kernel/Makefile 2008-03-06 05:54:14.000000000 +0300
1030 +++ linux-2.6.18-53.1.14.kgdb/arch/i386/kernel/Makefile 2008-06-10 15:38:03.000000000 +0400
1031 @@ -39,6 +39,7 @@ obj-$(CONFIG_VM86) += vm86.o
1032 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
1033 obj-$(CONFIG_HPET_TIMER) += hpet.o
1034 obj-$(CONFIG_K8_NB) += k8.o
1035 +obj-$(CONFIG_KGDB) += kgdb.o kgdb-jmp.o
1037 EXTRA_AFLAGS := -traditional
1039 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/i386/kernel/entry.S linux-2.6.18-53.1.14.kgdb/arch/i386/kernel/entry.S
1040 --- linux-2.6.18-53.1.14/arch/i386/kernel/entry.S 2008-03-06 05:55:00.000000000 +0300
1041 +++ linux-2.6.18-53.1.14.kgdb/arch/i386/kernel/entry.S 2008-06-10 15:39:01.000000000 +0400
1042 @@ -201,7 +201,7 @@ VM_MASK = 0x00020000
1043 CFI_OFFSET ecx, ECX-OLDESP;\
1044 CFI_OFFSET ebx, EBX-OLDESP
1046 -ENTRY(ret_from_fork)
1047 +KPROBE_ENTRY(ret_from_fork)
1050 CFI_ADJUST_CFA_OFFSET 4
1051 @@ -659,7 +659,7 @@ ENTRY(simd_coprocessor_error)
1055 -ENTRY(device_not_available)
1056 +KPROBE_ENTRY(device_not_available)
1058 pushl $-1 # mark this as an int
1059 CFI_ADJUST_CFA_OFFSET 4
1060 @@ -916,7 +916,7 @@ ENTRY(machine_check)
1064 -ENTRY(spurious_interrupt_bug)
1065 +KPROBE_ENTRY(spurious_interrupt_bug)
1068 CFI_ADJUST_CFA_OFFSET 4
1069 @@ -942,3 +942,108 @@ ENDPROC(kernel_thread_helper)
1070 #include "syscall_table.S"
1072 syscall_table_size=(.-sys_call_table)
1074 +# Here we do call frames. We cheat a bit as we only really need
1075 +# correct frames at locations we can actually look at from a
1076 +# debugger. Since the break instruction trap actually goes thru
1077 +# some of this code, we don't really need info on those areas, but
1078 +# only after the fact. I.e. if we can not step or break in a
1079 +# location or end up with a return address pointing at the
1080 +# location, we don't need a correct call frame for it.
1084 +#include <linux/dwarf2-lang.h>
1086 + * The register numbers as known by gdb
1108 + * This code uses macros defined in linux/dwarf2-lang.h
1109 + * They attempt to follow the dwarf2 naming conventions... sort of..
1111 +ENTRY(end_of_stack_stop_unwind_function)
1112 + .long end_of_stack_stop_unwind_function+1
1116 + CFI_preamble(c1,_PC,1,1)
1117 + CFA_define_reference(_ESP,OLDESP) /* Stack pointer */
1118 + CFA_expression(_EIP)
1119 + CFA_exp_OP_dup /* copy old esp */
1120 + CFA_exp_OP_consts(CS-OLDESP) /* offset to CS address */
1121 + CFA_exp_OP_plus /* should be CS address */
1122 + CFA_exp_OP_deref /* get the CS */
1123 + CFA_exp_OP_const4s(VM_MASK|3) /* prepare to mask it */
1124 + CFA_exp_OP_and /* mask it, zero means kernel */
1125 + CFA_exp_OP_bra(eip_user_rtn) /* branch if user */
1126 + CFA_exp_OP_const4s(EIP-OLDESP) /* offset to return address */
1127 + CFA_exp_OP_plus /* add that in */
1128 + CFA_exp_OP_skip(eip_end) /* done if kernel, skip out */
1130 + CFA_exp_OP_addr(end_of_stack_stop_unwind_function)/*dummy function */
1132 + CFA_expression_end
1133 + CFA_define_offset(_EBX,EBX-OLDESP)
1134 + CFA_define_offset(_ECX,ECX-OLDESP)
1135 + CFA_define_offset(_EDX,EDX-OLDESP)
1136 + CFA_define_offset(_ESI,ESI-OLDESP)
1137 + CFA_define_offset(_EDI,EDI-OLDESP)
1138 + CFA_define_offset(_EBP,EBP-OLDESP)
1139 + CFA_define_offset(_EAX,EAX-OLDESP)
1140 + CFA_define_offset(_EFLAGS,EFLAGS-OLDESP)
1144 + * This provides an uwind for our dummy end of unwind function.
1145 + * Current convention is to provied an undefined return address.
1147 + CFI_preamble(c2,_PC,1,1)
1148 + CFA_define_reference(_ESP,0) /* Stack pointer */
1149 + CFA_undefine_reg(_EIP)
1152 + FDE_preamble(c2,end_of_stack_stop_unwind_function, \
1153 + end_of_stack_stop_unwind_function+5)
1156 + * This is VERY sloppy. At this point all we want to do is get
1157 + * the frame right for back tracing. It will not be good if
1158 + * you try to single step. We use already defined labels.
1159 + * We want to cover all call outs.
1160 + * We could also recode this as just one FDE, but this works and
1161 + * I want to get it out.
1163 + FDE_preamble(c1,ret_from_fork,ret_from_exception)
1164 + CFA_define_cfa_offset(4) /* one extra word on stack */
1167 + FDE_preamble(c1,ret_from_exception,device_not_available_emulate)
1170 + FDE_preamble(c1,device_not_available_emulate,debug)
1171 + CFA_define_cfa_offset(4) /* one extra word on stack */
1174 + FDE_preamble(c1, debug,spurious_interrupt_bug)
1178 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/i386/kernel/head.S linux-2.6.18-53.1.14.kgdb/arch/i386/kernel/head.S
1179 --- linux-2.6.18-53.1.14/arch/i386/kernel/head.S 2008-03-06 05:54:34.000000000 +0300
1180 +++ linux-2.6.18-53.1.14.kgdb/arch/i386/kernel/head.S 2008-06-10 15:39:01.000000000 +0400
1183 #include <linux/threads.h>
1184 #include <linux/linkage.h>
1185 +#include <asm/kgdb.h>
1186 #include <asm/segment.h>
1187 #include <asm/page.h>
1188 #include <asm/pgtable.h>
1189 @@ -336,6 +337,10 @@ is386: movl $2,%ecx # set MP
1190 #endif /* CONFIG_SMP */
1193 + /* This dwarf code tells gdb that this is the end of the unwind */
1194 + /* This uses the CFA set up for pc=1 located in entry.S */
1195 + CFI_END_FRAME(is386)
1198 * We depend on ET to be correct. This checks for 287/387.
1200 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/i386/kernel/kgdb-jmp.S linux-2.6.18-53.1.14.kgdb/arch/i386/kernel/kgdb-jmp.S
1201 --- linux-2.6.18-53.1.14/arch/i386/kernel/kgdb-jmp.S 1970-01-01 03:00:00.000000000 +0300
1202 +++ linux-2.6.18-53.1.14.kgdb/arch/i386/kernel/kgdb-jmp.S 2008-06-10 15:38:03.000000000 +0400
1205 + * arch/i386/kernel/kgdb-jmp.S
1207 + * Save and restore system registers so that within a limited frame we
1208 + * may have a fault and "jump back" to a known safe location.
1210 + * Author: George Anzinger <george@mvista.com>
1212 + * Cribbed from glibc, which carries the following:
1213 + * Copyright (C) 1996, 1996, 1997, 2000, 2001 Free Software Foundation, Inc.
1214 + * Copyright (C) 2005 by MontaVista Software.
1216 + * This file is licensed under the terms of the GNU General Public License
1217 + * version 2. This program as licensed "as is" without any warranty of
1218 + * any kind, whether express or implied.
1221 +#include <linux/linkage.h>
1224 +#define LINKAGE 4 /* just the return address */
1226 +#define PARMS LINKAGE /* no space for saved regs */
1227 +#define JMPBUF PARMS
1228 +#define VAL JMPBUF+PTR_SIZE
1237 +/* This must be called prior to kgdb_fault_longjmp and
1238 + * kgdb_fault_longjmp must not be called outside of the context of the
1239 + * last call to kgdb_fault_setjmp.
1240 + * kgdb_fault_setjmp(int *jmp_buf[6])
1242 +ENTRY(kgdb_fault_setjmp)
1243 + movl JMPBUF(%esp), %eax
1245 + /* Save registers. */
1246 + movl %ebx, (JB_BX*4)(%eax)
1247 + movl %esi, (JB_SI*4)(%eax)
1248 + movl %edi, (JB_DI*4)(%eax)
1249 + /* Save SP as it will be after we return. */
1250 + leal JMPBUF(%esp), %ecx
1251 + movl %ecx, (JB_SP*4)(%eax)
1252 + movl PCOFF(%esp), %ecx /* Save PC we are returning to now. */
1253 + movl %ecx, (JB_PC*4)(%eax)
1254 + movl %ebp, (JB_BP*4)(%eax) /* Save caller's frame pointer. */
1256 + /* Restore state so we can now try the access. */
1257 + movl JMPBUF(%esp), %ecx /* User's jmp_buf in %ecx. */
1258 + /* Save the return address now. */
1259 + movl (JB_PC*4)(%ecx), %edx
1260 + /* Restore registers. */
1262 + movl (JB_SP*4)(%ecx), %esp
1263 + jmp *%edx /* Jump to saved PC. */
1265 +/* kgdb_fault_longjmp(int *jmp_buf[6]) */
1266 +ENTRY(kgdb_fault_longjmp)
1267 + movl JMPBUF(%esp), %ecx /* User's jmp_buf in %ecx. */
1268 + /* Save the return address now. */
1269 + movl (JB_PC*4)(%ecx), %edx
1270 + /* Restore registers. */
1271 + movl (JB_BX*4)(%ecx), %ebx
1272 + movl (JB_SI*4)(%ecx), %esi
1273 + movl (JB_DI*4)(%ecx), %edi
1274 + movl (JB_BP*4)(%ecx), %ebp
1276 + movl (JB_SP*4)(%ecx), %esp
1277 + jmp *%edx /* Jump to saved PC. */
1278 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/i386/kernel/kgdb.c linux-2.6.18-53.1.14.kgdb/arch/i386/kernel/kgdb.c
1279 --- linux-2.6.18-53.1.14/arch/i386/kernel/kgdb.c 1970-01-01 03:00:00.000000000 +0300
1280 +++ linux-2.6.18-53.1.14.kgdb/arch/i386/kernel/kgdb.c 2008-06-10 15:39:27.000000000 +0400
1284 + * This program is free software; you can redistribute it and/or modify it
1285 + * under the terms of the GNU General Public License as published by the
1286 + * Free Software Foundation; either version 2, or (at your option) any
1289 + * This program is distributed in the hope that it will be useful, but
1290 + * WITHOUT ANY WARRANTY; without even the implied warranty of
1291 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1292 + * General Public License for more details.
1297 + * Copyright (C) 2000-2001 VERITAS Software Corporation.
1300 + * Contributor: Lake Stevens Instrument Division$
1301 + * Written by: Glenn Engel $
1302 + * Updated by: Amit Kale<akale@veritas.com>
1303 + * Updated by: Tom Rini <trini@kernel.crashing.org>
1304 + * Modified for 386 by Jim Kingdon, Cygnus Support.
1305 + * Origianl kgdb, compatibility with 2.1.xx kernel by
1306 + * David Grothe <dave@gcom.com>
1307 + * Additional support from Tigran Aivazian <tigran@sco.com>
1310 +#include <linux/string.h>
1311 +#include <linux/kernel.h>
1312 +#include <linux/sched.h>
1313 +#include <linux/smp.h>
1314 +#include <linux/spinlock.h>
1315 +#include <linux/delay.h>
1316 +#include <asm/vm86.h>
1317 +#include <asm/system.h>
1318 +#include <asm/ptrace.h> /* for linux pt_regs struct */
1319 +#include <linux/kgdb.h>
1320 +#include <linux/init.h>
1321 +#include <asm/apicdef.h>
1322 +#include <asm/desc.h>
1323 +#include <asm/kdebug.h>
1325 +#include "mach_ipi.h"
1327 +/* Put the error code here just in case the user cares. */
1328 +int gdb_i386errcode;
1329 +/* Likewise, the vector number here (since GDB only gets the signal
1330 + number through the usual means, and that's not very specific). */
1331 +int gdb_i386vector = -1;
1333 +extern atomic_t cpu_doing_single_step;
1335 +void regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs)
1337 + gdb_regs[_EAX] = regs->eax;
1338 + gdb_regs[_EBX] = regs->ebx;
1339 + gdb_regs[_ECX] = regs->ecx;
1340 + gdb_regs[_EDX] = regs->edx;
1341 + gdb_regs[_ESI] = regs->esi;
1342 + gdb_regs[_EDI] = regs->edi;
1343 + gdb_regs[_EBP] = regs->ebp;
1344 + gdb_regs[_DS] = regs->xds;
1345 + gdb_regs[_ES] = regs->xes;
1346 + gdb_regs[_PS] = regs->eflags;
1347 + gdb_regs[_CS] = regs->xcs;
1348 + gdb_regs[_PC] = regs->eip;
1349 + gdb_regs[_ESP] = (int)(®s->esp);
1350 + gdb_regs[_SS] = __KERNEL_DS;
1351 + gdb_regs[_FS] = 0xFFFF;
1352 + gdb_regs[_GS] = 0xFFFF;
1356 + * Extracts ebp, esp and eip values understandable by gdb from the values
1357 + * saved by switch_to.
1358 + * thread.esp points to ebp. flags and ebp are pushed in switch_to hence esp
1359 + * prior to entering switch_to is 8 greater then the value that is saved.
1360 + * If switch_to changes, change following code appropriately.
1362 +void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p)
1364 + gdb_regs[_EAX] = 0;
1365 + gdb_regs[_EBX] = 0;
1366 + gdb_regs[_ECX] = 0;
1367 + gdb_regs[_EDX] = 0;
1368 + gdb_regs[_ESI] = 0;
1369 + gdb_regs[_EDI] = 0;
1370 + gdb_regs[_EBP] = *(unsigned long *)p->thread.esp;
1371 + gdb_regs[_DS] = __KERNEL_DS;
1372 + gdb_regs[_ES] = __KERNEL_DS;
1373 + gdb_regs[_PS] = 0;
1374 + gdb_regs[_CS] = __KERNEL_CS;
1375 + gdb_regs[_PC] = p->thread.eip;
1376 + gdb_regs[_ESP] = p->thread.esp;
1377 + gdb_regs[_SS] = __KERNEL_DS;
1378 + gdb_regs[_FS] = 0xFFFF;
1379 + gdb_regs[_GS] = 0xFFFF;
1382 +void gdb_regs_to_regs(unsigned long *gdb_regs, struct pt_regs *regs)
1384 + regs->eax = gdb_regs[_EAX];
1385 + regs->ebx = gdb_regs[_EBX];
1386 + regs->ecx = gdb_regs[_ECX];
1387 + regs->edx = gdb_regs[_EDX];
1388 + regs->esi = gdb_regs[_ESI];
1389 + regs->edi = gdb_regs[_EDI];
1390 + regs->ebp = gdb_regs[_EBP];
1391 + regs->xds = gdb_regs[_DS];
1392 + regs->xes = gdb_regs[_ES];
1393 + regs->eflags = gdb_regs[_PS];
1394 + regs->xcs = gdb_regs[_CS];
1395 + regs->eip = gdb_regs[_PC];
1398 +static struct hw_breakpoint {
1410 +void kgdb_correct_hw_break(void)
1417 + asm volatile ("movl %%db7, %0\n":"=r" (dr7)
1420 + unsigned addr0, addr1, addr2, addr3;
1421 + asm volatile ("movl %%db0, %0\n"
1422 + "movl %%db1, %1\n"
1423 + "movl %%db2, %2\n"
1424 + "movl %%db3, %3\n":"=r" (addr0), "=r"(addr1),
1425 + "=r"(addr2), "=r"(addr3):);
1428 + for (breakno = 0; breakno < 3; breakno++) {
1429 + breakbit = 2 << (breakno << 1);
1430 + if (!(dr7 & breakbit) && breakinfo[breakno].enabled) {
1433 + dr7 &= ~(0xf0000 << (breakno << 2));
1434 + dr7 |= (((breakinfo[breakno].len << 2) |
1435 + breakinfo[breakno].type) << 16) <<
1437 + switch (breakno) {
1439 + asm volatile ("movl %0, %%dr0\n"::"r"
1440 + (breakinfo[breakno].addr));
1444 + asm volatile ("movl %0, %%dr1\n"::"r"
1445 + (breakinfo[breakno].addr));
1449 + asm volatile ("movl %0, %%dr2\n"::"r"
1450 + (breakinfo[breakno].addr));
1454 + asm volatile ("movl %0, %%dr3\n"::"r"
1455 + (breakinfo[breakno].addr));
1458 + } else if ((dr7 & breakbit) && !breakinfo[breakno].enabled) {
1461 + dr7 &= ~(0xf0000 << (breakno << 2));
1465 + asm volatile ("movl %0, %%db7\n"::"r" (dr7));
1468 +int kgdb_remove_hw_break(unsigned long addr)
1471 + for (i = 0; i < 4; i++) {
1472 + if (breakinfo[i].addr == addr && breakinfo[i].enabled) {
1480 + breakinfo[idx].enabled = 0;
1484 +void kgdb_remove_all_hw_break(void)
1488 + for (i = 0; i < 4; i++) {
1489 + if (breakinfo[i].enabled) {
1493 + memset(&breakinfo[i], 0, sizeof(struct hw_breakpoint));
1497 +int kgdb_set_hw_break(unsigned long addr)
1500 + for (i = 0; i < 4; i++) {
1501 + if (!breakinfo[i].enabled) {
1509 + breakinfo[idx].enabled = 1;
1510 + breakinfo[idx].type = 1;
1511 + breakinfo[idx].len = 1;
1512 + breakinfo[idx].addr = addr;
1516 +void kgdb_disable_hw_debug(struct pt_regs *regs)
1518 + /* Disable hardware debugging while we are in kgdb */
1519 + asm volatile ("movl %0,%%db7": /* no output */ :"r" (0));
1522 +void kgdb_post_master_code(struct pt_regs *regs, int e_vector, int err_code)
1524 + /* Master processor is completely in the debugger */
1525 + gdb_i386vector = e_vector;
1526 + gdb_i386errcode = err_code;
1529 +void kgdb_roundup_cpus(unsigned long flags)
1531 + send_IPI_allbutself(APIC_DM_NMI);
1534 +int kgdb_arch_handle_exception(int e_vector, int signo,
1535 + int err_code, char *remcom_in_buffer,
1536 + char *remcom_out_buffer,
1537 + struct pt_regs *linux_regs)
1543 + switch (remcom_in_buffer[0]) {
1546 + /* try to read optional parameter, pc unchanged if no parm */
1547 + ptr = &remcom_in_buffer[1];
1548 + if (kgdb_hex2long(&ptr, &addr))
1549 + linux_regs->eip = addr;
1550 + newPC = linux_regs->eip;
1552 + /* clear the trace bit */
1553 + linux_regs->eflags &= ~TF_MASK;
1554 + atomic_set(&cpu_doing_single_step, -1);
1556 + /* set the trace bit if we're stepping */
1557 + if (remcom_in_buffer[0] == 's') {
1558 + linux_regs->eflags |= TF_MASK;
1559 + debugger_step = 1;
1560 + atomic_set(&cpu_doing_single_step,smp_processor_id());
1563 + asm volatile ("movl %%db6, %0\n":"=r" (dr6));
1564 + if (!(dr6 & 0x4000)) {
1566 + for (breakno = 0; breakno < 4; ++breakno) {
1567 + if (dr6 & (1 << breakno) &&
1568 + breakinfo[breakno].type == 0) {
1569 + /* Set restore flag */
1570 + linux_regs->eflags |= X86_EFLAGS_RF;
1575 + kgdb_correct_hw_break();
1576 + asm volatile ("movl %0, %%db6\n"::"r" (0));
1580 + /* this means that we do not want to exit from the handler */
1584 +/* Register KGDB with the i386die_chain so that we hook into all of the right
1586 +static int kgdb_notify(struct notifier_block *self, unsigned long cmd,
1589 + struct die_args *args = ptr;
1590 + struct pt_regs *regs = args->regs;
1592 + /* Bad memory access? */
1593 + if (cmd == DIE_PAGE_FAULT_NO_CONTEXT && atomic_read(&debugger_active)
1594 + && kgdb_may_fault) {
1595 + kgdb_fault_longjmp(kgdb_fault_jmp_regs);
1596 + return NOTIFY_STOP;
1597 + } else if (cmd == DIE_PAGE_FAULT)
1598 + /* A normal page fault, ignore. */
1599 + return NOTIFY_DONE;
1600 + else if ((cmd == DIE_NMI || cmd == DIE_NMI_IPI ||
1601 + cmd == DIE_NMIWATCHDOG) && atomic_read(&debugger_active)) {
1603 + kgdb_nmihook(smp_processor_id(), regs);
1604 + return NOTIFY_STOP;
1605 + } else if (cmd == DIE_NMI_IPI || cmd == DIE_NMI || user_mode(regs) ||
1606 + (cmd == DIE_DEBUG && atomic_read(&debugger_active)))
1607 + /* Normal watchdog event or userspace debugging, or spurious
1608 + * debug exception, ignore. */
1609 + return NOTIFY_DONE;
1611 + kgdb_handle_exception(args->trapnr, args->signr, args->err, regs);
1613 + return NOTIFY_STOP;
1616 +static struct notifier_block kgdb_notifier = {
1617 + .notifier_call = kgdb_notify,
1620 +int kgdb_arch_init(void)
1622 + atomic_notifier_chain_register(&i386die_chain, &kgdb_notifier);
1627 + * Skip an int3 exception when it occurs after a breakpoint has been
1628 + * removed. Backtrack eip by 1 since the int3 would have caused it to
1632 +int kgdb_skipexception(int exception, struct pt_regs *regs)
1634 + if (exception == 3 && kgdb_isremovedbreak(regs->eip - 1)) {
1641 +struct kgdb_arch arch_kgdb_ops = {
1642 + .gdb_bpt_instr = {0xcc},
1643 + .flags = KGDB_HW_BREAKPOINT,
1645 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/i386/kernel/setup.c linux-2.6.18-53.1.14.kgdb/arch/i386/kernel/setup.c
1646 --- linux-2.6.18-53.1.14/arch/i386/kernel/setup.c 2008-03-06 05:54:58.000000000 +0300
1647 +++ linux-2.6.18-53.1.14.kgdb/arch/i386/kernel/setup.c 2008-06-10 15:38:03.000000000 +0400
1648 @@ -148,6 +148,7 @@ EXPORT_SYMBOL(ist_info);
1649 struct e820map e820;
1651 extern void early_cpu_init(void);
1652 +extern void early_trap_init(void);
1653 extern void generic_apic_probe(char *);
1654 extern int root_mountflags;
1656 @@ -1470,6 +1471,7 @@ void __init setup_arch(char **cmdline_p)
1657 memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data));
1658 pre_setup_arch_hook();
1660 + early_trap_init();
1663 * FIXME: This isn't an official loader_type right
1664 @@ -1526,6 +1528,7 @@ void __init setup_arch(char **cmdline_p)
1665 data_resource.end = virt_to_phys(_edata)-1;
1667 parse_cmdline_early(cmdline_p);
1668 + parse_early_param();
1670 #ifdef CONFIG_EARLY_PRINTK
1672 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/i386/kernel/smpboot.c linux-2.6.18-53.1.14.kgdb/arch/i386/kernel/smpboot.c
1673 --- linux-2.6.18-53.1.14/arch/i386/kernel/smpboot.c 2008-03-06 05:54:34.000000000 +0300
1674 +++ linux-2.6.18-53.1.14.kgdb/arch/i386/kernel/smpboot.c 2008-06-10 15:39:01.000000000 +0400
1675 @@ -592,6 +592,9 @@ void __devinit initialize_secondary(void
1680 + "pushl end_of_stack_stop_unwind_function\n\t"
1684 :"r" (current->thread.esp),"r" (current->thread.eip));
1685 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/i386/kernel/traps.c linux-2.6.18-53.1.14.kgdb/arch/i386/kernel/traps.c
1686 --- linux-2.6.18-53.1.14/arch/i386/kernel/traps.c 2008-03-06 05:55:00.000000000 +0300
1687 +++ linux-2.6.18-53.1.14.kgdb/arch/i386/kernel/traps.c 2008-06-10 15:38:03.000000000 +0400
1688 @@ -964,6 +964,7 @@ fastcall void __kprobes do_debug(struct
1692 + notify_die(DIE_DEBUG, "debug2", regs, condition, error_code, SIGTRAP);
1696 @@ -1268,6 +1269,12 @@ static void __init set_task_gate(unsigne
1697 _set_gate(idt_table+n,5,0,0,(gdt_entry<<3));
1700 +/* Some traps need to be set early. */
1701 +void __init early_trap_init(void) {
1702 + set_intr_gate(1,&debug);
1703 + set_system_intr_gate(3, &int3); /* int3 can be called from all */
1704 + set_intr_gate(14,&page_fault);
1707 void __init trap_init(void)
1709 @@ -1284,10 +1291,8 @@ void __init trap_init(void)
1712 set_trap_gate(0,÷_error);
1713 - set_intr_gate(1,&debug);
1714 set_intr_gate(2,&nmi);
1715 - set_system_intr_gate(3, &int3); /* int3/4 can be called from all */
1716 - set_system_gate(4,&overflow);
1717 + set_system_gate(4,&overflow); /* int4/5 can be called from all */
1718 set_trap_gate(5,&bounds);
1719 set_trap_gate(6,&invalid_op);
1720 set_trap_gate(7,&device_not_available);
1721 @@ -1297,7 +1302,6 @@ void __init trap_init(void)
1722 set_trap_gate(11,&segment_not_present);
1723 set_trap_gate(12,&stack_segment);
1724 set_trap_gate(13,&general_protection);
1725 - set_intr_gate(14,&page_fault);
1726 set_trap_gate(15,&spurious_interrupt_bug);
1727 set_trap_gate(16,&coprocessor_error);
1728 set_trap_gate(17,&alignment_check);
1729 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/i386/mm/fault.c linux-2.6.18-53.1.14.kgdb/arch/i386/mm/fault.c
1730 --- linux-2.6.18-53.1.14/arch/i386/mm/fault.c 2006-09-20 07:42:06.000000000 +0400
1731 +++ linux-2.6.18-53.1.14.kgdb/arch/i386/mm/fault.c 2008-06-10 15:38:03.000000000 +0400
1732 @@ -539,6 +539,10 @@ no_context:
1733 if (is_prefetch(regs, address, error_code))
1736 + if (notify_die(DIE_PAGE_FAULT_NO_CONTEXT, "no context", regs,
1737 + error_code, 14, SIGSEGV) == NOTIFY_STOP)
1741 * Oops. The kernel tried to access some bad page. We'll have to
1742 * terminate things with extreme prejudice.
1743 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ia64/kernel/Makefile linux-2.6.18-53.1.14.kgdb/arch/ia64/kernel/Makefile
1744 --- linux-2.6.18-53.1.14/arch/ia64/kernel/Makefile 2008-03-06 05:54:11.000000000 +0300
1745 +++ linux-2.6.18-53.1.14.kgdb/arch/ia64/kernel/Makefile 2008-06-10 15:38:32.000000000 +0400
1746 @@ -32,6 +32,7 @@ obj-$(CONFIG_KEXEC) += machine_kexec.o
1747 obj-$(CONFIG_IA64_UNCACHED_ALLOCATOR) += uncached.o
1748 obj-$(CONFIG_AUDIT) += audit.o
1749 mca_recovery-y += mca_drv.o mca_drv_asm.o
1750 +obj-$(CONFIG_KGDB) += kgdb.o kgdb-jmp.o
1752 # The gate DSO image is built using a special linker script.
1753 targets += gate.so gate-syms.o
1754 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ia64/kernel/entry.S linux-2.6.18-53.1.14.kgdb/arch/ia64/kernel/entry.S
1755 --- linux-2.6.18-53.1.14/arch/ia64/kernel/entry.S 2008-03-06 05:54:43.000000000 +0300
1756 +++ linux-2.6.18-53.1.14.kgdb/arch/ia64/kernel/entry.S 2008-06-10 15:39:39.000000000 +0400
1757 @@ -959,9 +959,9 @@ GLOBAL_ENTRY(__ia64_leave_kernel)
1758 shr.u r18=r19,16 // get byte size of existing "dirty" partition
1760 mov r16=ar.bsp // get existing backing store pointer
1761 - addl r17=THIS_CPU(ia64_phys_stacked_size_p8),r0
1762 +(pUStk) addl r17=THIS_CPU(ia64_phys_stacked_size_p8),r0
1764 - ld4 r17=[r17] // r17 = cpu_data->phys_stacked_size_p8
1765 +(pUStk) ld4 r17=[r17] // r17 = cpu_data->phys_stacked_size_p8
1766 (pKStk) br.cond.dpnt skip_rbs_switch
1769 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ia64/kernel/ivt.S linux-2.6.18-53.1.14.kgdb/arch/ia64/kernel/ivt.S
1770 --- linux-2.6.18-53.1.14/arch/ia64/kernel/ivt.S 2006-09-20 07:42:06.000000000 +0400
1771 +++ linux-2.6.18-53.1.14.kgdb/arch/ia64/kernel/ivt.S 2008-06-10 15:39:39.000000000 +0400
1773 #include <asm/unistd.h>
1774 #include <asm/errno.h>
1777 +#define KGDB_ENABLE_PSR_DB mov r31=psr;; movl r30=IA64_PSR_DB;; \
1778 + or r31=r31,r30;; \
1779 + mov psr.l=r31;; srlz.i;;
1781 +#define KGDB_ENABLE_PSR_DB
1785 # define PSR_DEFAULT_BITS psr.ac
1787 @@ -519,6 +527,7 @@ ENTRY(page_fault)
1788 movl r14=ia64_leave_kernel
1791 + KGDB_ENABLE_PSR_DB
1794 adds out2=16,r12 // out2 = pointer to pt_regs
1795 @@ -863,6 +872,7 @@ ENTRY(interrupt)
1796 srlz.i // ensure everybody knows psr.ic is back on
1799 + KGDB_ENABLE_PSR_DB
1801 MCA_RECOVER_RANGE(interrupt)
1802 alloc r14=ar.pfs,0,0,2,0 // must be first in an insn group
1803 @@ -1110,6 +1120,7 @@ ENTRY(non_syscall)
1804 movl r15=ia64_leave_kernel
1807 + KGDB_ENABLE_PSR_DB
1810 br.call.sptk.many b6=ia64_bad_break // avoid WAW on CFM and ignore return addr
1811 @@ -1143,6 +1154,7 @@ ENTRY(dispatch_unaligned_handler)
1812 adds r3=8,r2 // set up second base pointer
1815 + KGDB_ENABLE_PSR_DB
1816 movl r14=ia64_leave_kernel
1819 @@ -1185,6 +1197,10 @@ ENTRY(dispatch_to_fault_handler)
1820 adds r3=8,r2 // set up second base pointer for SAVE_REST
1823 + cmp.eq p6,p0=29,out0
1824 +(p6) br.cond.spnt 1f;; // debug_vector
1825 + KGDB_ENABLE_PSR_DB
1827 movl r14=ia64_leave_kernel
1830 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ia64/kernel/kgdb-jmp.S linux-2.6.18-53.1.14.kgdb/arch/ia64/kernel/kgdb-jmp.S
1831 --- linux-2.6.18-53.1.14/arch/ia64/kernel/kgdb-jmp.S 1970-01-01 03:00:00.000000000 +0300
1832 +++ linux-2.6.18-53.1.14.kgdb/arch/ia64/kernel/kgdb-jmp.S 2008-06-10 15:38:32.000000000 +0400
1834 +/* setjmp() and longjmp() assembler support for kdb on ia64.
1836 + This code was copied from glibc CVS as of 2001-06-27 and modified where
1837 + necessary to fit the kernel.
1838 + Keith Owens <kaos@melbourne.sgi.com> 2001-06-27
1841 +/* Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
1842 + Contributed by David Mosberger-Tang <davidm@hpl.hp.com>.
1844 + The GNU C Library is free software; you can redistribute it and/or
1845 + modify it under the terms of the GNU Library General Public License as
1846 + published by the Free Software Foundation; either version 2 of the
1847 + License, or (at your option) any later version.
1849 + The GNU C Library is distributed in the hope that it will be useful,
1850 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1851 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1852 + Library General Public License for more details.
1854 + You should have received a copy of the GNU Library General Public
1855 + License along with the GNU C Library; see the file COPYING.LIB. If
1856 + not, write to the Free Software Foundation, Inc.,
1857 + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1860 +#include <asm/asmmacro.h>
1861 +GLOBAL_ENTRY(kgdb_fault_setjmp)
1862 + .prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(2)
1863 + alloc loc1=ar.pfs,2,2,2,0
1871 + st8.spill.nta [r2]=sp,16 // r12 (sp)
1873 + st8.spill.nta [r3]=gp,16 // r1 (gp)
1875 + st8.nta [r2]=r16,16 // save caller's unat
1876 + st8.nta [r3]=r17,16 // save fpsr
1880 + st8.spill.nta [r2]=r4,16 // r4
1882 + st8.spill.nta [r3]=r5,16 // r5
1885 + stf.spill.nta [r8]=f2,32
1886 + stf.spill.nta [r9]=f3,32
1890 + stf.spill.nta [r8]=f4,32
1891 + stf.spill.nta [r9]=f5,32
1894 + stf.spill.nta [r8]=f16,32
1895 + stf.spill.nta [r9]=f17,32
1898 + stf.spill.nta [r8]=f18,32
1899 + stf.spill.nta [r9]=f19,32
1902 + stf.spill.nta [r8]=f20,32
1903 + stf.spill.nta [r9]=f21,32
1906 + stf.spill.nta [r8]=f22,32
1907 + stf.spill.nta [r9]=f23,32
1910 + stf.spill.nta [r8]=f24,32
1911 + stf.spill.nta [r9]=f25,32
1914 + stf.spill.nta [r8]=f26,32
1915 + stf.spill.nta [r9]=f27,32
1918 + stf.spill.nta [r8]=f28,32
1919 + stf.spill.nta [r9]=f29,32
1921 + stf.spill.nta [r8]=f30
1922 + stf.spill.nta [r9]=f31
1925 + st8.spill.nta [r2]=r6,16 // r6
1927 + st8.spill.nta [r3]=r7,16 // r7
1931 + st8.nta [r2]=loc0,16 // b0
1932 + st8.nta [r3]=r17,16 // b1
1934 + st8.nta [r2]=r18,16 // b2
1935 + st8.nta [r3]=r19,16 // b3
1937 + st8.nta [r2]=r20,16 // b4
1938 + st8.nta [r3]=r21,16 // b5
1940 + st8.nta [r2]=loc1,16 // ar.pfs
1941 + st8.nta [r3]=r22,16 // ar.lc
1943 + st8.nta [r2]=r24,16 // pr
1944 + st8.nta [r3]=r23,16 // ar.bsp
1946 + st8.nta [r2]=r25 // ar.unat
1947 + st8.nta [r3]=in0 // &__jmp_buf
1951 + br.ret.sptk.few rp
1953 +#define pPos p6 /* is rotate count positive? */
1954 +#define pNeg p7 /* is rotate count negative? */
1955 +GLOBAL_ENTRY(kgdb_fault_longjmp)
1956 + alloc r8=ar.pfs,2,1,0,0
1958 + add r2=0x98,in0 // r2 <- &jmpbuf.orig_jmp_buf_addr
1960 + ld8 r8=[r2],-16 // r8 <- orig_jmp_buf_addr
1962 + and r11=~0x3,r27 // clear ar.rsc.mode
1964 + flushrs // flush dirty regs to backing store (must be first in insn grp)
1965 + ld8 r23=[r2],8 // r23 <- jmpbuf.ar_bsp
1966 + sub r8=r8,in0 // r8 <- &orig_jmpbuf - &jmpbuf
1968 + ld8 r25=[r2] // r25 <- jmpbuf.ar_unat
1969 + extr.u r8=r8,3,6 // r8 <- (&orig_jmpbuf - &jmpbuf)/8 & 0x3f
1971 + cmp.lt pNeg,pPos=r8,r0
1975 +(pNeg) add r16=64,r8
1976 +(pPos) sub r17=64,r8
1977 +(pNeg) sub r17=r0,r8
1979 + mov ar.rsc=r11 // put RSE in enforced lazy mode
1981 + add r3=8,in0 // r3 <- &jmpbuf.r1
1987 + mov ar.unat=r25 // setup ar.unat (NaT bits for r1, r4-r7, and r12)
1989 + ld8.fill.nta sp=[r2],16 // r12 (sp)
1990 + ld8.fill.nta gp=[r3],16 // r1 (gp)
1991 + dep r11=-1,r23,3,6 // r11 <- ia64_rse_rnat_addr(jmpbuf.ar_bsp)
1993 + ld8.nta r16=[r2],16 // caller's unat
1994 + ld8.nta r17=[r3],16 // fpsr
1996 + ld8.fill.nta r4=[r2],16 // r4
1997 + ld8.fill.nta r5=[r3],16 // r5 (gp)
1998 + cmp.geu p8,p0=r10,r11 // p8 <- (ar.bsp >= jmpbuf.ar_bsp)
2000 + ld8.fill.nta r6=[r2],16 // r6
2001 + ld8.fill.nta r7=[r3],16 // r7
2003 + mov ar.unat=r16 // restore caller's unat
2004 + mov ar.fpsr=r17 // restore fpsr
2006 + ld8.nta r16=[r2],16 // b0
2007 + ld8.nta r17=[r3],16 // b1
2009 +(p8) ld8 r26=[r11] // r26 <- *ia64_rse_rnat_addr(jmpbuf.ar_bsp)
2010 + mov ar.bspstore=r23 // restore ar.bspstore
2012 + ld8.nta r18=[r2],16 // b2
2013 + ld8.nta r19=[r3],16 // b3
2015 + ld8.nta r20=[r2],16 // b4
2016 + ld8.nta r21=[r3],16 // b5
2018 + ld8.nta r11=[r2],16 // ar.pfs
2019 + ld8.nta r22=[r3],56 // ar.lc
2021 + ld8.nta r24=[r2],32 // pr
2024 + ldf.fill.nta f2=[r2],32
2025 + ldf.fill.nta f3=[r3],32
2028 + ldf.fill.nta f4=[r2],32
2029 + ldf.fill.nta f5=[r3],32
2032 + ldf.fill.nta f16=[r2],32
2033 + ldf.fill.nta f17=[r3],32
2036 + ldf.fill.nta f18=[r2],32
2037 + ldf.fill.nta f19=[r3],32
2040 + ldf.fill.nta f20=[r2],32
2041 + ldf.fill.nta f21=[r3],32
2044 + ldf.fill.nta f22=[r2],32
2045 + ldf.fill.nta f23=[r3],32
2048 + ldf.fill.nta f24=[r2],32
2049 + ldf.fill.nta f25=[r3],32
2050 + cmp.eq p8,p9=0,in1
2052 + ldf.fill.nta f26=[r2],32
2053 + ldf.fill.nta f27=[r3],32
2056 + ldf.fill.nta f28=[r2],32
2057 + ldf.fill.nta f29=[r3],32
2059 + ldf.fill.nta f30=[r2]
2060 + ldf.fill.nta f31=[r3]
2063 + mov ar.rnat=r26 // restore ar.rnat
2065 + mov ar.rsc=r27 // restore ar.rsc
2068 + invala // virt. -> phys. regnum mapping may change
2070 + br.ret.sptk.few rp
2071 +END(kgdb_fault_longjmp)
2072 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ia64/kernel/kgdb.c linux-2.6.18-53.1.14.kgdb/arch/ia64/kernel/kgdb.c
2073 --- linux-2.6.18-53.1.14/arch/ia64/kernel/kgdb.c 1970-01-01 03:00:00.000000000 +0300
2074 +++ linux-2.6.18-53.1.14.kgdb/arch/ia64/kernel/kgdb.c 2008-06-10 15:38:32.000000000 +0400
2078 + * This program is free software; you can redistribute it and/or modify it
2079 + * under the terms of the GNU General Public License as published by the
2080 + * Free Software Foundation; either version 2, or (at your option) any
2083 + * This program is distributed in the hope that it will be useful, but
2084 + * WITHOUT ANY WARRANTY; without even the implied warranty of
2085 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2086 + * General Public License for more details.
2091 + * Copyright (C) 2000-2001 VERITAS Software Corporation.
2092 + * (c) Copyright 2005 Hewlett-Packard Development Company, L.P.
2093 + * Bob Picco <bob.picco@hp.com>
2096 + * Contributor: Lake Stevens Instrument Division$
2097 + * Written by: Glenn Engel $
2098 + * Updated by: Amit Kale<akale@veritas.com>
2099 + * Modified for 386 by Jim Kingdon, Cygnus Support.
2100 + * Origianl kgdb, compatibility with 2.1.xx kernel by David Grothe <dave@gcom.com>
2103 +#include <linux/string.h>
2104 +#include <linux/kernel.h>
2105 +#include <linux/sched.h>
2106 +#include <linux/smp.h>
2107 +#include <linux/spinlock.h>
2108 +#include <linux/delay.h>
2109 +#include <asm/system.h>
2110 +#include <asm/ptrace.h> /* for linux pt_regs struct */
2111 +#include <asm/unwind.h>
2112 +#include <asm/rse.h>
2113 +#include <linux/kgdb.h>
2114 +#include <linux/init.h>
2115 +#include <asm/cacheflush.h>
2116 +#include <asm/kdebug.h>
2118 +#define NUM_REGS 590
2119 +#define REGISTER_BYTES (NUM_REGS*8+128*8)
2120 +#define REGISTER_BYTE(N) (((N) * 8) \
2121 + + ((N) <= IA64_FR0_REGNUM ? \
2122 + 0 : 8 * (((N) > IA64_FR127_REGNUM) ? 128 : (N) - IA64_FR0_REGNUM)))
2123 +#define REGISTER_SIZE(N) \
2124 + (((N) >= IA64_FR0_REGNUM && (N) <= IA64_FR127_REGNUM) ? 16 : 8)
2125 +#define IA64_GR0_REGNUM 0
2126 +#define IA64_FR0_REGNUM 128
2127 +#define IA64_FR127_REGNUM (IA64_FR0_REGNUM+127)
2128 +#define IA64_PR0_REGNUM 256
2129 +#define IA64_BR0_REGNUM 320
2130 +#define IA64_VFP_REGNUM 328
2131 +#define IA64_PR_REGNUM 330
2132 +#define IA64_IP_REGNUM 331
2133 +#define IA64_PSR_REGNUM 332
2134 +#define IA64_CFM_REGNUM 333
2135 +#define IA64_AR0_REGNUM 334
2136 +#define IA64_NAT0_REGNUM 462
2137 +#define IA64_NAT31_REGNUM (IA64_NAT0_REGNUM+31)
2138 +#define IA64_NAT32_REGNUM (IA64_NAT0_REGNUM+32)
2139 +#define IA64_RSC_REGNUM (IA64_AR0_REGNUM+16)
2140 +#define IA64_BSP_REGNUM (IA64_AR0_REGNUM+17)
2141 +#define IA64_BSPSTORE_REGNUM (IA64_AR0_REGNUM+18)
2142 +#define IA64_RNAT_REGNUM (IA64_AR0_REGNUM+19)
2143 +#define IA64_FCR_REGNUM (IA64_AR0_REGNUM+21)
2144 +#define IA64_EFLAG_REGNUM (IA64_AR0_REGNUM+24)
2145 +#define IA64_CSD_REGNUM (IA64_AR0_REGNUM+25)
2146 +#define IA64_SSD_REGNUM (IA64_AR0_REGNUM+26)
2147 +#define IA64_CFLG_REGNUM (IA64_AR0_REGNUM+27)
2148 +#define IA64_FSR_REGNUM (IA64_AR0_REGNUM+28)
2149 +#define IA64_FIR_REGNUM (IA64_AR0_REGNUM+29)
2150 +#define IA64_FDR_REGNUM (IA64_AR0_REGNUM+30)
2151 +#define IA64_CCV_REGNUM (IA64_AR0_REGNUM+32)
2152 +#define IA64_UNAT_REGNUM (IA64_AR0_REGNUM+36)
2153 +#define IA64_FPSR_REGNUM (IA64_AR0_REGNUM+40)
2154 +#define IA64_ITC_REGNUM (IA64_AR0_REGNUM+44)
2155 +#define IA64_PFS_REGNUM (IA64_AR0_REGNUM+64)
2156 +#define IA64_LC_REGNUM (IA64_AR0_REGNUM+65)
2157 +#define IA64_EC_REGNUM (IA64_AR0_REGNUM+66)
2159 +#define REGISTER_INDEX(N) (REGISTER_BYTE(N) / sizeof (unsigned long))
2160 +#define BREAK_INSTR_ALIGN (~0xfULL)
2162 +#define ptoff(V) ((unsigned int) &((struct pt_regs *)0x0)->V)
2163 +struct reg_to_ptreg_index {
2165 + unsigned int ptregoff;
2168 +static struct reg_to_ptreg_index gr_reg_to_ptreg_index[] = {
2169 + {IA64_GR0_REGNUM + 1, ptoff(r1)},
2170 + {IA64_GR0_REGNUM + 2, ptoff(r2)},
2171 + {IA64_GR0_REGNUM + 3, ptoff(r3)},
2172 + {IA64_GR0_REGNUM + 8, ptoff(r8)},
2173 + {IA64_GR0_REGNUM + 9, ptoff(r9)},
2174 + {IA64_GR0_REGNUM + 10, ptoff(r10)},
2175 + {IA64_GR0_REGNUM + 11, ptoff(r11)},
2176 + {IA64_GR0_REGNUM + 12, ptoff(r12)},
2177 + {IA64_GR0_REGNUM + 13, ptoff(r13)},
2178 + {IA64_GR0_REGNUM + 14, ptoff(r14)},
2179 + {IA64_GR0_REGNUM + 15, ptoff(r15)},
2180 + {IA64_GR0_REGNUM + 16, ptoff(r16)},
2181 + {IA64_GR0_REGNUM + 17, ptoff(r17)},
2182 + {IA64_GR0_REGNUM + 18, ptoff(r18)},
2183 + {IA64_GR0_REGNUM + 19, ptoff(r19)},
2184 + {IA64_GR0_REGNUM + 20, ptoff(r20)},
2185 + {IA64_GR0_REGNUM + 21, ptoff(r21)},
2186 + {IA64_GR0_REGNUM + 22, ptoff(r22)},
2187 + {IA64_GR0_REGNUM + 23, ptoff(r23)},
2188 + {IA64_GR0_REGNUM + 24, ptoff(r24)},
2189 + {IA64_GR0_REGNUM + 25, ptoff(r25)},
2190 + {IA64_GR0_REGNUM + 26, ptoff(r26)},
2191 + {IA64_GR0_REGNUM + 27, ptoff(r27)},
2192 + {IA64_GR0_REGNUM + 28, ptoff(r28)},
2193 + {IA64_GR0_REGNUM + 29, ptoff(r29)},
2194 + {IA64_GR0_REGNUM + 30, ptoff(r30)},
2195 + {IA64_GR0_REGNUM + 31, ptoff(r31)},
2198 +static struct reg_to_ptreg_index br_reg_to_ptreg_index[] = {
2199 + {IA64_BR0_REGNUM, ptoff(b0)},
2200 + {IA64_BR0_REGNUM + 6, ptoff(b6)},
2201 + {IA64_BR0_REGNUM + 7, ptoff(b7)},
2204 +static struct reg_to_ptreg_index ar_reg_to_ptreg_index[] = {
2205 + {IA64_PFS_REGNUM, ptoff(ar_pfs)},
2206 + {IA64_UNAT_REGNUM, ptoff(ar_unat)},
2207 + {IA64_RNAT_REGNUM, ptoff(ar_rnat)},
2208 + {IA64_BSPSTORE_REGNUM, ptoff(ar_bspstore)},
2209 + {IA64_RSC_REGNUM, ptoff(ar_rsc)},
2210 + {IA64_CSD_REGNUM, ptoff(ar_csd)},
2211 + {IA64_SSD_REGNUM, ptoff(ar_ssd)},
2212 + {IA64_FPSR_REGNUM, ptoff(ar_fpsr)},
2213 + {IA64_CCV_REGNUM, ptoff(ar_ccv)},
2216 +extern atomic_t cpu_doing_single_step;
2218 +static int kgdb_gr_reg(int regnum, struct unw_frame_info *info,
2219 + unsigned long *reg, int rw)
2223 + if ((regnum >= IA64_GR0_REGNUM && regnum <= (IA64_GR0_REGNUM + 1)) ||
2224 + (regnum >= (IA64_GR0_REGNUM + 4) &&
2225 + regnum <= (IA64_GR0_REGNUM + 7)))
2226 + return !unw_access_gr(info, regnum - IA64_GR0_REGNUM,
2231 +static int kgdb_gr_ptreg(int regnum, struct pt_regs * ptregs,
2232 + struct unw_frame_info *info, unsigned long *reg, int rw)
2234 + int i, result = 1;
2237 + if (!((regnum >= (IA64_GR0_REGNUM + 2) &&
2238 + regnum <= (IA64_GR0_REGNUM + 3)) ||
2239 + (regnum >= (IA64_GR0_REGNUM + 8) &&
2240 + regnum <= (IA64_GR0_REGNUM + 15)) ||
2241 + (regnum >= (IA64_GR0_REGNUM + 16) &&
2242 + regnum <= (IA64_GR0_REGNUM + 31))))
2244 + else if (rw && ptregs) {
2245 + for (i = 0; i < ARRAY_SIZE(gr_reg_to_ptreg_index); i++)
2246 + if (gr_reg_to_ptreg_index[i].reg == regnum) {
2247 + *((unsigned long *)(((void *)ptregs) +
2248 + gr_reg_to_ptreg_index[i].ptregoff)) = *reg;
2251 + } else if (!rw && ptregs) {
2252 + for (i = 0; i < ARRAY_SIZE(gr_reg_to_ptreg_index); i++)
2253 + if (gr_reg_to_ptreg_index[i].reg == regnum) {
2254 + *reg = *((unsigned long *)
2255 + (((void *)ptregs) +
2256 + gr_reg_to_ptreg_index[i].ptregoff));
2260 + result = !unw_access_gr(info, regnum - IA64_GR0_REGNUM,
2265 +static int kgdb_br_reg(int regnum, struct pt_regs * ptregs,
2266 + struct unw_frame_info *info, unsigned long *reg, int rw)
2268 + int i, result = 1;
2270 + if (!(regnum >= IA64_BR0_REGNUM && regnum <= (IA64_BR0_REGNUM + 7)))
2274 + case IA64_BR0_REGNUM:
2275 + case IA64_BR0_REGNUM + 6:
2276 + case IA64_BR0_REGNUM + 7:
2278 + for (i = 0; i < ARRAY_SIZE(br_reg_to_ptreg_index); i++)
2279 + if (br_reg_to_ptreg_index[i].reg == regnum) {
2280 + *((unsigned long *)
2281 + (((void *)ptregs) +
2282 + br_reg_to_ptreg_index[i].ptregoff)) =
2287 + for (i = 0; i < ARRAY_SIZE(br_reg_to_ptreg_index); i++)
2288 + if (br_reg_to_ptreg_index[i].reg == regnum) {
2289 + *reg = *((unsigned long *)
2290 + (((void *)ptregs) +
2291 + br_reg_to_ptreg_index[i].
2296 + case IA64_BR0_REGNUM + 1:
2297 + case IA64_BR0_REGNUM + 2:
2298 + case IA64_BR0_REGNUM + 3:
2299 + case IA64_BR0_REGNUM + 4:
2300 + case IA64_BR0_REGNUM + 5:
2301 + result = !unw_access_br(info, regnum - IA64_BR0_REGNUM,
2309 +static int kgdb_fr_reg(int regnum, char *inbuffer, struct pt_regs * ptregs,
2310 + struct unw_frame_info *info, unsigned long *reg,
2311 + struct ia64_fpreg *freg, int rw)
2315 + if (!(regnum >= IA64_FR0_REGNUM && regnum <= (IA64_FR0_REGNUM + 127)))
2319 + case IA64_FR0_REGNUM + 6:
2320 + case IA64_FR0_REGNUM + 7:
2321 + case IA64_FR0_REGNUM + 8:
2322 + case IA64_FR0_REGNUM + 9:
2323 + case IA64_FR0_REGNUM + 10:
2324 + case IA64_FR0_REGNUM + 11:
2325 + case IA64_FR0_REGNUM + 12:
2327 + char *ptr = inbuffer;
2329 + freg->u.bits[0] = *reg;
2330 + kgdb_hex2long(&ptr, &freg->u.bits[1]);
2331 + *(&ptregs->f6 + (regnum - (IA64_FR0_REGNUM + 6))) =
2334 + } else if (!ptregs)
2335 + result = !unw_access_fr(info, regnum - IA64_FR0_REGNUM,
2339 + *(&ptregs->f6 + (regnum - (IA64_FR0_REGNUM + 6)));
2343 + result = !unw_access_fr(info, regnum - IA64_FR0_REGNUM,
2353 +static int kgdb_ar_reg(int regnum, struct pt_regs * ptregs,
2354 + struct unw_frame_info *info, unsigned long *reg, int rw)
2356 + int result = 0, i;
2358 + if (!(regnum >= IA64_AR0_REGNUM && regnum <= IA64_EC_REGNUM))
2361 + if (rw && ptregs) {
2362 + for (i = 0; i < ARRAY_SIZE(ar_reg_to_ptreg_index); i++)
2363 + if (ar_reg_to_ptreg_index[i].reg == regnum) {
2364 + *((unsigned long *) (((void *)ptregs) +
2365 + ar_reg_to_ptreg_index[i].ptregoff)) =
2370 + } else if (ptregs) {
2371 + for (i = 0; i < ARRAY_SIZE(ar_reg_to_ptreg_index); i++)
2372 + if (ar_reg_to_ptreg_index[i].reg == regnum) {
2373 + *reg = *((unsigned long *) (((void *)ptregs) +
2374 + ar_reg_to_ptreg_index[i].ptregoff));
2386 + case IA64_CSD_REGNUM:
2387 + result = !unw_access_ar(info, UNW_AR_CSD, reg, rw);
2389 + case IA64_SSD_REGNUM:
2390 + result = !unw_access_ar(info, UNW_AR_SSD, reg, rw);
2392 + case IA64_UNAT_REGNUM:
2393 + result = !unw_access_ar(info, UNW_AR_RNAT, reg, rw);
2395 + case IA64_RNAT_REGNUM:
2396 + result = !unw_access_ar(info, UNW_AR_RNAT, reg, rw);
2398 + case IA64_BSPSTORE_REGNUM:
2399 + result = !unw_access_ar(info, UNW_AR_RNAT, reg, rw);
2401 + case IA64_PFS_REGNUM:
2402 + result = !unw_access_ar(info, UNW_AR_RNAT, reg, rw);
2404 + case IA64_LC_REGNUM:
2405 + result = !unw_access_ar(info, UNW_AR_LC, reg, rw);
2407 + case IA64_EC_REGNUM:
2408 + result = !unw_access_ar(info, UNW_AR_EC, reg, rw);
2410 + case IA64_FPSR_REGNUM:
2411 + result = !unw_access_ar(info, UNW_AR_FPSR, reg, rw);
2413 + case IA64_RSC_REGNUM:
2414 + result = !unw_access_ar(info, UNW_AR_RSC, reg, rw);
2416 + case IA64_CCV_REGNUM:
2417 + result = !unw_access_ar(info, UNW_AR_CCV, reg, rw);
2426 +void kgdb_get_reg(char *outbuffer, int regnum, struct unw_frame_info *info,
2427 + struct pt_regs *ptregs)
2429 + unsigned long reg, size = 0, *mem = ®
2430 + struct ia64_fpreg freg;
2432 + if (kgdb_gr_reg(regnum, info, ®, 0) ||
2433 + kgdb_gr_ptreg(regnum, ptregs, info, ®, 0) ||
2434 + kgdb_br_reg(regnum, ptregs, info, ®, 0) ||
2435 + kgdb_ar_reg(regnum, ptregs, info, ®, 0))
2436 + size = sizeof(reg);
2437 + else if (kgdb_fr_reg(regnum, NULL, ptregs, info, ®, &freg, 0)) {
2438 + size = sizeof(freg);
2439 + mem = (unsigned long *)&freg;
2440 + } else if (regnum == IA64_IP_REGNUM) {
2442 + unw_get_ip(info, ®);
2443 + size = sizeof(reg);
2445 + reg = ptregs->cr_iip;
2446 + size = sizeof(reg);
2448 + } else if (regnum == IA64_CFM_REGNUM) {
2450 + unw_get_cfm(info, ®);
2452 + reg = ptregs->cr_ifs;
2453 + size = sizeof(reg);
2454 + } else if (regnum == IA64_PSR_REGNUM) {
2455 + if (!ptregs && kgdb_usethread)
2456 + ptregs = (struct pt_regs *)
2457 + ((unsigned long)kgdb_usethread +
2458 + IA64_STK_OFFSET) - 1;
2460 + reg = ptregs->cr_ipsr;
2461 + size = sizeof(reg);
2462 + } else if (regnum == IA64_PR_REGNUM) {
2466 + unw_access_pr(info, ®, 0);
2467 + size = sizeof(reg);
2468 + } else if (regnum == IA64_BSP_REGNUM) {
2469 + unw_get_bsp(info, ®);
2470 + size = sizeof(reg);
2474 + kgdb_mem2hex((char *) mem, outbuffer, size);
2475 + outbuffer[size*2] = 0;
2478 + strcpy(outbuffer, "E0");
2483 +void kgdb_put_reg(char *inbuffer, char *outbuffer, int regnum,
2484 + struct unw_frame_info *info, struct pt_regs *ptregs)
2486 + unsigned long reg;
2487 + struct ia64_fpreg freg;
2488 + char *ptr = inbuffer;
2490 + kgdb_hex2long(&ptr, ®);
2491 + strcpy(outbuffer, "OK");
2493 + if (kgdb_gr_reg(regnum, info, ®, 1) ||
2494 + kgdb_gr_ptreg(regnum, ptregs, info, ®, 1) ||
2495 + kgdb_br_reg(regnum, ptregs, info, ®, 1) ||
2496 + kgdb_fr_reg(regnum, inbuffer, ptregs, info, ®, &freg, 1) ||
2497 + kgdb_ar_reg(regnum, ptregs, info, ®, 1)) ;
2498 + else if (regnum == IA64_IP_REGNUM)
2499 + ptregs->cr_iip = reg;
2500 + else if (regnum == IA64_CFM_REGNUM)
2501 + ptregs->cr_ifs = reg;
2502 + else if (regnum == IA64_PSR_REGNUM)
2503 + ptregs->cr_ipsr = reg;
2504 + else if (regnum == IA64_PR_REGNUM)
2507 + strcpy(outbuffer, "E01");
2511 +void regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs)
2515 +void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p)
2519 +void gdb_regs_to_regs(unsigned long *gdb_regs, struct pt_regs *regs)
2524 +#define MAX_HW_BREAKPOINT (20)
2525 +long hw_break_total_dbr, hw_break_total_ibr;
2526 +#define HW_BREAKPOINT (hw_break_total_dbr + hw_break_total_ibr)
2527 +#define WATCH_INSTRUCTION 0x0
2528 +#define WATCH_WRITE 0x1
2529 +#define WATCH_READ 0x2
2530 +#define WATCH_ACCESS 0x3
2532 +#define HWCAP_DBR ((1 << WATCH_WRITE) | (1 << WATCH_READ))
2533 +#define HWCAP_IBR (1 << WATCH_INSTRUCTION)
2534 +struct hw_breakpoint {
2536 + unsigned long capable;
2537 + unsigned long type;
2538 + unsigned long mask;
2539 + unsigned long addr;
2542 +static struct hw_breakpoint hwbreaks[MAX_HW_BREAKPOINT];
2544 +enum instruction_type { A, I, M, F, B, L, X, u };
2546 +static enum instruction_type bundle_encoding[32][3] = {
2547 + {M, I, I}, /* 00 */
2548 + {M, I, I}, /* 01 */
2549 + {M, I, I}, /* 02 */
2550 + {M, I, I}, /* 03 */
2551 + {M, L, X}, /* 04 */
2552 + {M, L, X}, /* 05 */
2553 + {u, u, u}, /* 06 */
2554 + {u, u, u}, /* 07 */
2555 + {M, M, I}, /* 08 */
2556 + {M, M, I}, /* 09 */
2557 + {M, M, I}, /* 0A */
2558 + {M, M, I}, /* 0B */
2559 + {M, F, I}, /* 0C */
2560 + {M, F, I}, /* 0D */
2561 + {M, M, F}, /* 0E */
2562 + {M, M, F}, /* 0F */
2563 + {M, I, B}, /* 10 */
2564 + {M, I, B}, /* 11 */
2565 + {M, B, B}, /* 12 */
2566 + {M, B, B}, /* 13 */
2567 + {u, u, u}, /* 14 */
2568 + {u, u, u}, /* 15 */
2569 + {B, B, B}, /* 16 */
2570 + {B, B, B}, /* 17 */
2571 + {M, M, B}, /* 18 */
2572 + {M, M, B}, /* 19 */
2573 + {u, u, u}, /* 1A */
2574 + {u, u, u}, /* 1B */
2575 + {M, F, B}, /* 1C */
2576 + {M, F, B}, /* 1D */
2577 + {u, u, u}, /* 1E */
2578 + {u, u, u}, /* 1F */
2581 +int kgdb_validate_break_address(unsigned long addr)
2584 + char tmp_variable[BREAK_INSTR_SIZE];
2585 + error = kgdb_get_mem((char *)(addr & BREAK_INSTR_ALIGN), tmp_variable,
2586 + BREAK_INSTR_SIZE);
2590 +int kgdb_arch_set_breakpoint(unsigned long addr, char *saved_instr)
2592 + extern unsigned long _start[];
2593 + unsigned long slot = addr & BREAK_INSTR_ALIGN, bundle_addr;
2594 + unsigned long template;
2597 + unsigned long long template:5;
2598 + unsigned long long slot0:41;
2599 + unsigned long long slot1_p0:64 - 46;
2602 + unsigned long long slot1_p1:41 - (64 - 46);
2603 + unsigned long long slot2:41;
2608 + bundle_addr = addr & ~0xFULL;
2610 + if (bundle_addr == (unsigned long)_start)
2613 + ret = kgdb_get_mem((char *)bundle_addr, (char *)&bundle,
2614 + BREAK_INSTR_SIZE);
2621 + memcpy(saved_instr, &bundle, BREAK_INSTR_SIZE);
2622 + template = bundle.quad0.template;
2624 + if (slot == 1 && bundle_encoding[template][1] == L)
2629 + bundle.quad0.slot0 = BREAKNUM;
2632 + bundle.quad0.slot1_p0 = BREAKNUM;
2633 + bundle.quad1.slot1_p1 = (BREAKNUM >> (64 - 46));
2636 + bundle.quad1.slot2 = BREAKNUM;
2640 + return kgdb_set_mem((char *)bundle_addr, (char *)&bundle,
2641 + BREAK_INSTR_SIZE);
2644 +int kgdb_arch_remove_breakpoint(unsigned long addr, char *bundle)
2646 + extern unsigned long _start[];
2648 + addr = addr & BREAK_INSTR_ALIGN;
2649 + if (addr == (unsigned long)_start)
2651 + return kgdb_set_mem((char *)addr, (char *)bundle, BREAK_INSTR_SIZE);
2654 +static int hw_breakpoint_init;
2656 +void do_init_hw_break(void)
2661 + hw_breakpoint_init = 1;
2663 +#ifdef CONFIG_IA64_HP_SIM
2664 + hw_break_total_ibr = 8;
2665 + hw_break_total_dbr = 8;
2668 + status = ia64_pal_debug_info(&hw_break_total_ibr, &hw_break_total_dbr);
2672 + printk(KERN_INFO "do_init_hw_break: pal call failed %d\n",
2677 + if (HW_BREAKPOINT > MAX_HW_BREAKPOINT) {
2678 + printk(KERN_INFO "do_init_hw_break: %d exceeds max %d\n",
2679 + (int)HW_BREAKPOINT, (int)MAX_HW_BREAKPOINT);
2681 + while ((HW_BREAKPOINT > MAX_HW_BREAKPOINT)
2682 + && hw_break_total_ibr != 1)
2683 + hw_break_total_ibr--;
2684 + while (HW_BREAKPOINT > MAX_HW_BREAKPOINT)
2685 + hw_break_total_dbr--;
2688 + breakinfo = hwbreaks;
2690 + memset(breakinfo, 0, HW_BREAKPOINT * sizeof(struct hw_breakpoint));
2692 + for (i = 0; i < hw_break_total_dbr; i++)
2693 + breakinfo[i].capable = HWCAP_DBR;
2695 + for (; i < HW_BREAKPOINT; i++)
2696 + breakinfo[i].capable = HWCAP_IBR;
2701 +void kgdb_correct_hw_break(void)
2708 + for (breakno = 0; breakno < HW_BREAKPOINT; breakno++) {
2709 + if (breakinfo[breakno].enabled) {
2710 + if (breakinfo[breakno].capable & HWCAP_IBR) {
2711 + int ibreakno = breakno - hw_break_total_dbr;
2712 + ia64_set_ibr(ibreakno << 1,
2713 + breakinfo[breakno].addr);
2714 + ia64_set_ibr((ibreakno << 1) + 1,
2715 + (~breakinfo[breakno].mask &
2716 + ((1UL << 56UL) - 1)) |
2717 + (1UL << 56UL) | (1UL << 63UL));
2719 + ia64_set_dbr(breakno << 1,
2720 + breakinfo[breakno].addr);
2721 + ia64_set_dbr((breakno << 1) + 1,
2722 + (~breakinfo[breakno].
2723 + mask & ((1UL << 56UL) - 1)) |
2725 + (breakinfo[breakno].type << 62UL));
2728 + if (breakinfo[breakno].capable & HWCAP_IBR)
2729 + ia64_set_ibr(((breakno -
2730 + hw_break_total_dbr) << 1) + 1,
2733 + ia64_set_dbr((breakno << 1) + 1, 0);
2740 +int hardware_breakpoint(unsigned long addr, int length, int type, int action)
2742 + int breakno, found, watch;
2743 + unsigned long mask;
2744 + extern unsigned long _start[];
2746 + if (!hw_breakpoint_init)
2747 + do_init_hw_break();
2751 + else if (addr == (unsigned long)_start)
2754 + if (type == WATCH_ACCESS)
2757 + mask = 1UL << type;
2759 + for (watch = 0, found = 0, breakno = 0; breakno < HW_BREAKPOINT;
2762 + if (breakinfo[breakno].enabled
2763 + || !(breakinfo[breakno].capable & mask))
2765 + breakinfo[breakno].enabled = 1;
2766 + breakinfo[breakno].type = type;
2767 + breakinfo[breakno].mask = length - 1;
2768 + breakinfo[breakno].addr = addr;
2770 + } else if (breakinfo[breakno].enabled &&
2771 + ((length < 0 && breakinfo[breakno].addr == addr) ||
2772 + ((breakinfo[breakno].capable & mask) &&
2773 + (breakinfo[breakno].mask == (length - 1)) &&
2774 + (breakinfo[breakno].addr == addr)))) {
2775 + breakinfo[breakno].enabled = 0;
2776 + breakinfo[breakno].type = 0UL;
2780 + if (type != WATCH_ACCESS)
2782 + else if (found == 2)
2788 + if (type == WATCH_ACCESS && found == 1) {
2789 + breakinfo[watch].enabled = 0;
2797 +int kgdb_arch_set_hw_breakpoint(unsigned long addr, int len,
2798 + enum kgdb_bptype type)
2800 + return hardware_breakpoint(addr, len, type - '1', 1);
2803 +int kgdb_arch_remove_hw_breakpoint(unsigned long addr, int len,
2804 + enum kgdb_bptype type)
2806 + return hardware_breakpoint(addr, len, type - '1', 0);
2809 +int kgdb_remove_hw_break(unsigned long addr)
2811 + return hardware_breakpoint(addr, 8, WATCH_INSTRUCTION, 0);
2815 +void kgdb_remove_all_hw_break(void)
2819 + for (i = 0; i < HW_BREAKPOINT; i++)
2820 + memset(&breakinfo[i], 0, sizeof(struct hw_breakpoint));
2823 +int kgdb_set_hw_break(unsigned long addr)
2825 + return hardware_breakpoint(addr, 8, WATCH_INSTRUCTION, 1);
2828 +void kgdb_disable_hw_debug(struct pt_regs *regs)
2830 + unsigned long hw_breakpoint_status;
2832 + hw_breakpoint_status = ia64_getreg(_IA64_REG_PSR);
2833 + if (hw_breakpoint_status & IA64_PSR_DB)
2834 + ia64_setreg(_IA64_REG_PSR_L,
2835 + hw_breakpoint_status ^ IA64_PSR_DB);
2838 +volatile static struct smp_unw {
2839 + struct unw_frame_info *unw;
2840 + struct task_struct *task;
2841 +} smp_unw[NR_CPUS];
2843 +static int inline kgdb_get_blocked_state(struct task_struct *p,
2844 + struct unw_frame_info *unw)
2849 + unw_init_from_blocked_task(unw, p);
2852 + if (unw_unwind(unw) < 0)
2854 + unw_get_ip(unw, &ip);
2855 + if (!in_sched_functions(ip))
2857 + } while (count++ < 16);
2865 +static void inline kgdb_wait(struct pt_regs *regs)
2867 + unsigned long hw_breakpoint_status = ia64_getreg(_IA64_REG_PSR);
2868 + if (hw_breakpoint_status & IA64_PSR_DB)
2869 + ia64_setreg(_IA64_REG_PSR_L,
2870 + hw_breakpoint_status ^ IA64_PSR_DB);
2871 + kgdb_nmihook(smp_processor_id(), regs);
2872 + if (hw_breakpoint_status & IA64_PSR_DB)
2873 + ia64_setreg(_IA64_REG_PSR_L, hw_breakpoint_status);
2878 +static void inline normalize(struct unw_frame_info *running,
2879 + struct pt_regs *regs)
2884 + unw_get_sp(running, &sp);
2885 + if ((sp + 0x10) >= (unsigned long)regs)
2887 + } while (unw_unwind(running) >= 0);
2892 +static void kgdb_init_running(struct unw_frame_info *unw, void *data)
2894 + struct pt_regs *regs;
2897 + normalize(unw, regs);
2898 + smp_unw[smp_processor_id()].unw = unw;
2902 +void kgdb_wait_ipi(struct pt_regs *regs)
2904 + struct unw_frame_info unw;
2906 + smp_unw[smp_processor_id()].task = current;
2908 + if (user_mode(regs)) {
2909 + smp_unw[smp_processor_id()].unw = (struct unw_frame_info *)1;
2912 + if (current->state == TASK_RUNNING)
2913 + unw_init_running(kgdb_init_running, regs);
2915 + if (kgdb_get_blocked_state(current, &unw))
2916 + smp_unw[smp_processor_id()].unw =
2917 + (struct unw_frame_info *)1;
2919 + smp_unw[smp_processor_id()].unw = &unw;
2924 + smp_unw[smp_processor_id()].unw = NULL;
2928 +void kgdb_roundup_cpus(unsigned long flags)
2930 + if (num_online_cpus() > 1)
2931 + smp_send_nmi_allbutself();
2934 +static volatile int kgdb_hwbreak_sstep[NR_CPUS];
2936 +static int kgdb_notify(struct notifier_block *self, unsigned long cmd,
2939 + struct die_args *args = ptr;
2940 + struct pt_regs *regs = args->regs;
2941 + unsigned long err = args->err;
2945 + return NOTIFY_DONE;
2946 + case DIE_PAGE_FAULT_NO_CONTEXT:
2947 + if (atomic_read(&debugger_active) && kgdb_may_fault) {
2948 + kgdb_fault_longjmp(kgdb_fault_jmp_regs);
2949 + return NOTIFY_STOP;
2953 + if (user_mode(regs) || err == 0x80001)
2954 + return NOTIFY_DONE;
2957 + if (user_mode(regs))
2958 + return NOTIFY_DONE;
2959 + else if (err == 36 && kgdb_hwbreak_sstep[smp_processor_id()]) {
2960 + kgdb_hwbreak_sstep[smp_processor_id()] = 0;
2961 + regs->cr_ipsr &= ~IA64_PSR_SS;
2962 + return NOTIFY_STOP;
2964 + case DIE_MCA_MONARCH_PROCESS:
2965 + case DIE_INIT_MONARCH_PROCESS:
2969 + kgdb_handle_exception(args->trapnr, args->signr, args->err, regs);
2970 + return NOTIFY_STOP;
2973 +static struct notifier_block kgdb_notifier = {
2974 + .notifier_call = kgdb_notify,
2977 +int kgdb_arch_init(void)
2979 + atomic_notifier_chain_register(&ia64die_chain, &kgdb_notifier);
2983 +static void do_kgdb_handle_exception(struct unw_frame_info *, void *data);
2985 +struct kgdb_state {
2988 + unsigned long err_code;
2989 + struct pt_regs *regs;
2990 + struct unw_frame_info *unw;
2997 +static void inline kgdb_pc(struct pt_regs *regs, unsigned long pc)
2999 + regs->cr_iip = pc & ~0xf;
3000 + ia64_psr(regs)->ri = pc & 0x3;
3004 +int kgdb_arch_handle_exception(int e_vector, int signo,
3005 + int err_code, char *remcom_in_buffer,
3006 + char *remcom_out_buffer,
3007 + struct pt_regs *linux_regs)
3009 + struct kgdb_state info;
3011 + info.e_vector = e_vector;
3012 + info.signo = signo;
3013 + info.err_code = err_code;
3014 + info.unw = (void *)0;
3015 + info.inbuf = remcom_in_buffer;
3016 + info.outbuf = remcom_out_buffer;
3020 + if (remcom_in_buffer[0] == 'c' || remcom_in_buffer[0] == 's') {
3021 + info.regs = linux_regs;
3022 + do_kgdb_handle_exception(NULL, &info);
3023 + } else if (kgdb_usethread == current) {
3024 + info.regs = linux_regs;
3026 + unw_init_running(do_kgdb_handle_exception, &info);
3027 + } else if (kgdb_usethread->state != TASK_RUNNING) {
3028 + struct unw_frame_info unw_info;
3030 + if (kgdb_get_blocked_state(kgdb_usethread, &unw_info)) {
3035 + do_kgdb_handle_exception(&unw_info, &info);
3039 + for (i = 0; i < NR_CPUS; i++)
3040 + if (smp_unw[i].task == kgdb_usethread && smp_unw[i].unw
3041 + && smp_unw[i].unw != (struct unw_frame_info *)1) {
3043 + do_kgdb_handle_exception(smp_unw[i].unw, &info);
3052 + if (info.ret != -1 && remcom_in_buffer[0] == 'p') {
3053 + unsigned long bad = 0xbad4badbadbadbadUL;
3055 + printk("kgdb_arch_handle_exception: p packet bad (%s)\n",
3056 + remcom_in_buffer);
3057 + kgdb_mem2hex((char *)&bad, remcom_out_buffer, sizeof(bad));
3058 + remcom_out_buffer[sizeof(bad) * 2] = 0;
3065 + * This is done because I evidently made an incorrect 'p' encoding
3066 + * when my patch for gdb was committed. It was later corrected. This
3067 + * check supports both my wrong encoding of the register number and
3068 + * the correct encoding. Eventually this should be eliminated and
3069 + * kgdb_hex2long should be demarshalling the regnum.
3071 +static inline int check_packet(unsigned int regnum, char *packet)
3073 + static int check_done, swap;
3074 + unsigned long reglong;
3076 + if (likely(check_done)) {
3078 + kgdb_hex2long(&packet, ®long);
3079 + regnum = (int) reglong;
3083 + if (regnum > NUM_REGS) {
3084 + kgdb_hex2long(&packet, ®long);
3085 + regnum = (int) reglong;
3093 +static void do_kgdb_handle_exception(struct unw_frame_info *unw_info,
3098 + unsigned long newPC;
3099 + int e_vector, signo;
3100 + unsigned long err_code;
3101 + struct pt_regs *linux_regs;
3102 + struct kgdb_state *info;
3103 + char *remcom_in_buffer, *remcom_out_buffer;
3106 + info->unw = unw_info;
3107 + e_vector = info->e_vector;
3108 + signo = info->signo;
3109 + err_code = info->err_code;
3110 + remcom_in_buffer = info->inbuf;
3111 + remcom_out_buffer = info->outbuf;
3112 + linux_regs = info->regs;
3115 + normalize(unw_info, linux_regs);
3117 + switch (remcom_in_buffer[0]) {
3120 + unsigned int regnum;
3122 + kgdb_hex2mem(&remcom_in_buffer[1], (char *)®num,
3124 + regnum = check_packet(regnum, &remcom_in_buffer[1]);
3125 + if (regnum >= NUM_REGS) {
3126 + remcom_out_buffer[0] = 'E';
3127 + remcom_out_buffer[1] = 0;
3129 + kgdb_get_reg(remcom_out_buffer, regnum,
3130 + unw_info, linux_regs);
3135 + unsigned int regno;
3139 + ptr = &remcom_in_buffer[1];
3140 + if ((!kgdb_usethread || kgdb_usethread == current) &&
3141 + kgdb_hex2long(&ptr, &v) &&
3142 + *ptr++ == '=' && (v >= 0)) {
3143 + regno = (unsigned int)v;
3144 + regno = (regno >= NUM_REGS ? 0 : regno);
3145 + kgdb_put_reg(ptr, remcom_out_buffer, regno,
3146 + unw_info, linux_regs);
3148 + strcpy(remcom_out_buffer, "E01");
3153 + if (e_vector == TRAP_BRKPT && err_code == KGDBBREAKNUM) {
3154 + if (ia64_psr(linux_regs)->ri < 2)
3155 + kgdb_pc(linux_regs, linux_regs->cr_iip +
3156 + ia64_psr(linux_regs)->ri + 1);
3158 + kgdb_pc(linux_regs, linux_regs->cr_iip + 16);
3161 + /* try to read optional parameter, pc unchanged if no parm */
3162 + ptr = &remcom_in_buffer[1];
3163 + if (kgdb_hex2long(&ptr, &addr)) {
3164 + linux_regs->cr_iip = addr;
3166 + newPC = linux_regs->cr_iip;
3168 + /* clear the trace bit */
3169 + linux_regs->cr_ipsr &= ~IA64_PSR_SS;
3171 + atomic_set(&cpu_doing_single_step, -1);
3173 + /* set the trace bit if we're stepping or took a hardware break */
3174 + if (remcom_in_buffer[0] == 's' || e_vector == TRAP_HWBKPT) {
3175 + linux_regs->cr_ipsr |= IA64_PSR_SS;
3176 + debugger_step = 1;
3177 + if (kgdb_contthread)
3178 + atomic_set(&cpu_doing_single_step,
3179 + smp_processor_id());
3182 + kgdb_correct_hw_break();
3184 + /* if not hardware breakpoint, then reenable them */
3185 + if (e_vector != TRAP_HWBKPT)
3186 + linux_regs->cr_ipsr |= IA64_PSR_DB;
3188 + kgdb_hwbreak_sstep[smp_processor_id()] = 1;
3189 + linux_regs->cr_ipsr &= ~IA64_PSR_DB;
3201 +struct kgdb_arch arch_kgdb_ops = {
3202 + .set_hw_breakpoint = kgdb_arch_set_hw_breakpoint,
3203 + .remove_hw_breakpoint = kgdb_arch_remove_hw_breakpoint,
3204 + .gdb_bpt_instr = {0xcc},
3205 + .flags = KGDB_HW_BREAKPOINT,
3207 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ia64/kernel/process.c linux-2.6.18-53.1.14.kgdb/arch/ia64/kernel/process.c
3208 --- linux-2.6.18-53.1.14/arch/ia64/kernel/process.c 2008-03-06 05:55:00.000000000 +0300
3209 +++ linux-2.6.18-53.1.14.kgdb/arch/ia64/kernel/process.c 2008-06-10 15:39:39.000000000 +0400
3210 @@ -463,6 +463,9 @@ copy_thread (int nr, unsigned long clone
3212 child_ptregs->cr_ipsr = ((child_ptregs->cr_ipsr | IA64_PSR_BITS_TO_SET)
3213 & ~(IA64_PSR_BITS_TO_CLEAR | IA64_PSR_PP | IA64_PSR_UP));
3215 + child_ptregs->cr_ipsr |= IA64_PSR_DB;
3219 * NOTE: The calling convention considers all floating point
3220 @@ -691,6 +694,9 @@ kernel_thread (int (*fn)(void *), void *
3221 regs.pt.r11 = (unsigned long) arg; /* 2nd argument */
3222 /* Preserve PSR bits, except for bits 32-34 and 37-45, which we can't read. */
3223 regs.pt.cr_ipsr = ia64_getreg(_IA64_REG_PSR) | IA64_PSR_BN;
3225 + regs.pt.cr_ipsr |= IA64_PSR_DB;
3227 regs.pt.cr_ifs = 1UL << 63; /* mark as valid, empty frame */
3228 regs.sw.ar_fpsr = regs.pt.ar_fpsr = ia64_getreg(_IA64_REG_AR_FPSR);
3229 regs.sw.ar_bspstore = (unsigned long) current + IA64_RBS_OFFSET;
3230 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ia64/kernel/smp.c linux-2.6.18-53.1.14.kgdb/arch/ia64/kernel/smp.c
3231 --- linux-2.6.18-53.1.14/arch/ia64/kernel/smp.c 2008-03-06 05:54:27.000000000 +0300
3232 +++ linux-2.6.18-53.1.14.kgdb/arch/ia64/kernel/smp.c 2008-06-10 15:38:32.000000000 +0400
3234 #include <asm/tlbflush.h>
3235 #include <asm/unistd.h>
3236 #include <asm/mca.h>
3237 +#include <linux/kgdb.h>
3240 * Structure and data for smp_call_function(). This is designed to minimise static memory
3241 @@ -68,6 +69,9 @@ static volatile struct call_data_struct
3242 #define IPI_CALL_FUNC 0
3243 #define IPI_CPU_STOP 1
3244 #define IPI_KDUMP_CPU_STOP 3
3246 +#define IPI_KGDB_INTERRUPT 2
3249 /* This needs to be cacheline aligned because it is written to by *other* CPUs. */
3250 static DEFINE_PER_CPU(u64, ipi_operation) ____cacheline_aligned;
3251 @@ -185,6 +189,11 @@ handle_IPI (int irq, void *dev_id, struc
3256 + case IPI_KGDB_INTERRUPT:
3257 + kgdb_wait_ipi(regs);
3260 #ifdef CONFIG_CRASH_DUMP
3261 case IPI_KDUMP_CPU_STOP:
3262 unw_init_running(kdump_cpu_freeze, NULL);
3263 @@ -359,6 +368,14 @@ smp_call_function_single (int cpuid, voi
3265 EXPORT_SYMBOL(smp_call_function_single);
3269 +smp_send_nmi_allbutself(void)
3271 + send_IPI_allbutself(IPI_KGDB_INTERRUPT);
3276 * this function sends a 'generic call function' IPI to all other CPUs
3278 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ia64/kernel/traps.c linux-2.6.18-53.1.14.kgdb/arch/ia64/kernel/traps.c
3279 --- linux-2.6.18-53.1.14/arch/ia64/kernel/traps.c 2008-03-06 05:54:44.000000000 +0300
3280 +++ linux-2.6.18-53.1.14.kgdb/arch/ia64/kernel/traps.c 2008-06-10 15:38:32.000000000 +0400
3281 @@ -200,8 +200,12 @@ __kprobes ia64_bad_break (unsigned long
3285 - if (break_num < 0x40000 || break_num > 0x100000)
3286 + if (break_num < 0x40000 || break_num > 0x100000) {
3287 + if (notify_die(DIE_BREAK, "bad break", regs,
3288 + break_num, TRAP_BRKPT, SIGTRAP) == NOTIFY_STOP)
3290 die_if_kernel("Bad break", regs, break_num);
3293 if (break_num < 0x80000) {
3294 sig = SIGILL; code = __ILL_BREAK;
3295 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ia64/kernel/unwind.c linux-2.6.18-53.1.14.kgdb/arch/ia64/kernel/unwind.c
3296 --- linux-2.6.18-53.1.14/arch/ia64/kernel/unwind.c 2006-09-20 07:42:06.000000000 +0400
3297 +++ linux-2.6.18-53.1.14.kgdb/arch/ia64/kernel/unwind.c 2008-06-10 15:39:39.000000000 +0400
3303 +#define KGDB_EARLY_SIZE 100
3304 +static struct unw_reg_state __initdata kgdb_reg_state[KGDB_EARLY_SIZE];
3305 +static struct unw_labeled_state __initdata kgdb_labeled_state[KGDB_EARLY_SIZE];
3306 +void __initdata *kgdb_reg_state_free, __initdata *kgdb_labeled_state_free;
3309 +kgdb_malloc_init(void)
3313 + kgdb_reg_state_free = kgdb_reg_state;
3314 + for (i = 1; i < KGDB_EARLY_SIZE; i++) {
3315 + *((unsigned long *) &kgdb_reg_state[i]) = (unsigned long) kgdb_reg_state_free;
3316 + kgdb_reg_state_free = &kgdb_reg_state[i];
3319 + kgdb_labeled_state_free = kgdb_labeled_state;
3320 + for (i = 1; i < KGDB_EARLY_SIZE; i++) {
3321 + *((unsigned long *) &kgdb_labeled_state[i]) =
3322 + (unsigned long) kgdb_labeled_state_free;
3323 + kgdb_labeled_state_free = &kgdb_labeled_state[i];
3328 +static void * __init
3329 +kgdb_malloc(void **mem)
3334 + *mem = *((void **) p);
3339 +kgdb_free(void **mem, void *p)
3341 + *((void **)p) = *mem;
3345 +#define alloc_reg_state() (!malloc_sizes[0].cs_cachep ? \
3346 + kgdb_malloc(&kgdb_reg_state_free) : \
3347 + kmalloc(sizeof(struct unw_reg_state), GFP_ATOMIC))
3348 +#define free_reg_state(usr) (!malloc_sizes[0].cs_cachep ? \
3349 + kgdb_free(&kgdb_reg_state_free, usr) : \
3351 +#define alloc_labeled_state() (!malloc_sizes[0].cs_cachep ? \
3352 + kgdb_malloc(&kgdb_labeled_state_free) : \
3353 + kmalloc(sizeof(struct unw_labeled_state), GFP_ATOMIC))
3354 +#define free_labeled_state(usr) (!malloc_sizes[0].cs_cachep ? \
3355 + kgdb_free(&kgdb_labeled_state_free, usr) : \
3359 #define alloc_reg_state() kmalloc(sizeof(struct unw_reg_state), GFP_ATOMIC)
3360 #define free_reg_state(usr) kfree(usr)
3361 #define alloc_labeled_state() kmalloc(sizeof(struct unw_labeled_state), GFP_ATOMIC)
3362 #define free_labeled_state(usr) kfree(usr)
3365 typedef unsigned long unw_word;
3366 typedef unsigned char unw_hash_index_t;
3367 @@ -238,6 +296,24 @@ static struct {
3373 + * This makes it safe to call breakpoint() very early
3374 + * in setup_arch providing:
3375 + * 1) breakpoint isn't called between lines in cpu_init
3376 + * where init_mm.mm_count is incremented and ia64_mmu_init
3377 + * is called. Otherwise the test below is invalid.
3378 + * 2) the memory examined doesn't result in tlbmiss.
3380 +static unsigned long inline kgdb_unimpl_va_mask(void)
3382 + if (atomic_read(&init_mm.mm_count) > 1)
3383 + return local_cpu_data->unimpl_va_mask;
3390 read_only (void *addr)
3392 @@ -1786,7 +1862,11 @@ run_script (struct unw_script *script, s
3397 + if ((s[val] & (kgdb_unimpl_va_mask() | 0x7)) != 0
3399 if ((s[val] & (local_cpu_data->unimpl_va_mask | 0x7)) != 0
3401 || s[val] < TASK_SIZE)
3403 UNW_DPRINT(0, "unwind.%s: rejecting bad psp=0x%lx\n",
3404 @@ -1821,7 +1901,11 @@ find_save_locs (struct unw_frame_info *i
3405 struct unw_script *scr;
3406 unsigned long flags = 0;
3409 + if ((info->ip & (kgdb_unimpl_va_mask() | 0xf)) || info->ip < TASK_SIZE) {
3411 if ((info->ip & (local_cpu_data->unimpl_va_mask | 0xf)) || info->ip < TASK_SIZE) {
3413 /* don't let obviously bad addresses pollute the cache */
3414 /* FIXME: should really be level 0 but it occurs too often. KAO */
3415 UNW_DPRINT(1, "unwind.%s: rejecting bad ip=0x%lx\n", __FUNCTION__, info->ip);
3416 @@ -2249,6 +2333,9 @@ unw_init (void)
3418 init_unwind_table(&unw.kernel_table, "kernel", KERNEL_START, (unsigned long) __gp,
3419 __start_unwind, __end_unwind);
3421 + kgdb_malloc_init();
3426 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ia64/mm/extable.c linux-2.6.18-53.1.14.kgdb/arch/ia64/mm/extable.c
3427 --- linux-2.6.18-53.1.14/arch/ia64/mm/extable.c 2006-09-20 07:42:06.000000000 +0400
3428 +++ linux-2.6.18-53.1.14.kgdb/arch/ia64/mm/extable.c 2008-06-10 15:38:32.000000000 +0400
3432 #include <linux/sort.h>
3433 +#include <linux/kgdb.h>
3435 #include <asm/uaccess.h>
3436 #include <asm/module.h>
3437 @@ -73,6 +74,11 @@ search_extable (const struct exception_t
3442 + if (atomic_read(&debugger_active) && kgdb_may_fault)
3443 + kgdb_fault_longjmp(kgdb_fault_jmp_regs);
3444 + /* Not reached. */
3449 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ia64/mm/fault.c linux-2.6.18-53.1.14.kgdb/arch/ia64/mm/fault.c
3450 --- linux-2.6.18-53.1.14/arch/ia64/mm/fault.c 2006-09-20 07:42:06.000000000 +0400
3451 +++ linux-2.6.18-53.1.14.kgdb/arch/ia64/mm/fault.c 2008-06-10 15:38:32.000000000 +0400
3452 @@ -266,6 +266,10 @@ ia64_do_page_fault (unsigned long addres
3456 + if (notify_die(DIE_PAGE_FAULT_NO_CONTEXT, "no context", regs,
3457 + isr, 14, SIGSEGV) == NOTIFY_STOP)
3460 if (address < PAGE_SIZE)
3461 printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference (address %016lx)\n", address);
3463 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/mips/Kconfig.debug linux-2.6.18-53.1.14.kgdb/arch/mips/Kconfig.debug
3464 --- linux-2.6.18-53.1.14/arch/mips/Kconfig.debug 2006-09-20 07:42:06.000000000 +0400
3465 +++ linux-2.6.18-53.1.14.kgdb/arch/mips/Kconfig.debug 2008-06-10 15:38:24.000000000 +0400
3466 @@ -37,25 +37,6 @@ config DEBUG_STACK_USAGE
3468 This option will slow down process creation somewhat.
3471 - bool "Remote GDB kernel debugging"
3472 - depends on DEBUG_KERNEL
3475 - If you say Y here, it will be possible to remotely debug the MIPS
3476 - kernel using gdb. This enlarges your kernel image disk size by
3477 - several megabytes and requires a machine with more than 16 MB,
3478 - better 32 MB RAM to avoid excessive linking time. This is only
3479 - useful for kernel hackers. If unsure, say N.
3482 - bool "Console output to GDB"
3485 - If you are using GDB for remote debugging over a serial port and
3486 - would like kernel messages to be formatted into GDB $O packets so
3487 - that GDB prints them as program output, say 'Y'.
3489 config SB1XXX_CORELIS
3490 bool "Corelis Debugger"
3491 depends on SIBYTE_SB1xxx_SOC
3492 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/mips/kernel/Makefile linux-2.6.18-53.1.14.kgdb/arch/mips/kernel/Makefile
3493 --- linux-2.6.18-53.1.14/arch/mips/kernel/Makefile 2006-09-20 07:42:06.000000000 +0400
3494 +++ linux-2.6.18-53.1.14.kgdb/arch/mips/kernel/Makefile 2008-06-10 15:38:24.000000000 +0400
3495 @@ -59,7 +59,8 @@ obj-$(CONFIG_MIPS32_COMPAT) += linux32.o
3496 obj-$(CONFIG_MIPS32_N32) += binfmt_elfn32.o scall64-n32.o signal_n32.o
3497 obj-$(CONFIG_MIPS32_O32) += binfmt_elfo32.o scall64-o32.o ptrace32.o
3499 -obj-$(CONFIG_KGDB) += gdb-low.o gdb-stub.o
3500 +obj-$(CONFIG_KGDB) += kgdb_handler.o kgdb.o kgdb-jmp.o \
3502 obj-$(CONFIG_PROC_FS) += proc.o
3504 obj-$(CONFIG_64BIT) += cpu-bugs64.o
3505 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/mips/kernel/gdb-low.S linux-2.6.18-53.1.14.kgdb/arch/mips/kernel/gdb-low.S
3506 --- linux-2.6.18-53.1.14/arch/mips/kernel/gdb-low.S 2006-09-20 07:42:06.000000000 +0400
3507 +++ linux-2.6.18-53.1.14.kgdb/arch/mips/kernel/gdb-low.S 1970-01-01 03:00:00.000000000 +0300
3510 - * gdb-low.S contains the low-level trap handler for the GDB stub.
3512 - * Copyright (C) 1995 Andreas Busse
3514 -#include <linux/sys.h>
3516 -#include <asm/asm.h>
3517 -#include <asm/errno.h>
3518 -#include <asm/irqflags.h>
3519 -#include <asm/mipsregs.h>
3520 -#include <asm/regdef.h>
3521 -#include <asm/stackframe.h>
3522 -#include <asm/gdb-stub.h>
3524 -#ifdef CONFIG_32BIT
3530 -#ifdef CONFIG_64BIT
3531 -#define DMFC0 dmfc0
3532 -#define DMTC0 dmtc0
3538 - * [jsun] We reserves about 2x GDB_FR_SIZE in stack. The lower (addressed)
3539 - * part is used to store registers and passed to exception handler.
3540 - * The upper part is reserved for "call func" feature where gdb client
3541 - * saves some of the regs, setups call frame and passes args.
3543 - * A trace shows about 200 bytes are used to store about half of all regs.
3544 - * The rest should be big enough for frame setup and passing args.
3548 - * The low level trap handler
3551 - NESTED(trap_low, GDB_FR_SIZE, sp)
3555 - mfc0 k0, CP0_STATUS
3556 - sll k0, 3 /* extract cu0 bit */
3561 - * Called from user mode, go somewhere else.
3563 - mfc0 k0, CP0_CAUSE
3565 -#ifdef CONFIG_64BIT
3568 - PTR_L k1, saved_vectors(k0)
3573 - PTR_SUBU sp, k1, GDB_FR_SIZE*2 # see comment above
3574 - LONG_S k0, GDB_FR_REG29(sp)
3575 - LONG_S $2, GDB_FR_REG2(sp)
3578 - * First save the CP0 and special registers
3581 - mfc0 v0, CP0_STATUS
3582 - LONG_S v0, GDB_FR_STATUS(sp)
3583 - mfc0 v0, CP0_CAUSE
3584 - LONG_S v0, GDB_FR_CAUSE(sp)
3586 - LONG_S v0, GDB_FR_EPC(sp)
3587 - DMFC0 v0, CP0_BADVADDR
3588 - LONG_S v0, GDB_FR_BADVADDR(sp)
3590 - LONG_S v0, GDB_FR_HI(sp)
3592 - LONG_S v0, GDB_FR_LO(sp)
3595 - * Now the integer registers
3598 - LONG_S zero, GDB_FR_REG0(sp) /* I know... */
3599 - LONG_S $1, GDB_FR_REG1(sp)
3600 - /* v0 already saved */
3601 - LONG_S $3, GDB_FR_REG3(sp)
3602 - LONG_S $4, GDB_FR_REG4(sp)
3603 - LONG_S $5, GDB_FR_REG5(sp)
3604 - LONG_S $6, GDB_FR_REG6(sp)
3605 - LONG_S $7, GDB_FR_REG7(sp)
3606 - LONG_S $8, GDB_FR_REG8(sp)
3607 - LONG_S $9, GDB_FR_REG9(sp)
3608 - LONG_S $10, GDB_FR_REG10(sp)
3609 - LONG_S $11, GDB_FR_REG11(sp)
3610 - LONG_S $12, GDB_FR_REG12(sp)
3611 - LONG_S $13, GDB_FR_REG13(sp)
3612 - LONG_S $14, GDB_FR_REG14(sp)
3613 - LONG_S $15, GDB_FR_REG15(sp)
3614 - LONG_S $16, GDB_FR_REG16(sp)
3615 - LONG_S $17, GDB_FR_REG17(sp)
3616 - LONG_S $18, GDB_FR_REG18(sp)
3617 - LONG_S $19, GDB_FR_REG19(sp)
3618 - LONG_S $20, GDB_FR_REG20(sp)
3619 - LONG_S $21, GDB_FR_REG21(sp)
3620 - LONG_S $22, GDB_FR_REG22(sp)
3621 - LONG_S $23, GDB_FR_REG23(sp)
3622 - LONG_S $24, GDB_FR_REG24(sp)
3623 - LONG_S $25, GDB_FR_REG25(sp)
3624 - LONG_S $26, GDB_FR_REG26(sp)
3625 - LONG_S $27, GDB_FR_REG27(sp)
3626 - LONG_S $28, GDB_FR_REG28(sp)
3627 - /* sp already saved */
3628 - LONG_S $30, GDB_FR_REG30(sp)
3629 - LONG_S $31, GDB_FR_REG31(sp)
3631 - CLI /* disable interrupts */
3635 - * Followed by the floating point registers
3637 - mfc0 v0, CP0_STATUS /* FPU enabled? */
3639 - andi v0, v0, (ST0_CU1 >> 16)
3641 - beqz v0,2f /* disabled, skip */
3644 - SDC1 $0, GDB_FR_FPR0(sp)
3645 - SDC1 $1, GDB_FR_FPR1(sp)
3646 - SDC1 $2, GDB_FR_FPR2(sp)
3647 - SDC1 $3, GDB_FR_FPR3(sp)
3648 - SDC1 $4, GDB_FR_FPR4(sp)
3649 - SDC1 $5, GDB_FR_FPR5(sp)
3650 - SDC1 $6, GDB_FR_FPR6(sp)
3651 - SDC1 $7, GDB_FR_FPR7(sp)
3652 - SDC1 $8, GDB_FR_FPR8(sp)
3653 - SDC1 $9, GDB_FR_FPR9(sp)
3654 - SDC1 $10, GDB_FR_FPR10(sp)
3655 - SDC1 $11, GDB_FR_FPR11(sp)
3656 - SDC1 $12, GDB_FR_FPR12(sp)
3657 - SDC1 $13, GDB_FR_FPR13(sp)
3658 - SDC1 $14, GDB_FR_FPR14(sp)
3659 - SDC1 $15, GDB_FR_FPR15(sp)
3660 - SDC1 $16, GDB_FR_FPR16(sp)
3661 - SDC1 $17, GDB_FR_FPR17(sp)
3662 - SDC1 $18, GDB_FR_FPR18(sp)
3663 - SDC1 $19, GDB_FR_FPR19(sp)
3664 - SDC1 $20, GDB_FR_FPR20(sp)
3665 - SDC1 $21, GDB_FR_FPR21(sp)
3666 - SDC1 $22, GDB_FR_FPR22(sp)
3667 - SDC1 $23, GDB_FR_FPR23(sp)
3668 - SDC1 $24, GDB_FR_FPR24(sp)
3669 - SDC1 $25, GDB_FR_FPR25(sp)
3670 - SDC1 $26, GDB_FR_FPR26(sp)
3671 - SDC1 $27, GDB_FR_FPR27(sp)
3672 - SDC1 $28, GDB_FR_FPR28(sp)
3673 - SDC1 $29, GDB_FR_FPR29(sp)
3674 - SDC1 $30, GDB_FR_FPR30(sp)
3675 - SDC1 $31, GDB_FR_FPR31(sp)
3678 - * FPU control registers
3681 - cfc1 v0, CP1_STATUS
3682 - LONG_S v0, GDB_FR_FSR(sp)
3683 - cfc1 v0, CP1_REVISION
3684 - LONG_S v0, GDB_FR_FIR(sp)
3687 - * Current stack frame ptr
3691 - LONG_S sp, GDB_FR_FRP(sp)
3694 - * CP0 registers (R4000/R4400 unused registers skipped)
3697 - mfc0 v0, CP0_INDEX
3698 - LONG_S v0, GDB_FR_CP0_INDEX(sp)
3699 - mfc0 v0, CP0_RANDOM
3700 - LONG_S v0, GDB_FR_CP0_RANDOM(sp)
3701 - DMFC0 v0, CP0_ENTRYLO0
3702 - LONG_S v0, GDB_FR_CP0_ENTRYLO0(sp)
3703 - DMFC0 v0, CP0_ENTRYLO1
3704 - LONG_S v0, GDB_FR_CP0_ENTRYLO1(sp)
3705 - DMFC0 v0, CP0_CONTEXT
3706 - LONG_S v0, GDB_FR_CP0_CONTEXT(sp)
3707 - mfc0 v0, CP0_PAGEMASK
3708 - LONG_S v0, GDB_FR_CP0_PAGEMASK(sp)
3709 - mfc0 v0, CP0_WIRED
3710 - LONG_S v0, GDB_FR_CP0_WIRED(sp)
3711 - DMFC0 v0, CP0_ENTRYHI
3712 - LONG_S v0, GDB_FR_CP0_ENTRYHI(sp)
3714 - LONG_S v0, GDB_FR_CP0_PRID(sp)
3719 - * Continue with the higher level handler
3724 - jal handle_exception
3728 - * Restore all writable registers, in reverse order
3733 - LONG_L v0, GDB_FR_CP0_ENTRYHI(sp)
3734 - LONG_L v1, GDB_FR_CP0_WIRED(sp)
3735 - DMTC0 v0, CP0_ENTRYHI
3736 - mtc0 v1, CP0_WIRED
3737 - LONG_L v0, GDB_FR_CP0_PAGEMASK(sp)
3738 - LONG_L v1, GDB_FR_CP0_ENTRYLO1(sp)
3739 - mtc0 v0, CP0_PAGEMASK
3740 - DMTC0 v1, CP0_ENTRYLO1
3741 - LONG_L v0, GDB_FR_CP0_ENTRYLO0(sp)
3742 - LONG_L v1, GDB_FR_CP0_INDEX(sp)
3743 - DMTC0 v0, CP0_ENTRYLO0
3744 - LONG_L v0, GDB_FR_CP0_CONTEXT(sp)
3745 - mtc0 v1, CP0_INDEX
3746 - DMTC0 v0, CP0_CONTEXT
3750 - * Next, the floating point registers
3752 - mfc0 v0, CP0_STATUS /* check if the FPU is enabled */
3754 - andi v0, v0, (ST0_CU1 >> 16)
3756 - beqz v0, 3f /* disabled, skip */
3759 - LDC1 $31, GDB_FR_FPR31(sp)
3760 - LDC1 $30, GDB_FR_FPR30(sp)
3761 - LDC1 $29, GDB_FR_FPR29(sp)
3762 - LDC1 $28, GDB_FR_FPR28(sp)
3763 - LDC1 $27, GDB_FR_FPR27(sp)
3764 - LDC1 $26, GDB_FR_FPR26(sp)
3765 - LDC1 $25, GDB_FR_FPR25(sp)
3766 - LDC1 $24, GDB_FR_FPR24(sp)
3767 - LDC1 $23, GDB_FR_FPR23(sp)
3768 - LDC1 $22, GDB_FR_FPR22(sp)
3769 - LDC1 $21, GDB_FR_FPR21(sp)
3770 - LDC1 $20, GDB_FR_FPR20(sp)
3771 - LDC1 $19, GDB_FR_FPR19(sp)
3772 - LDC1 $18, GDB_FR_FPR18(sp)
3773 - LDC1 $17, GDB_FR_FPR17(sp)
3774 - LDC1 $16, GDB_FR_FPR16(sp)
3775 - LDC1 $15, GDB_FR_FPR15(sp)
3776 - LDC1 $14, GDB_FR_FPR14(sp)
3777 - LDC1 $13, GDB_FR_FPR13(sp)
3778 - LDC1 $12, GDB_FR_FPR12(sp)
3779 - LDC1 $11, GDB_FR_FPR11(sp)
3780 - LDC1 $10, GDB_FR_FPR10(sp)
3781 - LDC1 $9, GDB_FR_FPR9(sp)
3782 - LDC1 $8, GDB_FR_FPR8(sp)
3783 - LDC1 $7, GDB_FR_FPR7(sp)
3784 - LDC1 $6, GDB_FR_FPR6(sp)
3785 - LDC1 $5, GDB_FR_FPR5(sp)
3786 - LDC1 $4, GDB_FR_FPR4(sp)
3787 - LDC1 $3, GDB_FR_FPR3(sp)
3788 - LDC1 $2, GDB_FR_FPR2(sp)
3789 - LDC1 $1, GDB_FR_FPR1(sp)
3790 - LDC1 $0, GDB_FR_FPR0(sp)
3793 - * Now the CP0 and integer registers
3797 -#ifdef CONFIG_MIPS_MT_SMTC
3798 - /* Read-modify write of Status must be atomic */
3799 - mfc0 t2, CP0_TCSTATUS
3800 - ori t1, t2, TCSTATUS_IXMT
3801 - mtc0 t1, CP0_TCSTATUS
3802 - andi t2, t2, TCSTATUS_IXMT
3807 -#endif /* CONFIG_MIPS_MT_SMTC */
3808 - mfc0 t0, CP0_STATUS
3811 - mtc0 t0, CP0_STATUS
3812 -#ifdef CONFIG_MIPS_MT_SMTC
3813 - andi t1, t1, VPECONTROL_TE
3818 - mfc0 t1, CP0_TCSTATUS
3819 - xori t1, t1, TCSTATUS_IXMT
3821 - mtc0 t1, CP0_TCSTATUS
3823 -#endif /* CONFIG_MIPS_MT_SMTC */
3824 - LONG_L v0, GDB_FR_STATUS(sp)
3825 - LONG_L v1, GDB_FR_EPC(sp)
3826 - mtc0 v0, CP0_STATUS
3828 - LONG_L v0, GDB_FR_HI(sp)
3829 - LONG_L v1, GDB_FR_LO(sp)
3832 - LONG_L $31, GDB_FR_REG31(sp)
3833 - LONG_L $30, GDB_FR_REG30(sp)
3834 - LONG_L $28, GDB_FR_REG28(sp)
3835 - LONG_L $27, GDB_FR_REG27(sp)
3836 - LONG_L $26, GDB_FR_REG26(sp)
3837 - LONG_L $25, GDB_FR_REG25(sp)
3838 - LONG_L $24, GDB_FR_REG24(sp)
3839 - LONG_L $23, GDB_FR_REG23(sp)
3840 - LONG_L $22, GDB_FR_REG22(sp)
3841 - LONG_L $21, GDB_FR_REG21(sp)
3842 - LONG_L $20, GDB_FR_REG20(sp)
3843 - LONG_L $19, GDB_FR_REG19(sp)
3844 - LONG_L $18, GDB_FR_REG18(sp)
3845 - LONG_L $17, GDB_FR_REG17(sp)
3846 - LONG_L $16, GDB_FR_REG16(sp)
3847 - LONG_L $15, GDB_FR_REG15(sp)
3848 - LONG_L $14, GDB_FR_REG14(sp)
3849 - LONG_L $13, GDB_FR_REG13(sp)
3850 - LONG_L $12, GDB_FR_REG12(sp)
3851 - LONG_L $11, GDB_FR_REG11(sp)
3852 - LONG_L $10, GDB_FR_REG10(sp)
3853 - LONG_L $9, GDB_FR_REG9(sp)
3854 - LONG_L $8, GDB_FR_REG8(sp)
3855 - LONG_L $7, GDB_FR_REG7(sp)
3856 - LONG_L $6, GDB_FR_REG6(sp)
3857 - LONG_L $5, GDB_FR_REG5(sp)
3858 - LONG_L $4, GDB_FR_REG4(sp)
3859 - LONG_L $3, GDB_FR_REG3(sp)
3860 - LONG_L $2, GDB_FR_REG2(sp)
3861 - LONG_L $1, GDB_FR_REG1(sp)
3862 -#if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
3863 - LONG_L k0, GDB_FR_EPC(sp)
3864 - LONG_L $29, GDB_FR_REG29(sp) /* Deallocate stack */
3868 - LONG_L sp, GDB_FR_REG29(sp) /* Deallocate stack */
3878 -LEAF(kgdb_read_byte)
3883 - .section __ex_table,"a"
3886 - END(kgdb_read_byte)
3888 -LEAF(kgdb_write_byte)
3892 - .section __ex_table,"a"
3895 - END(kgdb_write_byte)
3897 - .type kgdbfault@function
3900 -kgdbfault: li v0, -EFAULT
3903 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/mips/kernel/gdb-stub.c linux-2.6.18-53.1.14.kgdb/arch/mips/kernel/gdb-stub.c
3904 --- linux-2.6.18-53.1.14/arch/mips/kernel/gdb-stub.c 2006-09-20 07:42:06.000000000 +0400
3905 +++ linux-2.6.18-53.1.14.kgdb/arch/mips/kernel/gdb-stub.c 1970-01-01 03:00:00.000000000 +0300
3908 - * arch/mips/kernel/gdb-stub.c
3910 - * Originally written by Glenn Engel, Lake Stevens Instrument Division
3912 - * Contributed by HP Systems
3914 - * Modified for SPARC by Stu Grossman, Cygnus Support.
3916 - * Modified for Linux/MIPS (and MIPS in general) by Andreas Busse
3917 - * Send complaints, suggestions etc. to <andy@waldorf-gmbh.de>
3919 - * Copyright (C) 1995 Andreas Busse
3921 - * Copyright (C) 2003 MontaVista Software Inc.
3922 - * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
3926 - * To enable debugger support, two things need to happen. One, a
3927 - * call to set_debug_traps() is necessary in order to allow any breakpoints
3928 - * or error conditions to be properly intercepted and reported to gdb.
3929 - * Two, a breakpoint needs to be generated to begin communication. This
3930 - * is most easily accomplished by a call to breakpoint(). Breakpoint()
3931 - * simulates a breakpoint by executing a BREAK instruction.
3934 - * The following gdb commands are supported:
3936 - * command function Return value
3938 - * g return the value of the CPU registers hex data or ENN
3939 - * G set the value of the CPU registers OK or ENN
3941 - * mAA..AA,LLLL Read LLLL bytes at address AA..AA hex data or ENN
3942 - * MAA..AA,LLLL: Write LLLL bytes at address AA.AA OK or ENN
3944 - * c Resume at current address SNN ( signal NN)
3945 - * cAA..AA Continue at address AA..AA SNN
3947 - * s Step one instruction SNN
3948 - * sAA..AA Step one instruction from AA..AA SNN
3952 - * ? What was the last sigval ? SNN (signal NN)
3954 - * bBB..BB Set baud rate to BB..BB OK or BNN, then sets
3957 - * All commands and responses are sent with a packet which includes a
3958 - * checksum. A packet consists of
3960 - * $<packet info>#<checksum>.
3963 - * <packet info> :: <characters representing the command or response>
3964 - * <checksum> :: < two hex digits computed as modulo 256 sum of <packetinfo>>
3966 - * When a packet is received, it is first acknowledged with either '+' or '-'.
3967 - * '+' indicates a successful transfer. '-' indicates a failed transfer.
3972 - * $m0,10#2a +$00010203040506070809101112131415#42
3979 - * For reference -- the following are the steps that one
3980 - * company took (RidgeRun Inc) to get remote gdb debugging
3981 - * going. In this scenario the host machine was a PC and the
3982 - * target platform was a Galileo EVB64120A MIPS evaluation
3986 - * First download gdb-5.0.tar.gz from the internet.
3987 - * and then build/install the package.
3990 - * $ tar zxf gdb-5.0.tar.gz
3992 - * $ ./configure --target=mips-linux-elf
3995 - * $ which mips-linux-elf-gdb
3996 - * /usr/local/bin/mips-linux-elf-gdb
3999 - * Configure linux for remote debugging and build it.
4003 - * $ make menuconfig <go to "Kernel Hacking" and turn on remote debugging>
4007 - * Download the kernel to the remote target and start
4008 - * the kernel running. It will promptly halt and wait
4009 - * for the host gdb session to connect. It does this
4010 - * since the "Kernel Hacking" option has defined
4011 - * CONFIG_KGDB which in turn enables your calls
4013 - * set_debug_traps();
4017 - * Start the gdb session on the host.
4020 - * $ mips-linux-elf-gdb vmlinux
4021 - * (gdb) set remotebaud 115200
4022 - * (gdb) target remote /dev/ttyS1
4023 - * ...at this point you are connected to
4024 - * the remote target and can use gdb
4025 - * in the normal fasion. Setting
4026 - * breakpoints, single stepping,
4027 - * printing variables, etc.
4029 -#include <linux/string.h>
4030 -#include <linux/kernel.h>
4031 -#include <linux/signal.h>
4032 -#include <linux/sched.h>
4033 -#include <linux/mm.h>
4034 -#include <linux/console.h>
4035 -#include <linux/init.h>
4036 -#include <linux/smp.h>
4037 -#include <linux/spinlock.h>
4038 -#include <linux/slab.h>
4039 -#include <linux/reboot.h>
4041 -#include <asm/asm.h>
4042 -#include <asm/cacheflush.h>
4043 -#include <asm/mipsregs.h>
4044 -#include <asm/pgtable.h>
4045 -#include <asm/system.h>
4046 -#include <asm/gdb-stub.h>
4047 -#include <asm/inst.h>
4048 -#include <asm/smp.h>
4051 - * external low-level support routines
4054 -extern int putDebugChar(char c); /* write a single character */
4055 -extern char getDebugChar(void); /* read and return a single char */
4056 -extern void trap_low(void);
4059 - * breakpoint and test functions
4061 -extern void breakpoint(void);
4062 -extern void breakinst(void);
4063 -extern void async_breakpoint(void);
4064 -extern void async_breakinst(void);
4065 -extern void adel(void);
4068 - * local prototypes
4071 -static void getpacket(char *buffer);
4072 -static void putpacket(char *buffer);
4073 -static int computeSignal(int tt);
4074 -static int hex(unsigned char ch);
4075 -static int hexToInt(char **ptr, int *intValue);
4076 -static int hexToLong(char **ptr, long *longValue);
4077 -static unsigned char *mem2hex(char *mem, char *buf, int count, int may_fault);
4078 -void handle_exception(struct gdb_regs *regs);
4083 - * spin locks for smp case
4085 -static DEFINE_SPINLOCK(kgdb_lock);
4086 -static raw_spinlock_t kgdb_cpulock[NR_CPUS] = {
4087 - [0 ... NR_CPUS-1] = __RAW_SPIN_LOCK_UNLOCKED,
4091 - * BUFMAX defines the maximum number of characters in inbound/outbound buffers
4092 - * at least NUMREGBYTES*2 are needed for register packets
4094 -#define BUFMAX 2048
4096 -static char input_buffer[BUFMAX];
4097 -static char output_buffer[BUFMAX];
4098 -static int initialized; /* !0 means we've been initialized */
4099 -static int kgdb_started;
4100 -static const char hexchars[]="0123456789abcdef";
4102 -/* Used to prevent crashes in memory access. Note that they'll crash anyway if
4103 - we haven't set up fault handlers yet... */
4104 -int kgdb_read_byte(unsigned char *address, unsigned char *dest);
4105 -int kgdb_write_byte(unsigned char val, unsigned char *dest);
4108 - * Convert ch from a hex digit to an int
4110 -static int hex(unsigned char ch)
4112 - if (ch >= 'a' && ch <= 'f')
4114 - if (ch >= '0' && ch <= '9')
4116 - if (ch >= 'A' && ch <= 'F')
4122 - * scan for the sequence $<data>#<checksum>
4124 -static void getpacket(char *buffer)
4126 - unsigned char checksum;
4127 - unsigned char xmitcsum;
4134 - * wait around for the start character,
4135 - * ignore all other characters
4137 - while ((ch = (getDebugChar() & 0x7f)) != '$') ;
4144 - * now, read until a # or end of buffer is found
4146 - while (count < BUFMAX) {
4147 - ch = getDebugChar();
4150 - checksum = checksum + ch;
4151 - buffer[count] = ch;
4152 - count = count + 1;
4155 - if (count >= BUFMAX)
4158 - buffer[count] = 0;
4161 - xmitcsum = hex(getDebugChar() & 0x7f) << 4;
4162 - xmitcsum |= hex(getDebugChar() & 0x7f);
4164 - if (checksum != xmitcsum)
4165 - putDebugChar('-'); /* failed checksum */
4167 - putDebugChar('+'); /* successful transfer */
4170 - * if a sequence char is present,
4171 - * reply the sequence ID
4173 - if (buffer[2] == ':') {
4174 - putDebugChar(buffer[0]);
4175 - putDebugChar(buffer[1]);
4178 - * remove sequence chars from buffer
4180 - count = strlen(buffer);
4181 - for (i=3; i <= count; i++)
4182 - buffer[i-3] = buffer[i];
4187 - while (checksum != xmitcsum);
4191 - * send the packet in buffer.
4193 -static void putpacket(char *buffer)
4195 - unsigned char checksum;
4200 - * $<packet info>#<checksum>.
4204 - putDebugChar('$');
4208 - while ((ch = buffer[count]) != 0) {
4209 - if (!(putDebugChar(ch)))
4215 - putDebugChar('#');
4216 - putDebugChar(hexchars[checksum >> 4]);
4217 - putDebugChar(hexchars[checksum & 0xf]);
4220 - while ((getDebugChar() & 0x7f) != '+');
4225 - * Convert the memory pointed to by mem into hex, placing result in buf.
4226 - * Return a pointer to the last char put in buf (null), in case of mem fault,
4228 - * may_fault is non-zero if we are reading from arbitrary memory, but is currently
4231 -static unsigned char *mem2hex(char *mem, char *buf, int count, int may_fault)
4235 - while (count-- > 0) {
4236 - if (kgdb_read_byte(mem++, &ch) != 0)
4238 - *buf++ = hexchars[ch >> 4];
4239 - *buf++ = hexchars[ch & 0xf];
4248 - * convert the hex array pointed to by buf into binary to be placed in mem
4249 - * return a pointer to the character AFTER the last byte written
4250 - * may_fault is non-zero if we are reading from arbitrary memory, but is currently
4253 -static char *hex2mem(char *buf, char *mem, int count, int binary, int may_fault)
4258 - for (i=0; i<count; i++)
4263 - ch = 0x20 ^ *buf++;
4266 - ch = hex(*buf++) << 4;
4267 - ch |= hex(*buf++);
4269 - if (kgdb_write_byte(ch, mem++) != 0)
4277 - * This table contains the mapping between SPARC hardware trap types, and
4278 - * signals, which are primarily what GDB understands. It also indicates
4279 - * which hardware traps we need to commandeer when initializing the stub.
4281 -static struct hard_trap_info {
4282 - unsigned char tt; /* Trap type code for MIPS R3xxx and R4xxx */
4283 - unsigned char signo; /* Signal that we map this trap into */
4284 -} hard_trap_info[] = {
4285 - { 6, SIGBUS }, /* instruction bus error */
4286 - { 7, SIGBUS }, /* data bus error */
4287 - { 9, SIGTRAP }, /* break */
4288 - { 10, SIGILL }, /* reserved instruction */
4289 -/* { 11, SIGILL }, */ /* CPU unusable */
4290 - { 12, SIGFPE }, /* overflow */
4291 - { 13, SIGTRAP }, /* trap */
4292 - { 14, SIGSEGV }, /* virtual instruction cache coherency */
4293 - { 15, SIGFPE }, /* floating point exception */
4294 - { 23, SIGSEGV }, /* watch */
4295 - { 31, SIGSEGV }, /* virtual data cache coherency */
4296 - { 0, 0} /* Must be last */
4299 -/* Save the normal trap handlers for user-mode traps. */
4300 -void *saved_vectors[32];
4303 - * Set up exception handlers for tracing and breakpoints
4305 -void set_debug_traps(void)
4307 - struct hard_trap_info *ht;
4308 - unsigned long flags;
4311 - local_irq_save(flags);
4312 - for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
4313 - saved_vectors[ht->tt] = set_except_vector(ht->tt, trap_low);
4315 - putDebugChar('+'); /* 'hello world' */
4317 - * In case GDB is started before us, ack any packets
4318 - * (presumably "$?#xx") sitting there.
4320 - while((c = getDebugChar()) != '$');
4321 - while((c = getDebugChar()) != '#');
4322 - c = getDebugChar(); /* eat first csum byte */
4323 - c = getDebugChar(); /* eat second csum byte */
4324 - putDebugChar('+'); /* ack it */
4327 - local_irq_restore(flags);
4330 -void restore_debug_traps(void)
4332 - struct hard_trap_info *ht;
4333 - unsigned long flags;
4335 - local_irq_save(flags);
4336 - for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
4337 - set_except_vector(ht->tt, saved_vectors[ht->tt]);
4338 - local_irq_restore(flags);
4342 - * Convert the MIPS hardware trap type code to a Unix signal number.
4344 -static int computeSignal(int tt)
4346 - struct hard_trap_info *ht;
4348 - for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
4352 - return SIGHUP; /* default for things we don't know about */
4356 - * While we find nice hex chars, build an int.
4357 - * Return number of chars processed.
4359 -static int hexToInt(char **ptr, int *intValue)
4367 - hexValue = hex(**ptr);
4371 - *intValue = (*intValue << 4) | hexValue;
4377 - return (numChars);
4380 -static int hexToLong(char **ptr, long *longValue)
4388 - hexValue = hex(**ptr);
4392 - *longValue = (*longValue << 4) | hexValue;
4404 - * Print registers (on target console)
4405 - * Used only to debug the stub...
4407 -void show_gdbregs(struct gdb_regs * regs)
4410 - * Saved main processor registers
4412 - printk("$0 : %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
4413 - regs->reg0, regs->reg1, regs->reg2, regs->reg3,
4414 - regs->reg4, regs->reg5, regs->reg6, regs->reg7);
4415 - printk("$8 : %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
4416 - regs->reg8, regs->reg9, regs->reg10, regs->reg11,
4417 - regs->reg12, regs->reg13, regs->reg14, regs->reg15);
4418 - printk("$16: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
4419 - regs->reg16, regs->reg17, regs->reg18, regs->reg19,
4420 - regs->reg20, regs->reg21, regs->reg22, regs->reg23);
4421 - printk("$24: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
4422 - regs->reg24, regs->reg25, regs->reg26, regs->reg27,
4423 - regs->reg28, regs->reg29, regs->reg30, regs->reg31);
4426 - * Saved cp0 registers
4428 - printk("epc : %08lx\nStatus: %08lx\nCause : %08lx\n",
4429 - regs->cp0_epc, regs->cp0_status, regs->cp0_cause);
4431 -#endif /* dead code */
4434 - * We single-step by setting breakpoints. When an exception
4435 - * is handled, we need to restore the instructions hoisted
4436 - * when the breakpoints were set.
4438 - * This is where we save the original instructions.
4440 -static struct gdb_bp_save {
4441 - unsigned long addr;
4445 -#define BP 0x0000000d /* break opcode */
4448 - * Set breakpoint instructions for single stepping.
4450 -static void single_step(struct gdb_regs *regs)
4452 - union mips_instruction insn;
4453 - unsigned long targ;
4454 - int is_branch, is_cond, i;
4456 - targ = regs->cp0_epc;
4457 - insn.word = *(unsigned int *)targ;
4458 - is_branch = is_cond = 0;
4460 - switch (insn.i_format.opcode) {
4462 - * jr and jalr are in r_format format.
4465 - switch (insn.r_format.func) {
4468 - targ = *(®s->reg0 + insn.r_format.rs);
4475 - * This group contains:
4476 - * bltz_op, bgez_op, bltzl_op, bgezl_op,
4477 - * bltzal_op, bgezal_op, bltzall_op, bgezall_op.
4480 - is_branch = is_cond = 1;
4481 - targ += 4 + (insn.i_format.simmediate << 2);
4485 - * These are unconditional and in j_format.
4493 - targ |= (insn.j_format.target << 2);
4497 - * These are conditional.
4511 - is_branch = is_cond = 1;
4512 - targ += 4 + (insn.i_format.simmediate << 2);
4518 - if (is_cond && targ != (regs->cp0_epc + 8)) {
4519 - step_bp[i].addr = regs->cp0_epc + 8;
4520 - step_bp[i++].val = *(unsigned *)(regs->cp0_epc + 8);
4521 - *(unsigned *)(regs->cp0_epc + 8) = BP;
4523 - step_bp[i].addr = targ;
4524 - step_bp[i].val = *(unsigned *)targ;
4525 - *(unsigned *)targ = BP;
4527 - step_bp[0].addr = regs->cp0_epc + 4;
4528 - step_bp[0].val = *(unsigned *)(regs->cp0_epc + 4);
4529 - *(unsigned *)(regs->cp0_epc + 4) = BP;
4534 - * If asynchronously interrupted by gdb, then we need to set a breakpoint
4535 - * at the interrupted instruction so that we wind up stopped with a
4536 - * reasonable stack frame.
4538 -static struct gdb_bp_save async_bp;
4541 - * Swap the interrupted EPC with our asynchronous breakpoint routine.
4542 - * This is safer than stuffing the breakpoint in-place, since no cache
4543 - * flushes (or resulting smp_call_functions) are required. The
4544 - * assumption is that only one CPU will be handling asynchronous bp's,
4545 - * and only one can be active at a time.
4547 -extern spinlock_t smp_call_lock;
4549 -void set_async_breakpoint(unsigned long *epc)
4551 - /* skip breaking into userland */
4552 - if ((*epc & 0x80000000) == 0)
4556 - /* avoid deadlock if someone is make IPC */
4557 - if (spin_is_locked(&smp_call_lock))
4561 - async_bp.addr = *epc;
4562 - *epc = (unsigned long)async_breakpoint;
4565 -static void kgdb_wait(void *arg)
4568 - int cpu = smp_processor_id();
4570 - local_irq_save(flags);
4572 - __raw_spin_lock(&kgdb_cpulock[cpu]);
4573 - __raw_spin_unlock(&kgdb_cpulock[cpu]);
4575 - local_irq_restore(flags);
4579 - * GDB stub needs to call kgdb_wait on all processor with interrupts
4580 - * disabled, so it uses it's own special variant.
4582 -static int kgdb_smp_call_kgdb_wait(void)
4585 - struct call_data_struct data;
4586 - int i, cpus = num_online_cpus() - 1;
4587 - int cpu = smp_processor_id();
4590 - * Can die spectacularly if this CPU isn't yet marked online
4592 - BUG_ON(!cpu_online(cpu));
4597 - if (spin_is_locked(&smp_call_lock)) {
4599 - * Some other processor is trying to make us do something
4600 - * but we're not going to respond... give up
4606 - * We will continue here, accepting the fact that
4607 - * the kernel may deadlock if another CPU attempts
4608 - * to call smp_call_function now...
4611 - data.func = kgdb_wait;
4613 - atomic_set(&data.started, 0);
4616 - spin_lock(&smp_call_lock);
4617 - call_data = &data;
4620 - /* Send a message to all other CPUs and wait for them to respond */
4621 - for (i = 0; i < NR_CPUS; i++)
4622 - if (cpu_online(i) && i != cpu)
4623 - core_send_ipi(i, SMP_CALL_FUNCTION);
4625 - /* Wait for response */
4626 - /* FIXME: lock-up detection, backtrace on lock-up */
4627 - while (atomic_read(&data.started) != cpus)
4631 - spin_unlock(&smp_call_lock);
4638 - * This function does all command processing for interfacing to gdb. It
4639 - * returns 1 if you should skip the instruction at the trap address, 0
4642 -void handle_exception (struct gdb_regs *regs)
4644 - int trap; /* Trap type */
4649 - unsigned long *stack;
4656 - * acquire the big kgdb spinlock
4658 - if (!spin_trylock(&kgdb_lock)) {
4660 - * some other CPU has the lock, we should go back to
4661 - * receive the gdb_wait IPC
4667 - * If we're in async_breakpoint(), restore the real EPC from
4670 - if (regs->cp0_epc == (unsigned long)async_breakinst) {
4671 - regs->cp0_epc = async_bp.addr;
4672 - async_bp.addr = 0;
4676 - * acquire the CPU spinlocks
4678 - for (i = num_online_cpus()-1; i >= 0; i--)
4679 - if (__raw_spin_trylock(&kgdb_cpulock[i]) == 0)
4680 - panic("kgdb: couldn't get cpulock %d\n", i);
4683 - * force other cpus to enter kgdb
4685 - kgdb_smp_call_kgdb_wait();
4688 - * If we're in breakpoint() increment the PC
4690 - trap = (regs->cp0_cause & 0x7c) >> 2;
4691 - if (trap == 9 && regs->cp0_epc == (unsigned long)breakinst)
4692 - regs->cp0_epc += 4;
4695 - * If we were single_stepping, restore the opcodes hoisted
4696 - * for the breakpoint[s].
4698 - if (step_bp[0].addr) {
4699 - *(unsigned *)step_bp[0].addr = step_bp[0].val;
4700 - step_bp[0].addr = 0;
4702 - if (step_bp[1].addr) {
4703 - *(unsigned *)step_bp[1].addr = step_bp[1].val;
4704 - step_bp[1].addr = 0;
4708 - stack = (long *)regs->reg29; /* stack ptr */
4709 - sigval = computeSignal(trap);
4712 - * reply to host that an exception has occurred
4714 - ptr = output_buffer;
4717 - * Send trap type (converted to signal)
4720 - *ptr++ = hexchars[sigval >> 4];
4721 - *ptr++ = hexchars[sigval & 0xf];
4726 - *ptr++ = hexchars[REG_EPC >> 4];
4727 - *ptr++ = hexchars[REG_EPC & 0xf];
4729 - ptr = mem2hex((char *)®s->cp0_epc, ptr, sizeof(long), 0);
4733 - * Send frame pointer
4735 - *ptr++ = hexchars[REG_FP >> 4];
4736 - *ptr++ = hexchars[REG_FP & 0xf];
4738 - ptr = mem2hex((char *)®s->reg30, ptr, sizeof(long), 0);
4742 - * Send stack pointer
4744 - *ptr++ = hexchars[REG_SP >> 4];
4745 - *ptr++ = hexchars[REG_SP & 0xf];
4747 - ptr = mem2hex((char *)®s->reg29, ptr, sizeof(long), 0);
4751 - putpacket(output_buffer); /* send it off... */
4754 - * Wait for input from remote GDB
4757 - output_buffer[0] = 0;
4758 - getpacket(input_buffer);
4760 - switch (input_buffer[0])
4763 - output_buffer[0] = 'S';
4764 - output_buffer[1] = hexchars[sigval >> 4];
4765 - output_buffer[2] = hexchars[sigval & 0xf];
4766 - output_buffer[3] = 0;
4770 - * Detach debugger; let CPU run
4773 - putpacket(output_buffer);
4778 - /* toggle debug flag */
4782 - * Return the value of the CPU registers
4785 - ptr = output_buffer;
4786 - ptr = mem2hex((char *)®s->reg0, ptr, 32*sizeof(long), 0); /* r0...r31 */
4787 - ptr = mem2hex((char *)®s->cp0_status, ptr, 6*sizeof(long), 0); /* cp0 */
4788 - ptr = mem2hex((char *)®s->fpr0, ptr, 32*sizeof(long), 0); /* f0...31 */
4789 - ptr = mem2hex((char *)®s->cp1_fsr, ptr, 2*sizeof(long), 0); /* cp1 */
4790 - ptr = mem2hex((char *)®s->frame_ptr, ptr, 2*sizeof(long), 0); /* frp */
4791 - ptr = mem2hex((char *)®s->cp0_index, ptr, 16*sizeof(long), 0); /* cp0 */
4795 - * set the value of the CPU registers - return OK
4799 - ptr = &input_buffer[1];
4800 - hex2mem(ptr, (char *)®s->reg0, 32*sizeof(long), 0, 0);
4801 - ptr += 32*(2*sizeof(long));
4802 - hex2mem(ptr, (char *)®s->cp0_status, 6*sizeof(long), 0, 0);
4803 - ptr += 6*(2*sizeof(long));
4804 - hex2mem(ptr, (char *)®s->fpr0, 32*sizeof(long), 0, 0);
4805 - ptr += 32*(2*sizeof(long));
4806 - hex2mem(ptr, (char *)®s->cp1_fsr, 2*sizeof(long), 0, 0);
4807 - ptr += 2*(2*sizeof(long));
4808 - hex2mem(ptr, (char *)®s->frame_ptr, 2*sizeof(long), 0, 0);
4809 - ptr += 2*(2*sizeof(long));
4810 - hex2mem(ptr, (char *)®s->cp0_index, 16*sizeof(long), 0, 0);
4811 - strcpy(output_buffer,"OK");
4816 - * mAA..AA,LLLL Read LLLL bytes at address AA..AA
4819 - ptr = &input_buffer[1];
4821 - if (hexToLong(&ptr, &addr)
4823 - && hexToInt(&ptr, &length)) {
4824 - if (mem2hex((char *)addr, output_buffer, length, 1))
4826 - strcpy (output_buffer, "E03");
4828 - strcpy(output_buffer,"E01");
4832 - * XAA..AA,LLLL: Write LLLL escaped binary bytes at address AA.AA
4836 - /* fall through */
4839 - * MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK
4842 - ptr = &input_buffer[1];
4844 - if (hexToLong(&ptr, &addr)
4846 - && hexToInt(&ptr, &length)
4847 - && *ptr++ == ':') {
4848 - if (hex2mem(ptr, (char *)addr, length, bflag, 1))
4849 - strcpy(output_buffer, "OK");
4851 - strcpy(output_buffer, "E03");
4854 - strcpy(output_buffer, "E02");
4858 - * cAA..AA Continue at address AA..AA(optional)
4861 - /* try to read optional parameter, pc unchanged if no parm */
4863 - ptr = &input_buffer[1];
4864 - if (hexToLong(&ptr, &addr))
4865 - regs->cp0_epc = addr;
4867 - goto exit_kgdb_exception;
4871 - * kill the program; let us try to restart the machine
4872 - * Reset the whole machine.
4876 - machine_restart("kgdb restarts machine");
4880 - * Step to next instruction
4884 - * There is no single step insn in the MIPS ISA, so we
4885 - * use breakpoints and continue, instead.
4887 - single_step(regs);
4888 - goto exit_kgdb_exception;
4893 - * Set baud rate (bBB)
4894 - * FIXME: Needs to be written
4900 - extern void set_timer_3();
4902 - ptr = &input_buffer[1];
4903 - if (!hexToInt(&ptr, &baudrate))
4905 - strcpy(output_buffer,"B01");
4909 - /* Convert baud rate to uart clock divider */
4924 - strcpy(output_buffer,"B02");
4929 - putpacket("OK"); /* Ack before changing speed */
4930 - set_timer_3(baudrate); /* Set it */
4939 - * reply to the request
4942 - putpacket(output_buffer);
4949 - restore_debug_traps();
4951 -exit_kgdb_exception:
4952 - /* release locks so other CPUs can go */
4953 - for (i = num_online_cpus()-1; i >= 0; i--)
4954 - __raw_spin_unlock(&kgdb_cpulock[i]);
4955 - spin_unlock(&kgdb_lock);
4957 - __flush_cache_all();
4962 - * This function will generate a breakpoint exception. It is used at the
4963 - * beginning of a program to sync up with a debugger and can be used
4964 - * otherwise as a quick means to stop program execution and "break" into
4967 -void breakpoint(void)
4972 - __asm__ __volatile__(
4973 - ".globl breakinst\n\t"
4974 - ".set\tnoreorder\n\t"
4976 - "breakinst:\tbreak\n\t"
4982 -/* Nothing but the break; don't pollute any registers */
4983 -void async_breakpoint(void)
4985 - __asm__ __volatile__(
4986 - ".globl async_breakinst\n\t"
4987 - ".set\tnoreorder\n\t"
4989 - "async_breakinst:\tbreak\n\t"
4997 - __asm__ __volatile__(
4998 - ".globl\tadel\n\t"
4999 - "lui\t$8,0x8000\n\t"
5000 - "lw\t$9,1($8)\n\t"
5005 - * malloc is needed by gdb client in "call func()", even a private one
5006 - * will make gdb happy
5008 -static void * __attribute_used__ malloc(size_t size)
5010 - return kmalloc(size, GFP_ATOMIC);
5013 -static void __attribute_used__ free (void *where)
5018 -#ifdef CONFIG_GDB_CONSOLE
5020 -void gdb_putsn(const char *str, int l)
5024 - if (!kgdb_started)
5030 - int i = (l>8)?8:l;
5031 - mem2hex((char *)str, &outbuf[1], i, 0);
5032 - outbuf[(i*2)+1]=0;
5033 - putpacket(outbuf);
5039 -static void gdb_console_write(struct console *con, const char *s, unsigned n)
5044 -static struct console gdb_console = {
5046 - .write = gdb_console_write,
5047 - .flags = CON_PRINTBUFFER,
5051 -static int __init register_gdb_console(void)
5053 - register_console(&gdb_console);
5058 -console_initcall(register_gdb_console);
5061 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/mips/kernel/irq.c linux-2.6.18-53.1.14.kgdb/arch/mips/kernel/irq.c
5062 --- linux-2.6.18-53.1.14/arch/mips/kernel/irq.c 2006-09-20 07:42:06.000000000 +0400
5063 +++ linux-2.6.18-53.1.14.kgdb/arch/mips/kernel/irq.c 2008-06-10 15:38:24.000000000 +0400
5065 #include <asm/atomic.h>
5066 #include <asm/system.h>
5067 #include <asm/uaccess.h>
5068 +#include <asm/kgdb.h>
5070 +/* Keep track of if we've done certain initialization already or not. */
5071 +int kgdb_early_setup;
5074 * 'what should we do if we get a hw irq event on an illegal vector'.
5075 @@ -115,23 +119,13 @@ asmlinkage void spurious_interrupt(struc
5076 atomic_inc(&irq_err_count);
5080 -extern void breakpoint(void);
5081 -extern void set_debug_traps(void);
5083 -static int kgdb_flag = 1;
5084 -static int __init nokgdb(char *str)
5089 -__setup("nokgdb", nokgdb);
5092 void __init init_IRQ(void)
5096 + if (kgdb_early_setup)
5099 for (i = 0; i < NR_IRQS; i++) {
5100 irq_desc[i].status = IRQ_DISABLED;
5101 irq_desc[i].action = NULL;
5102 @@ -144,12 +138,12 @@ void __init init_IRQ(void)
5109 - printk("Wait for gdb client connection ...\n");
5110 - set_debug_traps();
5114 + * We have been called before kgdb_arch_init(). Hence,
5115 + * we dont want the traps to be reinitialized
5117 + if (kgdb_early_setup == 0)
5118 + kgdb_early_setup = 1;
5121 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/mips/kernel/kgdb-jmp.c linux-2.6.18-53.1.14.kgdb/arch/mips/kernel/kgdb-jmp.c
5122 --- linux-2.6.18-53.1.14/arch/mips/kernel/kgdb-jmp.c 1970-01-01 03:00:00.000000000 +0300
5123 +++ linux-2.6.18-53.1.14.kgdb/arch/mips/kernel/kgdb-jmp.c 2008-06-10 15:38:24.000000000 +0400
5126 + * arch/mips/kernel/kgdb-jmp.c
5128 + * Save and restore system registers so that within a limited frame we
5129 + * may have a fault and "jump back" to a known safe location.
5131 + * Author: Tom Rini <trini@kernel.crashing.org>
5132 + * Author: Manish Lachwani <mlachwani@mvista.com>
5134 + * Cribbed from glibc, which carries the following:
5135 + * Copyright (C) 1996, 1997, 2000, 2002, 2003 Free Software Foundation, Inc.
5136 + * Copyright (C) 2005 by MontaVista Software.
5138 + * This file is licensed under the terms of the GNU General Public License
5139 + * version 2. This program as licensed "as is" without any warranty of
5140 + * any kind, whether express or implied.
5143 +#include <linux/kgdb.h>
5144 +#include <asm/interrupt.h>
5146 +#ifdef CONFIG_MIPS64
5151 +int kgdb_fault_setjmp_aux(unsigned long *curr_context, int sp, int fp)
5153 + __asm__ __volatile__ ("sd $gp, %0" : : "m" (curr_context[0]));
5154 + __asm__ __volatile__ ("sd $16, %0" : : "m" (curr_context[1]));
5155 + __asm__ __volatile__ ("sd $17, %0" : : "m" (curr_context[2]));
5156 + __asm__ __volatile__ ("sd $18, %0" : : "m" (curr_context[3]));
5157 + __asm__ __volatile__ ("sd $19, %0" : : "m" (curr_context[4]));
5158 + __asm__ __volatile__ ("sd $20, %0" : : "m" (curr_context[5]));
5159 + __asm__ __volatile__ ("sd $21, %0" : : "m" (curr_context[6]));
5160 + __asm__ __volatile__ ("sd $22, %0" : : "m" (curr_context[7]));
5161 + __asm__ __volatile__ ("sd $23, %0" : : "m" (curr_context[8]));
5162 + __asm__ __volatile__ ("sd $31, %0" : : "m" (curr_context[9]));
5163 + curr_context[10] = (long *)sp;
5164 + curr_context[11] = (long *)fp;
5169 +void kgdb_fault_longjmp(unsigned long *curr_context)
5171 + unsigned long sp_val, fp_val;
5173 + __asm__ __volatile__ ("ld $gp, %0" : : "m" (curr_context[0]));
5174 + __asm__ __volatile__ ("ld $16, %0" : : "m" (curr_context[1]));
5175 + __asm__ __volatile__ ("ld $17, %0" : : "m" (curr_context[2]));
5176 + __asm__ __volatile__ ("ld $18, %0" : : "m" (curr_context[3]));
5177 + __asm__ __volatile__ ("ld $19, %0" : : "m" (curr_context[4]));
5178 + __asm__ __volatile__ ("ld $20, %0" : : "m" (curr_context[5]));
5179 + __asm__ __volatile__ ("ld $21, %0" : : "m" (curr_context[6]));
5180 + __asm__ __volatile__ ("ld $22, %0" : : "m" (curr_context[7]));
5181 + __asm__ __volatile__ ("ld $23, %0" : : "m" (curr_context[8]));
5182 + __asm__ __volatile__ ("ld $25, %0" : : "m" (curr_context[9]));
5183 + sp_val = curr_context[10];
5184 + fp_val = curr_context[11];
5185 + __asm__ __volatile__ ("ld $29, %0\n\t"
5186 + "ld $30, %1\n\t" : : "m" (sp_val), "m" (fp_val));
5188 + __asm__ __volatile__ ("dli $2, 1");
5189 + __asm__ __volatile__ ("j $25");
5198 +int kgdb_fault_setjmp_aux(unsigned long *curr_context, int sp, int fp)
5200 + __asm__ __volatile__("sw $gp, %0" : : "m" (curr_context[0]));
5201 + __asm__ __volatile__("sw $16, %0" : : "m" (curr_context[1]));
5202 + __asm__ __volatile__("sw $17, %0" : : "m" (curr_context[2]));
5203 + __asm__ __volatile__("sw $18, %0" : : "m" (curr_context[3]));
5204 + __asm__ __volatile__("sw $19, %0" : : "m" (curr_context[4]));
5205 + __asm__ __volatile__("sw $20, %0" : : "m" (curr_context[5]));
5206 + __asm__ __volatile__("sw $21, %0" : : "m" (curr_context[6]));
5207 + __asm__ __volatile__("sw $22, %0" : : "m" (curr_context[7]));
5208 + __asm__ __volatile__("sw $23, %0" : : "m" (curr_context[8]));
5209 + __asm__ __volatile__("sw $31, %0" : : "m" (curr_context[9]));
5210 + curr_context[10] = (long *)sp;
5211 + curr_context[11] = (long *)fp;
5216 +void kgdb_fault_longjmp(unsigned long *curr_context)
5218 + unsigned long sp_val, fp_val;
5220 + __asm__ __volatile__("lw $gp, %0" : : "m" (curr_context[0]));
5221 + __asm__ __volatile__("lw $16, %0" : : "m" (curr_context[1]));
5222 + __asm__ __volatile__("lw $17, %0" : : "m" (curr_context[2]));
5223 + __asm__ __volatile__("lw $18, %0" : : "m" (curr_context[3]));
5224 + __asm__ __volatile__("lw $19, %0" : : "m" (curr_context[4]));
5225 + __asm__ __volatile__("lw $20, %0" : : "m" (curr_context[5]));
5226 + __asm__ __volatile__("lw $21, %0" : : "m" (curr_context[6]));
5227 + __asm__ __volatile__("lw $22, %0" : : "m" (curr_context[7]));
5228 + __asm__ __volatile__("lw $23, %0" : : "m" (curr_context[8]));
5229 + __asm__ __volatile__("lw $25, %0" : : "m" (curr_context[9]));
5230 + sp_val = curr_context[10];
5231 + fp_val = curr_context[11];
5232 + __asm__ __volatile__("lw $29, %0\n\t"
5233 + "lw $30, %1\n\t" : : "m" (sp_val), "m" (fp_val));
5235 + __asm__ __volatile__("li $2, 1");
5236 + __asm__ __volatile__("jr $25");
5241 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/mips/kernel/kgdb-setjmp.S linux-2.6.18-53.1.14.kgdb/arch/mips/kernel/kgdb-setjmp.S
5242 --- linux-2.6.18-53.1.14/arch/mips/kernel/kgdb-setjmp.S 1970-01-01 03:00:00.000000000 +0300
5243 +++ linux-2.6.18-53.1.14.kgdb/arch/mips/kernel/kgdb-setjmp.S 2008-06-10 15:38:24.000000000 +0400
5246 + * arch/mips/kernel/kgdb-jmp.c
5248 + * Save and restore system registers so that within a limited frame we
5249 + * may have a fault and "jump back" to a known safe location.
5251 + * Copyright (C) 2005 by MontaVista Software.
5252 + * Author: Manish Lachwani (mlachwani@mvista.com)
5254 + * This file is licensed under the terms of the GNU General Public License
5255 + * version 2. This program as licensed "as is" without any warranty of
5256 + * any kind, whether express or implied.
5259 +#include <asm/asm.h>
5260 +#include <asm/mipsregs.h>
5261 +#include <asm/regdef.h>
5262 +#include <asm/stackframe.h>
5264 + .ent kgdb_fault_setjmp,0
5265 +ENTRY (kgdb_fault_setjmp)
5268 +#ifdef CONFIG_MIPS64
5271 + j kgdb_fault_setjmp_aux
5272 + .end kgdb_fault_setjmp
5273 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/mips/kernel/kgdb.c linux-2.6.18-53.1.14.kgdb/arch/mips/kernel/kgdb.c
5274 --- linux-2.6.18-53.1.14/arch/mips/kernel/kgdb.c 1970-01-01 03:00:00.000000000 +0300
5275 +++ linux-2.6.18-53.1.14.kgdb/arch/mips/kernel/kgdb.c 2008-06-10 15:38:24.000000000 +0400
5278 + * arch/mips/kernel/kgdb.c
5280 + * Originally written by Glenn Engel, Lake Stevens Instrument Division
5282 + * Contributed by HP Systems
5284 + * Modified for SPARC by Stu Grossman, Cygnus Support.
5286 + * Modified for Linux/MIPS (and MIPS in general) by Andreas Busse
5287 + * Send complaints, suggestions etc. to <andy@waldorf-gmbh.de>
5289 + * Copyright (C) 1995 Andreas Busse
5291 + * Copyright (C) 2003 MontaVista Software Inc.
5292 + * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
5294 + * Copyright (C) 2004-2005 MontaVista Software Inc.
5295 + * Author: Manish Lachwani, mlachwani@mvista.com or manish@koffee-break.com
5297 + * This file is licensed under the terms of the GNU General Public License
5298 + * version 2. This program is licensed "as is" without any warranty of any
5299 + * kind, whether express or implied.
5302 +#include <linux/string.h>
5303 +#include <linux/kernel.h>
5304 +#include <linux/sched.h>
5305 +#include <linux/smp.h>
5306 +#include <linux/spinlock.h>
5307 +#include <linux/delay.h>
5308 +#include <asm/system.h>
5309 +#include <asm/ptrace.h> /* for linux pt_regs struct */
5310 +#include <linux/kgdb.h>
5311 +#include <linux/init.h>
5312 +#include <asm/inst.h>
5313 +#include <asm/gdb-stub.h>
5314 +#include <asm/cacheflush.h>
5315 +#include <asm/kdebug.h>
5317 +static struct hard_trap_info {
5318 + unsigned char tt; /* Trap type code for MIPS R3xxx and R4xxx */
5319 + unsigned char signo; /* Signal that we map this trap into */
5320 +} hard_trap_info[] = {
5321 + { 6, SIGBUS }, /* instruction bus error */
5322 + { 7, SIGBUS }, /* data bus error */
5323 + { 9, SIGTRAP }, /* break */
5324 +/* { 11, SIGILL }, */ /* CPU unusable */
5325 + { 12, SIGFPE }, /* overflow */
5326 + { 13, SIGTRAP }, /* trap */
5327 + { 14, SIGSEGV }, /* virtual instruction cache coherency */
5328 + { 15, SIGFPE }, /* floating point exception */
5329 + { 23, SIGSEGV }, /* watch */
5330 + { 31, SIGSEGV }, /* virtual data cache coherency */
5331 + { 0, 0} /* Must be last */
5334 +/* Save the normal trap handlers for user-mode traps. */
5335 +void *saved_vectors[32];
5337 +extern void trap_low(void);
5338 +extern void breakinst(void);
5339 +extern void init_IRQ(void);
5341 +void kgdb_call_nmi_hook(void *ignored)
5343 + kgdb_nmihook(smp_processor_id(), (void *)0);
5346 +void kgdb_roundup_cpus(unsigned long flags)
5348 + local_irq_restore(flags);
5349 + smp_call_function(kgdb_call_nmi_hook, 0, 0, 0);
5350 + local_irq_save(flags);
5353 +static int compute_signal(int tt)
5355 + struct hard_trap_info *ht;
5357 + for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
5361 + return SIGHUP; /* default for things we don't know about */
5365 + * Set up exception handlers for tracing and breakpoints
5367 +void handle_exception(struct pt_regs *regs)
5369 + int trap = (regs->cp0_cause & 0x7c) >> 2;
5371 + if (fixup_exception(regs)) {
5375 + if (atomic_read(&debugger_active))
5376 + kgdb_nmihook(smp_processor_id(), regs);
5378 + if (atomic_read(&kgdb_setting_breakpoint))
5379 + if ((trap == 9) && (regs->cp0_epc == (unsigned long)breakinst))
5380 + regs->cp0_epc += 4;
5382 + kgdb_handle_exception(0, compute_signal(trap), 0, regs);
5384 + /* In SMP mode, __flush_cache_all does IPI */
5385 + __flush_cache_all();
5388 +void set_debug_traps(void)
5390 + struct hard_trap_info *ht;
5391 + unsigned long flags;
5393 + local_irq_save(flags);
5395 + for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
5396 + saved_vectors[ht->tt] = set_except_vector(ht->tt, trap_low);
5398 + local_irq_restore(flags);
5402 +/* This should be called before we exit kgdb_handle_exception() I believe.
5405 +void restore_debug_traps(void)
5407 + struct hard_trap_info *ht;
5408 + unsigned long flags;
5410 + local_irq_save(flags);
5411 + for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
5412 + set_except_vector(ht->tt, saved_vectors[ht->tt]);
5413 + local_irq_restore(flags);
5417 +void regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs)
5420 + gdb_reg_t *ptr = (gdb_reg_t*)gdb_regs;
5422 + for (reg = 0; reg < 32; reg++)
5423 + *(ptr++) = regs->regs[reg];
5425 + *(ptr++) = regs->cp0_status;
5426 + *(ptr++) = regs->lo;
5427 + *(ptr++) = regs->hi;
5428 + *(ptr++) = regs->cp0_badvaddr;
5429 + *(ptr++) = regs->cp0_cause;
5430 + *(ptr++) = regs->cp0_epc;
5435 +void gdb_regs_to_regs(unsigned long *gdb_regs, struct pt_regs *regs)
5439 + const gdb_reg_t *ptr = (gdb_reg_t*)gdb_regs;
5441 + for (reg = 0; reg < 32; reg++)
5442 + regs->regs[reg] = *(ptr++);
5444 + regs->cp0_status = *(ptr++);
5445 + regs->lo = *(ptr++);
5446 + regs->hi = *(ptr++);
5447 + regs->cp0_badvaddr = *(ptr++);
5448 + regs->cp0_cause = *(ptr++);
5449 + regs->cp0_epc = *(ptr++);
5455 + * Similar to regs_to_gdb_regs() except that process is sleeping and so
5456 + * we may not be able to get all the info.
5458 +void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p)
5461 + struct thread_info *ti = p->thread_info;
5462 + unsigned long ksp = (unsigned long)ti + THREAD_SIZE - 32;
5463 + struct pt_regs *regs = (struct pt_regs *)ksp - 1;
5464 + gdb_reg_t *ptr = (gdb_reg_t*)gdb_regs;
5466 + for (reg = 0; reg < 16; reg++)
5467 + *(ptr++) = regs->regs[reg];
5470 + for (reg = 16; reg < 24; reg++)
5471 + *(ptr++) = regs->regs[reg];
5473 + for (reg = 24; reg < 28; reg++)
5476 + /* GP, SP, FP, RA */
5477 + for (reg = 28; reg < 32; reg++)
5478 + *(ptr++) = regs->regs[reg];
5480 + *(ptr++) = regs->cp0_status;
5481 + *(ptr++) = regs->lo;
5482 + *(ptr++) = regs->hi;
5483 + *(ptr++) = regs->cp0_badvaddr;
5484 + *(ptr++) = regs->cp0_cause;
5485 + *(ptr++) = regs->cp0_epc;
5491 + * Calls linux_debug_hook before the kernel dies. If KGDB is enabled,
5492 + * then try to fall into the debugger
5494 +static int kgdb_mips_notify(struct notifier_block *self, unsigned long cmd,
5497 + struct die_args *args = (struct die_args *)ptr;
5498 + struct pt_regs *regs = args->regs;
5499 + int trap = (regs->cp0_cause & 0x7c) >> 2;
5501 + /* See if KGDB is interested. */
5502 + if (user_mode(regs))
5503 + /* Userpace events, ignore. */
5504 + return NOTIFY_DONE;
5506 + kgdb_handle_exception(trap, compute_signal(trap), 0, regs);
5510 +static struct notifier_block kgdb_notifier = {
5511 + .notifier_call = kgdb_mips_notify,
5515 + * Handle the 's' and 'c' commands
5517 +int kgdb_arch_handle_exception(int vector, int signo, int err_code,
5518 + char *remcom_in_buffer, char *remcom_out_buffer,
5519 + struct pt_regs *regs)
5522 + unsigned long address;
5523 + int cpu = smp_processor_id();
5525 + switch (remcom_in_buffer[0]) {
5528 + /* handle the optional parameter */
5529 + ptr = &remcom_in_buffer[1];
5530 + if (kgdb_hex2long(&ptr, &address))
5531 + regs->cp0_epc = address;
5533 + atomic_set(&cpu_doing_single_step, -1);
5534 + if (remcom_in_buffer[0] == 's')
5535 + if (kgdb_contthread)
5536 + atomic_set(&cpu_doing_single_step, cpu);
5544 +struct kgdb_arch arch_kgdb_ops = {
5545 +#ifdef CONFIG_CPU_LITTLE_ENDIAN
5546 + .gdb_bpt_instr = {0xd},
5548 + .gdb_bpt_instr = {0x00, 0x00, 0x00, 0x0d},
5553 + * We use kgdb_early_setup so that functions we need to call now don't
5554 + * cause trouble when called again later.
5556 +int kgdb_arch_init(void)
5558 + /* Board-specifics. */
5559 + /* Force some calls to happen earlier. */
5560 + if (kgdb_early_setup == 0) {
5563 + kgdb_early_setup = 1;
5566 + /* Set our traps. */
5567 + /* This needs to be done more finely grained again, paired in
5568 + * a before/after in kgdb_handle_exception(...) -- Tom */
5569 + set_debug_traps();
5570 + notifier_chain_register(&mips_die_chain, &kgdb_notifier);
5574 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/mips/kernel/kgdb_handler.S linux-2.6.18-53.1.14.kgdb/arch/mips/kernel/kgdb_handler.S
5575 --- linux-2.6.18-53.1.14/arch/mips/kernel/kgdb_handler.S 1970-01-01 03:00:00.000000000 +0300
5576 +++ linux-2.6.18-53.1.14.kgdb/arch/mips/kernel/kgdb_handler.S 2008-06-10 15:38:24.000000000 +0400
5579 + * arch/mips/kernel/kgdb_handler.S
5581 + * Copyright (C) 2004-2005 MontaVista Software Inc.
5582 + * Author: Manish Lachwani, mlachwani@mvista.com or manish@koffee-break.com
5584 + * This file is licensed under the terms of the GNU General Public
5585 + * version 2. This program is licensed "as is" without any warranty of any
5586 + * kind, whether express or implied.
5590 + * Trap Handler for the new KGDB framework. The main KGDB handler is
5591 + * handle_exception that will be called from here
5595 +#include <linux/config.h>
5596 +#include <linux/sys.h>
5598 +#include <asm/asm.h>
5599 +#include <asm/errno.h>
5600 +#include <asm/mipsregs.h>
5601 +#include <asm/regdef.h>
5602 +#include <asm/stackframe.h>
5605 + NESTED(trap_low, PT_SIZE, sp)
5610 + * Check for privileged instructions in user mode. For
5611 + * this, check the cu0 bit in the CPU status register.
5613 + mfc0 k0, CP0_STATUS
5619 + * GDB userland from within KGDB. If a user mode address
5620 + * then jump to the saved exception handler
5622 + mfc0 k1, CP0_CAUSE
5624 + PTR_L k0, saved_vectors(k1)
5632 + jal handle_exception
5633 + j ret_from_exception
5635 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/mips/kernel/traps.c linux-2.6.18-53.1.14.kgdb/arch/mips/kernel/traps.c
5636 --- linux-2.6.18-53.1.14/arch/mips/kernel/traps.c 2006-09-20 07:42:06.000000000 +0400
5637 +++ linux-2.6.18-53.1.14.kgdb/arch/mips/kernel/traps.c 2008-06-10 15:38:24.000000000 +0400
5639 * Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
5640 * Copyright (C) 2000, 01 MIPS Technologies, Inc.
5641 * Copyright (C) 2002, 2003, 2004, 2005 Maciej W. Rozycki
5643 + * KGDB specific changes - Manish Lachwani (mlachwani@mvista.com)
5645 #include <linux/init.h>
5646 #include <linux/mm.h>
5648 #include <linux/spinlock.h>
5649 #include <linux/kallsyms.h>
5650 #include <linux/bootmem.h>
5651 +#include <linux/kgdb.h>
5653 #include <asm/bootinfo.h>
5654 #include <asm/branch.h>
5656 #include <asm/mmu_context.h>
5657 #include <asm/watch.h>
5658 #include <asm/types.h>
5659 +#include <asm/kdebug.h>
5661 extern asmlinkage void handle_int(void);
5662 extern asmlinkage void handle_tlbm(void);
5663 @@ -78,6 +82,21 @@ void (*board_bind_eic_interrupt)(int irq
5665 #define MODULE_RANGE (8*1024*1024)
5667 +struct notifier_block *mips_die_chain;
5668 +static spinlock_t die_notifier_lock = SPIN_LOCK_UNLOCKED;
5670 +int register_die_notifier(struct notifier_block *nb)
5673 + unsigned long flags;
5675 + spin_lock_irqsave(&die_notifier_lock, flags);
5676 + err = notifier_chain_register(&mips_die_chain, nb);
5677 + spin_unlock_irqrestore(&die_notifier_lock, flags);
5683 * This routine abuses get_user()/put_user() to reference pointers
5684 * with at least a bit of error checking ...
5685 @@ -1387,6 +1406,11 @@ void __init trap_init(void)
5686 extern char except_vec4;
5689 +#if defined(CONFIG_KGDB)
5690 + if (kgdb_early_setup)
5691 + return; /* Already done */
5694 if (cpu_has_veic || cpu_has_vint)
5695 ebase = (unsigned long) alloc_bootmem_low_pages (0x200 + VECTORSPACING*64);
5697 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/mips/mips-boards/generic/Makefile linux-2.6.18-53.1.14.kgdb/arch/mips/mips-boards/generic/Makefile
5698 --- linux-2.6.18-53.1.14/arch/mips/mips-boards/generic/Makefile 2006-09-20 07:42:06.000000000 +0400
5699 +++ linux-2.6.18-53.1.14.kgdb/arch/mips/mips-boards/generic/Makefile 2008-06-10 15:38:24.000000000 +0400
5701 obj-y := reset.o display.o init.o memory.o printf.o \
5703 obj-$(CONFIG_PCI) += pci.o
5704 -obj-$(CONFIG_KGDB) += gdb_hook.o
5706 EXTRA_AFLAGS := $(CFLAGS)
5707 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/mips/mips-boards/generic/init.c linux-2.6.18-53.1.14.kgdb/arch/mips/mips-boards/generic/init.c
5708 --- linux-2.6.18-53.1.14/arch/mips/mips-boards/generic/init.c 2006-09-20 07:42:06.000000000 +0400
5709 +++ linux-2.6.18-53.1.14.kgdb/arch/mips/mips-boards/generic/init.c 2008-06-10 15:38:24.000000000 +0400
5712 #include <asm/mips-boards/malta.h>
5715 -extern int rs_kgdb_hook(int, int);
5716 -extern int rs_putDebugChar(char);
5717 -extern char rs_getDebugChar(void);
5718 -extern int saa9730_kgdb_hook(int);
5719 -extern int saa9730_putDebugChar(char);
5720 -extern char saa9730_getDebugChar(void);
5724 int *_prom_argv, *_prom_envp;
5726 @@ -172,58 +163,6 @@ static void __init console_config(void)
5731 -void __init kgdb_config (void)
5733 - extern int (*generic_putDebugChar)(char);
5734 - extern char (*generic_getDebugChar)(void);
5738 - argptr = prom_getcmdline();
5739 - if ((argptr = strstr(argptr, "kgdb=ttyS")) != NULL) {
5740 - argptr += strlen("kgdb=ttyS");
5741 - if (*argptr != '0' && *argptr != '1')
5742 - printk("KGDB: Unknown serial line /dev/ttyS%c, "
5743 - "falling back to /dev/ttyS1\n", *argptr);
5744 - line = *argptr == '0' ? 0 : 1;
5745 - printk("KGDB: Using serial line /dev/ttyS%d for session\n", line);
5748 - if (*++argptr == ',')
5751 - while ((c = *++argptr) && ('0' <= c && c <= '9'))
5752 - speed = speed * 10 + c - '0';
5754 -#ifdef CONFIG_MIPS_ATLAS
5756 - speed = saa9730_kgdb_hook(speed);
5757 - generic_putDebugChar = saa9730_putDebugChar;
5758 - generic_getDebugChar = saa9730_getDebugChar;
5763 - speed = rs_kgdb_hook(line, speed);
5764 - generic_putDebugChar = rs_putDebugChar;
5765 - generic_getDebugChar = rs_getDebugChar;
5768 - prom_printf("KGDB: Using serial line /dev/ttyS%d at %d for session, "
5769 - "please connect your debugger\n", line ? 1 : 0, speed);
5773 - for (s = "Please connect GDB to this port\r\n"; *s; )
5774 - generic_putDebugChar (*s++);
5777 - /* Breakpoint is invoked after interrupts are initialised */
5782 void __init mips_nmi_setup (void)
5785 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/mips/mips-boards/malta/malta_setup.c linux-2.6.18-53.1.14.kgdb/arch/mips/mips-boards/malta/malta_setup.c
5786 --- linux-2.6.18-53.1.14/arch/mips/mips-boards/malta/malta_setup.c 2006-09-20 07:42:06.000000000 +0400
5787 +++ linux-2.6.18-53.1.14.kgdb/arch/mips/mips-boards/malta/malta_setup.c 2008-06-10 15:38:24.000000000 +0400
5788 @@ -46,10 +46,6 @@ extern void mips_reboot_setup(void);
5789 extern void mips_time_init(void);
5790 extern unsigned long mips_rtc_get_time(void);
5793 -extern void kgdb_config(void);
5796 struct resource standard_io_resources[] = {
5797 { .name = "dma1", .start = 0x00, .end = 0x1f, .flags = IORESOURCE_BUSY },
5798 { .name = "timer", .start = 0x40, .end = 0x5f, .flags = IORESOURCE_BUSY },
5799 @@ -124,10 +120,6 @@ void __init plat_mem_setup(void)
5807 if ((mips_revision_corid == MIPS_REVISION_CORID_BONITO64) ||
5808 (mips_revision_corid == MIPS_REVISION_CORID_CORE_20K) ||
5809 (mips_revision_corid == MIPS_REVISION_CORID_CORE_EMUL_BON)) {
5810 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/mips/mm/extable.c linux-2.6.18-53.1.14.kgdb/arch/mips/mm/extable.c
5811 --- linux-2.6.18-53.1.14/arch/mips/mm/extable.c 2006-09-20 07:42:06.000000000 +0400
5812 +++ linux-2.6.18-53.1.14.kgdb/arch/mips/mm/extable.c 2008-06-10 15:38:24.000000000 +0400
5815 #include <linux/module.h>
5816 #include <linux/spinlock.h>
5817 +#include <linux/kgdb.h>
5818 #include <asm/branch.h>
5819 #include <asm/uaccess.h>
5821 @@ -16,6 +17,12 @@ int fixup_exception(struct pt_regs *regs
5826 + if (atomic_read(&debugger_active) && kgdb_may_fault)
5827 + /* Restore our previous state. */
5828 + kgdb_fault_longjmp(kgdb_fault_jmp_regs);
5829 + /* Not reached. */
5834 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/mips/sibyte/cfe/setup.c linux-2.6.18-53.1.14.kgdb/arch/mips/sibyte/cfe/setup.c
5835 --- linux-2.6.18-53.1.14/arch/mips/sibyte/cfe/setup.c 2006-09-20 07:42:06.000000000 +0400
5836 +++ linux-2.6.18-53.1.14.kgdb/arch/mips/sibyte/cfe/setup.c 2008-06-10 15:38:24.000000000 +0400
5837 @@ -58,10 +58,6 @@ int cfe_cons_handle;
5838 extern unsigned long initrd_start, initrd_end;
5842 -extern int kgdb_port;
5845 static void ATTRIB_NORET cfe_linux_exit(void *arg)
5847 int warm = *(int *)arg;
5848 @@ -242,9 +238,6 @@ void __init prom_init(void)
5850 char **envp = (char **) fw_arg2;
5851 int *prom_vec = (int *) fw_arg3;
5856 _machine_restart = cfe_linux_restart;
5857 _machine_halt = cfe_linux_halt;
5858 @@ -308,13 +301,6 @@ void __init prom_init(void)
5863 - if ((arg = strstr(arcs_cmdline,"kgdb=duart")) != NULL)
5864 - kgdb_port = (arg[10] == '0') ? 0 : 1;
5869 #ifdef CONFIG_BLK_DEV_INITRD
5872 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/mips/sibyte/sb1250/Makefile linux-2.6.18-53.1.14.kgdb/arch/mips/sibyte/sb1250/Makefile
5873 --- linux-2.6.18-53.1.14/arch/mips/sibyte/sb1250/Makefile 2006-09-20 07:42:06.000000000 +0400
5874 +++ linux-2.6.18-53.1.14.kgdb/arch/mips/sibyte/sb1250/Makefile 2008-06-10 15:38:24.000000000 +0400
5875 @@ -4,5 +4,6 @@ obj-$(CONFIG_SMP) += smp.o
5876 obj-$(CONFIG_SIBYTE_TBPROF) += bcm1250_tbprof.o
5877 obj-$(CONFIG_SIBYTE_STANDALONE) += prom.o
5878 obj-$(CONFIG_SIBYTE_BUS_WATCHER) += bus_watcher.o
5879 +obj-$(CONFIG_KGDB_SIBYTE) += kgdb_sibyte.o
5881 EXTRA_AFLAGS := $(CFLAGS)
5882 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/mips/sibyte/sb1250/irq.c linux-2.6.18-53.1.14.kgdb/arch/mips/sibyte/sb1250/irq.c
5883 --- linux-2.6.18-53.1.14/arch/mips/sibyte/sb1250/irq.c 2006-09-20 07:42:06.000000000 +0400
5884 +++ linux-2.6.18-53.1.14.kgdb/arch/mips/sibyte/sb1250/irq.c 2008-06-10 15:38:24.000000000 +0400
5886 #include <asm/system.h>
5887 #include <asm/ptrace.h>
5889 +#include <asm/kgdb.h>
5891 #include <asm/sibyte/sb1250_regs.h>
5892 #include <asm/sibyte/sb1250_int.h>
5893 @@ -59,16 +60,6 @@ static void sb1250_set_affinity(unsigned
5894 extern unsigned long ldt_eoi_space;
5898 -static int kgdb_irq;
5900 -/* Default to UART1 */
5902 -#ifdef CONFIG_SIBYTE_SB1250_DUART
5903 -extern char sb1250_duart_present[];
5907 static struct irq_chip sb1250_irq_type = {
5908 .typename = "SB1250-IMR",
5909 .startup = startup_sb1250_irq,
5910 @@ -324,6 +315,11 @@ void __init arch_init_irq(void)
5911 unsigned int imask = STATUSF_IP4 | STATUSF_IP3 | STATUSF_IP2 |
5912 STATUSF_IP1 | STATUSF_IP0;
5915 + if (kgdb_early_setup)
5919 /* Default everything to IP2 */
5920 for (i = 0; i < SB1250_NR_IRQS; i++) { /* was I0 */
5921 __raw_writeq(IMR_IP2_VAL,
5922 @@ -375,50 +371,6 @@ void __init arch_init_irq(void)
5923 /* Enable necessary IPs, disable the rest */
5924 change_c0_status(ST0_IM, imask);
5928 - kgdb_irq = K_INT_UART_0 + kgdb_port;
5930 -#ifdef CONFIG_SIBYTE_SB1250_DUART
5931 - sb1250_duart_present[kgdb_port] = 0;
5933 - /* Setup uart 1 settings, mapper */
5934 - __raw_writeq(M_DUART_IMR_BRK,
5935 - IOADDR(A_DUART_IMRREG(kgdb_port)));
5937 - sb1250_steal_irq(kgdb_irq);
5938 - __raw_writeq(IMR_IP6_VAL,
5939 - IOADDR(A_IMR_REGISTER(0,
5940 - R_IMR_INTERRUPT_MAP_BASE) +
5941 - (kgdb_irq << 3)));
5942 - sb1250_unmask_irq(0, kgdb_irq);
5949 -#include <linux/delay.h>
5951 -#define duart_out(reg, val) csr_out32(val, IOADDR(A_DUART_CHANREG(kgdb_port,reg)))
5952 -#define duart_in(reg) csr_in32(IOADDR(A_DUART_CHANREG(kgdb_port,reg)))
5954 -static void sb1250_kgdb_interrupt(struct pt_regs *regs)
5957 - * Clear break-change status (allow some time for the remote
5958 - * host to stop the break, since we would see another
5959 - * interrupt on the end-of-break too)
5961 - kstat_this_cpu.irqs[kgdb_irq]++;
5963 - duart_out(R_DUART_CMD, V_DUART_MISC_CMD_RESET_BREAK_INT |
5964 - M_DUART_RX_EN | M_DUART_TX_EN);
5965 - set_async_breakpoint(®s->cp0_epc);
5968 -#endif /* CONFIG_KGDB */
5970 static inline int dclz(unsigned long long x)
5973 @@ -473,7 +425,7 @@ asmlinkage void plat_irq_dispatch(struct
5974 sb1250_mailbox_interrupt(regs);
5978 +#ifdef CONFIG_KGDB_SIBYTE
5979 else if (pending & CAUSEF_IP6) /* KGDB (uart 1) */
5980 sb1250_kgdb_interrupt(regs);
5982 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/mips/sibyte/sb1250/kgdb_sibyte.c linux-2.6.18-53.1.14.kgdb/arch/mips/sibyte/sb1250/kgdb_sibyte.c
5983 --- linux-2.6.18-53.1.14/arch/mips/sibyte/sb1250/kgdb_sibyte.c 1970-01-01 03:00:00.000000000 +0300
5984 +++ linux-2.6.18-53.1.14.kgdb/arch/mips/sibyte/sb1250/kgdb_sibyte.c 2008-06-10 15:38:24.000000000 +0400
5987 + * arch/mips/sibyte/sb1250/kgdb_sibyte.c
5989 + * Author: Manish Lachwani, mlachwani@mvista.com or manish@koffee-break.com
5991 + * 2004 (c) MontaVista Software, Inc. This file is licensed under
5992 + * the terms of the GNU General Public License version 2. This program
5993 + * is licensed "as is" without any warranty of any kind, whether express
5998 + * Support for KGDB on the Broadcom Sibyte. The SWARM board
5999 + * for example does not have a 8250/16550 compatible serial
6000 + * port. Hence, we need to have a driver for the serial
6001 + * ports to handle KGDB. This board needs nothing in addition
6002 + * to what is normally provided by the gdb portion of the stub.
6005 +#include <linux/delay.h>
6006 +#include <linux/kernel_stat.h>
6007 +#include <linux/init.h>
6008 +#include <linux/kgdb.h>
6010 +#include <asm/io.h>
6011 +#include <asm/sibyte/sb1250.h>
6012 +#include <asm/sibyte/sb1250_regs.h>
6013 +#include <asm/sibyte/sb1250_uart.h>
6014 +#include <asm/sibyte/sb1250_int.h>
6015 +#include <asm/addrspace.h>
6018 +static int kgdb_irq;
6020 +extern char sb1250_duart_present[];
6021 +extern int sb1250_steal_irq(int irq);
6023 +/* Forward declarations. */
6024 +static void kgdbsibyte_init_duart(void);
6025 +static int kgdb_init_io(void);
6027 +#define IMR_IP6_VAL K_INT_MAP_I4
6028 +#define duart_out(reg, val) csr_out32(val, IOADDR(A_DUART_CHANREG(kgdb_port,reg)))
6029 +#define duart_in(reg) csr_in32(IOADDR(A_DUART_CHANREG(kgdb_port,reg)))
6031 +static void kgdb_swarm_write_char(int c)
6033 + while ((duart_in(R_DUART_STATUS) & M_DUART_TX_RDY) == 0) ;
6034 + duart_out(R_DUART_TX_HOLD, c);
6037 +static int kgdb_swarm_read_char(void)
6040 + unsigned int status;
6042 + status = duart_in(R_DUART_STATUS);
6043 + while ((status & M_DUART_RX_RDY) == 0) {
6044 + status = duart_in(R_DUART_STATUS);
6048 + * Check for framing error
6050 + if (status & M_DUART_FRM_ERR) {
6051 + kgdbsibyte_init_duart();
6052 + kgdb_swarm_write_char('-');
6056 + ret_char = duart_in(R_DUART_RX_HOLD);
6061 +void sb1250_kgdb_interrupt(struct pt_regs *regs)
6063 + int kgdb_irq = K_INT_UART_0 + kgdb_port;
6065 + * Clear break-change status (allow some time for the remote
6066 + * host to stop the break, since we would see another
6067 + * interrupt on the end-of-break too)
6069 + kstat_this_cpu.irqs[kgdb_irq]++;
6071 + duart_out(R_DUART_CMD, V_DUART_MISC_CMD_RESET_BREAK_INT |
6072 + M_DUART_RX_EN | M_DUART_TX_EN);
6073 + if (kgdb_io_ops.init != kgdb_init_io) {
6074 + /* Throw away the data if another I/O routine is
6077 + unsigned int status;
6079 + status = duart_in(R_DUART_STATUS);
6080 + while ((status & M_DUART_RX_RDY) == 0) {
6081 + status = duart_in(R_DUART_STATUS);
6084 + * Check for framing error
6086 + if (status & M_DUART_FRM_ERR) {
6087 + kgdbsibyte_init_duart();
6089 + duart_in(R_DUART_RX_HOLD);
6096 + * We use port #1 and we set it for 115200 BAUD, 8n1.
6098 +static void kgdbsibyte_init_duart(void)
6101 + duart_out(R_DUART_MODE_REG_1,
6102 + V_DUART_BITS_PER_CHAR_8 | V_DUART_PARITY_MODE_NONE);
6103 + duart_out(R_DUART_MODE_REG_2, M_DUART_STOP_BIT_LEN_1);
6104 + /* Set baud rate of 115200. */
6105 + duart_out(R_DUART_CLK_SEL, V_DUART_BAUD_RATE(115200));
6106 + /* Enable rx and tx */
6107 + duart_out(R_DUART_CMD, M_DUART_RX_EN | M_DUART_TX_EN);
6110 +static int kgdb_init_io(void)
6112 +#ifdef CONFIG_SIBYTE_SB1250_DUART
6113 + sb1250_duart_present[kgdb_port] = 0;
6116 + kgdbsibyte_init_duart();
6122 + * Hookup our IRQ line. We will already have been initialized a
6125 +static void __init kgdbsibyte_hookup_irq(void)
6127 + /* Steal the IRQ. */
6128 + kgdb_irq = K_INT_UART_0 + kgdb_port;
6130 + /* Setup uart 1 settings, mapper */
6131 + __raw_writeq(M_DUART_IMR_BRK, IOADDR(A_DUART_IMRREG(kgdb_port)));
6133 + sb1250_steal_irq(kgdb_irq);
6135 + __raw_writeq(IMR_IP6_VAL,
6136 + IOADDR(A_IMR_REGISTER(0, R_IMR_INTERRUPT_MAP_BASE) +
6137 + (kgdb_irq << 3)));
6139 + sb1250_unmask_irq(0, kgdb_irq);
6142 +struct kgdb_io kgdb_io_ops = {
6143 + .read_char = kgdb_swarm_read_char,
6144 + .write_char = kgdb_swarm_write_char,
6145 + .init = kgdb_init_io,
6146 + .late_init = kgdbsibyte_hookup_irq,
6147 + .pre_exception = NULL,
6148 + .post_exception = NULL
6150 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/mips/sibyte/swarm/Makefile linux-2.6.18-53.1.14.kgdb/arch/mips/sibyte/swarm/Makefile
6151 --- linux-2.6.18-53.1.14/arch/mips/sibyte/swarm/Makefile 2006-09-20 07:42:06.000000000 +0400
6152 +++ linux-2.6.18-53.1.14.kgdb/arch/mips/sibyte/swarm/Makefile 2008-06-10 15:38:24.000000000 +0400
6154 lib-y = setup.o rtc_xicor1241.o rtc_m41t81.o
6156 -lib-$(CONFIG_KGDB) += dbg_io.o
6157 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/mips/sibyte/swarm/dbg_io.c linux-2.6.18-53.1.14.kgdb/arch/mips/sibyte/swarm/dbg_io.c
6158 --- linux-2.6.18-53.1.14/arch/mips/sibyte/swarm/dbg_io.c 2006-09-20 07:42:06.000000000 +0400
6159 +++ linux-2.6.18-53.1.14.kgdb/arch/mips/sibyte/swarm/dbg_io.c 1970-01-01 03:00:00.000000000 +0300
6162 - * kgdb debug routines for SiByte boards.
6164 - * Copyright (C) 2001 MontaVista Software Inc.
6165 - * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
6167 - * This program is free software; you can redistribute it and/or modify it
6168 - * under the terms of the GNU General Public License as published by the
6169 - * Free Software Foundation; either version 2 of the License, or (at your
6170 - * option) any later version.
6174 -/* -------------------- BEGINNING OF CONFIG --------------------- */
6176 -#include <linux/delay.h>
6177 -#include <asm/io.h>
6178 -#include <asm/sibyte/sb1250.h>
6179 -#include <asm/sibyte/sb1250_regs.h>
6180 -#include <asm/sibyte/sb1250_uart.h>
6181 -#include <asm/sibyte/sb1250_int.h>
6182 -#include <asm/addrspace.h>
6185 - * We use the second serial port for kgdb traffic.
6186 - * 115200, 8, N, 1.
6189 -#define BAUD_RATE 115200
6190 -#define CLK_DIVISOR V_DUART_BAUD_RATE(BAUD_RATE)
6191 -#define DATA_BITS V_DUART_BITS_PER_CHAR_8 /* or 7 */
6192 -#define PARITY V_DUART_PARITY_MODE_NONE /* or even */
6193 -#define STOP_BITS M_DUART_STOP_BIT_LEN_1 /* or 2 */
6195 -static int duart_initialized = 0; /* 0: need to be init'ed by kgdb */
6197 -/* -------------------- END OF CONFIG --------------------- */
6198 -extern int kgdb_port;
6200 -#define duart_out(reg, val) csr_out32(val, IOADDR(A_DUART_CHANREG(kgdb_port,reg)))
6201 -#define duart_in(reg) csr_in32(IOADDR(A_DUART_CHANREG(kgdb_port,reg)))
6203 -void putDebugChar(unsigned char c);
6204 -unsigned char getDebugChar(void);
6206 -duart_init(int clk_divisor, int data, int parity, int stop)
6208 - duart_out(R_DUART_MODE_REG_1, data | parity);
6209 - duart_out(R_DUART_MODE_REG_2, stop);
6210 - duart_out(R_DUART_CLK_SEL, clk_divisor);
6212 - duart_out(R_DUART_CMD, M_DUART_RX_EN | M_DUART_TX_EN); /* enable rx and tx */
6216 -putDebugChar(unsigned char c)
6218 - if (!duart_initialized) {
6219 - duart_initialized = 1;
6220 - duart_init(CLK_DIVISOR, DATA_BITS, PARITY, STOP_BITS);
6222 - while ((duart_in(R_DUART_STATUS) & M_DUART_TX_RDY) == 0);
6223 - duart_out(R_DUART_TX_HOLD, c);
6229 - if (!duart_initialized) {
6230 - duart_initialized = 1;
6231 - duart_init(CLK_DIVISOR, DATA_BITS, PARITY, STOP_BITS);
6233 - while ((duart_in(R_DUART_STATUS) & M_DUART_RX_RDY) == 0) ;
6234 - return duart_in(R_DUART_RX_HOLD);
6237 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/mips/tx4938/common/Makefile linux-2.6.18-53.1.14.kgdb/arch/mips/tx4938/common/Makefile
6238 --- linux-2.6.18-53.1.14/arch/mips/tx4938/common/Makefile 2006-09-20 07:42:06.000000000 +0400
6239 +++ linux-2.6.18-53.1.14.kgdb/arch/mips/tx4938/common/Makefile 2008-06-10 15:38:24.000000000 +0400
6243 obj-y += prom.o setup.o irq.o rtc_rx5c348.o
6244 -obj-$(CONFIG_KGDB) += dbgio.o
6245 +obj-$(CONFIG_KGDB_8250) += dbgio.o
6247 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/powerpc/Kconfig.debug linux-2.6.18-53.1.14.kgdb/arch/powerpc/Kconfig.debug
6248 --- linux-2.6.18-53.1.14/arch/powerpc/Kconfig.debug 2006-09-20 07:42:06.000000000 +0400
6249 +++ linux-2.6.18-53.1.14.kgdb/arch/powerpc/Kconfig.debug 2008-06-10 15:38:14.000000000 +0400
6250 @@ -18,52 +18,9 @@ config DEBUG_STACK_USAGE
6252 This option will slow down process creation somewhat.
6255 - bool "Enable debugger hooks"
6256 - depends on DEBUG_KERNEL
6258 - Include in-kernel hooks for kernel debuggers. Unless you are
6259 - intending to debug the kernel, say N here.
6262 - bool "Include kgdb kernel debugger"
6263 - depends on DEBUGGER && (BROKEN || PPC_GEN550 || 4xx)
6266 - Include in-kernel hooks for kgdb, the Linux kernel source level
6267 - debugger. See <http://kgdb.sourceforge.net/> for more information.
6268 - Unless you are intending to debug the kernel, say N here.
6271 - prompt "Serial Port"
6273 - default KGDB_TTYS1
6289 -config KGDB_CONSOLE
6290 - bool "Enable serial console thru kgdb port"
6291 - depends on KGDB && 8xx || CPM2
6293 - If you enable this, all serial console messages will be sent
6294 - over the gdb stub.
6298 bool "Include xmon kernel debugger"
6299 - depends on DEBUGGER && !PPC_ISERIES
6300 + depends on DEBUG_KERNEL && !PPC_ISERIES
6302 Include in-kernel hooks for the xmon kernel monitor/debugger.
6303 Unless you are intending to debug the kernel, say N here.
6304 @@ -82,6 +39,11 @@ config XMON_DEFAULT
6305 xmon is normally disabled unless booted with 'xmon=on'.
6306 Use 'xmon=off' to disable xmon init during runtime.
6310 + depends on KGDB || XMON
6314 bool "Use separate kernel stacks when processing interrupts"
6316 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/powerpc/kernel/Makefile linux-2.6.18-53.1.14.kgdb/arch/powerpc/kernel/Makefile
6317 --- linux-2.6.18-53.1.14/arch/powerpc/kernel/Makefile 2008-03-06 05:54:47.000000000 +0300
6318 +++ linux-2.6.18-53.1.14.kgdb/arch/powerpc/kernel/Makefile 2008-06-10 15:38:14.000000000 +0400
6319 @@ -59,6 +59,7 @@ obj-$(CONFIG_PPC64) += misc_64.o dma_64
6320 obj-$(CONFIG_PPC_MULTIPLATFORM) += prom_init.o
6321 obj-$(CONFIG_MODULES) += ppc_ksyms.o
6322 obj-$(CONFIG_BOOTX_TEXT) += btext.o
6323 +obj-$(CONFIG_KGDB) += kgdb.o
6324 obj-$(CONFIG_SMP) += smp.o
6325 obj-$(CONFIG_KPROBES) += kprobes.o
6326 obj-$(CONFIG_PPC_UDBG_16550) += legacy_serial.o udbg_16550.o
6327 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/powerpc/kernel/kgdb.c linux-2.6.18-53.1.14.kgdb/arch/powerpc/kernel/kgdb.c
6328 --- linux-2.6.18-53.1.14/arch/powerpc/kernel/kgdb.c 1970-01-01 03:00:00.000000000 +0300
6329 +++ linux-2.6.18-53.1.14.kgdb/arch/powerpc/kernel/kgdb.c 2008-06-10 15:38:14.000000000 +0400
6332 + * arch/powerpc/kernel/kgdb.c
6334 + * PowerPC backend to the KGDB stub.
6336 + * Maintainer: Tom Rini <trini@kernel.crashing.org>
6338 + * Copied from arch/ppc/kernel/kgdb.c, updated for ppc64
6340 + * Copyright (C) 1996 Paul Mackerras (setjmp/longjmp)
6341 + * 1998 (c) Michael AK Tesch (tesch@cs.wisc.edu)
6342 + * Copyright (C) 2003 Timesys Corporation.
6343 + * Copyright (C) 2004-2006 MontaVista Software, Inc.
6344 + * PPC64 Mods (C) 2005 Frank Rowand (frowand@mvista.com)
6345 + * PPC32 support restored by Vitaly Wool <vwool@ru.mvista.com> and
6346 + * Sergei Shtylyov <sshtylyov@ru.mvista.com>
6348 + * This file is licensed under the terms of the GNU General Public License
6349 + * version 2. This program as licensed "as is" without any warranty of any
6350 + * kind, whether express or implied.
6353 +#include <linux/config.h>
6354 +#include <linux/kernel.h>
6355 +#include <linux/init.h>
6356 +#include <linux/kgdb.h>
6357 +#include <linux/smp.h>
6358 +#include <linux/signal.h>
6359 +#include <linux/ptrace.h>
6360 +#include <asm/current.h>
6361 +#include <asm/ptrace.h>
6362 +#include <asm/processor.h>
6363 +#include <asm/machdep.h>
6366 + * This table contains the mapping between PowerPC hardware trap types, and
6367 + * signals, which are primarily what GDB understands. GDB and the kernel
6368 + * don't always agree on values, so we use constants taken from gdb-6.2.
6370 +static struct hard_trap_info
6372 + unsigned int tt; /* Trap type code for powerpc */
6373 + unsigned char signo; /* Signal that we map this trap into */
6374 +} hard_trap_info[] = {
6375 + { 0x0100, 0x02 /* SIGINT */ }, /* system reset */
6376 + { 0x0200, 0x0b /* SIGSEGV */ }, /* machine check */
6377 + { 0x0300, 0x0b /* SIGSEGV */ }, /* data access */
6378 + { 0x0400, 0x0b /* SIGSEGV */ }, /* instruction access */
6379 + { 0x0500, 0x02 /* SIGINT */ }, /* external interrupt */
6380 + { 0x0600, 0x0a /* SIGBUS */ }, /* alignment */
6381 + { 0x0700, 0x05 /* SIGTRAP */ }, /* program check */
6382 + { 0x0800, 0x08 /* SIGFPE */ }, /* fp unavailable */
6383 + { 0x0900, 0x0e /* SIGALRM */ }, /* decrementer */
6384 + { 0x0c00, 0x14 /* SIGCHLD */ }, /* system call */
6385 +#if defined(CONFIG_40x) || defined(CONFIG_BOOKE)
6386 + { 0x2002, 0x05 /* SIGTRAP */ }, /* debug */
6387 +#if defined(CONFIG_FSL_BOOKE)
6388 + { 0x2010, 0x08 /* SIGFPE */ }, /* spe unavailable */
6389 + { 0x2020, 0x08 /* SIGFPE */ }, /* spe unavailable */
6390 + { 0x2030, 0x08 /* SIGFPE */ }, /* spe fp data */
6391 + { 0x2040, 0x08 /* SIGFPE */ }, /* spe fp data */
6392 + { 0x2050, 0x08 /* SIGFPE */ }, /* spe fp round */
6393 + { 0x2060, 0x0e /* SIGILL */ }, /* performace monitor */
6394 + { 0x2900, 0x08 /* SIGFPE */ }, /* apu unavailable */
6395 + { 0x3100, 0x0e /* SIGALRM */ }, /* fixed interval timer */
6396 + { 0x3200, 0x02 /* SIGINT */ }, /* watchdog */
6398 + { 0x1000, 0x0e /* SIGALRM */ }, /* programmable interval timer */
6399 + { 0x1010, 0x0e /* SIGALRM */ }, /* fixed interval timer */
6400 + { 0x1020, 0x02 /* SIGINT */ }, /* watchdog */
6401 + { 0x2010, 0x08 /* SIGFPE */ }, /* fp unavailable */
6402 + { 0x2020, 0x08 /* SIGFPE */ }, /* ap unavailable */
6405 + { 0x0d00, 0x05 /* SIGTRAP */ }, /* single-step */
6406 +#if defined(CONFIG_8xx)
6407 + { 0x1000, 0x04 /* SIGILL */ }, /* software emulation */
6409 + { 0x0f00, 0x04 /* SIGILL */ }, /* performance monitor */
6410 + { 0x0f20, 0x08 /* SIGFPE */ }, /* altivec unavailable */
6411 + { 0x1300, 0x05 /* SIGTRAP */ }, /* instruction address break */
6412 +#if defined(CONFIG_PPC64)
6413 + { 0x1200, 0x05 /* SIGILL */ }, /* system error */
6414 + { 0x1500, 0x04 /* SIGILL */ }, /* soft patch */
6415 + { 0x1600, 0x04 /* SIGILL */ }, /* maintenance */
6416 + { 0x1700, 0x08 /* SIGFPE */ }, /* altivec assist */
6417 + { 0x1800, 0x04 /* SIGILL */ }, /* thermal */
6419 + { 0x1400, 0x02 /* SIGINT */ }, /* SMI */
6420 + { 0x1600, 0x08 /* SIGFPE */ }, /* altivec assist */
6421 + { 0x1700, 0x04 /* SIGILL */ }, /* TAU */
6422 + { 0x2000, 0x05 /* SIGTRAP */ }, /* run mode */
6426 + { 0x0000, 0x00 } /* Must be last */
6429 +extern atomic_t cpu_doing_single_step;
6431 +static int computeSignal(unsigned int tt)
6433 + struct hard_trap_info *ht;
6435 + for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
6439 + return SIGHUP; /* default for things we don't know about */
6442 +static int kgdb_call_nmi_hook(struct pt_regs *regs)
6444 + kgdb_nmihook(smp_processor_id(), regs);
6449 +void kgdb_roundup_cpus(unsigned long flags)
6451 + smp_send_debugger_break(MSG_ALL_BUT_SELF);
6455 +/* KGDB functions to use existing PowerPC64 hooks. */
6456 +static int kgdb_debugger(struct pt_regs *regs)
6458 + return kgdb_handle_exception(0, computeSignal(TRAP(regs)), 0, regs);
6461 +static int kgdb_breakpoint(struct pt_regs *regs)
6463 + if (user_mode(regs))
6466 + kgdb_handle_exception(0, SIGTRAP, 0, regs);
6468 + if (*(u32 *) (regs->nip) == *(u32 *) (&arch_kgdb_ops.gdb_bpt_instr))
6474 +static int kgdb_singlestep(struct pt_regs *regs)
6476 + struct thread_info *thread_info, *exception_thread_info;
6477 + if (user_mode(regs))
6480 + * On Book E and perhaps other processsors, singlestep is handled on
6481 + * the critical exception stack. This causes current_thread_info()
6482 + * to fail, since it it locates the thread_info by masking off
6483 + * the low bits of the current stack pointer. We work around
6484 + * this issue by copying the thread_info from the kernel stack
6485 + * before calling kgdb_handle_exception, and copying it back
6486 + * afterwards. On most processors the copy is avoided since
6487 + * exception_thread_info == thread_info.
6489 + thread_info = (struct thread_info *)(regs->gpr[1] & ~(THREAD_SIZE-1));
6490 + exception_thread_info = current_thread_info();
6492 + if (thread_info != exception_thread_info)
6493 + memcpy(exception_thread_info, thread_info, sizeof *thread_info);
6495 + kgdb_handle_exception(0, SIGTRAP, 0, regs);
6497 + if (thread_info != exception_thread_info)
6498 + memcpy(thread_info, exception_thread_info, sizeof *thread_info);
6503 +int kgdb_iabr_match(struct pt_regs *regs)
6505 + if (user_mode(regs))
6508 + kgdb_handle_exception(0, computeSignal(TRAP(regs)), 0, regs);
6512 +int kgdb_dabr_match(struct pt_regs *regs)
6514 + if (user_mode(regs))
6517 + kgdb_handle_exception(0, computeSignal(TRAP(regs)), 0, regs);
6521 +#define PACK64(ptr,src) do { *(ptr++) = (src); } while(0)
6523 +#define PACK32(ptr,src) do { \
6525 + ptr32 = (u32 *)ptr; \
6526 + *(ptr32++) = (src); \
6527 + ptr = (unsigned long *)ptr32; \
6530 +void regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs)
6532 + unsigned long *ptr = gdb_regs;
6535 + memset(gdb_regs, 0, NUMREGBYTES);
6537 + for (reg = 0; reg < 32; reg++)
6538 + PACK64(ptr, regs->gpr[reg]);
6540 +#ifdef CONFIG_FSL_BOOKE
6542 + for (reg = 0; reg < 32; reg++)
6543 + PACK64(ptr, current->thread.evr[reg]);
6548 + /* fp registers not used by kernel, leave zero */
6549 + ptr += 32 * 8 / sizeof(long);
6552 + PACK64(ptr, regs->nip);
6553 + PACK64(ptr, regs->msr);
6554 + PACK32(ptr, regs->ccr);
6555 + PACK64(ptr, regs->link);
6556 + PACK64(ptr, regs->ctr);
6557 + PACK32(ptr, regs->xer);
6560 + Following are in struct thread_struct, not struct pt_regs,
6561 + ignoring for now since kernel does not use them. Would it
6562 + make sense to get them from the thread that kgdb is set to?
6564 + If this code is enabled, update the definition of NUMREGBYTES to
6565 + include the vector registers and vector state registers.
6567 + PACK32(ptr, current->thread->fpscr);
6569 + /* vr registers not used by kernel, leave zero */
6570 + ptr += 32 * 16 / sizeof(long);
6572 +#ifdef CONFIG_ALTIVEC
6573 + PACK32(ptr, current->thread->vscr);
6574 + PACK32(ptr, current->thread->vrsave);
6576 + ptr += 2 * 4 / sizeof(long);
6579 +#ifdef CONFIG_FSL_BOOKE
6582 + PACK32(ptr, current->thread.acc >> 32);
6583 + PACK32(ptr, current->thread.acc & 0xffffffff);
6584 + PACK64(ptr, current->thread.spefscr);
6589 + /* fpscr not used by kernel, leave zero */
6594 + BUG_ON((unsigned long)ptr >
6595 + (unsigned long)(((void *)gdb_regs) + NUMREGBYTES));
6598 +void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p)
6600 + struct pt_regs *regs = (struct pt_regs *)(p->thread.ksp +
6601 + STACK_FRAME_OVERHEAD);
6602 + unsigned long *ptr = gdb_regs;
6605 + memset(gdb_regs, 0, NUMREGBYTES);
6608 + for (reg = 0; reg < 3; reg++)
6609 + PACK64(ptr, regs->gpr[reg]);
6611 + /* Regs GPR3-13 are caller saved, not in regs->gpr[] */
6614 + /* Regs GPR14-31 */
6615 + for (reg = 14; reg < 32; reg++)
6616 + PACK64(ptr, regs->gpr[reg]);
6618 +#ifdef CONFIG_FSL_BOOKE
6620 + for (reg = 0; reg < 32; reg++)
6621 + PACK64(ptr, p->thread.evr[reg]);
6626 + /* fp registers not used by kernel, leave zero */
6627 + ptr += 32 * 8 / sizeof(long);
6629 + PACK64(ptr, regs->nip);
6630 + PACK64(ptr, regs->msr);
6631 + PACK32(ptr, regs->ccr);
6632 + PACK64(ptr, regs->link);
6633 + PACK64(ptr, regs->ctr);
6634 + PACK32(ptr, regs->xer);
6637 + Following are in struct thread_struct, not struct pt_regs,
6638 + ignoring for now since kernel does not use them. Would it
6639 + make sense to get them from the thread that kgdb is set to?
6641 + If this code is enabled, update the definition of NUMREGBYTES to
6642 + include the vector registers and vector state registers.
6644 + PACK32(ptr, p->thread->fpscr);
6646 + /* vr registers not used by kernel, leave zero */
6647 + ptr += 32 * 16 / sizeof(long);
6649 +#ifdef CONFIG_ALTIVEC
6650 + PACK32(ptr, p->thread->vscr);
6651 + PACK32(ptr, p->thread->vrsave);
6653 + ptr += 2 * 4 / sizeof(long);
6656 +#ifdef CONFIG_FSL_BOOKE
6659 + PACK32(ptr, p->thread.acc >> 32);
6660 + PACK32(ptr, p->thread.acc & 0xffffffff);
6661 + PACK64(ptr, p->thread.spefscr);
6666 + /* fpscr not used by kernel, leave zero */
6671 + BUG_ON((unsigned long)ptr >
6672 + (unsigned long)(((void *)gdb_regs) + NUMREGBYTES));
6675 +#define UNPACK64(dest,ptr) do { dest = *(ptr++); } while(0)
6677 +#define UNPACK32(dest,ptr) do { \
6679 + ptr32 = (u32 *)ptr; \
6680 + dest = *(ptr32++); \
6681 + ptr = (unsigned long *)ptr32; \
6684 +void gdb_regs_to_regs(unsigned long *gdb_regs, struct pt_regs *regs)
6686 + unsigned long *ptr = gdb_regs;
6695 + for (reg = 0; reg < 32; reg++)
6696 + UNPACK64(regs->gpr[reg], ptr);
6698 +#ifdef CONFIG_FSL_BOOKE
6700 + for (reg = 0; reg < 32; reg++)
6701 + UNPACK64(current->thread.evr[reg], ptr);
6706 + /* fp registers not used by kernel, leave zero */
6707 + ptr += 32 * 8 / sizeof(int);
6709 + UNPACK64(regs->nip, ptr);
6710 + UNPACK64(regs->msr, ptr);
6711 + UNPACK32(regs->ccr, ptr);
6712 + UNPACK64(regs->link, ptr);
6713 + UNPACK64(regs->ctr, ptr);
6714 + UNPACK32(regs->xer, ptr);
6717 + Following are in struct thread_struct, not struct pt_regs,
6718 + ignoring for now since kernel does not use them. Would it
6719 + make sense to get them from the thread that kgdb is set to?
6721 + If this code is enabled, update the definition of NUMREGBYTES to
6722 + include the vector registers and vector state registers.
6724 + /* fpscr, vscr, vrsave not used by kernel, leave unchanged */
6726 + UNPACK32(current->thread->fpscr, ptr);
6728 + /* vr registers not used by kernel, leave zero */
6729 + ptr += 32 * 16 / sizeof(long);
6731 + #ifdef CONFIG_ALTIVEC
6732 + UNPACK32(current->thread->vscr, ptr);
6733 + UNPACK32(current->thread->vrsave, ptr);
6735 + ptr += 2 * 4 / sizeof(long);
6738 +#ifdef CONFIG_FSL_BOOKE
6741 + UNPACK32(acc.v32[0], ptr);
6742 + UNPACK32(acc.v32[1], ptr);
6743 + current->thread.acc = acc.v64;
6744 + UNPACK64(current->thread.spefscr, ptr);
6751 + BUG_ON((unsigned long)ptr >
6752 + (unsigned long)(((void *)gdb_regs) + NUMREGBYTES));
6756 + * This function does PowerPC specific procesing for interfacing to gdb.
6758 +int kgdb_arch_handle_exception(int vector, int signo, int err_code,
6759 + char *remcom_in_buffer, char *remcom_out_buffer,
6760 + struct pt_regs *linux_regs)
6762 + char *ptr = &remcom_in_buffer[1];
6763 + unsigned long addr;
6765 + switch (remcom_in_buffer[0]) {
6767 + * sAA..AA Step one instruction from AA..AA
6768 + * This will return an error to gdb ..
6772 + /* handle the optional parameter */
6773 + if (kgdb_hex2long(&ptr, &addr))
6774 + linux_regs->nip = addr;
6776 + atomic_set(&cpu_doing_single_step, -1);
6777 + /* set the trace bit if we're stepping */
6778 + if (remcom_in_buffer[0] == 's') {
6779 +#if defined(CONFIG_40x) || defined(CONFIG_BOOKE)
6781 + mfspr(SPRN_DBCR0) | DBCR0_IC | DBCR0_IDM);
6782 + linux_regs->msr |= MSR_DE;
6784 + linux_regs->msr |= MSR_SE;
6786 + debugger_step = 1;
6787 + if (kgdb_contthread)
6788 + atomic_set(&cpu_doing_single_step,
6789 + smp_processor_id());
6797 +int kgdb_fault_setjmp(unsigned long *curr_context)
6799 +#ifdef CONFIG_PPC32
6800 + __asm__ __volatile__("mflr 0; stw 0,0(%0);\n\
6801 + stw 1,4(%0); stw 2,8(%0);\n\
6802 + mfcr 0; stw 0,12(%0);\n\
6803 + stmw 13,16(%0)\n" : : "r" (curr_context));
6805 + __asm__ __volatile__("mflr 0; std 0,0(%0)\n\
6808 + mfcr 0; std 0,24(%0)\n\
6827 + std 31,176(%0)\n" : : "r" (curr_context));
6832 +void kgdb_fault_longjmp(unsigned long *curr_context)
6834 +#ifdef CONFIG_PPC32
6835 + __asm__ __volatile__("lmw 13,16(%0);\n\
6836 + lwz 0,12(%0); mtcrf 0x38,0;\n\
6837 + lwz 0,0(%0); lwz 1,4(%0); lwz 2,8(%0);\n\
6838 + mtlr 0; mr 3,1\n" : : "r" (curr_context));
6840 + __asm__ __volatile__("ld 13,32(%0)\n\
6865 + mr 3,1\n" : : "r" (curr_context));
6872 +struct kgdb_arch arch_kgdb_ops = {
6873 + .gdb_bpt_instr = {0x7d, 0x82, 0x10, 0x08},
6876 +int kgdb_not_implemented(struct pt_regs *regs)
6881 +int kgdb_arch_init(void)
6884 +#error Both XMON and KGDB selected in .config. Unselect one of them.
6887 + __debugger_ipi = kgdb_call_nmi_hook;
6888 + __debugger = kgdb_debugger;
6889 + __debugger_bpt = kgdb_breakpoint;
6890 + __debugger_sstep = kgdb_singlestep;
6891 + __debugger_iabr_match = kgdb_iabr_match;
6892 + __debugger_dabr_match = kgdb_dabr_match;
6893 + __debugger_fault_handler = kgdb_not_implemented;
6898 +arch_initcall(kgdb_arch_init);
6899 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/powerpc/kernel/legacy_serial.c linux-2.6.18-53.1.14.kgdb/arch/powerpc/kernel/legacy_serial.c
6900 --- linux-2.6.18-53.1.14/arch/powerpc/kernel/legacy_serial.c 2008-03-06 05:54:47.000000000 +0300
6901 +++ linux-2.6.18-53.1.14.kgdb/arch/powerpc/kernel/legacy_serial.c 2008-06-10 15:38:14.000000000 +0400
6903 #include <asm/udbg.h>
6904 #include <asm/pci-bridge.h>
6905 #include <asm/ppc-pci.h>
6906 +#ifdef CONFIG_KGDB_8250
6907 +#include <linux/kgdb.h>
6912 @@ -485,6 +488,9 @@ static int __init serial_dev_init(void)
6913 fixup_port_pio(i, np, port);
6914 if ((port->iotype == UPIO_MEM) || (port->iotype == UPIO_TSI))
6915 fixup_port_mmio(i, np, port);
6916 +#ifdef CONFIG_KGDB_8250
6917 + kgdb8250_add_platform_port(i, port);
6921 DBG("Registering platform serial ports\n");
6922 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/powerpc/kernel/setup_32.c linux-2.6.18-53.1.14.kgdb/arch/powerpc/kernel/setup_32.c
6923 --- linux-2.6.18-53.1.14/arch/powerpc/kernel/setup_32.c 2008-03-06 05:54:45.000000000 +0300
6924 +++ linux-2.6.18-53.1.14.kgdb/arch/powerpc/kernel/setup_32.c 2008-06-10 15:38:14.000000000 +0400
6929 -#if defined CONFIG_KGDB
6930 -#include <asm/kgdb.h>
6933 extern void bootx_init(unsigned long r4, unsigned long phys);
6935 struct ide_machdep_calls ppc_ide_md;
6936 @@ -251,18 +247,6 @@ void __init setup_arch(char **cmdline_p)
6940 -#if defined(CONFIG_KGDB)
6941 - if (ppc_md.kgdb_map_scc)
6942 - ppc_md.kgdb_map_scc();
6943 - set_debug_traps();
6944 - if (strstr(cmd_line, "gdb")) {
6945 - if (ppc_md.progress)
6946 - ppc_md.progress("setup_arch: kgdb breakpoint", 0x4000);
6947 - printk("kgdb breakpoint activated\n");
6953 * Set cache line size based on type of cpu as a default.
6954 * Systems with OF can look in the properties on the cpu node(s)
6955 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/powerpc/mm/fault.c linux-2.6.18-53.1.14.kgdb/arch/powerpc/mm/fault.c
6956 --- linux-2.6.18-53.1.14/arch/powerpc/mm/fault.c 2006-09-20 07:42:06.000000000 +0400
6957 +++ linux-2.6.18-53.1.14.kgdb/arch/powerpc/mm/fault.c 2008-06-10 15:38:14.000000000 +0400
6959 #include <linux/highmem.h>
6960 #include <linux/module.h>
6961 #include <linux/kprobes.h>
6962 +#include <linux/kgdb.h>
6964 #include <asm/page.h>
6965 #include <asm/pgtable.h>
6966 @@ -424,6 +425,13 @@ void bad_page_fault(struct pt_regs *regs
6971 + if (atomic_read(&debugger_active) && kgdb_may_fault)
6972 + /* Restore our previous state. */
6973 + kgdb_fault_longjmp(kgdb_fault_jmp_regs);
6974 + /* Not reached. */
6977 /* kernel has accessed a bad area */
6979 printk(KERN_ALERT "Unable to handle kernel paging request for ");
6980 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/powerpc/platforms/powermac/setup.c linux-2.6.18-53.1.14.kgdb/arch/powerpc/platforms/powermac/setup.c
6981 --- linux-2.6.18-53.1.14/arch/powerpc/platforms/powermac/setup.c 2006-09-20 07:42:06.000000000 +0400
6982 +++ linux-2.6.18-53.1.14.kgdb/arch/powerpc/platforms/powermac/setup.c 2008-06-10 15:38:14.000000000 +0400
6983 @@ -98,8 +98,6 @@ extern struct machdep_calls pmac_md;
6987 -extern void zs_kgdb_hook(int tty_num);
6989 sys_ctrler_t sys_ctrler = SYS_CTRLER_UNKNOWN;
6990 EXPORT_SYMBOL(sys_ctrler);
6992 @@ -319,10 +317,6 @@ static void __init pmac_setup_arch(void)
6994 #endif /* CONFIG_PPC32 */
7003 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ppc/Kconfig.debug linux-2.6.18-53.1.14.kgdb/arch/ppc/Kconfig.debug
7004 --- linux-2.6.18-53.1.14/arch/ppc/Kconfig.debug 2006-09-20 07:42:06.000000000 +0400
7005 +++ linux-2.6.18-53.1.14.kgdb/arch/ppc/Kconfig.debug 2008-06-10 15:38:14.000000000 +0400
7006 @@ -2,42 +2,6 @@ menu "Kernel hacking"
7008 source "lib/Kconfig.debug"
7011 - bool "Include kgdb kernel debugger"
7012 - depends on DEBUG_KERNEL && (BROKEN || PPC_GEN550 || 4xx)
7015 - Include in-kernel hooks for kgdb, the Linux kernel source level
7016 - debugger. See <http://kgdb.sourceforge.net/> for more information.
7017 - Unless you are intending to debug the kernel, say N here.
7020 - prompt "Serial Port"
7022 - default KGDB_TTYS1
7038 -config KGDB_CONSOLE
7039 - bool "Enable serial console thru kgdb port"
7040 - depends on KGDB && 8xx || CPM2
7042 - If you enable this, all serial console messages will be sent
7043 - over the gdb stub.
7047 bool "Include xmon kernel debugger"
7048 depends on DEBUG_KERNEL
7049 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ppc/kernel/kgdb.c linux-2.6.18-53.1.14.kgdb/arch/ppc/kernel/kgdb.c
7050 --- linux-2.6.18-53.1.14/arch/ppc/kernel/kgdb.c 1970-01-01 03:00:00.000000000 +0300
7051 +++ linux-2.6.18-53.1.14.kgdb/arch/ppc/kernel/kgdb.c 2008-06-10 15:39:34.000000000 +0400
7054 + * arch/ppc/kernel/kgdb.c
7056 + * PowerPC backend to the KGDB stub.
7058 + * Maintainer: Tom Rini <trini@kernel.crashing.org>
7060 + * 1998 (c) Michael AK Tesch (tesch@cs.wisc.edu)
7061 + * Copyright (C) 2003 Timesys Corporation.
7062 + * 2004 (c) MontaVista Software, Inc.
7064 + * This file is licensed under the terms of the GNU General Public License
7065 + * version 2. This program as licensed "as is" without any warranty of any
7066 + * kind, whether express or implied.
7069 +#include <linux/config.h>
7070 +#include <linux/kernel.h>
7071 +#include <linux/init.h>
7072 +#include <linux/kgdb.h>
7073 +#include <linux/smp.h>
7074 +#include <linux/signal.h>
7075 +#include <linux/ptrace.h>
7076 +#include <asm/current.h>
7077 +#include <asm/ptrace.h>
7078 +#include <asm/processor.h>
7079 +#include <asm/machdep.h>
7082 + * This table contains the mapping between PowerPC hardware trap types, and
7083 + * signals, which are primarily what GDB understands. GDB and the kernel
7084 + * don't always agree on values, so we use constants taken from gdb-6.2.
7086 +static struct hard_trap_info
7088 + unsigned int tt; /* Trap type code for powerpc */
7089 + unsigned char signo; /* Signal that we map this trap into */
7090 +} hard_trap_info[] = {
7091 +#if defined(CONFIG_40x) || defined(CONFIG_BOOKE)
7092 + { 0x0100, 0x02 /* SIGINT */ }, /* critical input interrupt */
7093 + { 0x0200, 0x0b /* SIGSEGV */ }, /* machine check */
7094 + { 0x0300, 0x0b /* SIGSEGV */ }, /* data storage */
7095 + { 0x0400, 0x0a /* SIGBUS */ }, /* instruction storage */
7096 + { 0x0500, 0x02 /* SIGINT */ }, /* interrupt */
7097 + { 0x0600, 0x0a /* SIGBUS */ }, /* alignment */
7098 + { 0x0700, 0x04 /* SIGILL */ }, /* program */
7099 + { 0x0800, 0x04 /* SIGILL */ }, /* reserved */
7100 + { 0x0900, 0x04 /* SIGILL */ }, /* reserved */
7101 + { 0x0a00, 0x04 /* SIGILL */ }, /* reserved */
7102 + { 0x0b00, 0x04 /* SIGILL */ }, /* reserved */
7103 + { 0x0c00, 0x14 /* SIGCHLD */ }, /* syscall */
7104 + { 0x0d00, 0x04 /* SIGILL */ }, /* reserved */
7105 + { 0x0e00, 0x04 /* SIGILL */ }, /* reserved */
7106 + { 0x0f00, 0x04 /* SIGILL */ }, /* reserved */
7107 + { 0x2002, 0x05 /* SIGTRAP */}, /* debug */
7109 + { 0x0200, 0x0b /* SIGSEGV */ }, /* machine check */
7110 + { 0x0300, 0x0b /* SIGSEGV */ }, /* address error (store) */
7111 + { 0x0400, 0x0a /* SIGBUS */ }, /* instruction bus error */
7112 + { 0x0500, 0x02 /* SIGINT */ }, /* interrupt */
7113 + { 0x0600, 0x0a /* SIGBUS */ }, /* alingment */
7114 + { 0x0700, 0x05 /* SIGTRAP */ }, /* breakpoint trap */
7115 + { 0x0800, 0x08 /* SIGFPE */}, /* fpu unavail */
7116 + { 0x0900, 0x0e /* SIGALRM */ }, /* decrementer */
7117 + { 0x0a00, 0x04 /* SIGILL */ }, /* reserved */
7118 + { 0x0b00, 0x04 /* SIGILL */ }, /* reserved */
7119 + { 0x0c00, 0x14 /* SIGCHLD */ }, /* syscall */
7120 + { 0x0d00, 0x05 /* SIGTRAP */ }, /* single-step/watch */
7121 + { 0x0e00, 0x08 /* SIGFPE */ }, /* fp assist */
7123 + { 0x0000, 0x000 } /* Must be last */
7126 +extern atomic_t cpu_doing_single_step;
7128 +static int computeSignal(unsigned int tt)
7130 + struct hard_trap_info *ht;
7132 + for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
7136 + return SIGHUP; /* default for things we don't know about */
7139 +/* KGDB functions to use existing PowerPC hooks. */
7140 +static void kgdb_debugger(struct pt_regs *regs)
7142 + kgdb_handle_exception(0, computeSignal(TRAP(regs)), 0, regs);
7145 +static int kgdb_breakpoint(struct pt_regs *regs)
7147 + if (user_mode(regs))
7150 + kgdb_handle_exception(0, SIGTRAP, 0, regs);
7152 + if (*(u32 *) (regs->nip) == *(u32 *) (&arch_kgdb_ops.gdb_bpt_instr))
7158 +static int kgdb_singlestep(struct pt_regs *regs)
7160 + struct thread_info *thread_info, *exception_thread_info;
7162 + if (user_mode(regs))
7165 + * On Book E and perhaps other processsors, singlestep is handled on
7166 + * the critical exception stack. This causes current_thread_info()
7167 + * to fail, since it it locates the thread_info by masking off
7168 + * the low bits of the current stack pointer. We work around
7169 + * this issue by copying the thread_info from the kernel stack
7170 + * before calling kgdb_handle_exception, and copying it back
7171 + * afterwards. On most processors the copy is avoided since
7172 + * exception_thread_info == thread_info.
7174 + thread_info = (struct thread_info *)(regs->gpr[1] & ~(THREAD_SIZE-1));
7175 + exception_thread_info = current_thread_info();
7177 + if (thread_info != exception_thread_info)
7178 + memcpy(exception_thread_info, thread_info, sizeof *thread_info);
7180 + kgdb_handle_exception(0, SIGTRAP, 0, regs);
7182 + if (thread_info != exception_thread_info)
7183 + memcpy(thread_info, exception_thread_info, sizeof *thread_info);
7188 +int kgdb_iabr_match(struct pt_regs *regs)
7190 + if (user_mode(regs))
7193 + kgdb_handle_exception(0, computeSignal(TRAP(regs)), 0, regs);
7197 +int kgdb_dabr_match(struct pt_regs *regs)
7199 + if (user_mode(regs))
7202 + kgdb_handle_exception(0, computeSignal(TRAP(regs)), 0, regs);
7206 +void regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs)
7209 + unsigned long *ptr = gdb_regs;
7211 + memset(gdb_regs, 0, MAXREG * 4);
7213 + for (reg = 0; reg < 32; reg++)
7214 + *(ptr++) = regs->gpr[reg];
7216 +#ifndef CONFIG_E500
7217 + for (reg = 0; reg < 64; reg++)
7220 + for (reg = 0; reg < 32; reg++)
7221 + *(ptr++) = current->thread.evr[reg];
7224 + *(ptr++) = regs->nip;
7225 + *(ptr++) = regs->msr;
7226 + *(ptr++) = regs->ccr;
7227 + *(ptr++) = regs->link;
7228 + *(ptr++) = regs->ctr;
7229 + *(ptr++) = regs->xer;
7233 + *(ptr++) = (current->thread.acc >> 32);
7234 + *(ptr++) = (current->thread.acc & 0xffffffff);
7235 + *(ptr++) = current->thread.spefscr;
7239 +void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p)
7241 + struct pt_regs *regs = (struct pt_regs *)(p->thread.ksp +
7242 + STACK_FRAME_OVERHEAD);
7244 + unsigned long *ptr = gdb_regs;
7246 + memset(gdb_regs, 0, MAXREG * 4);
7249 + for (reg = 0; reg < 3; reg++)
7250 + *(ptr++) = regs->gpr[reg];
7252 + /* Regs GPR3-13 are not saved */
7253 + for (reg = 3; reg < 14; reg++)
7256 + /* Regs GPR14-31 */
7257 + for (reg = 14; reg < 32; reg++)
7258 + *(ptr++) = regs->gpr[reg];
7260 +#ifndef CONFIG_E500
7261 + for (reg = 0; reg < 64; reg++)
7264 + for (reg = 0; reg < 32; reg++)
7265 + *(ptr++) = current->thread.evr[reg];
7268 + *(ptr++) = regs->nip;
7269 + *(ptr++) = regs->msr;
7270 + *(ptr++) = regs->ccr;
7271 + *(ptr++) = regs->link;
7272 + *(ptr++) = regs->ctr;
7273 + *(ptr++) = regs->xer;
7277 + *(ptr++) = (current->thread.acc >> 32);
7278 + *(ptr++) = (current->thread.acc & 0xffffffff);
7279 + *(ptr++) = current->thread.spefscr;
7283 +void gdb_regs_to_regs(unsigned long *gdb_regs, struct pt_regs *regs)
7286 + unsigned long *ptr = gdb_regs;
7294 + for (reg = 0; reg < 32; reg++)
7295 + regs->gpr[reg] = *(ptr++);
7297 +#ifndef CONFIG_E500
7298 + for (reg = 0; reg < 64; reg++)
7301 + for (reg = 0; reg < 32; reg++)
7302 + current->thread.evr[reg] = *(ptr++);
7305 + regs->nip = *(ptr++);
7306 + regs->msr = *(ptr++);
7307 + regs->ccr = *(ptr++);
7308 + regs->link = *(ptr++);
7309 + regs->ctr = *(ptr++);
7310 + regs->xer = *(ptr++);
7314 + u.v32[0] = *(ptr++);
7315 + u.v32[1] = *(ptr++);
7316 + current->thread.acc = u.v64;
7317 + current->thread.spefscr = *(ptr++);
7322 + * Save/restore state in case a memory access causes a fault.
7324 +int kgdb_fault_setjmp(unsigned long *curr_context)
7326 + __asm__ __volatile__("mflr 0; stw 0,0(%0);"
7327 + "stw 1,4(%0); stw 2,8(%0);"
7328 + "mfcr 0; stw 0,12(%0);"
7329 + "stmw 13,16(%0)"::"r"(curr_context));
7333 +void kgdb_fault_longjmp(unsigned long *curr_context)
7335 + __asm__ __volatile__("lmw 13,16(%0);"
7336 + "lwz 0,12(%0); mtcrf 0x38,0;"
7337 + "lwz 0,0(%0); lwz 1,4(%0); lwz 2,8(%0);"
7338 + "mtlr 0; mr 3,1"::"r"(curr_context));
7342 + * This function does PoerPC specific procesing for interfacing to gdb.
7344 +int kgdb_arch_handle_exception(int vector, int signo, int err_code,
7345 + char *remcom_in_buffer, char *remcom_out_buffer,
7346 + struct pt_regs *linux_regs)
7348 + char *ptr = &remcom_in_buffer[1];
7349 + unsigned long addr;
7351 + switch (remcom_in_buffer[0])
7354 + * sAA..AA Step one instruction from AA..AA
7355 + * This will return an error to gdb ..
7359 + /* handle the optional parameter */
7360 + if (kgdb_hex2long (&ptr, &addr))
7361 + linux_regs->nip = addr;
7363 + atomic_set(&cpu_doing_single_step, -1);
7364 + /* set the trace bit if we're stepping */
7365 + if (remcom_in_buffer[0] == 's') {
7366 +#if defined (CONFIG_40x) || defined(CONFIG_BOOKE)
7367 + mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) |
7368 + DBCR0_IC | DBCR0_IDM);
7369 + linux_regs->msr |= MSR_DE;
7371 + linux_regs->msr |= MSR_SE;
7373 + debugger_step = 1;
7374 + if (kgdb_contthread)
7375 + atomic_set(&cpu_doing_single_step,
7376 + smp_processor_id());
7387 +struct kgdb_arch arch_kgdb_ops = {
7388 + .gdb_bpt_instr = {0x7d, 0x82, 0x10, 0x08},
7391 +int kgdb_arch_init(void)
7393 + debugger = kgdb_debugger;
7394 + debugger_bpt = kgdb_breakpoint;
7395 + debugger_sstep = kgdb_singlestep;
7396 + debugger_iabr_match = kgdb_iabr_match;
7397 + debugger_dabr_match = kgdb_dabr_match;
7402 +arch_initcall(kgdb_arch_init);
7403 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ppc/kernel/ppc-stub.c linux-2.6.18-53.1.14.kgdb/arch/ppc/kernel/ppc-stub.c
7404 --- linux-2.6.18-53.1.14/arch/ppc/kernel/ppc-stub.c 2006-09-20 07:42:06.000000000 +0400
7405 +++ linux-2.6.18-53.1.14.kgdb/arch/ppc/kernel/ppc-stub.c 1970-01-01 03:00:00.000000000 +0300
7408 - * ppc-stub.c: KGDB support for the Linux kernel.
7410 - * adapted from arch/sparc/kernel/sparc-stub.c for the PowerPC
7411 - * some stuff borrowed from Paul Mackerras' xmon
7412 - * Copyright (C) 1998 Michael AK Tesch (tesch@cs.wisc.edu)
7414 - * Modifications to run under Linux
7415 - * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
7417 - * This file originally came from the gdb sources, and the
7418 - * copyright notices have been retained below.
7421 -/****************************************************************************
7423 - THIS SOFTWARE IS NOT COPYRIGHTED
7425 - HP offers the following for use in the public domain. HP makes no
7426 - warranty with regard to the software or its performance and the
7427 - user accepts the software "AS IS" with all faults.
7429 - HP DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD
7430 - TO THIS SOFTWARE INCLUDING BUT NOT LIMITED TO THE WARRANTIES
7431 - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
7433 -****************************************************************************/
7435 -/****************************************************************************
7436 - * Header: remcom.c,v 1.34 91/03/09 12:29:49 glenne Exp $
7438 - * Module name: remcom.c $
7439 - * Revision: 1.34 $
7440 - * Date: 91/03/09 12:29:49 $
7441 - * Contributor: Lake Stevens Instrument Division$
7443 - * Description: low level support for gdb debugger. $
7445 - * Considerations: only works on target hardware $
7447 - * Written by: Glenn Engel $
7448 - * ModuleState: Experimental $
7450 - * NOTES: See Below $
7452 - * Modified for SPARC by Stu Grossman, Cygnus Support.
7454 - * This code has been extensively tested on the Fujitsu SPARClite demo board.
7456 - * To enable debugger support, two things need to happen. One, a
7457 - * call to set_debug_traps() is necessary in order to allow any breakpoints
7458 - * or error conditions to be properly intercepted and reported to gdb.
7459 - * Two, a breakpoint needs to be generated to begin communication. This
7460 - * is most easily accomplished by a call to breakpoint(). Breakpoint()
7461 - * simulates a breakpoint by executing a trap #1.
7465 - * The following gdb commands are supported:
7467 - * command function Return value
7469 - * g return the value of the CPU registers hex data or ENN
7470 - * G set the value of the CPU registers OK or ENN
7471 - * qOffsets Get section offsets. Reply is Text=xxx;Data=yyy;Bss=zzz
7473 - * mAA..AA,LLLL Read LLLL bytes at address AA..AA hex data or ENN
7474 - * MAA..AA,LLLL: Write LLLL bytes at address AA.AA OK or ENN
7476 - * c Resume at current address SNN ( signal NN)
7477 - * cAA..AA Continue at address AA..AA SNN
7479 - * s Step one instruction SNN
7480 - * sAA..AA Step one instruction from AA..AA SNN
7484 - * ? What was the last sigval ? SNN (signal NN)
7486 - * bBB..BB Set baud rate to BB..BB OK or BNN, then sets
7489 - * All commands and responses are sent with a packet which includes a
7490 - * checksum. A packet consists of
7492 - * $<packet info>#<checksum>.
7495 - * <packet info> :: <characters representing the command or response>
7496 - * <checksum> :: <two hex digits computed as modulo 256 sum of <packetinfo>>
7498 - * When a packet is received, it is first acknowledged with either '+' or '-'.
7499 - * '+' indicates a successful transfer. '-' indicates a failed transfer.
7504 - * $m0,10#2a +$00010203040506070809101112131415#42
7506 - ****************************************************************************/
7508 -#include <linux/kernel.h>
7509 -#include <linux/string.h>
7510 -#include <linux/mm.h>
7511 -#include <linux/smp.h>
7512 -#include <linux/smp_lock.h>
7513 -#include <linux/init.h>
7514 -#include <linux/sysrq.h>
7516 -#include <asm/cacheflush.h>
7517 -#include <asm/system.h>
7518 -#include <asm/signal.h>
7519 -#include <asm/kgdb.h>
7520 -#include <asm/pgtable.h>
7521 -#include <asm/ptrace.h>
7523 -void breakinst(void);
7526 - * BUFMAX defines the maximum number of characters in inbound/outbound buffers
7527 - * at least NUMREGBYTES*2 are needed for register packets
7529 -#define BUFMAX 2048
7530 -static char remcomInBuffer[BUFMAX];
7531 -static char remcomOutBuffer[BUFMAX];
7533 -static int initialized;
7534 -static int kgdb_active;
7535 -static int kgdb_started;
7536 -static u_int fault_jmp_buf[100];
7540 -static const char hexchars[]="0123456789abcdef";
7542 -/* Place where we save old trap entries for restoration - sparc*/
7543 -/* struct tt_entry kgdb_savettable[256]; */
7544 -/* typedef void (*trapfunc_t)(void); */
7546 -static void kgdb_fault_handler(struct pt_regs *regs);
7547 -static int handle_exception (struct pt_regs *regs);
7550 -/* Install an exception handler for kgdb */
7551 -static void exceptionHandler(int tnum, unsigned int *tfunc)
7553 - /* We are dorking with a live trap table, all irqs off */
7558 -kgdb_setjmp(long *buf)
7560 - asm ("mflr 0; stw 0,0(%0);"
7561 - "stw 1,4(%0); stw 2,8(%0);"
7562 - "mfcr 0; stw 0,12(%0);"
7565 - /* XXX should save fp regs as well */
7569 -kgdb_longjmp(long *buf, int val)
7573 - asm ("lmw 13,16(%0);"
7574 - "lwz 0,12(%0); mtcrf 0x38,0;"
7575 - "lwz 0,0(%0); lwz 1,4(%0); lwz 2,8(%0);"
7577 - : : "r" (buf), "r" (val));
7579 -/* Convert ch from a hex digit to an int */
7581 -hex(unsigned char ch)
7583 - if (ch >= 'a' && ch <= 'f')
7585 - if (ch >= '0' && ch <= '9')
7587 - if (ch >= 'A' && ch <= 'F')
7592 -/* Convert the memory pointed to by mem into hex, placing result in buf.
7593 - * Return a pointer to the last char put in buf (null), in case of mem fault,
7596 -static unsigned char *
7597 -mem2hex(const char *mem, char *buf, int count)
7600 - unsigned short tmp_s;
7601 - unsigned long tmp_l;
7603 - if (kgdb_setjmp((long*)fault_jmp_buf) == 0) {
7604 - debugger_fault_handler = kgdb_fault_handler;
7606 - /* Accessing 16 bit and 32 bit objects in a single
7607 - ** load instruction is required to avoid bad side
7608 - ** effects for some IO registers.
7611 - if ((count == 2) && (((long)mem & 1) == 0)) {
7612 - tmp_s = *(unsigned short *)mem;
7614 - *buf++ = hexchars[(tmp_s >> 12) & 0xf];
7615 - *buf++ = hexchars[(tmp_s >> 8) & 0xf];
7616 - *buf++ = hexchars[(tmp_s >> 4) & 0xf];
7617 - *buf++ = hexchars[tmp_s & 0xf];
7619 - } else if ((count == 4) && (((long)mem & 3) == 0)) {
7620 - tmp_l = *(unsigned int *)mem;
7622 - *buf++ = hexchars[(tmp_l >> 28) & 0xf];
7623 - *buf++ = hexchars[(tmp_l >> 24) & 0xf];
7624 - *buf++ = hexchars[(tmp_l >> 20) & 0xf];
7625 - *buf++ = hexchars[(tmp_l >> 16) & 0xf];
7626 - *buf++ = hexchars[(tmp_l >> 12) & 0xf];
7627 - *buf++ = hexchars[(tmp_l >> 8) & 0xf];
7628 - *buf++ = hexchars[(tmp_l >> 4) & 0xf];
7629 - *buf++ = hexchars[tmp_l & 0xf];
7632 - while (count-- > 0) {
7634 - *buf++ = hexchars[ch >> 4];
7635 - *buf++ = hexchars[ch & 0xf];
7640 - /* error condition */
7642 - debugger_fault_handler = NULL;
7647 -/* convert the hex array pointed to by buf into binary to be placed in mem
7648 - * return a pointer to the character AFTER the last byte written.
7651 -hex2mem(char *buf, char *mem, int count)
7656 - unsigned short tmp_s;
7657 - unsigned long tmp_l;
7661 - if (kgdb_setjmp((long*)fault_jmp_buf) == 0) {
7662 - debugger_fault_handler = kgdb_fault_handler;
7664 - /* Accessing 16 bit and 32 bit objects in a single
7665 - ** store instruction is required to avoid bad side
7666 - ** effects for some IO registers.
7669 - if ((count == 2) && (((long)mem & 1) == 0)) {
7670 - tmp_s = hex(*buf++) << 12;
7671 - tmp_s |= hex(*buf++) << 8;
7672 - tmp_s |= hex(*buf++) << 4;
7673 - tmp_s |= hex(*buf++);
7675 - *(unsigned short *)mem = tmp_s;
7678 - } else if ((count == 4) && (((long)mem & 3) == 0)) {
7679 - tmp_l = hex(*buf++) << 28;
7680 - tmp_l |= hex(*buf++) << 24;
7681 - tmp_l |= hex(*buf++) << 20;
7682 - tmp_l |= hex(*buf++) << 16;
7683 - tmp_l |= hex(*buf++) << 12;
7684 - tmp_l |= hex(*buf++) << 8;
7685 - tmp_l |= hex(*buf++) << 4;
7686 - tmp_l |= hex(*buf++);
7688 - *(unsigned long *)mem = tmp_l;
7692 - for (i=0; i<count; i++) {
7693 - ch = hex(*buf++) << 4;
7694 - ch |= hex(*buf++);
7701 - ** Flush the data cache, invalidate the instruction cache.
7703 - flush_icache_range((int)orig_mem, (int)orig_mem + count - 1);
7706 - /* error condition */
7708 - debugger_fault_handler = NULL;
7713 - * While we find nice hex chars, build an int.
7714 - * Return number of chars processed.
7717 -hexToInt(char **ptr, int *intValue)
7724 - if (kgdb_setjmp((long*)fault_jmp_buf) == 0) {
7725 - debugger_fault_handler = kgdb_fault_handler;
7727 - hexValue = hex(**ptr);
7731 - *intValue = (*intValue << 4) | hexValue;
7737 - /* error condition */
7739 - debugger_fault_handler = NULL;
7741 - return (numChars);
7744 -/* scan for the sequence $<data>#<checksum> */
7746 -getpacket(char *buffer)
7748 - unsigned char checksum;
7749 - unsigned char xmitcsum;
7755 - /* wait around for the start character, ignore all other
7757 - while ((ch = (getDebugChar() & 0x7f)) != '$') ;
7764 - /* now, read until a # or end of buffer is found */
7765 - while (count < BUFMAX) {
7766 - ch = getDebugChar() & 0x7f;
7769 - checksum = checksum + ch;
7770 - buffer[count] = ch;
7771 - count = count + 1;
7774 - if (count >= BUFMAX)
7777 - buffer[count] = 0;
7780 - xmitcsum = hex(getDebugChar() & 0x7f) << 4;
7781 - xmitcsum |= hex(getDebugChar() & 0x7f);
7782 - if (checksum != xmitcsum)
7783 - putDebugChar('-'); /* failed checksum */
7785 - putDebugChar('+'); /* successful transfer */
7786 - /* if a sequence char is present, reply the ID */
7787 - if (buffer[2] == ':') {
7788 - putDebugChar(buffer[0]);
7789 - putDebugChar(buffer[1]);
7790 - /* remove sequence chars from buffer */
7791 - count = strlen(buffer);
7792 - for (i=3; i <= count; i++)
7793 - buffer[i-3] = buffer[i];
7797 - } while (checksum != xmitcsum);
7800 -/* send the packet in buffer. */
7801 -static void putpacket(unsigned char *buffer)
7803 - unsigned char checksum;
7805 - unsigned char ch, recv;
7807 - /* $<packet info>#<checksum>. */
7809 - putDebugChar('$');
7813 - while ((ch = buffer[count])) {
7819 - putDebugChar('#');
7820 - putDebugChar(hexchars[checksum >> 4]);
7821 - putDebugChar(hexchars[checksum & 0xf]);
7822 - recv = getDebugChar();
7823 - } while ((recv & 0x7f) != '+');
7826 -static void kgdb_flush_cache_all(void)
7828 - flush_instruction_cache();
7831 -/* Set up exception handlers for tracing and breakpoints
7832 - * [could be called kgdb_init()]
7834 -void set_debug_traps(void)
7839 - save_and_cli(flags);
7841 - /* In case GDB is started before us, ack any packets (presumably
7842 - * "$?#xx") sitting there.
7844 - * I've found this code causes more problems than it solves,
7845 - * so that's why it's commented out. GDB seems to work fine
7846 - * now starting either before or after the kernel -bwb
7849 - while((c = getDebugChar()) != '$');
7850 - while((c = getDebugChar()) != '#');
7851 - c = getDebugChar(); /* eat first csum byte */
7852 - c = getDebugChar(); /* eat second csum byte */
7853 - putDebugChar('+'); /* ack it */
7856 - debugger_bpt = kgdb_bpt;
7857 - debugger_sstep = kgdb_sstep;
7858 - debugger_iabr_match = kgdb_iabr_match;
7859 - debugger_dabr_match = kgdb_dabr_match;
7864 -static void kgdb_fault_handler(struct pt_regs *regs)
7866 - kgdb_longjmp((long*)fault_jmp_buf, 1);
7869 -int kgdb_bpt(struct pt_regs *regs)
7871 - return handle_exception(regs);
7874 -int kgdb_sstep(struct pt_regs *regs)
7876 - return handle_exception(regs);
7879 -void kgdb(struct pt_regs *regs)
7881 - handle_exception(regs);
7884 -int kgdb_iabr_match(struct pt_regs *regs)
7886 - printk(KERN_ERR "kgdb doesn't support iabr, what?!?\n");
7887 - return handle_exception(regs);
7890 -int kgdb_dabr_match(struct pt_regs *regs)
7892 - printk(KERN_ERR "kgdb doesn't support dabr, what?!?\n");
7893 - return handle_exception(regs);
7896 -/* Convert the hardware trap type code to a unix signal number. */
7898 - * This table contains the mapping between PowerPC hardware trap types, and
7899 - * signals, which are primarily what GDB understands.
7901 -static struct hard_trap_info
7903 - unsigned int tt; /* Trap type code for powerpc */
7904 - unsigned char signo; /* Signal that we map this trap into */
7905 -} hard_trap_info[] = {
7906 -#if defined(CONFIG_40x) || defined(CONFIG_BOOKE)
7907 - { 0x100, SIGINT }, /* critical input interrupt */
7908 - { 0x200, SIGSEGV }, /* machine check */
7909 - { 0x300, SIGSEGV }, /* data storage */
7910 - { 0x400, SIGBUS }, /* instruction storage */
7911 - { 0x500, SIGINT }, /* interrupt */
7912 - { 0x600, SIGBUS }, /* alignment */
7913 - { 0x700, SIGILL }, /* program */
7914 - { 0x800, SIGILL }, /* reserved */
7915 - { 0x900, SIGILL }, /* reserved */
7916 - { 0xa00, SIGILL }, /* reserved */
7917 - { 0xb00, SIGILL }, /* reserved */
7918 - { 0xc00, SIGCHLD }, /* syscall */
7919 - { 0xd00, SIGILL }, /* reserved */
7920 - { 0xe00, SIGILL }, /* reserved */
7921 - { 0xf00, SIGILL }, /* reserved */
7925 - ** 0x1020 watchdog
7926 - ** 0x1100 data TLB miss
7927 - ** 0x1200 instruction TLB miss
7929 - { 0x2002, SIGTRAP}, /* debug */
7931 - { 0x200, SIGSEGV }, /* machine check */
7932 - { 0x300, SIGSEGV }, /* address error (store) */
7933 - { 0x400, SIGBUS }, /* instruction bus error */
7934 - { 0x500, SIGINT }, /* interrupt */
7935 - { 0x600, SIGBUS }, /* alingment */
7936 - { 0x700, SIGTRAP }, /* breakpoint trap */
7937 - { 0x800, SIGFPE }, /* fpu unavail */
7938 - { 0x900, SIGALRM }, /* decrementer */
7939 - { 0xa00, SIGILL }, /* reserved */
7940 - { 0xb00, SIGILL }, /* reserved */
7941 - { 0xc00, SIGCHLD }, /* syscall */
7942 - { 0xd00, SIGTRAP }, /* single-step/watch */
7943 - { 0xe00, SIGFPE }, /* fp assist */
7945 - { 0, 0} /* Must be last */
7949 -static int computeSignal(unsigned int tt)
7951 - struct hard_trap_info *ht;
7953 - for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
7957 - return SIGHUP; /* default for things we don't know about */
7960 -#define PC_REGNUM 64
7961 -#define SP_REGNUM 1
7964 - * This function does all command processing for interfacing to gdb.
7967 -handle_exception (struct pt_regs *regs)
7975 - /* We don't handle user-mode breakpoints. */
7976 - if (user_mode(regs))
7979 - if (debugger_fault_handler) {
7980 - debugger_fault_handler(regs);
7981 - panic("kgdb longjump failed!\n");
7983 - if (kgdb_active) {
7984 - printk(KERN_ERR "interrupt while in kgdb, returning\n");
7992 - printk("kgdb: entering handle_exception; trap [0x%x]\n",
7993 - (unsigned int)regs->trap);
7996 - kgdb_interruptible(0);
7999 - mtmsr(msr & ~MSR_EE); /* disable interrupts */
8001 - if (regs->nip == (unsigned long)breakinst) {
8002 - /* Skip over breakpoint trap insn */
8006 - /* reply to host that an exception has occurred */
8007 - sigval = computeSignal(regs->trap);
8008 - ptr = remcomOutBuffer;
8011 - *ptr++ = hexchars[sigval >> 4];
8012 - *ptr++ = hexchars[sigval & 0xf];
8013 - *ptr++ = hexchars[PC_REGNUM >> 4];
8014 - *ptr++ = hexchars[PC_REGNUM & 0xf];
8016 - ptr = mem2hex((char *)®s->nip, ptr, 4);
8018 - *ptr++ = hexchars[SP_REGNUM >> 4];
8019 - *ptr++ = hexchars[SP_REGNUM & 0xf];
8021 - ptr = mem2hex(((char *)regs) + SP_REGNUM*4, ptr, 4);
8025 - putpacket(remcomOutBuffer);
8027 - printk("remcomOutBuffer: %s\n", remcomOutBuffer);
8029 - /* XXX We may want to add some features dealing with poking the
8030 - * XXX page tables, ... (look at sparc-stub.c for more info)
8031 - * XXX also required hacking to the gdb sources directly...
8035 - remcomOutBuffer[0] = 0;
8037 - getpacket(remcomInBuffer);
8038 - switch (remcomInBuffer[0]) {
8039 - case '?': /* report most recent signal */
8040 - remcomOutBuffer[0] = 'S';
8041 - remcomOutBuffer[1] = hexchars[sigval >> 4];
8042 - remcomOutBuffer[2] = hexchars[sigval & 0xf];
8043 - remcomOutBuffer[3] = 0;
8046 - case 'q': /* this screws up gdb for some reason...*/
8048 - extern long _start, sdata, __bss_start;
8050 - ptr = &remcomInBuffer[1];
8051 - if (strncmp(ptr, "Offsets", 7) != 0)
8054 - ptr = remcomOutBuffer;
8055 - sprintf(ptr, "Text=%8.8x;Data=%8.8x;Bss=%8.8x",
8056 - &_start, &sdata, &__bss_start);
8061 - /* toggle debug flag */
8065 - case 'g': /* return the value of the CPU registers.
8066 - * some of them are non-PowerPC names :(
8067 - * they are stored in gdb like:
8071 - * u32 pc, ps, cnd, lr; (ps=msr)
8072 - * u32 cnt, xer, mq;
8077 - ptr = remcomOutBuffer;
8078 - /* General Purpose Regs */
8079 - ptr = mem2hex((char *)regs, ptr, 32 * 4);
8080 - /* Floating Point Regs - FIXME */
8081 - /*ptr = mem2hex((char *), ptr, 32 * 8);*/
8082 - for(i=0; i<(32*8*2); i++) { /* 2chars/byte */
8086 - /* pc, msr, cr, lr, ctr, xer, (mq is unused) */
8087 - ptr = mem2hex((char *)®s->nip, ptr, 4);
8088 - ptr = mem2hex((char *)®s->msr, ptr, 4);
8089 - ptr = mem2hex((char *)®s->ccr, ptr, 4);
8090 - ptr = mem2hex((char *)®s->link, ptr, 4);
8091 - ptr = mem2hex((char *)®s->ctr, ptr, 4);
8092 - ptr = mem2hex((char *)®s->xer, ptr, 4);
8096 - case 'G': /* set the value of the CPU registers */
8098 - ptr = &remcomInBuffer[1];
8101 - * If the stack pointer has moved, you should pray.
8102 - * (cause only god can help you).
8105 - /* General Purpose Regs */
8106 - hex2mem(ptr, (char *)regs, 32 * 4);
8108 - /* Floating Point Regs - FIXME?? */
8109 - /*ptr = hex2mem(ptr, ??, 32 * 8);*/
8112 - /* pc, msr, cr, lr, ctr, xer, (mq is unused) */
8113 - ptr = hex2mem(ptr, (char *)®s->nip, 4);
8114 - ptr = hex2mem(ptr, (char *)®s->msr, 4);
8115 - ptr = hex2mem(ptr, (char *)®s->ccr, 4);
8116 - ptr = hex2mem(ptr, (char *)®s->link, 4);
8117 - ptr = hex2mem(ptr, (char *)®s->ctr, 4);
8118 - ptr = hex2mem(ptr, (char *)®s->xer, 4);
8120 - strcpy(remcomOutBuffer,"OK");
8124 - /* don't do anything, yet, just acknowledge */
8125 - hexToInt(&ptr, &addr);
8126 - strcpy(remcomOutBuffer,"OK");
8129 - case 'm': /* mAA..AA,LLLL Read LLLL bytes at address AA..AA */
8130 - /* Try to read %x,%x. */
8132 - ptr = &remcomInBuffer[1];
8134 - if (hexToInt(&ptr, &addr) && *ptr++ == ','
8135 - && hexToInt(&ptr, &length)) {
8136 - if (mem2hex((char *)addr, remcomOutBuffer,
8139 - strcpy(remcomOutBuffer, "E03");
8141 - strcpy(remcomOutBuffer, "E01");
8144 - case 'M': /* MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK */
8145 - /* Try to read '%x,%x:'. */
8147 - ptr = &remcomInBuffer[1];
8149 - if (hexToInt(&ptr, &addr) && *ptr++ == ','
8150 - && hexToInt(&ptr, &length)
8151 - && *ptr++ == ':') {
8152 - if (hex2mem(ptr, (char *)addr, length))
8153 - strcpy(remcomOutBuffer, "OK");
8155 - strcpy(remcomOutBuffer, "E03");
8156 - flush_icache_range(addr, addr+length);
8158 - strcpy(remcomOutBuffer, "E02");
8162 - case 'k': /* kill the program, actually just continue */
8163 - case 'c': /* cAA..AA Continue; address AA..AA optional */
8164 - /* try to read optional parameter, pc unchanged if no parm */
8166 - ptr = &remcomInBuffer[1];
8167 - if (hexToInt(&ptr, &addr))
8170 -/* Need to flush the instruction cache here, as we may have deposited a
8171 - * breakpoint, and the icache probably has no way of knowing that a data ref to
8172 - * some location may have changed something that is in the instruction cache.
8174 - kgdb_flush_cache_all();
8177 - kgdb_interruptible(1);
8181 - printk("remcomInBuffer: %s\n", remcomInBuffer);
8182 - printk("remcomOutBuffer: %s\n", remcomOutBuffer);
8187 - kgdb_flush_cache_all();
8188 -#if defined(CONFIG_40x) || defined(CONFIG_BOOKE)
8189 - mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) | DBCR0_IC);
8190 - regs->msr |= MSR_DE;
8192 - regs->msr |= MSR_SE;
8197 - printk("remcomInBuffer: %s\n", remcomInBuffer);
8198 - printk("remcomOutBuffer: %s\n", remcomOutBuffer);
8202 - case 'r': /* Reset (if user process..exit ???)*/
8203 - panic("kgdb reset.");
8206 - if (remcomOutBuffer[0] && kdebug) {
8207 - printk("remcomInBuffer: %s\n", remcomInBuffer);
8208 - printk("remcomOutBuffer: %s\n", remcomOutBuffer);
8210 - /* reply to the request */
8211 - putpacket(remcomOutBuffer);
8215 -/* This function will generate a breakpoint exception. It is used at the
8216 - beginning of a program to sync up with a debugger and can be used
8217 - otherwise as a quick means to stop program execution and "break" into
8223 - if (!initialized) {
8224 - printk("breakpoint() called b4 kgdb init\n");
8228 - asm(" .globl breakinst \n\
8229 - breakinst: .long 0x7d821008");
8232 -#ifdef CONFIG_KGDB_CONSOLE
8233 -/* Output string in GDB O-packet format if GDB has connected. If nothing
8234 - output, returns 0 (caller must then handle output). */
8236 -kgdb_output_string (const char* s, unsigned int count)
8240 - if (!kgdb_started)
8243 - count = (count <= (sizeof(buffer) / 2 - 2))
8244 - ? count : (sizeof(buffer) / 2 - 2);
8247 - mem2hex (s, &buffer[1], count);
8248 - putpacket(buffer);
8254 -static void sysrq_handle_gdb(int key, struct pt_regs *pt_regs,
8255 - struct tty_struct *tty)
8257 - printk("Entering GDB stub\n");
8260 -static struct sysrq_key_op sysrq_gdb_op = {
8261 - .handler = sysrq_handle_gdb,
8262 - .help_msg = "Gdb",
8263 - .action_msg = "GDB",
8266 -static int gdb_register_sysrq(void)
8268 - printk("Registering GDB sysrq handler\n");
8269 - register_sysrq_key('g', &sysrq_gdb_op);
8272 -module_init(gdb_register_sysrq);
8273 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ppc/kernel/setup.c linux-2.6.18-53.1.14.kgdb/arch/ppc/kernel/setup.c
8274 --- linux-2.6.18-53.1.14/arch/ppc/kernel/setup.c 2008-03-06 05:54:43.000000000 +0300
8275 +++ linux-2.6.18-53.1.14.kgdb/arch/ppc/kernel/setup.c 2008-06-10 15:38:14.000000000 +0400
8277 #include <asm/ppc_sys.h>
8280 -#if defined CONFIG_KGDB
8281 -#include <asm/kgdb.h>
8284 extern void platform_init(unsigned long r3, unsigned long r4,
8285 unsigned long r5, unsigned long r6, unsigned long r7);
8286 extern void reloc_got2(unsigned long offset);
8287 @@ -506,18 +502,6 @@ void __init setup_arch(char **cmdline_p)
8288 #endif /* CONFIG_XMON */
8289 if ( ppc_md.progress ) ppc_md.progress("setup_arch: enter", 0x3eab);
8291 -#if defined(CONFIG_KGDB)
8292 - if (ppc_md.kgdb_map_scc)
8293 - ppc_md.kgdb_map_scc();
8294 - set_debug_traps();
8295 - if (strstr(cmd_line, "gdb")) {
8296 - if (ppc_md.progress)
8297 - ppc_md.progress("setup_arch: kgdb breakpoint", 0x4000);
8298 - printk("kgdb breakpoint activated\n");
8304 * Set cache line size based on type of cpu as a default.
8305 * Systems with OF can look in the properties on the cpu node(s)
8306 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ppc/mm/fault.c linux-2.6.18-53.1.14.kgdb/arch/ppc/mm/fault.c
8307 --- linux-2.6.18-53.1.14/arch/ppc/mm/fault.c 2006-09-20 07:42:06.000000000 +0400
8308 +++ linux-2.6.18-53.1.14.kgdb/arch/ppc/mm/fault.c 2008-06-10 15:38:14.000000000 +0400
8310 #include <linux/interrupt.h>
8311 #include <linux/highmem.h>
8312 #include <linux/module.h>
8313 +#include <linux/kgdb.h>
8315 #include <asm/page.h>
8316 #include <asm/pgtable.h>
8317 @@ -329,6 +330,14 @@ bad_page_fault(struct pt_regs *regs, uns
8322 + if (atomic_read(&debugger_active) && kgdb_may_fault) {
8323 + /* Restore our previous state. */
8324 + kgdb_fault_longjmp(kgdb_fault_jmp_regs);
8325 + /* Not reached. */
8329 /* kernel has accessed a bad area */
8330 #if defined(CONFIG_XMON) || defined(CONFIG_KGDB)
8331 if (debugger_kernel_faults)
8332 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ppc/platforms/4xx/bubinga.c linux-2.6.18-53.1.14.kgdb/arch/ppc/platforms/4xx/bubinga.c
8333 --- linux-2.6.18-53.1.14/arch/ppc/platforms/4xx/bubinga.c 2006-09-20 07:42:06.000000000 +0400
8334 +++ linux-2.6.18-53.1.14.kgdb/arch/ppc/platforms/4xx/bubinga.c 2008-06-10 15:38:14.000000000 +0400
8336 * Author: SAW (IBM), derived from walnut.c.
8337 * Maintained by MontaVista Software <source@mvista.com>
8339 - * 2003 (c) MontaVista Softare Inc. This file is licensed under the
8340 + * 2003-2004 (c) MontaVista Softare Inc. This file is licensed under the
8341 * terms of the GNU General Public License version 2. This program is
8342 * licensed "as is" without any warranty of any kind, whether express
8344 @@ -100,17 +100,26 @@ bubinga_early_serial_map(void)
8345 port.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST;
8348 - if (early_serial_setup(&port) != 0) {
8349 +#ifdef CONFIG_SERIAL_8250
8350 + if (early_serial_setup(&port) != 0)
8351 printk("Early serial init of port 0 failed\n");
8355 +#ifdef CONFIG_KGDB_8250
8356 + kgdb8250_add_port(0, &port);
8359 port.membase = (void*)ACTING_UART1_IO_BASE;
8360 port.irq = ACTING_UART1_INT;
8363 - if (early_serial_setup(&port) != 0) {
8364 +#ifdef CONFIG_SERIAL_8250
8365 + if (early_serial_setup(&port) != 0)
8366 printk("Early serial init of port 1 failed\n");
8369 +#ifdef CONFIG_KGDB_8250
8370 + kgdb8250_add_port(1, &port);
8375 @@ -255,8 +264,4 @@ platform_init(unsigned long r3, unsigned
8376 ppc_md.nvram_read_val = todc_direct_read_val;
8377 ppc_md.nvram_write_val = todc_direct_write_val;
8380 - ppc_md.early_serial_map = bubinga_early_serial_map;
8384 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ppc/platforms/4xx/ebony.c linux-2.6.18-53.1.14.kgdb/arch/ppc/platforms/4xx/ebony.c
8385 --- linux-2.6.18-53.1.14/arch/ppc/platforms/4xx/ebony.c 2006-09-20 07:42:06.000000000 +0400
8386 +++ linux-2.6.18-53.1.14.kgdb/arch/ppc/platforms/4xx/ebony.c 2008-06-10 15:38:14.000000000 +0400
8388 #include <linux/tty.h>
8389 #include <linux/serial.h>
8390 #include <linux/serial_core.h>
8391 +#include <linux/kgdb.h>
8393 #include <asm/system.h>
8394 #include <asm/pgtable.h>
8395 @@ -226,14 +227,20 @@ ebony_early_serial_map(void)
8396 port.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST;
8399 - if (early_serial_setup(&port) != 0) {
8400 +#ifdef CONFIG_SERIAL_8250
8401 + if (early_serial_setup(&port) != 0)
8402 printk("Early serial init of port 0 failed\n");
8406 -#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
8407 +#ifdef CONFIG_SERIAL_TEXT_DEBUG
8408 /* Configure debug serial access */
8409 gen550_init(0, &port);
8411 +#ifdef CONFIG_KGDB_8250
8412 + kgdb8250_add_port(0, &port);
8415 +#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB_8250)
8416 /* Purge TLB entry added in head_44x.S for early serial access */
8417 _tlbie(UART0_IO_BASE);
8419 @@ -243,14 +250,18 @@ ebony_early_serial_map(void)
8420 port.uartclk = clocks.uart1;
8423 - if (early_serial_setup(&port) != 0) {
8424 +#ifdef CONFIG_SERIAL_8250
8425 + if (early_serial_setup(&port) != 1)
8426 printk("Early serial init of port 1 failed\n");
8430 -#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
8431 +#ifdef CONFIG_SERIAL_TEXT_DEBUG
8432 /* Configure debug serial access */
8433 gen550_init(1, &port);
8435 +#ifdef CONFIG_KGDB_8250
8436 + kgdb8250_add_port(1, &port);
8441 @@ -327,8 +338,4 @@ void __init platform_init(unsigned long
8443 ppc_md.nvram_read_val = todc_direct_read_val;
8444 ppc_md.nvram_write_val = todc_direct_write_val;
8446 - ppc_md.early_serial_map = ebony_early_serial_map;
8450 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ppc/platforms/4xx/ocotea.c linux-2.6.18-53.1.14.kgdb/arch/ppc/platforms/4xx/ocotea.c
8451 --- linux-2.6.18-53.1.14/arch/ppc/platforms/4xx/ocotea.c 2006-09-20 07:42:06.000000000 +0400
8452 +++ linux-2.6.18-53.1.14.kgdb/arch/ppc/platforms/4xx/ocotea.c 2008-06-10 15:38:14.000000000 +0400
8454 #include <linux/tty.h>
8455 #include <linux/serial.h>
8456 #include <linux/serial_core.h>
8457 +#include <linux/kgdb.h>
8459 #include <asm/system.h>
8460 #include <asm/pgtable.h>
8461 @@ -249,14 +250,20 @@ ocotea_early_serial_map(void)
8462 port.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST;
8465 - if (early_serial_setup(&port) != 0) {
8466 +#ifdef CONFIG_SERIAL_8250
8467 + if (early_serial_setup(&port) != 0)
8468 printk("Early serial init of port 0 failed\n");
8472 -#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
8473 +#ifdef CONFIG_SERIAL_TEXT_DEBUG
8474 /* Configure debug serial access */
8475 gen550_init(0, &port);
8477 +#ifdef CONFIG_KGDB_8250
8478 + kgdb8250_add_port(0, &port);
8481 +#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB_8250)
8482 /* Purge TLB entry added in head_44x.S for early serial access */
8483 _tlbie(UART0_IO_BASE);
8485 @@ -266,14 +273,18 @@ ocotea_early_serial_map(void)
8486 port.uartclk = clocks.uart1;
8489 - if (early_serial_setup(&port) != 0) {
8490 +#ifdef CONFIG_SERIAL_8250
8491 + if (early_serial_setup(&port) != 1)
8492 printk("Early serial init of port 1 failed\n");
8496 -#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
8497 +#ifdef CONFIG_SERIAL_TEXT_DEBUG
8498 /* Configure debug serial access */
8499 gen550_init(1, &port);
8501 +#ifdef CONFIG_KGDB_8250
8502 + kgdb8250_add_port(1, &port);
8507 @@ -343,8 +354,5 @@ void __init platform_init(unsigned long
8509 ppc_md.nvram_read_val = todc_direct_read_val;
8510 ppc_md.nvram_write_val = todc_direct_write_val;
8512 - ppc_md.early_serial_map = ocotea_early_serial_map;
8514 ppc_md.init = ocotea_init;
8516 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ppc/platforms/4xx/xilinx_ml300.c linux-2.6.18-53.1.14.kgdb/arch/ppc/platforms/4xx/xilinx_ml300.c
8517 --- linux-2.6.18-53.1.14/arch/ppc/platforms/4xx/xilinx_ml300.c 2006-09-20 07:42:06.000000000 +0400
8518 +++ linux-2.6.18-53.1.14.kgdb/arch/ppc/platforms/4xx/xilinx_ml300.c 2008-06-10 15:38:14.000000000 +0400
8520 * ppc4xx_map_io arch/ppc/syslib/ppc4xx_setup.c
8521 * start_kernel init/main.c
8522 * setup_arch arch/ppc/kernel/setup.c
8523 - * #if defined(CONFIG_KGDB)
8524 - * *ppc_md.kgdb_map_scc() == gen550_kgdb_map_scc
8526 * *ppc_md.setup_arch == ml300_setup_arch this file
8527 * ppc4xx_setup_arch arch/ppc/syslib/ppc4xx_setup.c
8528 * ppc4xx_find_bridges arch/ppc/syslib/ppc405_pci.c
8529 @@ -117,7 +114,6 @@ ml300_early_serial_init(int num, struct
8531 ml300_early_serial_map(void)
8533 -#ifdef CONFIG_SERIAL_8250
8534 struct plat_serial8250_port *pdata;
8537 @@ -129,7 +125,14 @@ ml300_early_serial_map(void)
8541 -#endif /* CONFIG_SERIAL_8250 */
8542 +#ifdef CONFIG_SERIAL_8250
8543 + if (early_serial_setup(&port) != 0)
8544 + printk("Early serial init of port %d failed\n", i);
8547 +#ifdef CONFIG_KGDB_8250
8548 + kgdb8250_add_port(i, &port)
8553 @@ -165,9 +168,4 @@ platform_init(unsigned long r3, unsigned
8554 #if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
8555 ppc_md.power_off = xilinx_power_off;
8559 - ppc_md.early_serial_map = ml300_early_serial_map;
8563 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ppc/platforms/85xx/sbc8560.c linux-2.6.18-53.1.14.kgdb/arch/ppc/platforms/85xx/sbc8560.c
8564 --- linux-2.6.18-53.1.14/arch/ppc/platforms/85xx/sbc8560.c 2006-09-20 07:42:06.000000000 +0400
8565 +++ linux-2.6.18-53.1.14.kgdb/arch/ppc/platforms/85xx/sbc8560.c 2008-06-10 15:38:14.000000000 +0400
8567 #include <syslib/ppc85xx_common.h>
8568 #include <syslib/ppc85xx_setup.h>
8570 -#ifdef CONFIG_SERIAL_8250
8572 sbc8560_early_serial_map(void)
8574 @@ -66,12 +65,16 @@ sbc8560_early_serial_map(void)
8575 uart_req.membase = ioremap(uart_req.mapbase, MPC85xx_UART0_SIZE);
8576 uart_req.type = PORT_16650;
8578 -#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
8579 - gen550_init(0, &uart_req);
8582 +#ifdef CONFIG_SERIAL_8250
8583 if (early_serial_setup(&uart_req) != 0)
8584 printk("Early serial init of port 0 failed\n");
8586 +#ifdef CONFIG_SERIAL_TEXT_DEBUG
8587 + gen550_init(0, &uart_req);
8589 +#ifdef CONFIG_KGDB_8250
8590 + kgdb8250_add_port(0, &uart_req);
8593 /* Assume early_serial_setup() doesn't modify uart_req */
8595 @@ -79,14 +82,17 @@ sbc8560_early_serial_map(void)
8596 uart_req.membase = ioremap(uart_req.mapbase, MPC85xx_UART1_SIZE);
8597 uart_req.irq = MPC85xx_IRQ_EXT10;
8599 -#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
8600 - gen550_init(1, &uart_req);
8603 +#ifdef CONFIG_SERIAL_8250
8604 if (early_serial_setup(&uart_req) != 0)
8605 - printk("Early serial init of port 1 failed\n");
8607 + printk("Early serial init of port 0 failed\n");
8609 +#ifdef CONFIG_SERIAL_TEXT_DEBUG
8610 + gen550_init(0, &uart_req);
8612 +#ifdef CONFIG_KGDB_8250
8613 + kgdb8250_add_port(0, &uart_req);
8617 /* ************************************************************************
8619 @@ -115,9 +121,7 @@ sbc8560_setup_arch(void)
8620 /* setup PCI host bridges */
8621 mpc85xx_setup_hose();
8623 -#ifdef CONFIG_SERIAL_8250
8624 sbc8560_early_serial_map();
8626 #ifdef CONFIG_SERIAL_TEXT_DEBUG
8627 /* Invalidate the entry we stole earlier the serial ports
8628 * should be properly mapped */
8629 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ppc/platforms/chestnut.c linux-2.6.18-53.1.14.kgdb/arch/ppc/platforms/chestnut.c
8630 --- linux-2.6.18-53.1.14/arch/ppc/platforms/chestnut.c 2006-09-20 07:42:06.000000000 +0400
8631 +++ linux-2.6.18-53.1.14.kgdb/arch/ppc/platforms/chestnut.c 2008-06-10 15:38:14.000000000 +0400
8632 @@ -492,7 +492,7 @@ chestnut_power_off(void)
8634 chestnut_map_io(void)
8636 -#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
8637 +#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB_8250)
8638 io_block_mapping(CHESTNUT_UART_BASE, CHESTNUT_UART_BASE, 0x100000,
8641 @@ -566,9 +566,6 @@ platform_init(unsigned long r3, unsigned
8642 #if defined(CONFIG_SERIAL_TEXT_DEBUG)
8643 ppc_md.progress = gen550_progress;
8645 -#if defined(CONFIG_KGDB)
8646 - ppc_md.kgdb_map_scc = gen550_kgdb_map_scc;
8649 if (ppc_md.progress)
8650 ppc_md.progress("chestnut_init(): exit", 0);
8651 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ppc/platforms/pplus.c linux-2.6.18-53.1.14.kgdb/arch/ppc/platforms/pplus.c
8652 --- linux-2.6.18-53.1.14/arch/ppc/platforms/pplus.c 2006-09-20 07:42:06.000000000 +0400
8653 +++ linux-2.6.18-53.1.14.kgdb/arch/ppc/platforms/pplus.c 2008-06-10 15:38:14.000000000 +0400
8654 @@ -893,9 +893,6 @@ platform_init(unsigned long r3, unsigned
8655 #ifdef CONFIG_SERIAL_TEXT_DEBUG
8656 ppc_md.progress = gen550_progress;
8657 #endif /* CONFIG_SERIAL_TEXT_DEBUG */
8659 - ppc_md.kgdb_map_scc = gen550_kgdb_map_scc;
8662 smp_ops = &pplus_smp_ops;
8663 #endif /* CONFIG_SMP */
8664 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ppc/platforms/sandpoint.c linux-2.6.18-53.1.14.kgdb/arch/ppc/platforms/sandpoint.c
8665 --- linux-2.6.18-53.1.14/arch/ppc/platforms/sandpoint.c 2006-09-20 07:42:06.000000000 +0400
8666 +++ linux-2.6.18-53.1.14.kgdb/arch/ppc/platforms/sandpoint.c 2008-06-10 15:38:14.000000000 +0400
8667 @@ -730,9 +730,6 @@ platform_init(unsigned long r3, unsigned
8668 ppc_md.nvram_read_val = todc_mc146818_read_val;
8669 ppc_md.nvram_write_val = todc_mc146818_write_val;
8672 - ppc_md.kgdb_map_scc = gen550_kgdb_map_scc;
8674 #ifdef CONFIG_SERIAL_TEXT_DEBUG
8675 ppc_md.progress = gen550_progress;
8677 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ppc/platforms/spruce.c linux-2.6.18-53.1.14.kgdb/arch/ppc/platforms/spruce.c
8678 --- linux-2.6.18-53.1.14/arch/ppc/platforms/spruce.c 2006-09-20 07:42:06.000000000 +0400
8679 +++ linux-2.6.18-53.1.14.kgdb/arch/ppc/platforms/spruce.c 2008-06-10 15:38:14.000000000 +0400
8680 @@ -178,26 +178,32 @@ spruce_early_serial_map(void)
8681 serial_req.membase = (u_char *)UART0_IO_BASE;
8682 serial_req.regshift = 0;
8684 -#if defined(CONFIG_KGDB) || defined(CONFIG_SERIAL_TEXT_DEBUG)
8685 - gen550_init(0, &serial_req);
8687 #ifdef CONFIG_SERIAL_8250
8688 if (early_serial_setup(&serial_req) != 0)
8689 printk("Early serial init of port 0 failed\n");
8691 +#ifdef CONFIG_SERIAL_TEXT_DEBUG
8692 + gen550_init(0, &serial_req);
8694 +#ifdef CONFIG_KGDB_8250
8695 + kgdb8250_add_port(0, &port);
8698 /* Assume early_serial_setup() doesn't modify serial_req */
8699 serial_req.line = 1;
8700 serial_req.irq = UART1_INT;
8701 serial_req.membase = (u_char *)UART1_IO_BASE;
8703 -#if defined(CONFIG_KGDB) || defined(CONFIG_SERIAL_TEXT_DEBUG)
8704 - gen550_init(1, &serial_req);
8706 #ifdef CONFIG_SERIAL_8250
8707 if (early_serial_setup(&serial_req) != 0)
8708 printk("Early serial init of port 1 failed\n");
8710 +#ifdef CONFIG_SERIAL_TEXT_DEBUG
8711 + gen550_init(1, &serial_req);
8713 +#ifdef CONFIG_KGDB_8250
8714 + kgdb8250_add_port(1, &serial_req);
8719 @@ -316,7 +322,4 @@ platform_init(unsigned long r3, unsigned
8720 #ifdef CONFIG_SERIAL_TEXT_DEBUG
8721 ppc_md.progress = gen550_progress;
8722 #endif /* CONFIG_SERIAL_TEXT_DEBUG */
8724 - ppc_md.kgdb_map_scc = gen550_kgdb_map_scc;
8727 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ppc/syslib/Makefile linux-2.6.18-53.1.14.kgdb/arch/ppc/syslib/Makefile
8728 --- linux-2.6.18-53.1.14/arch/ppc/syslib/Makefile 2006-09-20 07:42:06.000000000 +0400
8729 +++ linux-2.6.18-53.1.14.kgdb/arch/ppc/syslib/Makefile 2008-06-10 15:38:14.000000000 +0400
8730 @@ -76,7 +76,6 @@ obj-$(CONFIG_PCI_8260) += m82xx_pci.o p
8731 obj-$(CONFIG_8260_PCI9) += m8260_pci_erratum9.o
8732 obj-$(CONFIG_CPM2) += cpm2_common.o cpm2_pic.o
8733 ifeq ($(CONFIG_PPC_GEN550),y)
8734 -obj-$(CONFIG_KGDB) += gen550_kgdb.o gen550_dbg.o
8735 obj-$(CONFIG_SERIAL_TEXT_DEBUG) += gen550_dbg.o
8737 ifeq ($(CONFIG_SERIAL_MPSC_CONSOLE),y)
8738 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ppc/syslib/gen550.h linux-2.6.18-53.1.14.kgdb/arch/ppc/syslib/gen550.h
8739 --- linux-2.6.18-53.1.14/arch/ppc/syslib/gen550.h 2006-09-20 07:42:06.000000000 +0400
8740 +++ linux-2.6.18-53.1.14.kgdb/arch/ppc/syslib/gen550.h 2008-06-10 15:38:14.000000000 +0400
8743 extern void gen550_progress(char *, unsigned short);
8744 extern void gen550_init(int, struct uart_port *);
8745 -extern void gen550_kgdb_map_scc(void);
8746 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ppc/syslib/ibm44x_common.c linux-2.6.18-53.1.14.kgdb/arch/ppc/syslib/ibm44x_common.c
8747 --- linux-2.6.18-53.1.14/arch/ppc/syslib/ibm44x_common.c 2006-09-20 07:42:06.000000000 +0400
8748 +++ linux-2.6.18-53.1.14.kgdb/arch/ppc/syslib/ibm44x_common.c 2008-06-10 15:38:14.000000000 +0400
8749 @@ -192,9 +192,6 @@ void __init ibm44x_platform_init(unsigne
8750 #ifdef CONFIG_SERIAL_TEXT_DEBUG
8751 ppc_md.progress = gen550_progress;
8752 #endif /* CONFIG_SERIAL_TEXT_DEBUG */
8754 - ppc_md.kgdb_map_scc = gen550_kgdb_map_scc;
8758 * The Abatron BDI JTAG debugger does not tolerate others
8759 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ppc/syslib/mv64x60.c linux-2.6.18-53.1.14.kgdb/arch/ppc/syslib/mv64x60.c
8760 --- linux-2.6.18-53.1.14/arch/ppc/syslib/mv64x60.c 2006-09-20 07:42:06.000000000 +0400
8761 +++ linux-2.6.18-53.1.14.kgdb/arch/ppc/syslib/mv64x60.c 2008-06-10 15:38:14.000000000 +0400
8762 @@ -241,6 +241,12 @@ static struct resource mv64x60_mpsc0_res
8763 .end = MV64x60_IRQ_SDMA_0,
8764 .flags = IORESOURCE_IRQ,
8767 + .name = "mpsc 0 irq",
8768 + .start = MV64x60_IRQ_MPSC_0,
8769 + .end = MV64x60_IRQ_MPSC_0,
8770 + .flags = IORESOURCE_IRQ,
8774 static struct platform_device mpsc0_device = {
8775 @@ -298,6 +304,12 @@ static struct resource mv64x60_mpsc1_res
8776 .end = MV64360_IRQ_SDMA_1,
8777 .flags = IORESOURCE_IRQ,
8780 + .name = "mpsc 1 irq",
8781 + .start = MV64360_IRQ_MPSC_1,
8782 + .end = MV64360_IRQ_MPSC_1,
8783 + .flags = IORESOURCE_IRQ,
8787 static struct platform_device mpsc1_device = {
8788 @@ -1426,12 +1438,46 @@ mv64x60_pd_fixup(struct mv64x60_handle *
8790 mv64x60_add_pds(void)
8792 - return platform_add_devices(mv64x60_pd_devs,
8793 - ARRAY_SIZE(mv64x60_pd_devs));
8796 + for (i = 0; i < ARRAY_SIZE(mv64x60_pd_devs); i++) {
8797 + if (mv64x60_pd_devs[i]) {
8798 + ret = platform_device_register(mv64x60_pd_devs[i]);
8802 + platform_device_unregister(mv64x60_pd_devs[i]);
8808 arch_initcall(mv64x60_add_pds);
8811 + * mv64x60_early_get_pdev_data()
8813 + * Get the data associated with a platform device by name and number.
8815 +struct platform_device * __init
8816 +mv64x60_early_get_pdev_data(const char *name, int id, int remove)
8819 + struct platform_device *pdev;
8821 + for (i = 0; i <ARRAY_SIZE(mv64x60_pd_devs); i++) {
8822 + if ((pdev = mv64x60_pd_devs[i]) &&
8824 + !strcmp(pdev->name, name)) {
8826 + mv64x60_pd_devs[i] = NULL;
8834 *****************************************************************************
8836 * GT64260-Specific Routines
8837 @@ -1764,6 +1810,11 @@ gt64260a_chip_specific_init(struct mv64x
8838 r->start = MV64x60_IRQ_SDMA_0;
8839 r->end = MV64x60_IRQ_SDMA_0;
8841 + if ((r = platform_get_resource(&mpsc1_device, IORESOURCE_IRQ, 1))
8843 + r->start = GT64260_IRQ_MPSC_1;
8844 + r->end = GT64260_IRQ_MPSC_1;
8849 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ppc/syslib/mv64x60_dbg.c linux-2.6.18-53.1.14.kgdb/arch/ppc/syslib/mv64x60_dbg.c
8850 --- linux-2.6.18-53.1.14/arch/ppc/syslib/mv64x60_dbg.c 2006-09-20 07:42:06.000000000 +0400
8851 +++ linux-2.6.18-53.1.14.kgdb/arch/ppc/syslib/mv64x60_dbg.c 2008-06-10 15:38:14.000000000 +0400
8852 @@ -34,7 +34,7 @@ static struct mv64x60_handle mv64x60_dbg
8854 mv64x60_progress_init(u32 base)
8856 - mv64x60_dbg_bh.v_base = base;
8857 + mv64x60_dbg_bh.v_base = (void*)base;
8861 @@ -69,53 +69,3 @@ mv64x60_mpsc_progress(char *s, unsigned
8864 #endif /* CONFIG_SERIAL_TEXT_DEBUG */
8867 -#if defined(CONFIG_KGDB)
8869 -#if defined(CONFIG_KGDB_TTYS0)
8870 -#define KGDB_PORT 0
8871 -#elif defined(CONFIG_KGDB_TTYS1)
8872 -#define KGDB_PORT 1
8874 -#error "Invalid kgdb_tty port"
8878 -putDebugChar(unsigned char c)
8880 - mv64x60_polled_putc(KGDB_PORT, (char)c);
8888 - while (!mv64x60_polled_getc(KGDB_PORT, &c));
8893 -putDebugString(char* str)
8895 - while (*str != '\0') {
8896 - putDebugChar(*str);
8899 - putDebugChar('\r');
8904 -kgdb_interruptible(int enable)
8911 - if (ppc_md.early_serial_map)
8912 - ppc_md.early_serial_map();
8914 -#endif /* CONFIG_KGDB */
8915 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/ppc/syslib/ppc85xx_setup.c linux-2.6.18-53.1.14.kgdb/arch/ppc/syslib/ppc85xx_setup.c
8916 --- linux-2.6.18-53.1.14/arch/ppc/syslib/ppc85xx_setup.c 2006-09-20 07:42:06.000000000 +0400
8917 +++ linux-2.6.18-53.1.14.kgdb/arch/ppc/syslib/ppc85xx_setup.c 2008-06-10 15:38:14.000000000 +0400
8918 @@ -69,7 +69,6 @@ mpc85xx_calibrate_decr(void)
8919 mtspr(SPRN_TCR, TCR_DIE);
8922 -#ifdef CONFIG_SERIAL_8250
8924 mpc85xx_early_serial_map(void)
8926 @@ -85,7 +84,7 @@ mpc85xx_early_serial_map(void)
8927 pdata[0].mapbase += binfo->bi_immr_base;
8928 pdata[0].membase = ioremap(pdata[0].mapbase, MPC85xx_UART0_SIZE);
8930 -#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
8931 +#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB_8250)
8932 memset(&serial_req, 0, sizeof (serial_req));
8933 serial_req.iotype = UPIO_MEM;
8934 serial_req.mapbase = pdata[0].mapbase;
8935 @@ -93,18 +92,24 @@ mpc85xx_early_serial_map(void)
8936 serial_req.regshift = 0;
8938 gen550_init(0, &serial_req);
8939 +#ifdef CONFIG_KGDB_8250
8940 + kgdb8250_add_port(0, &serial_req);
8944 pdata[1].uartclk = binfo->bi_busfreq;
8945 pdata[1].mapbase += binfo->bi_immr_base;
8946 pdata[1].membase = ioremap(pdata[1].mapbase, MPC85xx_UART0_SIZE);
8948 -#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
8949 +#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB_8250)
8950 /* Assume gen550_init() doesn't modify serial_req */
8951 serial_req.mapbase = pdata[1].mapbase;
8952 serial_req.membase = pdata[1].membase;
8954 gen550_init(1, &serial_req);
8955 +#ifdef CONFIG_KGDB_8250
8956 + kgdb8250_add_port(1, &serial_req);
8961 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/sh/Kconfig.debug linux-2.6.18-53.1.14.kgdb/arch/sh/Kconfig.debug
8962 --- linux-2.6.18-53.1.14/arch/sh/Kconfig.debug 2006-09-20 07:42:06.000000000 +0400
8963 +++ linux-2.6.18-53.1.14.kgdb/arch/sh/Kconfig.debug 2008-06-10 15:38:50.000000000 +0400
8964 @@ -29,96 +29,4 @@ config EARLY_PRINTK
8965 This option is only useful porting the kernel to a new machine,
8966 when the kernel may crash or hang before the serial console is
8967 initialised. If unsure, say N.
8970 - bool "Include KGDB kernel debugger"
8972 - Include in-kernel hooks for kgdb, the Linux kernel source level
8973 - debugger. See <http://kgdb.sourceforge.net/> for more information.
8974 - Unless you are intending to debug the kernel, say N here.
8976 -menu "KGDB configuration options"
8979 -config MORE_COMPILE_OPTIONS
8980 - bool "Add any additional compile options"
8982 - If you want to add additional CFLAGS to the kernel build, enable this
8983 - option and then enter what you would like to add in the next question.
8984 - Note however that -g is already appended with the selection of KGDB.
8986 -config COMPILE_OPTIONS
8987 - string "Additional compile arguments"
8988 - depends on MORE_COMPILE_OPTIONS
8991 - bool "Enter KGDB on NMI"
8995 - bool "Include KGDB thread support"
8998 -config SH_KGDB_CONSOLE
8999 - bool "Console messages through GDB"
9003 - bool "Allow SysRq 'G' to enter KGDB"
9006 -config KGDB_KERNEL_ASSERTS
9007 - bool "Include KGDB kernel assertions"
9010 -comment "Serial port setup"
9012 -config KGDB_DEFPORT
9013 - int "Port number (ttySCn)"
9016 -config KGDB_DEFBAUD
9023 - default KGDB_DEFPARITY_N
9025 -config KGDB_DEFPARITY_N
9028 -config KGDB_DEFPARITY_E
9031 -config KGDB_DEFPARITY_O
9037 - prompt "Data bits"
9039 - default KGDB_DEFBITS_8
9041 -config KGDB_DEFBITS_8
9044 -config KGDB_DEFBITS_7
9051 -config FRAME_POINTER
9052 - bool "Compile the kernel with frame pointers"
9055 - If you say Y here the resulting kernel image will be slightly larger
9056 - and slower, but it will give very useful debugging information.
9057 - If you don't debug the kernel, you can say N, but we may not be able
9058 - to solve problems without frame pointers.
9061 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/sh/Makefile linux-2.6.18-53.1.14.kgdb/arch/sh/Makefile
9062 --- linux-2.6.18-53.1.14/arch/sh/Makefile 2006-09-20 07:42:06.000000000 +0400
9063 +++ linux-2.6.18-53.1.14.kgdb/arch/sh/Makefile 2008-06-10 15:38:50.000000000 +0400
9064 @@ -43,7 +43,6 @@ cflags-$(CONFIG_CPU_SH4) += -m4 \
9065 cflags-$(CONFIG_CPU_SH4A) += $(call cc-option,-m4a-nofpu,)
9067 cflags-$(CONFIG_SH_DSP) += -Wa,-dsp
9068 -cflags-$(CONFIG_SH_KGDB) += -g
9070 cflags-$(CONFIG_MORE_COMPILE_OPTIONS) += \
9071 $(shell echo $(CONFIG_COMPILE_OPTIONS) | sed -e 's/"//g')
9072 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/sh/boards/se/7751/setup.c linux-2.6.18-53.1.14.kgdb/arch/sh/boards/se/7751/setup.c
9073 --- linux-2.6.18-53.1.14/arch/sh/boards/se/7751/setup.c 2006-09-20 07:42:06.000000000 +0400
9074 +++ linux-2.6.18-53.1.14.kgdb/arch/sh/boards/se/7751/setup.c 2008-06-10 15:38:50.000000000 +0400
9077 #include <asm/se7751/se7751.h>
9079 -#ifdef CONFIG_SH_KGDB
9080 -#include <asm/kgdb.h>
9084 * Configure the Super I/O chip
9086 @@ -82,12 +78,6 @@ const char *get_system_type(void)
9087 return "7751 SolutionEngine";
9090 -#ifdef CONFIG_SH_KGDB
9091 -static int kgdb_uart_setup(void);
9092 -static struct kgdb_sermap kgdb_uart_sermap =
9093 -{ "ttyS", 0, kgdb_uart_setup, NULL };
9097 * Initialize the board
9099 @@ -95,133 +85,4 @@ void __init platform_setup(void)
9101 /* Call init_smsc() replacement to set up SuperIO. */
9102 /* XXX: RTC setting comes here */
9103 -#ifdef CONFIG_SH_KGDB
9104 - kgdb_register_sermap(&kgdb_uart_sermap);
9108 -/*********************************************************************
9109 - * Currently a hack (e.g. does not interact well w/serial.c, lots of *
9110 - * hardcoded stuff) but may be useful if SCI/F needs debugging. *
9111 - * Mostly copied from x86 code (see files asm-i386/kgdb_local.h and *
9112 - * arch/i386/lib/kgdb_serial.c). *
9113 - *********************************************************************/
9115 -#ifdef CONFIG_SH_KGDB
9116 -#include <linux/types.h>
9117 -#include <linux/serial.h>
9118 -#include <linux/serialP.h>
9119 -#include <linux/serial_reg.h>
9121 -#define COM1_PORT 0x3f8 /* Base I/O address */
9122 -#define COM1_IRQ 4 /* IRQ not used yet */
9123 -#define COM2_PORT 0x2f8 /* Base I/O address */
9124 -#define COM2_IRQ 3 /* IRQ not used yet */
9126 -#define SB_CLOCK 1843200 /* Serial baud clock */
9127 -#define SB_BASE (SB_CLOCK/16)
9128 -#define SB_MCR UART_MCR_OUT2 | UART_MCR_DTR | UART_MCR_RTS
9133 -#define UART_NPORTS 2
9134 -struct uart_port uart_ports[] = {
9138 -struct uart_port *kgdb_uart_port;
9140 -#define UART_IN(reg) inb_p(kgdb_uart_port->base + reg)
9141 -#define UART_OUT(reg,v) outb_p((v), kgdb_uart_port->base + reg)
9143 -/* Basic read/write functions for the UART */
9144 -#define UART_LSR_RXCERR (UART_LSR_BI | UART_LSR_FE | UART_LSR_PE)
9145 -static int kgdb_uart_getchar(void)
9151 - lsr = UART_IN(UART_LSR);
9152 - if (lsr & UART_LSR_DR)
9153 - c = UART_IN(UART_RX);
9154 - if ((lsr & UART_LSR_RXCERR))
9160 -static void kgdb_uart_putchar(int c)
9162 - while ((UART_IN(UART_LSR) & UART_LSR_THRE) == 0)
9164 - UART_OUT(UART_TX, c);
9168 - * Initialize UART to configured/requested values.
9169 - * (But we don't interrupts yet, or interact w/serial.c)
9171 -static int kgdb_uart_setup(void)
9177 - if (kgdb_portnum >= UART_NPORTS) {
9178 - KGDB_PRINTK("uart port %d invalid.\n", kgdb_portnum);
9182 - kgdb_uart_port = &uart_ports[kgdb_portnum];
9184 - /* Init sequence from gdb_hook_interrupt */
9186 - UART_OUT(UART_IER, 0);
9188 - UART_IN(UART_RX); /* Serial driver comments say */
9189 - UART_IN(UART_IIR); /* this clears interrupt regs */
9190 - UART_IN(UART_MSR);
9192 - /* Figure basic LCR values */
9193 - switch (kgdb_bits) {
9195 - lcr |= UART_LCR_WLEN7;
9197 - default: case '8':
9198 - lcr |= UART_LCR_WLEN8;
9201 - switch (kgdb_parity) {
9203 - lcr |= UART_LCR_PARITY;
9206 - lcr |= (UART_LCR_PARITY | UART_LCR_EPAR);
9211 - /* Figure the baud rate divisor */
9212 - bdiv = (SB_BASE/kgdb_baud);
9214 - /* Set the baud rate and LCR values */
9215 - UART_OUT(UART_LCR, (lcr | UART_LCR_DLAB));
9216 - UART_OUT(UART_DLL, (bdiv & 0xff));
9217 - UART_OUT(UART_DLM, ((bdiv >> 8) & 0xff));
9218 - UART_OUT(UART_LCR, lcr);
9221 - UART_OUT(UART_MCR, SB_MCR);
9223 - /* Turn off FIFOs for now */
9224 - UART_OUT(UART_FCR, 0);
9226 - /* Setup complete: initialize function pointers */
9227 - kgdb_getchar = kgdb_uart_getchar;
9228 - kgdb_putchar = kgdb_uart_putchar;
9232 -#endif /* CONFIG_SH_KGDB */
9233 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/sh/kernel/Makefile linux-2.6.18-53.1.14.kgdb/arch/sh/kernel/Makefile
9234 --- linux-2.6.18-53.1.14/arch/sh/kernel/Makefile 2006-09-20 07:42:06.000000000 +0400
9235 +++ linux-2.6.18-53.1.14.kgdb/arch/sh/kernel/Makefile 2008-06-10 15:38:50.000000000 +0400
9236 @@ -13,7 +13,7 @@ obj-y += cpu/ timers/
9237 obj-$(CONFIG_SMP) += smp.o
9238 obj-$(CONFIG_CF_ENABLER) += cf-enabler.o
9239 obj-$(CONFIG_SH_STANDARD_BIOS) += sh_bios.o
9240 -obj-$(CONFIG_SH_KGDB) += kgdb_stub.o kgdb_jmp.o
9241 +obj-$(CONFIG_KGDB) += kgdb.o kgdb-jmp.o
9242 obj-$(CONFIG_SH_CPU_FREQ) += cpufreq.o
9243 obj-$(CONFIG_MODULES) += module.o
9244 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
9245 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/sh/kernel/cpu/sh3/ex.S linux-2.6.18-53.1.14.kgdb/arch/sh/kernel/cpu/sh3/ex.S
9246 --- linux-2.6.18-53.1.14/arch/sh/kernel/cpu/sh3/ex.S 2006-09-20 07:42:06.000000000 +0400
9247 +++ linux-2.6.18-53.1.14.kgdb/arch/sh/kernel/cpu/sh3/ex.S 2008-06-10 15:38:50.000000000 +0400
9248 @@ -42,7 +42,7 @@ ENTRY(exception_handling_table)
9249 .long exception_error ! reserved_instruction (filled by trap_init) /* 180 */
9250 .long exception_error ! illegal_slot_instruction (filled by trap_init) /*1A0*/
9252 -#if defined (CONFIG_KGDB_NMI)
9253 +#if defined (CONFIG_KGDB)
9254 .long debug_enter /* 1C0 */ ! Allow trap to debugger
9256 .long exception_none /* 1C0 */ ! Not implemented yet
9257 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/sh/kernel/cpu/sh4/ex.S linux-2.6.18-53.1.14.kgdb/arch/sh/kernel/cpu/sh4/ex.S
9258 --- linux-2.6.18-53.1.14/arch/sh/kernel/cpu/sh4/ex.S 2006-09-20 07:42:06.000000000 +0400
9259 +++ linux-2.6.18-53.1.14.kgdb/arch/sh/kernel/cpu/sh4/ex.S 2008-06-10 15:38:50.000000000 +0400
9260 @@ -46,7 +46,7 @@ ENTRY(exception_handling_table)
9261 .long exception_error ! reserved_instruction (filled by trap_init) /* 180 */
9262 .long exception_error ! illegal_slot_instruction (filled by trap_init) /*1A0*/
9264 -#if defined (CONFIG_KGDB_NMI)
9265 +#if defined (CONFIG_KGDB)
9266 .long debug_enter /* 1C0 */ ! Allow trap to debugger
9268 .long exception_none /* 1C0 */ ! Not implemented yet
9269 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/sh/kernel/entry.S linux-2.6.18-53.1.14.kgdb/arch/sh/kernel/entry.S
9270 --- linux-2.6.18-53.1.14/arch/sh/kernel/entry.S 2006-09-20 07:42:06.000000000 +0400
9271 +++ linux-2.6.18-53.1.14.kgdb/arch/sh/kernel/entry.S 2008-06-10 15:38:50.000000000 +0400
9276 -#if defined(CONFIG_KGDB_NMI)
9277 +#if defined(CONFIG_KGDB)
9278 NMI_VEC = 0x1c0 ! Must catch early for debounce
9281 @@ -227,31 +227,33 @@ call_dae:
9282 2: .long do_address_error
9283 #endif /* CONFIG_MMU */
9285 -#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
9286 +#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_KGDB)
9287 ! Handle kernel debug if either kgdb (SW) or gdb-stub (FW) is present.
9288 ! If both are configured, handle the debug traps (breakpoints) in SW,
9289 ! but still allow BIOS traps to FW.
9293 -#if defined(CONFIG_SH_STANDARD_BIOS) && defined(CONFIG_SH_KGDB)
9294 +#if defined(CONFIG_SH_STANDARD_BIOS) && defined(CONFIG_KGDB)
9295 /* Force BIOS call to FW (debug_trap put TRA in r8) */
9300 -#endif /* CONFIG_SH_STANDARD_BIOS && CONFIG_SH_KGDB */
9301 +#endif /* CONFIG_SH_STANDARD_BIOS && CONFIG_KGDB */
9304 + .globl debug_enter
9306 -#if defined(CONFIG_SH_KGDB)
9307 +#if defined(CONFIG_KGDB)
9308 /* Jump to kgdb, pass stacked regs as arg */
9314 -3: .long kgdb_handle_exception
9315 -#endif /* CONFIG_SH_KGDB */
9316 +3: .long kgdb_exception_handler
9317 +#endif /* CONFIG_KGDB */
9319 #if defined(CONFIG_SH_STANDARD_BIOS)
9320 /* Unwind the stack and jmp to the debug entry */
9321 @@ -293,12 +295,12 @@ debug_kernel_fw:
9322 2: .long gdb_vbr_vector
9323 #endif /* CONFIG_SH_STANDARD_BIOS */
9325 -#endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_SH_KGDB */
9326 +#endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_KGDB */
9331 -#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
9332 +#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_KGDB)
9334 mov.l @(r0,r15), r0 ! get status register
9336 @@ -642,7 +644,7 @@ skip_restore:
9337 6: or k0, k2 ! Set the IMASK-bits
9340 -#if defined(CONFIG_KGDB_NMI)
9341 +#if defined(CONFIG_KGDB)
9345 @@ -694,7 +696,7 @@ tlb_miss:
9349 -#if defined(CONFIG_KGDB_NMI)
9350 +#if defined(CONFIG_KGDB)
9351 ! Debounce (filter nested NMI)
9354 @@ -709,7 +711,7 @@ interrupt:
9358 -#endif /* defined(CONFIG_KGDB_NMI) */
9359 +#endif /* defined(CONFIG_KGDB) */
9360 bra handle_exception
9363 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/sh/kernel/kgdb-jmp.S linux-2.6.18-53.1.14.kgdb/arch/sh/kernel/kgdb-jmp.S
9364 --- linux-2.6.18-53.1.14/arch/sh/kernel/kgdb-jmp.S 1970-01-01 03:00:00.000000000 +0300
9365 +++ linux-2.6.18-53.1.14.kgdb/arch/sh/kernel/kgdb-jmp.S 2008-06-10 15:38:50.000000000 +0400
9367 +#include <linux/linkage.h>
9369 +ENTRY(kgdb_fault_setjmp)
9383 +ENTRY(kgdb_fault_longjmp)
9399 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/sh/kernel/kgdb.c linux-2.6.18-53.1.14.kgdb/arch/sh/kernel/kgdb.c
9400 --- linux-2.6.18-53.1.14/arch/sh/kernel/kgdb.c 1970-01-01 03:00:00.000000000 +0300
9401 +++ linux-2.6.18-53.1.14.kgdb/arch/sh/kernel/kgdb.c 2008-06-10 15:38:50.000000000 +0400
9404 + * arch/sh/kernel/kgdb.c
9406 + * Contains SH-specific low-level support for KGDB.
9408 + * Containes extracts from code by Glenn Engel, Jim Kingdon,
9409 + * David Grothe <dave@gcom.com>, Tigran Aivazian <tigran@sco.com>,
9410 + * Amit S. Kale <akale@veritas.com>, William Gatliff <bgat@open-widgets.com>,
9411 + * Ben Lee, Steve Chamberlain and Benoit Miller <fulg@iname.com>,
9412 + * Henry Bell <henry.bell@st.com> and Jeremy Siegel <jsiegel@mvista.com>
9414 + * Maintainer: Tom Rini <trini@kernel.crashing.org>
9416 + * 2004 (c) MontaVista Software, Inc. This file is licensed under
9417 + * the terms of the GNU General Public License version 2. This program
9418 + * is licensed "as is" without any warranty of any kind, whether express
9422 +#include <linux/string.h>
9423 +#include <linux/kernel.h>
9424 +#include <linux/sched.h>
9425 +#include <linux/smp.h>
9426 +#include <linux/spinlock.h>
9427 +#include <linux/delay.h>
9428 +#include <linux/linkage.h>
9429 +#include <linux/init.h>
9430 +#include <linux/kgdb.h>
9432 +#include <asm/system.h>
9433 +#include <asm/current.h>
9434 +#include <asm/signal.h>
9435 +#include <asm/pgtable.h>
9436 +#include <asm/ptrace.h>
9438 +extern void per_cpu_trap_init(void);
9439 +extern atomic_t cpu_doing_single_step;
9441 +/* Function pointers for linkage */
9442 +static struct kgdb_regs trap_registers;
9445 +char in_nmi; /* Set during NMI to prevent reentry */
9447 +/* TRA differs sh3/4 */
9448 +#if defined(CONFIG_CPU_SH3)
9449 +#define TRA 0xffffffd0
9450 +#elif defined(CONFIG_CPU_SH4)
9451 +#define TRA 0xff000020
9454 +/* Macros for single step instruction identification */
9455 +#define OPCODE_BT(op) (((op) & 0xff00) == 0x8900)
9456 +#define OPCODE_BF(op) (((op) & 0xff00) == 0x8b00)
9457 +#define OPCODE_BTF_DISP(op) (((op) & 0x80) ? (((op) | 0xffffff80) << 1) : \
9458 + (((op) & 0x7f ) << 1))
9459 +#define OPCODE_BFS(op) (((op) & 0xff00) == 0x8f00)
9460 +#define OPCODE_BTS(op) (((op) & 0xff00) == 0x8d00)
9461 +#define OPCODE_BRA(op) (((op) & 0xf000) == 0xa000)
9462 +#define OPCODE_BRA_DISP(op) (((op) & 0x800) ? (((op) | 0xfffff800) << 1) : \
9463 + (((op) & 0x7ff) << 1))
9464 +#define OPCODE_BRAF(op) (((op) & 0xf0ff) == 0x0023)
9465 +#define OPCODE_BRAF_REG(op) (((op) & 0x0f00) >> 8)
9466 +#define OPCODE_BSR(op) (((op) & 0xf000) == 0xb000)
9467 +#define OPCODE_BSR_DISP(op) (((op) & 0x800) ? (((op) | 0xfffff800) << 1) : \
9468 + (((op) & 0x7ff) << 1))
9469 +#define OPCODE_BSRF(op) (((op) & 0xf0ff) == 0x0003)
9470 +#define OPCODE_BSRF_REG(op) (((op) >> 8) & 0xf)
9471 +#define OPCODE_JMP(op) (((op) & 0xf0ff) == 0x402b)
9472 +#define OPCODE_JMP_REG(op) (((op) >> 8) & 0xf)
9473 +#define OPCODE_JSR(op) (((op) & 0xf0ff) == 0x400b)
9474 +#define OPCODE_JSR_REG(op) (((op) >> 8) & 0xf)
9475 +#define OPCODE_RTS(op) ((op) == 0xb)
9476 +#define OPCODE_RTE(op) ((op) == 0x2b)
9478 +#define SR_T_BIT_MASK 0x1
9479 +#define STEP_OPCODE 0xc320
9480 +#define BIOS_CALL_TRAP 0x3f
9482 +/* Exception codes as per SH-4 core manual */
9483 +#define ADDRESS_ERROR_LOAD_VEC 7
9484 +#define ADDRESS_ERROR_STORE_VEC 8
9485 +#define TRAP_VEC 11
9486 +#define INVALID_INSN_VEC 12
9487 +#define INVALID_SLOT_VEC 13
9489 +#define SERIAL_BREAK_VEC 58
9492 +static int stepped_address;
9493 +static short stepped_opcode;
9495 +/* Translate SH-3/4 exception numbers to unix-like signal values */
9496 +static int compute_signal(const int excep_code)
9498 + switch (excep_code) {
9499 + case INVALID_INSN_VEC:
9500 + case INVALID_SLOT_VEC:
9502 + case ADDRESS_ERROR_LOAD_VEC:
9503 + case ADDRESS_ERROR_STORE_VEC:
9505 + case SERIAL_BREAK_VEC:
9509 + /* Act like it was a break/trap. */
9515 + * Translate the registers of the system into the format that GDB wants. Since
9516 + * we use a local structure to store things, instead of getting them out
9517 + * of pt_regs, we can just do a memcpy.
9519 +void regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *ign)
9521 + memcpy(gdb_regs, &trap_registers, sizeof(trap_registers));
9525 + * On SH we save: r1 (prev->thread.sp) r2 (prev->thread.pc) r4 (prev) r5 (next)
9526 + * r6 (next->thread.sp) r7 (next->thread.pc)
9528 +void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p)
9532 + for (count = 0; count < 16; count++)
9533 + *(gdb_regs++) = 0;
9534 + *(gdb_regs++) = p->thread.pc;
9535 + *(gdb_regs++) = 0;
9536 + *(gdb_regs++) = 0;
9537 + *(gdb_regs++) = 0;
9538 + *(gdb_regs++) = 0;
9539 + *(gdb_regs++) = 0;
9540 + *(gdb_regs++) = 0;
9544 + * Translate the registers values that GDB has given us back into the
9545 + * format of the system. See the comment above about memcpy.
9547 +void gdb_regs_to_regs(unsigned long *gdb_regs, struct pt_regs *ign)
9549 + memcpy(&trap_registers, gdb_regs, sizeof(trap_registers));
9552 +/* Calculate the new address for after a step */
9553 +static short *get_step_address(void)
9555 + short op = *(short *)trap_registers.pc;
9559 + if (OPCODE_BT(op)) {
9560 + if (trap_registers.sr & SR_T_BIT_MASK)
9561 + addr = trap_registers.pc + 4 + OPCODE_BTF_DISP(op);
9563 + addr = trap_registers.pc + 2;
9567 + else if (OPCODE_BTS(op)) {
9568 + if (trap_registers.sr & SR_T_BIT_MASK)
9569 + addr = trap_registers.pc + 4 + OPCODE_BTF_DISP(op);
9571 + addr = trap_registers.pc + 4; /* Not in delay slot */
9575 + else if (OPCODE_BF(op)) {
9576 + if (!(trap_registers.sr & SR_T_BIT_MASK))
9577 + addr = trap_registers.pc + 4 + OPCODE_BTF_DISP(op);
9579 + addr = trap_registers.pc + 2;
9583 + else if (OPCODE_BFS(op)) {
9584 + if (!(trap_registers.sr & SR_T_BIT_MASK))
9585 + addr = trap_registers.pc + 4 + OPCODE_BTF_DISP(op);
9587 + addr = trap_registers.pc + 4; /* Not in delay slot */
9591 + else if (OPCODE_BRA(op))
9592 + addr = trap_registers.pc + 4 + OPCODE_BRA_DISP(op);
9595 + else if (OPCODE_BRAF(op))
9596 + addr = trap_registers.pc + 4
9597 + + trap_registers.regs[OPCODE_BRAF_REG(op)];
9600 + else if (OPCODE_BSR(op))
9601 + addr = trap_registers.pc + 4 + OPCODE_BSR_DISP(op);
9604 + else if (OPCODE_BSRF(op))
9605 + addr = trap_registers.pc + 4
9606 + + trap_registers.regs[OPCODE_BSRF_REG(op)];
9609 + else if (OPCODE_JMP(op))
9610 + addr = trap_registers.regs[OPCODE_JMP_REG(op)];
9613 + else if (OPCODE_JSR(op))
9614 + addr = trap_registers.regs[OPCODE_JSR_REG(op)];
9617 + else if (OPCODE_RTS(op))
9618 + addr = trap_registers.pr;
9621 + else if (OPCODE_RTE(op))
9622 + addr = trap_registers.regs[15];
9626 + addr = trap_registers.pc + 2;
9628 + kgdb_flush_icache_range(addr, addr + 2);
9629 + return (short *)addr;
9632 +/* The command loop, read and act on requests */
9633 +int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
9634 + char *remcom_in_buffer, char *remcom_out_buffer,
9635 + struct pt_regs *ign)
9637 + unsigned long addr;
9638 + char *ptr = &remcom_in_buffer[1];
9640 + /* Examine first char of buffer to see what we need to do */
9641 + switch (remcom_in_buffer[0]) {
9642 + case 'c': /* Continue at address AA..AA (optional) */
9643 + case 's': /* Step one instruction from AA..AA */
9644 + /* Try to read optional parameter, PC unchanged if none */
9645 + if (kgdb_hex2long(&ptr, &addr))
9646 + trap_registers.pc = addr;
9648 + atomic_set(&cpu_doing_single_step, -1);
9649 + if (remcom_in_buffer[0] == 's') {
9650 + /* Replace the instruction immediately after the
9651 + * current instruction (i.e. next in the expected
9652 + * flow of control) with a trap instruction, so that
9653 + * returning will cause only a single instruction to
9654 + * be executed. Note that this model is slightly
9655 + * broken for instructions with delay slots
9656 + * (e.g. B[TF]S, BSR, BRA etc), where both the branch
9657 + * and the instruction in the delay slot will be
9660 + /* Determine where the target instruction will send
9662 + unsigned short *next_addr = get_step_address();
9663 + stepped_address = (int)next_addr;
9666 + stepped_opcode = *(short *)next_addr;
9667 + *next_addr = STEP_OPCODE;
9669 + /* Flush and return */
9670 + kgdb_flush_icache_range((long)next_addr,
9671 + (long)next_addr + 2);
9672 + if (kgdb_contthread)
9673 + atomic_set(&cpu_doing_single_step,
9674 + smp_processor_id());
9682 + * When an exception has occured, we are called. We need to set things
9683 + * up so that we can call kgdb_handle_exception to handle requests from
9686 +void kgdb_exception_handler(struct pt_regs *regs)
9688 + int excep_code, vbr_val;
9691 + /* Copy kernel regs (from stack) */
9692 + for (count = 0; count < 16; count++)
9693 + trap_registers.regs[count] = regs->regs[count];
9694 + trap_registers.pc = regs->pc;
9695 + trap_registers.pr = regs->pr;
9696 + trap_registers.sr = regs->sr;
9697 + trap_registers.gbr = regs->gbr;
9698 + trap_registers.mach = regs->mach;
9699 + trap_registers.macl = regs->macl;
9701 + __asm__ __volatile__("stc vbr, %0":"=r"(vbr_val));
9702 + trap_registers.vbr = vbr_val;
9704 + /* Get the execption code. */
9705 + __asm__ __volatile__("stc r2_bank, %0":"=r"(excep_code));
9709 + /* If we got an NMI, and KGDB is not yet initialized, call
9710 + * breakpoint() to try and initialize everything for us. */
9711 + if (excep_code == NMI_VEC && !kgdb_initialized) {
9716 + /* TRAP_VEC exception indicates a software trap inserted in place of
9717 + * code by GDB so back up PC by one instruction, as this instruction
9718 + * will later be replaced by its original one. Do NOT do this for
9719 + * trap 0xff, since that indicates a compiled-in breakpoint which
9720 + * will not be replaced (and we would retake the trap forever) */
9721 + if (excep_code == TRAP_VEC &&
9722 + (*(volatile unsigned long *)TRA != (0xff << 2)))
9723 + trap_registers.pc -= 2;
9725 + /* If we have been single-stepping, put back the old instruction.
9726 + * We use stepped_address in case we have stopped more than one
9727 + * instruction away. */
9728 + if (stepped_opcode != 0) {
9729 + *(short *)stepped_address = stepped_opcode;
9730 + kgdb_flush_icache_range(stepped_address, stepped_address + 2);
9732 + stepped_opcode = 0;
9734 + /* Call the stub to do the processing. Note that not everything we
9735 + * need to send back and forth lives in pt_regs. */
9736 + kgdb_handle_exception(excep_code, compute_signal(excep_code), 0, regs);
9738 + /* Copy back the (maybe modified) registers */
9739 + for (count = 0; count < 16; count++)
9740 + regs->regs[count] = trap_registers.regs[count];
9741 + regs->pc = trap_registers.pc;
9742 + regs->pr = trap_registers.pr;
9743 + regs->sr = trap_registers.sr;
9744 + regs->gbr = trap_registers.gbr;
9745 + regs->mach = trap_registers.mach;
9746 + regs->macl = trap_registers.macl;
9748 + vbr_val = trap_registers.vbr;
9749 + __asm__ __volatile__("ldc %0, vbr": :"r"(vbr_val));
9752 +int __init kgdb_arch_init(void)
9754 + per_cpu_trap_init();
9759 +struct kgdb_arch arch_kgdb_ops = {
9760 +#ifdef CONFIG_CPU_LITTLE_ENDIAN
9761 + .gdb_bpt_instr = {0xff, 0xc3},
9763 + .gdb_bpt_instr = {0xc3, 0xff},
9766 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/sh/kernel/kgdb_jmp.S linux-2.6.18-53.1.14.kgdb/arch/sh/kernel/kgdb_jmp.S
9767 --- linux-2.6.18-53.1.14/arch/sh/kernel/kgdb_jmp.S 2006-09-20 07:42:06.000000000 +0400
9768 +++ linux-2.6.18-53.1.14.kgdb/arch/sh/kernel/kgdb_jmp.S 1970-01-01 03:00:00.000000000 +0300
9770 -#include <linux/linkage.h>
9799 - mov #1, r0 ! in case val==0
9803 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/sh/kernel/kgdb_stub.c linux-2.6.18-53.1.14.kgdb/arch/sh/kernel/kgdb_stub.c
9804 --- linux-2.6.18-53.1.14/arch/sh/kernel/kgdb_stub.c 2006-09-20 07:42:06.000000000 +0400
9805 +++ linux-2.6.18-53.1.14.kgdb/arch/sh/kernel/kgdb_stub.c 1970-01-01 03:00:00.000000000 +0300
9808 - * May be copied or modified under the terms of the GNU General Public
9809 - * License. See linux/COPYING for more information.
9811 - * Containes extracts from code by Glenn Engel, Jim Kingdon,
9812 - * David Grothe <dave@gcom.com>, Tigran Aivazian <tigran@sco.com>,
9813 - * Amit S. Kale <akale@veritas.com>, William Gatliff <bgat@open-widgets.com>,
9814 - * Ben Lee, Steve Chamberlain and Benoit Miller <fulg@iname.com>.
9816 - * This version by Henry Bell <henry.bell@st.com>
9817 - * Minor modifications by Jeremy Siegel <jsiegel@mvista.com>
9819 - * Contains low-level support for remote debug using GDB.
9821 - * To enable debugger support, two things need to happen. A call to
9822 - * set_debug_traps() is necessary in order to allow any breakpoints
9823 - * or error conditions to be properly intercepted and reported to gdb.
9824 - * A breakpoint also needs to be generated to begin communication. This
9825 - * is most easily accomplished by a call to breakpoint() which does
9826 - * a trapa if the initialisation phase has been successfully completed.
9828 - * In this case, set_debug_traps() is not used to "take over" exceptions;
9829 - * other kernel code is modified instead to enter the kgdb functions here
9830 - * when appropriate (see entry.S for breakpoint traps and NMI interrupts,
9831 - * see traps.c for kernel error exceptions).
9833 - * The following gdb commands are supported:
9835 - * Command Function Return value
9837 - * g return the value of the CPU registers hex data or ENN
9838 - * G set the value of the CPU registers OK or ENN
9840 - * mAA..AA,LLLL Read LLLL bytes at address AA..AA hex data or ENN
9841 - * MAA..AA,LLLL: Write LLLL bytes at address AA.AA OK or ENN
9842 - * XAA..AA,LLLL: Same, but data is binary (not hex) OK or ENN
9844 - * c Resume at current address SNN ( signal NN)
9845 - * cAA..AA Continue at address AA..AA SNN
9846 - * CNN; Resume at current address with signal SNN
9847 - * CNN;AA..AA Resume at address AA..AA with signal SNN
9849 - * s Step one instruction SNN
9850 - * sAA..AA Step one instruction from AA..AA SNN
9851 - * SNN; Step one instruction with signal SNN
9852 - * SNNAA..AA Step one instruction from AA..AA w/NN SNN
9854 - * k kill (Detach GDB)
9856 - * d Toggle debug flag
9859 - * Hct Set thread t for operations, OK or ENN
9860 - * c = 'c' (step, cont), c = 'g' (other
9863 - * qC Query current thread ID QCpid
9864 - * qfThreadInfo Get list of current threads (first) m<id>
9865 - * qsThreadInfo " " " " " (subsequent)
9866 - * qOffsets Get section offsets Text=x;Data=y;Bss=z
9868 - * TXX Find if thread XX is alive OK or ENN
9869 - * ? What was the last sigval ? SNN (signal NN)
9870 - * O Output to GDB console
9872 - * Remote communication protocol.
9874 - * A debug packet whose contents are <data> is encapsulated for
9875 - * transmission in the form:
9877 - * $ <data> # CSUM1 CSUM2
9879 - * <data> must be ASCII alphanumeric and cannot include characters
9880 - * '$' or '#'. If <data> starts with two characters followed by
9881 - * ':', then the existing stubs interpret this as a sequence number.
9883 - * CSUM1 and CSUM2 are ascii hex representation of an 8-bit
9884 - * checksum of <data>, the most significant nibble is sent first.
9885 - * the hex digits 0-9,a-f are used.
9887 - * Receiver responds with:
9889 - * + - if CSUM is correct and ready for next packet
9890 - * - - if CSUM is incorrect
9892 - * Responses can be run-length encoded to save space. A '*' means that
9893 - * the next character is an ASCII encoding giving a repeat count which
9894 - * stands for that many repititions of the character preceding the '*'.
9895 - * The encoding is n+29, yielding a printable character where n >=3
9896 - * (which is where RLE starts to win). Don't use an n > 126.
9898 - * So "0* " means the same as "0000".
9901 -#include <linux/string.h>
9902 -#include <linux/kernel.h>
9903 -#include <linux/sched.h>
9904 -#include <linux/smp.h>
9905 -#include <linux/spinlock.h>
9906 -#include <linux/delay.h>
9907 -#include <linux/linkage.h>
9908 -#include <linux/init.h>
9910 -#include <asm/system.h>
9911 -#include <asm/current.h>
9912 -#include <asm/signal.h>
9913 -#include <asm/pgtable.h>
9914 -#include <asm/ptrace.h>
9915 -#include <asm/kgdb.h>
9917 -#ifdef CONFIG_SH_KGDB_CONSOLE
9918 -#include <linux/console.h>
9921 -/* Function pointers for linkage */
9922 -kgdb_debug_hook_t *kgdb_debug_hook;
9923 -kgdb_bus_error_hook_t *kgdb_bus_err_hook;
9925 -int (*kgdb_getchar)(void);
9926 -void (*kgdb_putchar)(int);
9928 -static void put_debug_char(int c)
9930 - if (!kgdb_putchar)
9932 - (*kgdb_putchar)(c);
9934 -static int get_debug_char(void)
9936 - if (!kgdb_getchar)
9938 - return (*kgdb_getchar)();
9941 -/* Num chars in in/out bound buffers, register packets need NUMREGBYTES * 2 */
9942 -#define BUFMAX 1024
9943 -#define NUMREGBYTES (MAXREG*4)
9944 -#define OUTBUFMAX (NUMREGBYTES*2+512)
9947 - R0 = 0, R1, R2, R3, R4, R5, R6, R7,
9948 - R8, R9, R10, R11, R12, R13, R14, R15,
9949 - PC, PR, GBR, VBR, MACH, MACL, SR,
9954 -static unsigned int registers[MAXREG];
9955 -struct kgdb_regs trap_registers;
9957 -char kgdb_in_gdb_mode;
9958 -char in_nmi; /* Set during NMI to prevent reentry */
9959 -int kgdb_nofault; /* Boolean to ignore bus errs (i.e. in GDB) */
9960 -int kgdb_enabled = 1; /* Default to enabled, cmdline can disable */
9963 -/* Exposed for user access */
9964 -struct task_struct *kgdb_current;
9965 -unsigned int kgdb_g_imask;
9966 -int kgdb_trapa_val;
9969 -/* Default values for SCI (can override via kernel args in setup.c) */
9970 -#ifndef CONFIG_KGDB_DEFPORT
9971 -#define CONFIG_KGDB_DEFPORT 1
9974 -#ifndef CONFIG_KGDB_DEFBAUD
9975 -#define CONFIG_KGDB_DEFBAUD 115200
9978 -#if defined(CONFIG_KGDB_DEFPARITY_E)
9979 -#define CONFIG_KGDB_DEFPARITY 'E'
9980 -#elif defined(CONFIG_KGDB_DEFPARITY_O)
9981 -#define CONFIG_KGDB_DEFPARITY 'O'
9982 -#else /* CONFIG_KGDB_DEFPARITY_N */
9983 -#define CONFIG_KGDB_DEFPARITY 'N'
9986 -#ifdef CONFIG_KGDB_DEFBITS_7
9987 -#define CONFIG_KGDB_DEFBITS '7'
9988 -#else /* CONFIG_KGDB_DEFBITS_8 */
9989 -#define CONFIG_KGDB_DEFBITS '8'
9992 -/* SCI/UART settings, used in kgdb_console_setup() */
9993 -int kgdb_portnum = CONFIG_KGDB_DEFPORT;
9994 -int kgdb_baud = CONFIG_KGDB_DEFBAUD;
9995 -char kgdb_parity = CONFIG_KGDB_DEFPARITY;
9996 -char kgdb_bits = CONFIG_KGDB_DEFBITS;
9998 -/* Jump buffer for setjmp/longjmp */
9999 -static jmp_buf rem_com_env;
10001 -/* TRA differs sh3/4 */
10002 -#if defined(CONFIG_CPU_SH3)
10003 -#define TRA 0xffffffd0
10004 -#elif defined(CONFIG_CPU_SH4)
10005 -#define TRA 0xff000020
10008 -/* Macros for single step instruction identification */
10009 -#define OPCODE_BT(op) (((op) & 0xff00) == 0x8900)
10010 -#define OPCODE_BF(op) (((op) & 0xff00) == 0x8b00)
10011 -#define OPCODE_BTF_DISP(op) (((op) & 0x80) ? (((op) | 0xffffff80) << 1) : \
10012 - (((op) & 0x7f ) << 1))
10013 -#define OPCODE_BFS(op) (((op) & 0xff00) == 0x8f00)
10014 -#define OPCODE_BTS(op) (((op) & 0xff00) == 0x8d00)
10015 -#define OPCODE_BRA(op) (((op) & 0xf000) == 0xa000)
10016 -#define OPCODE_BRA_DISP(op) (((op) & 0x800) ? (((op) | 0xfffff800) << 1) : \
10017 - (((op) & 0x7ff) << 1))
10018 -#define OPCODE_BRAF(op) (((op) & 0xf0ff) == 0x0023)
10019 -#define OPCODE_BRAF_REG(op) (((op) & 0x0f00) >> 8)
10020 -#define OPCODE_BSR(op) (((op) & 0xf000) == 0xb000)
10021 -#define OPCODE_BSR_DISP(op) (((op) & 0x800) ? (((op) | 0xfffff800) << 1) : \
10022 - (((op) & 0x7ff) << 1))
10023 -#define OPCODE_BSRF(op) (((op) & 0xf0ff) == 0x0003)
10024 -#define OPCODE_BSRF_REG(op) (((op) >> 8) & 0xf)
10025 -#define OPCODE_JMP(op) (((op) & 0xf0ff) == 0x402b)
10026 -#define OPCODE_JMP_REG(op) (((op) >> 8) & 0xf)
10027 -#define OPCODE_JSR(op) (((op) & 0xf0ff) == 0x400b)
10028 -#define OPCODE_JSR_REG(op) (((op) >> 8) & 0xf)
10029 -#define OPCODE_RTS(op) ((op) == 0xb)
10030 -#define OPCODE_RTE(op) ((op) == 0x2b)
10032 -#define SR_T_BIT_MASK 0x1
10033 -#define STEP_OPCODE 0xc320
10034 -#define BIOS_CALL_TRAP 0x3f
10036 -/* Exception codes as per SH-4 core manual */
10037 -#define ADDRESS_ERROR_LOAD_VEC 7
10038 -#define ADDRESS_ERROR_STORE_VEC 8
10039 -#define TRAP_VEC 11
10040 -#define INVALID_INSN_VEC 12
10041 -#define INVALID_SLOT_VEC 13
10042 -#define NMI_VEC 14
10043 -#define USER_BREAK_VEC 15
10044 -#define SERIAL_BREAK_VEC 58
10047 -static int stepped_address;
10048 -static short stepped_opcode;
10049 -static const char hexchars[] = "0123456789abcdef";
10050 -static char in_buffer[BUFMAX];
10051 -static char out_buffer[OUTBUFMAX];
10053 -static void kgdb_to_gdb(const char *s);
10055 -#ifdef CONFIG_KGDB_THREAD
10056 -static struct task_struct *trapped_thread;
10057 -static struct task_struct *current_thread;
10058 -typedef unsigned char threadref[8];
10059 -#define BUF_THREAD_ID_SIZE 16
10062 -/* Return addr as a real volatile address */
10063 -static inline unsigned int ctrl_inl(const unsigned long addr)
10065 - return *(volatile unsigned long *) addr;
10068 -/* Correctly set *addr using volatile */
10069 -static inline void ctrl_outl(const unsigned int b, unsigned long addr)
10071 - *(volatile unsigned long *) addr = b;
10074 -/* Get high hex bits */
10075 -static char highhex(const int x)
10077 - return hexchars[(x >> 4) & 0xf];
10080 -/* Get low hex bits */
10081 -static char lowhex(const int x)
10083 - return hexchars[x & 0xf];
10086 -/* Convert ch to hex */
10087 -static int hex(const char ch)
10089 - if ((ch >= 'a') && (ch <= 'f'))
10090 - return (ch - 'a' + 10);
10091 - if ((ch >= '0') && (ch <= '9'))
10092 - return (ch - '0');
10093 - if ((ch >= 'A') && (ch <= 'F'))
10094 - return (ch - 'A' + 10);
10098 -/* Convert the memory pointed to by mem into hex, placing result in buf.
10099 - Returns a pointer to the last char put in buf (null) */
10100 -static char *mem_to_hex(const char *mem, char *buf, const int count)
10104 - unsigned short s_val;
10105 - unsigned long l_val;
10107 - /* Check for 16 or 32 */
10108 - if (count == 2 && ((long) mem & 1) == 0) {
10109 - s_val = *(unsigned short *) mem;
10110 - mem = (char *) &s_val;
10111 - } else if (count == 4 && ((long) mem & 3) == 0) {
10112 - l_val = *(unsigned long *) mem;
10113 - mem = (char *) &l_val;
10115 - for (i = 0; i < count; i++) {
10117 - *buf++ = highhex(ch);
10118 - *buf++ = lowhex(ch);
10124 -/* Convert the hex array pointed to by buf into binary, to be placed in mem.
10125 - Return a pointer to the character after the last byte written */
10126 -static char *hex_to_mem(const char *buf, char *mem, const int count)
10129 - unsigned char ch;
10131 - for (i = 0; i < count; i++) {
10132 - ch = hex(*buf++) << 4;
10133 - ch = ch + hex(*buf++);
10139 -/* While finding valid hex chars, convert to an integer, then return it */
10140 -static int hex_to_int(char **ptr, int *int_value)
10142 - int num_chars = 0;
10148 - hex_value = hex(**ptr);
10149 - if (hex_value >= 0) {
10150 - *int_value = (*int_value << 4) | hex_value;
10156 - return num_chars;
10159 -/* Copy the binary array pointed to by buf into mem. Fix $, #,
10160 - and 0x7d escaped with 0x7d. Return a pointer to the character
10161 - after the last byte written. */
10162 -static char *ebin_to_mem(const char *buf, char *mem, int count)
10164 - for (; count > 0; count--, buf++) {
10165 - if (*buf == 0x7d)
10166 - *mem++ = *(++buf) ^ 0x20;
10173 -/* Pack a hex byte */
10174 -static char *pack_hex_byte(char *pkt, int byte)
10176 - *pkt++ = hexchars[(byte >> 4) & 0xf];
10177 - *pkt++ = hexchars[(byte & 0xf)];
10181 -#ifdef CONFIG_KGDB_THREAD
10183 -/* Pack a thread ID */
10184 -static char *pack_threadid(char *pkt, threadref * id)
10187 - unsigned char *altid;
10189 - altid = (unsigned char *) id;
10191 - limit = pkt + BUF_THREAD_ID_SIZE;
10192 - while (pkt < limit)
10193 - pkt = pack_hex_byte(pkt, *altid++);
10197 -/* Convert an integer into our threadref */
10198 -static void int_to_threadref(threadref * id, const int value)
10200 - unsigned char *scan = (unsigned char *) id;
10206 - *scan++ = (value >> 24) & 0xff;
10207 - *scan++ = (value >> 16) & 0xff;
10208 - *scan++ = (value >> 8) & 0xff;
10209 - *scan++ = (value & 0xff);
10212 -/* Return a task structure ptr for a particular pid */
10213 -static struct task_struct *get_thread(int pid)
10215 - struct task_struct *thread;
10217 - /* Use PID_MAX w/gdb for pid 0 */
10218 - if (pid == PID_MAX) pid = 0;
10220 - /* First check via PID */
10221 - thread = find_task_by_pid(pid);
10226 - /* Start at the start */
10227 - thread = init_tasks[0];
10229 - /* Walk along the linked list of tasks */
10231 - if (thread->pid == pid)
10233 - thread = thread->next_task;
10234 - } while (thread != init_tasks[0]);
10239 -#endif /* CONFIG_KGDB_THREAD */
10241 -/* Scan for the start char '$', read the packet and check the checksum */
10242 -static void get_packet(char *buffer, int buflen)
10244 - unsigned char checksum;
10245 - unsigned char xmitcsum;
10251 - /* Ignore everything until the start character */
10252 - while ((ch = get_debug_char()) != '$');
10258 - /* Now, read until a # or end of buffer is found */
10259 - while (count < (buflen - 1)) {
10260 - ch = get_debug_char();
10265 - checksum = checksum + ch;
10266 - buffer[count] = ch;
10267 - count = count + 1;
10270 - buffer[count] = 0;
10272 - /* Continue to read checksum following # */
10274 - xmitcsum = hex(get_debug_char()) << 4;
10275 - xmitcsum += hex(get_debug_char());
10278 - if (checksum != xmitcsum)
10279 - put_debug_char('-'); /* Failed checksum */
10281 - /* Ack successful transfer */
10282 - put_debug_char('+');
10284 - /* If a sequence char is present, reply
10285 - the sequence ID */
10286 - if (buffer[2] == ':') {
10287 - put_debug_char(buffer[0]);
10288 - put_debug_char(buffer[1]);
10290 - /* Remove sequence chars from buffer */
10291 - count = strlen(buffer);
10292 - for (i = 3; i <= count; i++)
10293 - buffer[i - 3] = buffer[i];
10298 - while (checksum != xmitcsum); /* Keep trying while we fail */
10301 -/* Send the packet in the buffer with run-length encoding */
10302 -static void put_packet(char *buffer)
10311 - put_debug_char('$');
10314 - /* Continue while we still have chars left */
10316 - /* Check for runs up to 99 chars long */
10317 - for (runlen = 1; runlen < 99; runlen++) {
10318 - if (src[0] != src[runlen])
10322 - if (runlen > 3) {
10323 - /* Got a useful amount, send encoding */
10324 - encode = runlen + ' ' - 4;
10325 - put_debug_char(*src); checksum += *src;
10326 - put_debug_char('*'); checksum += '*';
10327 - put_debug_char(encode); checksum += encode;
10330 - /* Otherwise just send the current char */
10331 - put_debug_char(*src); checksum += *src;
10336 - /* '#' Separator, put high and low components of checksum */
10337 - put_debug_char('#');
10338 - put_debug_char(highhex(checksum));
10339 - put_debug_char(lowhex(checksum));
10341 - while ((get_debug_char()) != '+'); /* While no ack */
10344 -/* A bus error has occurred - perform a longjmp to return execution and
10345 - allow handling of the error */
10346 -static void kgdb_handle_bus_error(void)
10348 - longjmp(rem_com_env, 1);
10351 -/* Translate SH-3/4 exception numbers to unix-like signal values */
10352 -static int compute_signal(const int excep_code)
10356 - switch (excep_code) {
10358 - case INVALID_INSN_VEC:
10359 - case INVALID_SLOT_VEC:
10362 - case ADDRESS_ERROR_LOAD_VEC:
10363 - case ADDRESS_ERROR_STORE_VEC:
10364 - sigval = SIGSEGV;
10367 - case SERIAL_BREAK_VEC:
10372 - case USER_BREAK_VEC:
10374 - sigval = SIGTRAP;
10378 - sigval = SIGBUS; /* "software generated" */
10385 -/* Make a local copy of the registers passed into the handler (bletch) */
10386 -static void kgdb_regs_to_gdb_regs(const struct kgdb_regs *regs,
10389 - gdb_regs[R0] = regs->regs[R0];
10390 - gdb_regs[R1] = regs->regs[R1];
10391 - gdb_regs[R2] = regs->regs[R2];
10392 - gdb_regs[R3] = regs->regs[R3];
10393 - gdb_regs[R4] = regs->regs[R4];
10394 - gdb_regs[R5] = regs->regs[R5];
10395 - gdb_regs[R6] = regs->regs[R6];
10396 - gdb_regs[R7] = regs->regs[R7];
10397 - gdb_regs[R8] = regs->regs[R8];
10398 - gdb_regs[R9] = regs->regs[R9];
10399 - gdb_regs[R10] = regs->regs[R10];
10400 - gdb_regs[R11] = regs->regs[R11];
10401 - gdb_regs[R12] = regs->regs[R12];
10402 - gdb_regs[R13] = regs->regs[R13];
10403 - gdb_regs[R14] = regs->regs[R14];
10404 - gdb_regs[R15] = regs->regs[R15];
10405 - gdb_regs[PC] = regs->pc;
10406 - gdb_regs[PR] = regs->pr;
10407 - gdb_regs[GBR] = regs->gbr;
10408 - gdb_regs[MACH] = regs->mach;
10409 - gdb_regs[MACL] = regs->macl;
10410 - gdb_regs[SR] = regs->sr;
10411 - gdb_regs[VBR] = regs->vbr;
10414 -/* Copy local gdb registers back to kgdb regs, for later copy to kernel */
10415 -static void gdb_regs_to_kgdb_regs(const int *gdb_regs,
10416 - struct kgdb_regs *regs)
10418 - regs->regs[R0] = gdb_regs[R0];
10419 - regs->regs[R1] = gdb_regs[R1];
10420 - regs->regs[R2] = gdb_regs[R2];
10421 - regs->regs[R3] = gdb_regs[R3];
10422 - regs->regs[R4] = gdb_regs[R4];
10423 - regs->regs[R5] = gdb_regs[R5];
10424 - regs->regs[R6] = gdb_regs[R6];
10425 - regs->regs[R7] = gdb_regs[R7];
10426 - regs->regs[R8] = gdb_regs[R8];
10427 - regs->regs[R9] = gdb_regs[R9];
10428 - regs->regs[R10] = gdb_regs[R10];
10429 - regs->regs[R11] = gdb_regs[R11];
10430 - regs->regs[R12] = gdb_regs[R12];
10431 - regs->regs[R13] = gdb_regs[R13];
10432 - regs->regs[R14] = gdb_regs[R14];
10433 - regs->regs[R15] = gdb_regs[R15];
10434 - regs->pc = gdb_regs[PC];
10435 - regs->pr = gdb_regs[PR];
10436 - regs->gbr = gdb_regs[GBR];
10437 - regs->mach = gdb_regs[MACH];
10438 - regs->macl = gdb_regs[MACL];
10439 - regs->sr = gdb_regs[SR];
10440 - regs->vbr = gdb_regs[VBR];
10443 -#ifdef CONFIG_KGDB_THREAD
10444 -/* Make a local copy of registers from the specified thread */
10445 -asmlinkage void ret_from_fork(void);
10446 -static void thread_regs_to_gdb_regs(const struct task_struct *thread,
10452 - /* Initialize to zero */
10453 - for (regno = 0; regno < MAXREG; regno++)
10454 - gdb_regs[regno] = 0;
10456 - /* Just making sure... */
10457 - if (thread == NULL)
10460 - /* A new fork has pt_regs on the stack from a fork() call */
10461 - if (thread->thread.pc == (unsigned long)ret_from_fork) {
10464 - struct pt_regs *kregs;
10465 - kregs = (struct pt_regs*)thread->thread.sp;
10467 - gdb_regs[R0] = kregs->regs[R0];
10468 - gdb_regs[R1] = kregs->regs[R1];
10469 - gdb_regs[R2] = kregs->regs[R2];
10470 - gdb_regs[R3] = kregs->regs[R3];
10471 - gdb_regs[R4] = kregs->regs[R4];
10472 - gdb_regs[R5] = kregs->regs[R5];
10473 - gdb_regs[R6] = kregs->regs[R6];
10474 - gdb_regs[R7] = kregs->regs[R7];
10475 - gdb_regs[R8] = kregs->regs[R8];
10476 - gdb_regs[R9] = kregs->regs[R9];
10477 - gdb_regs[R10] = kregs->regs[R10];
10478 - gdb_regs[R11] = kregs->regs[R11];
10479 - gdb_regs[R12] = kregs->regs[R12];
10480 - gdb_regs[R13] = kregs->regs[R13];
10481 - gdb_regs[R14] = kregs->regs[R14];
10482 - gdb_regs[R15] = kregs->regs[R15];
10483 - gdb_regs[PC] = kregs->pc;
10484 - gdb_regs[PR] = kregs->pr;
10485 - gdb_regs[GBR] = kregs->gbr;
10486 - gdb_regs[MACH] = kregs->mach;
10487 - gdb_regs[MACL] = kregs->macl;
10488 - gdb_regs[SR] = kregs->sr;
10490 - asm("stc vbr, %0":"=r"(vbr_val));
10491 - gdb_regs[VBR] = vbr_val;
10495 - /* Otherwise, we have only some registers from switch_to() */
10496 - tregs = (int *)thread->thread.sp;
10497 - gdb_regs[R15] = (int)tregs;
10498 - gdb_regs[R14] = *tregs++;
10499 - gdb_regs[R13] = *tregs++;
10500 - gdb_regs[R12] = *tregs++;
10501 - gdb_regs[R11] = *tregs++;
10502 - gdb_regs[R10] = *tregs++;
10503 - gdb_regs[R9] = *tregs++;
10504 - gdb_regs[R8] = *tregs++;
10505 - gdb_regs[PR] = *tregs++;
10506 - gdb_regs[GBR] = *tregs++;
10507 - gdb_regs[PC] = thread->thread.pc;
10509 -#endif /* CONFIG_KGDB_THREAD */
10511 -/* Calculate the new address for after a step */
10512 -static short *get_step_address(void)
10514 - short op = *(short *) trap_registers.pc;
10518 - if (OPCODE_BT(op)) {
10519 - if (trap_registers.sr & SR_T_BIT_MASK)
10520 - addr = trap_registers.pc + 4 + OPCODE_BTF_DISP(op);
10522 - addr = trap_registers.pc + 2;
10526 - else if (OPCODE_BTS(op)) {
10527 - if (trap_registers.sr & SR_T_BIT_MASK)
10528 - addr = trap_registers.pc + 4 + OPCODE_BTF_DISP(op);
10530 - addr = trap_registers.pc + 4; /* Not in delay slot */
10534 - else if (OPCODE_BF(op)) {
10535 - if (!(trap_registers.sr & SR_T_BIT_MASK))
10536 - addr = trap_registers.pc + 4 + OPCODE_BTF_DISP(op);
10538 - addr = trap_registers.pc + 2;
10542 - else if (OPCODE_BFS(op)) {
10543 - if (!(trap_registers.sr & SR_T_BIT_MASK))
10544 - addr = trap_registers.pc + 4 + OPCODE_BTF_DISP(op);
10546 - addr = trap_registers.pc + 4; /* Not in delay slot */
10550 - else if (OPCODE_BRA(op))
10551 - addr = trap_registers.pc + 4 + OPCODE_BRA_DISP(op);
10554 - else if (OPCODE_BRAF(op))
10555 - addr = trap_registers.pc + 4
10556 - + trap_registers.regs[OPCODE_BRAF_REG(op)];
10559 - else if (OPCODE_BSR(op))
10560 - addr = trap_registers.pc + 4 + OPCODE_BSR_DISP(op);
10563 - else if (OPCODE_BSRF(op))
10564 - addr = trap_registers.pc + 4
10565 - + trap_registers.regs[OPCODE_BSRF_REG(op)];
10568 - else if (OPCODE_JMP(op))
10569 - addr = trap_registers.regs[OPCODE_JMP_REG(op)];
10572 - else if (OPCODE_JSR(op))
10573 - addr = trap_registers.regs[OPCODE_JSR_REG(op)];
10576 - else if (OPCODE_RTS(op))
10577 - addr = trap_registers.pr;
10580 - else if (OPCODE_RTE(op))
10581 - addr = trap_registers.regs[15];
10585 - addr = trap_registers.pc + 2;
10587 - kgdb_flush_icache_range(addr, addr + 2);
10588 - return (short *) addr;
10591 -/* Set up a single-step. Replace the instruction immediately after the
10592 - current instruction (i.e. next in the expected flow of control) with a
10593 - trap instruction, so that returning will cause only a single instruction
10594 - to be executed. Note that this model is slightly broken for instructions
10595 - with delay slots (e.g. B[TF]S, BSR, BRA etc), where both the branch
10596 - and the instruction in the delay slot will be executed. */
10597 -static void do_single_step(void)
10599 - unsigned short *addr = 0;
10601 - /* Determine where the target instruction will send us to */
10602 - addr = get_step_address();
10603 - stepped_address = (int)addr;
10606 - stepped_opcode = *(short *)addr;
10607 - *addr = STEP_OPCODE;
10609 - /* Flush and return */
10610 - kgdb_flush_icache_range((long) addr, (long) addr + 2);
10614 -/* Undo a single step */
10615 -static void undo_single_step(void)
10617 - /* If we have stepped, put back the old instruction */
10618 - /* Use stepped_address in case we stopped elsewhere */
10619 - if (stepped_opcode != 0) {
10620 - *(short*)stepped_address = stepped_opcode;
10621 - kgdb_flush_icache_range(stepped_address, stepped_address + 2);
10623 - stepped_opcode = 0;
10626 -/* Send a signal message */
10627 -static void send_signal_msg(const int signum)
10629 -#ifndef CONFIG_KGDB_THREAD
10630 - out_buffer[0] = 'S';
10631 - out_buffer[1] = highhex(signum);
10632 - out_buffer[2] = lowhex(signum);
10633 - out_buffer[3] = 0;
10634 - put_packet(out_buffer);
10635 -#else /* CONFIG_KGDB_THREAD */
10638 - char *out = out_buffer;
10639 - const char *tstring = "thread";
10642 - *out++ = highhex(signum);
10643 - *out++ = lowhex(signum);
10645 - while (*tstring) {
10646 - *out++ = *tstring++;
10650 - threadid = trapped_thread->pid;
10651 - if (threadid == 0) threadid = PID_MAX;
10652 - int_to_threadref(&thref, threadid);
10653 - pack_threadid(out, &thref);
10654 - out += BUF_THREAD_ID_SIZE;
10658 - put_packet(out_buffer);
10659 -#endif /* CONFIG_KGDB_THREAD */
10662 -/* Reply that all was well */
10663 -static void send_ok_msg(void)
10665 - strcpy(out_buffer, "OK");
10666 - put_packet(out_buffer);
10669 -/* Reply that an error occurred */
10670 -static void send_err_msg(void)
10672 - strcpy(out_buffer, "E01");
10673 - put_packet(out_buffer);
10676 -/* Empty message indicates unrecognised command */
10677 -static void send_empty_msg(void)
10682 -/* Read memory due to 'm' message */
10683 -static void read_mem_msg(void)
10689 - /* Jmp, disable bus error handler */
10690 - if (setjmp(rem_com_env) == 0) {
10692 - kgdb_nofault = 1;
10694 - /* Walk through, have m<addr>,<length> */
10695 - ptr = &in_buffer[1];
10696 - if (hex_to_int(&ptr, &addr) && (*ptr++ == ','))
10697 - if (hex_to_int(&ptr, &length)) {
10699 - if (length * 2 > OUTBUFMAX)
10700 - length = OUTBUFMAX / 2;
10701 - mem_to_hex((char *) addr, out_buffer, length);
10706 - put_packet(out_buffer);
10710 - /* Restore bus error handler */
10711 - kgdb_nofault = 0;
10714 -/* Write memory due to 'M' or 'X' message */
10715 -static void write_mem_msg(int binary)
10721 - if (setjmp(rem_com_env) == 0) {
10723 - kgdb_nofault = 1;
10725 - /* Walk through, have M<addr>,<length>:<data> */
10726 - ptr = &in_buffer[1];
10727 - if (hex_to_int(&ptr, &addr) && (*ptr++ == ','))
10728 - if (hex_to_int(&ptr, &length) && (*ptr++ == ':')) {
10730 - ebin_to_mem(ptr, (char*)addr, length);
10732 - hex_to_mem(ptr, (char*)addr, length);
10733 - kgdb_flush_icache_range(addr, addr + length);
10742 - /* Restore bus error handler */
10743 - kgdb_nofault = 0;
10746 -/* Continue message */
10747 -static void continue_msg(void)
10749 - /* Try to read optional parameter, PC unchanged if none */
10750 - char *ptr = &in_buffer[1];
10753 - if (hex_to_int(&ptr, &addr))
10754 - trap_registers.pc = addr;
10757 -/* Continue message with signal */
10758 -static void continue_with_sig_msg(void)
10761 - char *ptr = &in_buffer[1];
10764 - /* Report limitation */
10765 - kgdb_to_gdb("Cannot force signal in kgdb, continuing anyway.\n");
10768 - hex_to_int(&ptr, &signal);
10772 - /* Optional address */
10773 - if (hex_to_int(&ptr, &addr))
10774 - trap_registers.pc = addr;
10777 -/* Step message */
10778 -static void step_msg(void)
10781 - do_single_step();
10784 -/* Step message with signal */
10785 -static void step_with_sig_msg(void)
10787 - continue_with_sig_msg();
10788 - do_single_step();
10791 -/* Send register contents */
10792 -static void send_regs_msg(void)
10794 -#ifdef CONFIG_KGDB_THREAD
10795 - if (!current_thread)
10796 - kgdb_regs_to_gdb_regs(&trap_registers, registers);
10798 - thread_regs_to_gdb_regs(current_thread, registers);
10800 - kgdb_regs_to_gdb_regs(&trap_registers, registers);
10803 - mem_to_hex((char *) registers, out_buffer, NUMREGBYTES);
10804 - put_packet(out_buffer);
10807 -/* Set register contents - currently can't set other thread's registers */
10808 -static void set_regs_msg(void)
10810 -#ifdef CONFIG_KGDB_THREAD
10811 - if (!current_thread) {
10813 - kgdb_regs_to_gdb_regs(&trap_registers, registers);
10814 - hex_to_mem(&in_buffer[1], (char *) registers, NUMREGBYTES);
10815 - gdb_regs_to_kgdb_regs(registers, &trap_registers);
10817 -#ifdef CONFIG_KGDB_THREAD
10824 -#ifdef CONFIG_KGDB_THREAD
10826 -/* Set the status for a thread */
10827 -void set_thread_msg(void)
10830 - struct task_struct *thread = NULL;
10833 - switch (in_buffer[1]) {
10835 - /* To select which thread for gG etc messages, i.e. supported */
10838 - ptr = &in_buffer[2];
10839 - hex_to_int(&ptr, &threadid);
10840 - thread = get_thread(threadid);
10842 - /* If we haven't found it */
10848 - /* Set current_thread (or not) */
10849 - if (thread == trapped_thread)
10850 - current_thread = NULL;
10852 - current_thread = thread;
10856 - /* To select which thread for cCsS messages, i.e. unsupported */
10862 - send_empty_msg();
10867 -/* Is a thread alive? */
10868 -static void thread_status_msg(void)
10872 - struct task_struct *thread = NULL;
10874 - ptr = &in_buffer[1];
10875 - hex_to_int(&ptr, &threadid);
10876 - thread = get_thread(threadid);
10882 -/* Send the current thread ID */
10883 -static void thread_id_msg(void)
10888 - out_buffer[0] = 'Q';
10889 - out_buffer[1] = 'C';
10891 - if (current_thread)
10892 - threadid = current_thread->pid;
10893 - else if (trapped_thread)
10894 - threadid = trapped_thread->pid;
10895 - else /* Impossible, but just in case! */
10901 - /* Translate pid 0 to PID_MAX for gdb */
10902 - if (threadid == 0) threadid = PID_MAX;
10904 - int_to_threadref(&thref, threadid);
10905 - pack_threadid(out_buffer + 2, &thref);
10906 - out_buffer[2 + BUF_THREAD_ID_SIZE] = '\0';
10907 - put_packet(out_buffer);
10910 -/* Send thread info */
10911 -static void thread_info_msg(void)
10913 - struct task_struct *thread = NULL;
10918 - /* Start with 'm' */
10919 - out_buffer[0] = 'm';
10920 - pos = &out_buffer[1];
10922 - /* For all possible thread IDs - this will overrun if > 44 threads! */
10923 - /* Start at 1 and include PID_MAX (since GDB won't use pid 0...) */
10924 - for (threadid = 1; threadid <= PID_MAX; threadid++) {
10926 - read_lock(&tasklist_lock);
10927 - thread = get_thread(threadid);
10928 - read_unlock(&tasklist_lock);
10930 - /* If it's a valid thread */
10932 - int_to_threadref(&thref, threadid);
10933 - pack_threadid(pos, &thref);
10934 - pos += BUF_THREAD_ID_SIZE;
10938 - *--pos = 0; /* Lose final comma */
10939 - put_packet(out_buffer);
10943 -/* Return printable info for gdb's 'info threads' command */
10944 -static void thread_extra_info_msg(void)
10947 - struct task_struct *thread = NULL;
10948 - char buffer[20], *ptr;
10951 - /* Extract thread ID */
10952 - ptr = &in_buffer[17];
10953 - hex_to_int(&ptr, &threadid);
10954 - thread = get_thread(threadid);
10956 - /* If we don't recognise it, say so */
10957 - if (thread == NULL)
10958 - strcpy(buffer, "(unknown)");
10960 - strcpy(buffer, thread->comm);
10962 - /* Construct packet */
10963 - for (i = 0, ptr = out_buffer; buffer[i]; i++)
10964 - ptr = pack_hex_byte(ptr, buffer[i]);
10966 - if (thread->thread.pc == (unsigned long)ret_from_fork) {
10967 - strcpy(buffer, "<new fork>");
10968 - for (i = 0; buffer[i]; i++)
10969 - ptr = pack_hex_byte(ptr, buffer[i]);
10973 - put_packet(out_buffer);
10976 -/* Handle all qFooBarBaz messages - have to use an if statement as
10977 - opposed to a switch because q messages can have > 1 char id. */
10978 -static void query_msg(void)
10980 - const char *q_start = &in_buffer[1];
10982 - /* qC = return current thread ID */
10983 - if (strncmp(q_start, "C", 1) == 0)
10986 - /* qfThreadInfo = query all threads (first) */
10987 - else if (strncmp(q_start, "fThreadInfo", 11) == 0)
10988 - thread_info_msg();
10990 - /* qsThreadInfo = query all threads (subsequent). We know we have sent
10991 - them all after the qfThreadInfo message, so there are no to send */
10992 - else if (strncmp(q_start, "sThreadInfo", 11) == 0)
10993 - put_packet("l"); /* el = last */
10995 - /* qThreadExtraInfo = supply printable information per thread */
10996 - else if (strncmp(q_start, "ThreadExtraInfo", 15) == 0)
10997 - thread_extra_info_msg();
10999 - /* Unsupported - empty message as per spec */
11001 - send_empty_msg();
11003 -#endif /* CONFIG_KGDB_THREAD */
11006 - * Bring up the ports..
11008 -static int kgdb_serial_setup(void)
11010 - extern int kgdb_console_setup(struct console *co, char *options);
11011 - struct console dummy;
11013 - kgdb_console_setup(&dummy, 0);
11018 -/* The command loop, read and act on requests */
11019 -static void kgdb_command_loop(const int excep_code, const int trapa_value)
11023 - if (excep_code == NMI_VEC) {
11024 -#ifndef CONFIG_KGDB_NMI
11025 - KGDB_PRINTK("Ignoring unexpected NMI?\n");
11027 -#else /* CONFIG_KGDB_NMI */
11028 - if (!kgdb_enabled) {
11029 - kgdb_enabled = 1;
11032 -#endif /* CONFIG_KGDB_NMI */
11035 - /* Ignore if we're disabled */
11036 - if (!kgdb_enabled)
11039 -#ifdef CONFIG_KGDB_THREAD
11040 - /* Until GDB specifies a thread */
11041 - current_thread = NULL;
11042 - trapped_thread = current;
11045 - /* Enter GDB mode (e.g. after detach) */
11046 - if (!kgdb_in_gdb_mode) {
11047 - /* Do serial setup, notify user, issue preemptive ack */
11048 - kgdb_serial_setup();
11049 - KGDB_PRINTK("Waiting for GDB (on %s%d at %d baud)\n",
11050 - (kgdb_porttype ? kgdb_porttype->name : ""),
11051 - kgdb_portnum, kgdb_baud);
11052 - kgdb_in_gdb_mode = 1;
11053 - put_debug_char('+');
11056 - /* Reply to host that an exception has occurred */
11057 - sigval = compute_signal(excep_code);
11058 - send_signal_msg(sigval);
11060 - /* TRAP_VEC exception indicates a software trap inserted in place of
11061 - code by GDB so back up PC by one instruction, as this instruction
11062 - will later be replaced by its original one. Do NOT do this for
11063 - trap 0xff, since that indicates a compiled-in breakpoint which
11064 - will not be replaced (and we would retake the trap forever) */
11065 - if ((excep_code == TRAP_VEC) && (trapa_value != (0xff << 2))) {
11066 - trap_registers.pc -= 2;
11069 - /* Undo any stepping we may have done */
11070 - undo_single_step();
11074 - out_buffer[0] = 0;
11075 - get_packet(in_buffer, BUFMAX);
11077 - /* Examine first char of buffer to see what we need to do */
11078 - switch (in_buffer[0]) {
11080 - case '?': /* Send which signal we've received */
11081 - send_signal_msg(sigval);
11084 - case 'g': /* Return the values of the CPU registers */
11088 - case 'G': /* Set the value of the CPU registers */
11092 - case 'm': /* Read LLLL bytes address AA..AA */
11096 - case 'M': /* Write LLLL bytes address AA..AA, ret OK */
11097 - write_mem_msg(0); /* 0 = data in hex */
11100 - case 'X': /* Write LLLL bytes esc bin address AA..AA */
11101 - if (kgdb_bits == '8')
11102 - write_mem_msg(1); /* 1 = data in binary */
11104 - send_empty_msg();
11107 - case 'C': /* Continue, signum included, we ignore it */
11108 - continue_with_sig_msg();
11111 - case 'c': /* Continue at address AA..AA (optional) */
11115 - case 'S': /* Step, signum included, we ignore it */
11116 - step_with_sig_msg();
11119 - case 's': /* Step one instruction from AA..AA */
11123 -#ifdef CONFIG_KGDB_THREAD
11125 - case 'H': /* Task related */
11126 - set_thread_msg();
11129 - case 'T': /* Query thread status */
11130 - thread_status_msg();
11133 - case 'q': /* Handle query - currently thread-related */
11138 - case 'k': /* 'Kill the program' with a kernel ? */
11141 - case 'D': /* Detach from program, send reply OK */
11142 - kgdb_in_gdb_mode = 0;
11144 - get_debug_char();
11148 - send_empty_msg();
11154 -/* There has been an exception, most likely a breakpoint. */
11155 -void kgdb_handle_exception(struct pt_regs *regs)
11157 - int excep_code, vbr_val;
11159 - int trapa_value = ctrl_inl(TRA);
11161 - /* Copy kernel regs (from stack) */
11162 - for (count = 0; count < 16; count++)
11163 - trap_registers.regs[count] = regs->regs[count];
11164 - trap_registers.pc = regs->pc;
11165 - trap_registers.pr = regs->pr;
11166 - trap_registers.sr = regs->sr;
11167 - trap_registers.gbr = regs->gbr;
11168 - trap_registers.mach = regs->mach;
11169 - trap_registers.macl = regs->macl;
11171 - asm("stc vbr, %0":"=r"(vbr_val));
11172 - trap_registers.vbr = vbr_val;
11174 - /* Get excode for command loop call, user access */
11175 - asm("stc r2_bank, %0":"=r"(excep_code));
11176 - kgdb_excode = excep_code;
11178 - /* Other interesting environment items for reference */
11179 - asm("stc r6_bank, %0":"=r"(kgdb_g_imask));
11180 - kgdb_current = current;
11181 - kgdb_trapa_val = trapa_value;
11183 - /* Act on the exception */
11184 - kgdb_command_loop(excep_code >> 5, trapa_value);
11186 - kgdb_current = NULL;
11188 - /* Copy back the (maybe modified) registers */
11189 - for (count = 0; count < 16; count++)
11190 - regs->regs[count] = trap_registers.regs[count];
11191 - regs->pc = trap_registers.pc;
11192 - regs->pr = trap_registers.pr;
11193 - regs->sr = trap_registers.sr;
11194 - regs->gbr = trap_registers.gbr;
11195 - regs->mach = trap_registers.mach;
11196 - regs->macl = trap_registers.macl;
11198 - vbr_val = trap_registers.vbr;
11199 - asm("ldc %0, vbr": :"r"(vbr_val));
11204 -/* Trigger a breakpoint by function */
11205 -void breakpoint(void)
11207 - if (!kgdb_enabled) {
11208 - kgdb_enabled = 1;
11214 -/* Initialise the KGDB data structures and serial configuration */
11215 -int kgdb_init(void)
11217 - if (!kgdb_enabled)
11221 - kgdb_nofault = 0;
11222 - stepped_opcode = 0;
11223 - kgdb_in_gdb_mode = 0;
11225 - if (kgdb_serial_setup() != 0) {
11226 - KGDB_PRINTK("serial setup error\n");
11230 - /* Init ptr to exception handler */
11231 - kgdb_debug_hook = kgdb_handle_exception;
11232 - kgdb_bus_err_hook = kgdb_handle_bus_error;
11234 - /* Enter kgdb now if requested, or just report init done */
11236 - kgdb_in_gdb_mode = 1;
11237 - put_debug_char('+');
11242 - KGDB_PRINTK("stub is initialized.\n");
11248 -/* Make function available for "user messages"; console will use it too. */
11250 -char gdbmsgbuf[BUFMAX];
11251 -#define MAXOUT ((BUFMAX-2)/2)
11253 -static void kgdb_msg_write(const char *s, unsigned count)
11260 - gdbmsgbuf[0] = 'O';
11262 - /* Fill and send buffers... */
11263 - while (count > 0) {
11264 - bufptr = gdbmsgbuf + 1;
11266 - /* Calculate how many this time */
11267 - wcount = (count > MAXOUT) ? MAXOUT : count;
11269 - /* Pack in hex chars */
11270 - for (i = 0; i < wcount; i++)
11271 - bufptr = pack_hex_byte(bufptr, s[i]);
11278 - /* Write packet */
11279 - put_packet(gdbmsgbuf);
11283 -static void kgdb_to_gdb(const char *s)
11285 - kgdb_msg_write(s, strlen(s));
11288 -#ifdef CONFIG_SH_KGDB_CONSOLE
11289 -void kgdb_console_write(struct console *co, const char *s, unsigned count)
11291 - /* Bail if we're not talking to GDB */
11292 - if (!kgdb_in_gdb_mode)
11295 - kgdb_msg_write(s, count);
11298 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/sh/kernel/setup.c linux-2.6.18-53.1.14.kgdb/arch/sh/kernel/setup.c
11299 --- linux-2.6.18-53.1.14/arch/sh/kernel/setup.c 2006-09-20 07:42:06.000000000 +0400
11300 +++ linux-2.6.18-53.1.14.kgdb/arch/sh/kernel/setup.c 2008-06-10 15:38:50.000000000 +0400
11302 #include <asm/setup.h>
11303 #include <asm/clock.h>
11305 -#ifdef CONFIG_SH_KGDB
11306 -#include <asm/kgdb.h>
11307 -static int kgdb_parse_options(char *options);
11309 extern void * __rd_start, * __rd_end;
11312 @@ -528,93 +524,3 @@ struct seq_operations cpuinfo_op = {
11313 .show = show_cpuinfo,
11315 #endif /* CONFIG_PROC_FS */
11317 -#ifdef CONFIG_SH_KGDB
11319 - * Parse command-line kgdb options. By default KGDB is enabled,
11320 - * entered on error (or other action) using default serial info.
11321 - * The command-line option can include a serial port specification
11322 - * and an action to override default or configured behavior.
11324 -struct kgdb_sermap kgdb_sci_sermap =
11325 -{ "ttySC", 5, kgdb_sci_setup, NULL };
11327 -struct kgdb_sermap *kgdb_serlist = &kgdb_sci_sermap;
11328 -struct kgdb_sermap *kgdb_porttype = &kgdb_sci_sermap;
11330 -void kgdb_register_sermap(struct kgdb_sermap *map)
11332 - struct kgdb_sermap *last;
11334 - for (last = kgdb_serlist; last->next; last = last->next)
11336 - last->next = map;
11337 - if (!map->namelen) {
11338 - map->namelen = strlen(map->name);
11342 -static int __init kgdb_parse_options(char *options)
11347 - /* Check for port spec (or use default) */
11349 - /* Determine port type and instance */
11350 - if (!memcmp(options, "tty", 3)) {
11351 - struct kgdb_sermap *map = kgdb_serlist;
11353 - while (map && memcmp(options, map->name, map->namelen))
11357 - KGDB_PRINTK("unknown port spec in %s\n", options);
11361 - kgdb_porttype = map;
11362 - kgdb_serial_setup = map->setup_fn;
11363 - kgdb_portnum = options[map->namelen] - '0';
11364 - options += map->namelen + 1;
11366 - options = (*options == ',') ? options+1 : options;
11368 - /* Read optional parameters (baud/parity/bits) */
11369 - baud = simple_strtoul(options, &options, 10);
11371 - kgdb_baud = baud;
11373 - c = toupper(*options);
11374 - if (c == 'E' || c == 'O' || c == 'N') {
11380 - if (c == '7' || c == '8') {
11384 - options = (*options == ',') ? options+1 : options;
11388 - /* Check for action specification */
11389 - if (!memcmp(options, "halt", 4)) {
11392 - } else if (!memcmp(options, "disabled", 8)) {
11393 - kgdb_enabled = 0;
11398 - KGDB_PRINTK("ignored unknown options: %s\n", options);
11403 -__setup("kgdb=", kgdb_parse_options);
11404 -#endif /* CONFIG_SH_KGDB */
11406 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/sh/kernel/time.c linux-2.6.18-53.1.14.kgdb/arch/sh/kernel/time.c
11407 --- linux-2.6.18-53.1.14/arch/sh/kernel/time.c 2006-09-20 07:42:06.000000000 +0400
11408 +++ linux-2.6.18-53.1.14.kgdb/arch/sh/kernel/time.c 2008-06-10 15:38:50.000000000 +0400
11409 @@ -184,12 +184,4 @@ void __init time_init(void)
11411 sys_timer = get_sys_timer();
11412 printk(KERN_INFO "Using %s for system timer\n", sys_timer->name);
11414 -#if defined(CONFIG_SH_KGDB)
11416 - * Set up kgdb as requested. We do it here because the serial
11417 - * init uses the timer vars we just set up for figuring baud.
11422 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/sh/kernel/traps.c linux-2.6.18-53.1.14.kgdb/arch/sh/kernel/traps.c
11423 --- linux-2.6.18-53.1.14/arch/sh/kernel/traps.c 2006-09-20 07:42:06.000000000 +0400
11424 +++ linux-2.6.18-53.1.14.kgdb/arch/sh/kernel/traps.c 2008-06-10 15:38:50.000000000 +0400
11426 #include <linux/spinlock.h>
11427 #include <linux/module.h>
11428 #include <linux/kallsyms.h>
11429 +#include <linux/kgdb.h>
11431 #include <asm/system.h>
11432 #include <asm/uaccess.h>
11434 #include <asm/processor.h>
11435 #include <asm/sections.h>
11437 -#ifdef CONFIG_SH_KGDB
11438 -#include <asm/kgdb.h>
11439 -#define CHK_REMOTE_DEBUG(regs) \
11441 - if ((kgdb_debug_hook != (kgdb_debug_hook_t *) NULL) && (!user_mode(regs))) \
11443 - (*kgdb_debug_hook)(regs); \
11447 -#define CHK_REMOTE_DEBUG(regs)
11448 +#ifndef CONFIG_KGDB
11449 +#define kgdb_handle_exception(t, s, e, r)
11452 #define DO_ERROR(trapnr, signr, str, name, tsk) \
11453 @@ -65,7 +57,7 @@ asmlinkage void do_##name(unsigned long
11454 local_irq_enable(); \
11455 tsk->thread.error_code = error_code; \
11456 tsk->thread.trap_no = trapnr; \
11457 - CHK_REMOTE_DEBUG(®s); \
11458 + kgdb_handle_exception(trapnr, signr, error_code, ®s); \
11459 force_sig(signr, tsk); \
11460 die_if_no_fixup(str,®s,error_code); \
11462 @@ -92,10 +84,12 @@ void die(const char * str, struct pt_reg
11464 static int die_counter;
11466 +#ifdef CONFIG_KGDB
11467 + kgdb_handle_exception(1, SIGTRAP, err, regs);
11470 spin_lock_irq(&die_lock);
11471 printk("%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter);
11472 - CHK_REMOTE_DEBUG(regs);
11474 spin_unlock_irq(&die_lock);
11476 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/sh/mm/extable.c linux-2.6.18-53.1.14.kgdb/arch/sh/mm/extable.c
11477 --- linux-2.6.18-53.1.14/arch/sh/mm/extable.c 2006-09-20 07:42:06.000000000 +0400
11478 +++ linux-2.6.18-53.1.14.kgdb/arch/sh/mm/extable.c 2008-06-10 15:38:50.000000000 +0400
11482 #include <linux/module.h>
11483 +#include <linux/kgdb.h>
11484 #include <asm/uaccess.h>
11486 int fixup_exception(struct pt_regs *regs)
11487 @@ -16,6 +17,12 @@ int fixup_exception(struct pt_regs *regs
11488 regs->pc = fixup->fixup;
11491 +#ifdef CONFIG_KGDB
11492 + if (atomic_read(&debugger_active) && kgdb_may_fault)
11493 + /* Restore our previous state. */
11494 + kgdb_fault_longjmp(kgdb_fault_jmp_regs);
11495 + /* Never reached. */
11500 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/sh/mm/fault-nommu.c linux-2.6.18-53.1.14.kgdb/arch/sh/mm/fault-nommu.c
11501 --- linux-2.6.18-53.1.14/arch/sh/mm/fault-nommu.c 2006-09-20 07:42:06.000000000 +0400
11502 +++ linux-2.6.18-53.1.14.kgdb/arch/sh/mm/fault-nommu.c 2008-06-10 15:38:50.000000000 +0400
11504 #include <asm/mmu_context.h>
11505 #include <asm/cacheflush.h>
11507 -#if defined(CONFIG_SH_KGDB)
11508 -#include <asm/kgdb.h>
11511 extern void die(const char *,struct pt_regs *,long);
11514 @@ -43,11 +39,6 @@ extern void die(const char *,struct pt_r
11515 asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long writeaccess,
11516 unsigned long address)
11518 -#if defined(CONFIG_SH_KGDB)
11519 - if (kgdb_nofault && kgdb_bus_err_hook)
11520 - kgdb_bus_err_hook();
11524 * Oops. The kernel tried to access some bad page. We'll have to
11525 * terminate things with extreme prejudice.
11526 @@ -69,11 +60,6 @@ asmlinkage void do_page_fault(struct pt_
11527 asmlinkage int __do_page_fault(struct pt_regs *regs, unsigned long writeaccess,
11528 unsigned long address)
11530 -#if defined(CONFIG_SH_KGDB)
11531 - if (kgdb_nofault && kgdb_bus_err_hook)
11532 - kgdb_bus_err_hook();
11535 if (address >= TASK_SIZE)
11538 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/sh/mm/fault.c linux-2.6.18-53.1.14.kgdb/arch/sh/mm/fault.c
11539 --- linux-2.6.18-53.1.14/arch/sh/mm/fault.c 2006-09-20 07:42:06.000000000 +0400
11540 +++ linux-2.6.18-53.1.14.kgdb/arch/sh/mm/fault.c 2008-06-10 15:38:50.000000000 +0400
11542 #include <asm/pgalloc.h>
11543 #include <asm/mmu_context.h>
11544 #include <asm/cacheflush.h>
11545 -#include <asm/kgdb.h>
11547 extern void die(const char *,struct pt_regs *,long);
11549 @@ -45,11 +44,6 @@ asmlinkage void do_page_fault(struct pt_
11550 struct vm_area_struct * vma;
11551 unsigned long page;
11553 -#ifdef CONFIG_SH_KGDB
11554 - if (kgdb_nofault && kgdb_bus_err_hook)
11555 - kgdb_bus_err_hook();
11561 @@ -153,6 +147,7 @@ no_context:
11563 die("Oops", regs, writeaccess);
11568 * We ran out of memory, or some other thing happened to us that made
11569 @@ -202,11 +197,6 @@ asmlinkage int __do_page_fault(struct pt
11573 -#ifdef CONFIG_SH_KGDB
11574 - if (kgdb_nofault && kgdb_bus_err_hook)
11575 - kgdb_bus_err_hook();
11578 #ifdef CONFIG_SH_STORE_QUEUES
11579 addrmax = P4SEG_STORE_QUE + 0x04000000;
11581 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/x86_64/Kconfig.debug linux-2.6.18-53.1.14.kgdb/arch/x86_64/Kconfig.debug
11582 --- linux-2.6.18-53.1.14/arch/x86_64/Kconfig.debug 2006-09-20 07:42:06.000000000 +0400
11583 +++ linux-2.6.18-53.1.14.kgdb/arch/x86_64/Kconfig.debug 2008-06-10 15:38:44.000000000 +0400
11584 @@ -55,7 +55,4 @@ config DEBUG_STACK_USAGE
11586 This option will slow down process creation somewhat.
11588 -#config X86_REMOTE_DEBUG
11589 -# bool "kgdb debugging stub"
11592 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/x86_64/kernel/Makefile linux-2.6.18-53.1.14.kgdb/arch/x86_64/kernel/Makefile
11593 --- linux-2.6.18-53.1.14/arch/x86_64/kernel/Makefile 2008-03-06 05:54:48.000000000 +0300
11594 +++ linux-2.6.18-53.1.14.kgdb/arch/x86_64/kernel/Makefile 2008-06-10 15:38:44.000000000 +0400
11595 @@ -35,6 +35,7 @@ obj-$(CONFIG_IOMMU) += pci-gart.o apert
11596 obj-$(CONFIG_CALGARY_IOMMU) += pci-calgary.o tce.o
11597 obj-$(CONFIG_SWIOTLB) += pci-swiotlb.o
11598 obj-$(CONFIG_KPROBES) += kprobes.o
11599 +obj-$(CONFIG_KGDB) += kgdb.o kgdb-jmp.o
11600 obj-$(CONFIG_X86_PM_TIMER) += pmtimer.o
11601 obj-$(CONFIG_X86_VSMP) += vsmp.o
11602 obj-$(CONFIG_K8_NB) += k8.o
11603 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/x86_64/kernel/entry.S linux-2.6.18-53.1.14.kgdb/arch/x86_64/kernel/entry.S
11604 --- linux-2.6.18-53.1.14/arch/x86_64/kernel/entry.S 2008-03-06 05:54:50.000000000 +0300
11605 +++ linux-2.6.18-53.1.14.kgdb/arch/x86_64/kernel/entry.S 2008-06-10 15:39:01.000000000 +0400
11607 #include <asm/hw_irq.h>
11608 #include <asm/page.h>
11609 #include <asm/irqflags.h>
11610 +#include <asm/kgdb.h>
11614 @@ -887,6 +888,7 @@ error_exit:
11618 + CFI_END_FRAME(kernel_thread)
11622 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/x86_64/kernel/kgdb-jmp.S linux-2.6.18-53.1.14.kgdb/arch/x86_64/kernel/kgdb-jmp.S
11623 --- linux-2.6.18-53.1.14/arch/x86_64/kernel/kgdb-jmp.S 1970-01-01 03:00:00.000000000 +0300
11624 +++ linux-2.6.18-53.1.14.kgdb/arch/x86_64/kernel/kgdb-jmp.S 2008-06-10 15:38:44.000000000 +0400
11627 + * arch/x86_64/kernel/kgdb-jmp.S
11629 + * Save and restore system registers so that within a limited frame we
11630 + * may have a fault and "jump back" to a known safe location.
11632 + * Author: Tom Rini <trini@kernel.crashing.org>
11634 + * Cribbed from glibc, which carries the following:
11635 + * Copyright (C) 2001, 2003, 2004 Free Software Foundation, Inc.
11636 + * Copyright (C) 2005 by MontaVista Software.
11638 + * This file is licensed under the terms of the GNU General Public License
11639 + * version 2. This program as licensed "as is" without any warranty of
11640 + * any kind, whether express or implied.
11643 +#include <linux/linkage.h>
11656 +/* This must be called prior to kgdb_fault_longjmp and
11657 + * kgdb_fault_longjmp must not be called outside of the context of the
11658 + * last call to kgdb_fault_setjmp.
11660 +ENTRY(kgdb_fault_setjmp)
11661 + /* Save registers. */
11662 + movq %rbx, (JB_RBX*8)(%rdi)
11663 + movq %rbp, (JB_RBP*8)(%rdi)
11664 + movq %r12, (JB_R12*8)(%rdi)
11665 + movq %r13, (JB_R13*8)(%rdi)
11666 + movq %r14, (JB_R14*8)(%rdi)
11667 + movq %r15, (JB_R15*8)(%rdi)
11668 + leaq 8(%rsp), %rdx /* Save SP as it will be after we return. */
11669 + movq %rdx, (JB_RSP*8)(%rdi)
11670 + movq (%rsp), %rax /* Save PC we are returning to now. */
11671 + movq %rax, (JB_PC*8)(%rdi)
11672 + /* Set return value for setjmp. */
11674 + movq (JB_PC*8)(%rdi),%rdx
11675 + movq (JB_RSP*8)(%rdi),%rsp
11678 +ENTRY(kgdb_fault_longjmp)
11679 + /* Restore registers. */
11680 + movq (JB_RBX*8)(%rdi),%rbx
11681 + movq (JB_RBP*8)(%rdi),%rbp
11682 + movq (JB_R12*8)(%rdi),%r12
11683 + movq (JB_R13*8)(%rdi),%r13
11684 + movq (JB_R14*8)(%rdi),%r14
11685 + movq (JB_R15*8)(%rdi),%r15
11686 + /* Set return value for setjmp. */
11687 + movq (JB_PC*8)(%rdi),%rdx
11688 + movq (JB_RSP*8)(%rdi),%rsp
11691 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/x86_64/kernel/kgdb.c linux-2.6.18-53.1.14.kgdb/arch/x86_64/kernel/kgdb.c
11692 --- linux-2.6.18-53.1.14/arch/x86_64/kernel/kgdb.c 1970-01-01 03:00:00.000000000 +0300
11693 +++ linux-2.6.18-53.1.14.kgdb/arch/x86_64/kernel/kgdb.c 2008-06-10 15:38:44.000000000 +0400
11697 + * This program is free software; you can redistribute it and/or modify it
11698 + * under the terms of the GNU General Public License as published by the
11699 + * Free Software Foundation; either version 2, or (at your option) any
11702 + * This program is distributed in the hope that it will be useful, but
11703 + * WITHOUT ANY WARRANTY; without even the implied warranty of
11704 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11705 + * General Public License for more details.
11710 + * Copyright (C) 2004 Amit S. Kale <amitkale@linsyssoft.com>
11711 + * Copyright (C) 2000-2001 VERITAS Software Corporation.
11712 + * Copyright (C) 2002 Andi Kleen, SuSE Labs
11713 + * Copyright (C) 2004 LinSysSoft Technologies Pvt. Ltd.
11715 +/****************************************************************************
11716 + * Contributor: Lake Stevens Instrument Division$
11717 + * Written by: Glenn Engel $
11718 + * Updated by: Amit Kale<akale@veritas.com>
11719 + * Modified for 386 by Jim Kingdon, Cygnus Support.
11720 + * Origianl kgdb, compatibility with 2.1.xx kernel by
11721 + * David Grothe <dave@gcom.com>
11722 + * Integrated into 2.2.5 kernel by Tigran Aivazian <tigran@sco.com>
11723 + * X86_64 changes from Andi Kleen's patch merged by Jim Houston
11726 +#include <linux/string.h>
11727 +#include <linux/kernel.h>
11728 +#include <linux/sched.h>
11729 +#include <linux/smp.h>
11730 +#include <linux/spinlock.h>
11731 +#include <linux/delay.h>
11732 +#include <asm/system.h>
11733 +#include <asm/ptrace.h> /* for linux pt_regs struct */
11734 +#include <linux/kgdb.h>
11735 +#include <linux/init.h>
11736 +#include <asm/apicdef.h>
11737 +#include <asm/mach_apic.h>
11738 +#include <asm/kdebug.h>
11739 +#include <asm/debugreg.h>
11741 +/* Put the error code here just in case the user cares. */
11742 +int gdb_x86_64errcode;
11743 +/* Likewise, the vector number here (since GDB only gets the signal
11744 + number through the usual means, and that's not very specific). */
11745 +int gdb_x86_64vector = -1;
11747 +extern atomic_t cpu_doing_single_step;
11749 +void regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs)
11751 + gdb_regs[_RAX] = regs->rax;
11752 + gdb_regs[_RBX] = regs->rbx;
11753 + gdb_regs[_RCX] = regs->rcx;
11754 + gdb_regs[_RDX] = regs->rdx;
11755 + gdb_regs[_RSI] = regs->rsi;
11756 + gdb_regs[_RDI] = regs->rdi;
11757 + gdb_regs[_RBP] = regs->rbp;
11758 + gdb_regs[_PS] = regs->eflags;
11759 + gdb_regs[_PC] = regs->rip;
11760 + gdb_regs[_R8] = regs->r8;
11761 + gdb_regs[_R9] = regs->r9;
11762 + gdb_regs[_R10] = regs->r10;
11763 + gdb_regs[_R11] = regs->r11;
11764 + gdb_regs[_R12] = regs->r12;
11765 + gdb_regs[_R13] = regs->r13;
11766 + gdb_regs[_R14] = regs->r14;
11767 + gdb_regs[_R15] = regs->r15;
11768 + gdb_regs[_RSP] = regs->rsp;
11771 +extern void thread_return(void);
11772 +void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p)
11774 + gdb_regs[_RAX] = 0;
11775 + gdb_regs[_RBX] = 0;
11776 + gdb_regs[_RCX] = 0;
11777 + gdb_regs[_RDX] = 0;
11778 + gdb_regs[_RSI] = 0;
11779 + gdb_regs[_RDI] = 0;
11780 + gdb_regs[_RBP] = *(unsigned long *)p->thread.rsp;
11781 + gdb_regs[_PS] = *(unsigned long *)(p->thread.rsp + 8);
11782 + gdb_regs[_PC] = (unsigned long)&thread_return;
11783 + gdb_regs[_R8] = 0;
11784 + gdb_regs[_R9] = 0;
11785 + gdb_regs[_R10] = 0;
11786 + gdb_regs[_R11] = 0;
11787 + gdb_regs[_R12] = 0;
11788 + gdb_regs[_R13] = 0;
11789 + gdb_regs[_R14] = 0;
11790 + gdb_regs[_R15] = 0;
11791 + gdb_regs[_RSP] = p->thread.rsp;
11794 +void gdb_regs_to_regs(unsigned long *gdb_regs, struct pt_regs *regs)
11796 + regs->rax = gdb_regs[_RAX];
11797 + regs->rbx = gdb_regs[_RBX];
11798 + regs->rcx = gdb_regs[_RCX];
11799 + regs->rdx = gdb_regs[_RDX];
11800 + regs->rsi = gdb_regs[_RSI];
11801 + regs->rdi = gdb_regs[_RDI];
11802 + regs->rbp = gdb_regs[_RBP];
11803 + regs->eflags = gdb_regs[_PS];
11804 + regs->rip = gdb_regs[_PC];
11805 + regs->r8 = gdb_regs[_R8];
11806 + regs->r9 = gdb_regs[_R9];
11807 + regs->r10 = gdb_regs[_R10];
11808 + regs->r11 = gdb_regs[_R11];
11809 + regs->r12 = gdb_regs[_R12];
11810 + regs->r13 = gdb_regs[_R13];
11811 + regs->r14 = gdb_regs[_R14];
11812 + regs->r15 = gdb_regs[_R15];
11813 +#if 0 /* can't change these */
11814 + regs->rsp = gdb_regs[_RSP];
11815 + regs->ss = gdb_regs[_SS];
11816 + regs->fs = gdb_regs[_FS];
11817 + regs->gs = gdb_regs[_GS];
11820 +} /* gdb_regs_to_regs */
11822 +struct hw_breakpoint {
11823 + unsigned enabled;
11826 + unsigned long addr;
11827 +} breakinfo[4] = { {
11833 +void kgdb_correct_hw_break(void)
11838 + unsigned long dr7;
11840 + asm volatile ("movq %%db7, %0\n":"=r" (dr7):);
11842 + unsigned long addr0, addr1, addr2, addr3;
11843 + asm volatile ("movq %%db0, %0\n"
11844 + "movq %%db1, %1\n"
11845 + "movq %%db2, %2\n"
11846 + "movq %%db3, %3\n":"=r" (addr0), "=r"(addr1),
11847 + "=r"(addr2), "=r"(addr3):);
11850 + for (breakno = 0; breakno < 3; breakno++) {
11851 + breakbit = 2 << (breakno << 1);
11852 + if (!(dr7 & breakbit) && breakinfo[breakno].enabled) {
11855 + dr7 &= ~(0xf0000 << (breakno << 2));
11856 + dr7 |= (((breakinfo[breakno].len << 2) |
11857 + breakinfo[breakno].type) << 16) <<
11859 + switch (breakno) {
11861 + asm volatile ("movq %0, %%dr0\n"::"r"
11862 + (breakinfo[breakno].addr));
11866 + asm volatile ("movq %0, %%dr1\n"::"r"
11867 + (breakinfo[breakno].addr));
11871 + asm volatile ("movq %0, %%dr2\n"::"r"
11872 + (breakinfo[breakno].addr));
11876 + asm volatile ("movq %0, %%dr3\n"::"r"
11877 + (breakinfo[breakno].addr));
11880 + } else if ((dr7 & breakbit) && !breakinfo[breakno].enabled) {
11882 + dr7 &= ~breakbit;
11883 + dr7 &= ~(0xf0000 << (breakno << 2));
11887 + asm volatile ("movq %0, %%db7\n"::"r" (dr7));
11891 +int kgdb_remove_hw_break(unsigned long addr)
11894 + for (i = 0; i < 4; i++) {
11895 + if (breakinfo[i].addr == addr && breakinfo[i].enabled) {
11903 + breakinfo[idx].enabled = 0;
11907 +int kgdb_set_hw_break(unsigned long addr)
11910 + for (i = 0; i < 4; i++) {
11911 + if (!breakinfo[i].enabled) {
11919 + breakinfo[idx].enabled = 1;
11920 + breakinfo[idx].type = 1;
11921 + breakinfo[idx].len = 1;
11922 + breakinfo[idx].addr = addr;
11926 +int remove_hw_break(unsigned breakno)
11928 + if (!breakinfo[breakno].enabled) {
11931 + breakinfo[breakno].enabled = 0;
11935 +int set_hw_break(unsigned breakno, unsigned type, unsigned len, unsigned addr)
11937 + if (breakinfo[breakno].enabled) {
11940 + breakinfo[breakno].enabled = 1;
11941 + breakinfo[breakno].type = type;
11942 + breakinfo[breakno].len = len;
11943 + breakinfo[breakno].addr = addr;
11947 +void kgdb_disable_hw_debug(struct pt_regs *regs)
11949 + /* Disable hardware debugging while we are in kgdb */
11950 + asm volatile ("movq %0,%%db7": /* no output */ :"r" (0UL));
11953 +void kgdb_post_master_code(struct pt_regs *regs, int e_vector, int err_code)
11955 + /* Master processor is completely in the debugger */
11956 + gdb_x86_64vector = e_vector;
11957 + gdb_x86_64errcode = err_code;
11960 +void kgdb_roundup_cpus(unsigned long flags)
11962 + send_IPI_allbutself(APIC_DM_NMI);
11965 +int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
11966 + char *remcomInBuffer, char *remcomOutBuffer,
11967 + struct pt_regs *linux_regs)
11969 + unsigned long addr, length;
11970 + unsigned long breakno, breaktype;
11973 + unsigned long dr6;
11975 + switch (remcomInBuffer[0]) {
11978 + /* try to read optional parameter, pc unchanged if no parm */
11979 + ptr = &remcomInBuffer[1];
11980 + if (kgdb_hex2long(&ptr, &addr))
11981 + linux_regs->rip = addr;
11982 + newPC = linux_regs->rip;
11984 + /* clear the trace bit */
11985 + linux_regs->eflags &= ~TF_MASK;
11987 + atomic_set(&cpu_doing_single_step, -1);
11988 + /* set the trace bit if we're stepping */
11989 + if (remcomInBuffer[0] == 's') {
11990 + linux_regs->eflags |= TF_MASK;
11991 + debugger_step = 1;
11992 + if (kgdb_contthread)
11993 + atomic_set(&cpu_doing_single_step,
11994 + smp_processor_id());
11998 + asm volatile ("movq %%db6, %0\n":"=r" (dr6));
11999 + if (!(dr6 & 0x4000)) {
12000 + for (breakno = 0; breakno < 4; ++breakno) {
12001 + if (dr6 & (1 << breakno)) {
12002 + if (breakinfo[breakno].type == 0) {
12003 + /* Set restore flag */
12004 + linux_regs->eflags |=
12011 + kgdb_correct_hw_break();
12012 + asm volatile ("movq %0, %%db6\n"::"r" (0UL));
12017 + ptr = &remcomInBuffer[1];
12018 + kgdb_hex2long(&ptr, &breakno);
12020 + kgdb_hex2long(&ptr, &breaktype);
12022 + kgdb_hex2long(&ptr, &length);
12024 + kgdb_hex2long(&ptr, &addr);
12025 + if (set_hw_break(breakno & 0x3, breaktype & 0x3,
12026 + length & 0x3, addr) == 0)
12027 + strcpy(remcomOutBuffer, "OK");
12029 + strcpy(remcomOutBuffer, "ERROR");
12032 + /* Remove hardware breakpoint */
12034 + ptr = &remcomInBuffer[1];
12035 + kgdb_hex2long(&ptr, &breakno);
12036 + if (remove_hw_break(breakno & 0x3) == 0)
12037 + strcpy(remcomOutBuffer, "OK");
12039 + strcpy(remcomOutBuffer, "ERROR");
12046 +static struct pt_regs *in_interrupt_stack(unsigned long rsp, int cpu)
12048 + struct pt_regs *regs;
12049 + unsigned long end = (unsigned long)cpu_pda(cpu)->irqstackptr;
12050 + if (rsp <= end && rsp >= end - IRQSTACKSIZE + 8) {
12051 + regs = *(((struct pt_regs **)end) - 1);
12057 +static struct pt_regs *in_exception_stack(unsigned long rsp, int cpu)
12060 + struct tss_struct *init_tss = &__get_cpu_var(init_tss);
12061 + for (i = 0; i < N_EXCEPTION_STACKS; i++)
12062 + if (rsp >= init_tss[cpu].ist[i] &&
12063 + rsp <= init_tss[cpu].ist[i] + EXCEPTION_STKSZ) {
12064 + struct pt_regs *r =
12065 + (void *)init_tss[cpu].ist[i] + EXCEPTION_STKSZ;
12071 +void kgdb_shadowinfo(struct pt_regs *regs, char *buffer, unsigned threadid)
12073 + static char intr_desc[] = "Stack at interrupt entrypoint";
12074 + static char exc_desc[] = "Stack at exception entrypoint";
12075 + struct pt_regs *stregs;
12076 + int cpu = hard_smp_processor_id();
12078 + if ((stregs = in_interrupt_stack(regs->rsp, cpu)))
12079 + kgdb_mem2hex(intr_desc, buffer, strlen(intr_desc));
12080 + else if ((stregs = in_exception_stack(regs->rsp, cpu)))
12081 + kgdb_mem2hex(exc_desc, buffer, strlen(exc_desc));
12084 +struct task_struct *kgdb_get_shadow_thread(struct pt_regs *regs, int threadid)
12086 + struct pt_regs *stregs;
12087 + int cpu = hard_smp_processor_id();
12089 + if ((stregs = in_interrupt_stack(regs->rsp, cpu)))
12091 + else if ((stregs = in_exception_stack(regs->rsp, cpu)))
12097 +struct pt_regs *kgdb_shadow_regs(struct pt_regs *regs, int threadid)
12099 + struct pt_regs *stregs;
12100 + int cpu = hard_smp_processor_id();
12102 + if ((stregs = in_interrupt_stack(regs->rsp, cpu)))
12104 + else if ((stregs = in_exception_stack(regs->rsp, cpu)))
12110 +/* Register KGDB with the die_chain so that we hook into all of the right
12112 +static int kgdb_notify(struct notifier_block *self, unsigned long cmd,
12115 + struct die_args *args = ptr;
12116 + struct pt_regs *regs = args->regs;
12118 + if (cmd == DIE_PAGE_FAULT_NO_CONTEXT && atomic_read(&debugger_active)
12119 + && kgdb_may_fault) {
12120 + kgdb_fault_longjmp(kgdb_fault_jmp_regs);
12121 + return NOTIFY_STOP;
12122 + /* CPU roundup? */
12123 + } else if (atomic_read(&debugger_active) && cmd == DIE_NMI_IPI) {
12124 + kgdb_nmihook(smp_processor_id(), regs);
12125 + return NOTIFY_STOP;
12126 + /* See if KGDB is interested. */
12127 + } else if (cmd == DIE_PAGE_FAULT || user_mode(regs) ||
12128 + cmd == DIE_NMI_IPI || (cmd == DIE_DEBUG &&
12129 + atomic_read(&debugger_active)))
12130 + /* Userpace events, normal watchdog event, or spurious
12131 + * debug exception. Ignore. */
12132 + return NOTIFY_DONE;
12134 + kgdb_handle_exception(args->trapnr, args->signr, args->err, regs);
12136 + return NOTIFY_STOP;
12139 +static struct notifier_block kgdb_notifier = {
12140 + .notifier_call = kgdb_notify,
12141 + .priority = 0x7fffffff, /* we need to notified first */
12144 +int kgdb_arch_init(void)
12146 + atomic_notifier_chain_register(&die_chain, &kgdb_notifier);
12150 + * Skip an int3 exception when it occurs after a breakpoint has been
12151 + * removed. Backtrack eip by 1 since the int3 would have caused it to
12152 + * increment by 1.
12155 +int kgdb_skipexception(int exception, struct pt_regs *regs)
12157 + if (exception == 3 && kgdb_isremovedbreak(regs->rip - 1)) {
12164 +struct kgdb_arch arch_kgdb_ops = {
12165 + .gdb_bpt_instr = {0xcc},
12166 + .flags = KGDB_HW_BREAKPOINT,
12169 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/arch/x86_64/mm/fault.c linux-2.6.18-53.1.14.kgdb/arch/x86_64/mm/fault.c
12170 --- linux-2.6.18-53.1.14/arch/x86_64/mm/fault.c 2008-03-06 05:54:27.000000000 +0300
12171 +++ linux-2.6.18-53.1.14.kgdb/arch/x86_64/mm/fault.c 2008-06-10 15:38:41.000000000 +0400
12172 @@ -557,6 +557,10 @@ no_context:
12173 if (is_errata93(regs, address))
12176 + if (notify_die(DIE_PAGE_FAULT_NO_CONTEXT, "no context", regs,
12177 + error_code, 14, SIGSEGV) == NOTIFY_STOP)
12181 * Oops. The kernel tried to access some bad page. We'll have to
12182 * terminate things with extreme prejudice.
12183 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/drivers/char/keyboard.c linux-2.6.18-53.1.14.kgdb/drivers/char/keyboard.c
12184 --- linux-2.6.18-53.1.14/drivers/char/keyboard.c 2008-03-06 05:54:23.000000000 +0300
12185 +++ linux-2.6.18-53.1.14.kgdb/drivers/char/keyboard.c 2008-06-10 15:39:11.000000000 +0400
12186 @@ -1174,6 +1174,7 @@ static void kbd_keycode(unsigned int key
12188 if (sysrq_down && down && !rep) {
12189 handle_sysrq(kbd_sysrq_xlate[keycode], regs, tty);
12190 + sysrq_down = 0; /* In case we miss the 'up' event. */
12194 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/drivers/net/Makefile linux-2.6.18-53.1.14.kgdb/drivers/net/Makefile
12195 --- linux-2.6.18-53.1.14/drivers/net/Makefile 2008-03-06 05:54:59.000000000 +0300
12196 +++ linux-2.6.18-53.1.14.kgdb/drivers/net/Makefile 2008-06-10 15:37:55.000000000 +0400
12197 @@ -221,6 +221,7 @@ obj-$(CONFIG_ETRAX_ETHERNET) += cris/
12198 obj-$(CONFIG_ENP2611_MSF_NET) += ixp2000/
12200 obj-$(CONFIG_NETCONSOLE) += netconsole.o
12201 +obj-$(CONFIG_KGDBOE) += kgdboe.o
12203 obj-$(CONFIG_FS_ENET) += fs_enet/
12205 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/drivers/net/kgdboe.c linux-2.6.18-53.1.14.kgdb/drivers/net/kgdboe.c
12206 --- linux-2.6.18-53.1.14/drivers/net/kgdboe.c 1970-01-01 03:00:00.000000000 +0300
12207 +++ linux-2.6.18-53.1.14.kgdb/drivers/net/kgdboe.c 2008-06-10 15:37:55.000000000 +0400
12210 + * drivers/net/kgdboe.c
12212 + * A network interface for GDB.
12213 + * Based upon 'gdbserial' by David Grothe <dave@gcom.com>
12214 + * and Scott Foehner <sfoehner@engr.sgi.com>
12216 + * Maintainers: Amit S. Kale <amitkale@linsyssoft.com> and
12217 + * Tom Rini <trini@kernel.crashing.org>
12219 + * 2004 (c) Amit S. Kale <amitkale@linsyssoft.com>
12220 + * 2004-2005 (c) MontaVista Software, Inc.
12221 + * 2005 (c) Wind River Systems, Inc.
12223 + * Contributors at various stages not listed above:
12224 + * San Mehat <nettwerk@biodome.org>, Robert Walsh <rjwalsh@durables.org>,
12225 + * wangdi <wangdi@clusterfs.com>, Matt Mackall <mpm@selenic.com>,
12226 + * Pavel Machek <pavel@suse.cz>, Jason Wessel <jason.wessel@windriver.com>
12228 + * This file is licensed under the terms of the GNU General Public License
12229 + * version 2. This program is licensed "as is" without any warranty of any
12230 + * kind, whether express or implied.
12233 +#include <linux/kernel.h>
12234 +#include <linux/interrupt.h>
12235 +#include <linux/string.h>
12236 +#include <linux/kgdb.h>
12237 +#include <linux/netpoll.h>
12238 +#include <linux/init.h>
12240 +#include <asm/atomic.h>
12242 +#define IN_BUF_SIZE 512 /* power of 2, please */
12243 +#define NOT_CONFIGURED_STRING "not_configured"
12244 +#define OUT_BUF_SIZE 30 /* We don't want to send too big of a packet. */
12245 +#define MAX_KGDBOE_CONFIG_STR 256
12247 +static char in_buf[IN_BUF_SIZE], out_buf[OUT_BUF_SIZE];
12248 +static int in_head, in_tail, out_count;
12249 +static atomic_t in_count;
12250 +/* 0 = unconfigured, 1 = netpoll options parsed, 2 = fully configured. */
12251 +static int configured;
12252 +static struct kgdb_io local_kgdb_io_ops;
12253 +static int use_dynamic_mac;
12255 +MODULE_DESCRIPTION("KGDB driver for network interfaces");
12256 +MODULE_LICENSE("GPL");
12257 +static char config[MAX_KGDBOE_CONFIG_STR] = NOT_CONFIGURED_STRING;
12258 +static struct kparam_string kps = {
12259 + .string = config,
12260 + .maxlen = MAX_KGDBOE_CONFIG_STR,
12263 +static void rx_hook(struct netpoll *np, int port, char *msg, int len,
12264 + struct sk_buff *skb)
12268 + np->remote_port = port;
12270 + /* Copy the MAC address if we need to. */
12271 + if (use_dynamic_mac) {
12272 + memcpy(np->remote_mac, eth_hdr(skb)->h_source,
12273 + sizeof(np->remote_mac));
12274 + use_dynamic_mac = 0;
12278 + * This could be GDB trying to attach. But it could also be GDB
12279 + * finishing up a session, with kgdb_connected=0 but GDB sending
12280 + * an ACK for the final packet. To make sure we don't try and
12281 + * make a breakpoint when GDB is leaving, make sure that if
12282 + * !kgdb_connected the only len == 1 packet we allow is ^C.
12284 + if (!kgdb_connected && (len != 1 || msg[0] == 3) &&
12285 + !atomic_read(&kgdb_setting_breakpoint)) {
12286 + tasklet_schedule(&kgdb_tasklet_breakpoint);
12289 + for (i = 0; i < len; i++) {
12291 + tasklet_schedule(&kgdb_tasklet_breakpoint);
12293 + if (atomic_read(&in_count) >= IN_BUF_SIZE) {
12294 + /* buffer overflow, clear it */
12295 + in_head = in_tail = 0;
12296 + atomic_set(&in_count, 0);
12299 + in_buf[in_head++] = msg[i];
12300 + in_head &= (IN_BUF_SIZE - 1);
12301 + atomic_inc(&in_count);
12305 +static struct netpoll np = {
12306 + .dev_name = "eth0",
12307 + .name = "kgdboe",
12308 + .rx_hook = rx_hook,
12309 + .local_port = 6443,
12310 + .remote_port = 6442,
12311 + .remote_mac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
12314 +static void eth_pre_exception_handler(void)
12316 + /* Increment the module count when the debugger is active */
12317 + if (!kgdb_connected)
12318 + try_module_get(THIS_MODULE);
12319 + netpoll_set_trap(1);
12322 +static void eth_post_exception_handler(void)
12324 + /* decrement the module count when the debugger detaches */
12325 + if (!kgdb_connected)
12326 + module_put(THIS_MODULE);
12327 + netpoll_set_trap(0);
12330 +static int eth_get_char(void)
12334 + while (atomic_read(&in_count) == 0)
12335 + netpoll_poll(&np);
12337 + chr = in_buf[in_tail++];
12338 + in_tail &= (IN_BUF_SIZE - 1);
12339 + atomic_dec(&in_count);
12343 +static void eth_flush_buf(void)
12345 + if (out_count && np.dev) {
12346 + netpoll_send_udp(&np, out_buf, out_count);
12347 + memset(out_buf, 0, sizeof(out_buf));
12352 +static void eth_put_char(u8 chr)
12354 + out_buf[out_count++] = chr;
12355 + if (out_count == OUT_BUF_SIZE)
12359 +static int option_setup(char *opt)
12361 + char opt_scratch[MAX_KGDBOE_CONFIG_STR];
12363 + /* If we're being given a new configuration, copy it in. */
12364 + if (opt != config)
12365 + strcpy(config, opt);
12366 + /* But work on a copy as netpoll_parse_options will eat it. */
12367 + strcpy(opt_scratch, opt);
12368 + configured = !netpoll_parse_options(&np, opt_scratch);
12370 + use_dynamic_mac = 1;
12374 +__setup("kgdboe=", option_setup);
12376 +/* With our config string set by some means, configure kgdboe. */
12377 +static int configure_kgdboe(void)
12379 + /* Try out the string. */
12380 + option_setup(config);
12382 + if (!configured) {
12383 + printk(KERN_ERR "kgdboe: configuration incorrect - kgdboe not "
12385 + printk(KERN_ERR " Usage: kgdboe=[src-port]@[src-ip]/[dev],"
12386 + "[tgt-port]@<tgt-ip>/<tgt-macaddr>\n");
12390 + /* Bring it up. */
12391 + if (netpoll_setup(&np)) {
12392 + printk(KERN_ERR "kgdboe: netpoll_setup failed kgdboe failed\n");
12396 + if (kgdb_register_io_module(&local_kgdb_io_ops)) {
12397 + netpoll_cleanup(&np);
12406 +static int init_kgdboe(void)
12410 + /* Already done? */
12411 + if (configured == 2)
12414 + /* OK, go ahead and do it. */
12415 + ret = configure_kgdboe();
12417 + if (configured == 2)
12418 + printk(KERN_INFO "kgdboe: debugging over ethernet enabled\n");
12423 +static void cleanup_kgdboe(void)
12425 + netpoll_cleanup(&np);
12427 + kgdb_unregister_io_module(&local_kgdb_io_ops);
12430 +static int param_set_kgdboe_var(const char *kmessage, struct kernel_param *kp)
12432 + char kmessage_save[MAX_KGDBOE_CONFIG_STR];
12433 + int msg_len = strlen(kmessage);
12435 + if (msg_len + 1 > MAX_KGDBOE_CONFIG_STR) {
12436 + printk(KERN_ERR "%s: string doesn't fit in %u chars.\n",
12437 + kp->name, MAX_KGDBOE_CONFIG_STR - 1);
12441 + if (kgdb_connected) {
12442 + printk(KERN_ERR "kgdboe: Cannot reconfigure while KGDB is "
12447 + /* Start the reconfiguration process by saving the old string */
12448 + strncpy(kmessage_save, config, sizeof(kmessage_save));
12451 + /* Copy in the new param and strip out invalid characters so we
12452 + * can optionally specify the MAC.
12454 + strncpy(config, kmessage, sizeof(config));
12456 + while (msg_len > 0 &&
12457 + (config[msg_len] < ',' || config[msg_len] > 'f')) {
12458 + config[msg_len] = '\0';
12462 + /* Check to see if we are unconfiguring the io module and that it
12463 + * was in a fully configured state, as this is the only time that
12464 + * netpoll_cleanup should get called
12466 + if (configured == 2 && strcmp(config, NOT_CONFIGURED_STRING) == 0) {
12467 + printk(KERN_INFO "kgdboe: reverting to unconfigured state\n");
12468 + cleanup_kgdboe();
12471 + /* Go and configure with the new params. */
12472 + configure_kgdboe();
12474 + if (configured == 2)
12477 + /* If the new string was invalid, revert to the previous state, which
12478 + * is at a minimum not_configured. */
12479 + strncpy(config, kmessage_save, sizeof(config));
12480 + if (strcmp(kmessage_save, NOT_CONFIGURED_STRING) != 0) {
12481 + printk(KERN_INFO "kgdboe: reverting to prior configuration\n");
12482 + /* revert back to the original config */
12483 + strncpy(config, kmessage_save, sizeof(config));
12484 + configure_kgdboe();
12489 +static struct kgdb_io local_kgdb_io_ops = {
12490 + .read_char = eth_get_char,
12491 + .write_char = eth_put_char,
12492 + .init = init_kgdboe,
12493 + .flush = eth_flush_buf,
12494 + .pre_exception = eth_pre_exception_handler,
12495 + .post_exception = eth_post_exception_handler
12498 +module_init(init_kgdboe);
12499 +module_exit(cleanup_kgdboe);
12500 +module_param_call(kgdboe, param_set_kgdboe_var, param_get_string, &kps, 0644);
12501 +MODULE_PARM_DESC(kgdboe, " kgdboe=[src-port]@[src-ip]/[dev],"
12502 + "[tgt-port]@<tgt-ip>/<tgt-macaddr>\n");
12503 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/drivers/serial/8250.c linux-2.6.18-53.1.14.kgdb/drivers/serial/8250.c
12504 --- linux-2.6.18-53.1.14/drivers/serial/8250.c 2008-03-06 05:54:43.000000000 +0300
12505 +++ linux-2.6.18-53.1.14.kgdb/drivers/serial/8250.c 2008-06-10 15:37:43.000000000 +0400
12506 @@ -2656,6 +2656,25 @@ void serial8250_unregister_port(int line
12508 EXPORT_SYMBOL(serial8250_unregister_port);
12511 + * serial8250_unregister_by_port - remove a 16x50 serial port
12513 + * @port: A &struct uart_port that describes the port to remove.
12515 + * Remove one serial port. This may not be called from interrupt
12516 + * context. We hand the port back to the our control.
12518 +void serial8250_unregister_by_port(struct uart_port *port)
12520 + struct uart_8250_port *uart;
12522 + uart = serial8250_find_match_or_unused(port);
12525 + serial8250_unregister_port(uart->port.line);
12527 +EXPORT_SYMBOL(serial8250_unregister_by_port);
12529 static int __init serial8250_init(void)
12532 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/drivers/serial/8250_kgdb.c linux-2.6.18-53.1.14.kgdb/drivers/serial/8250_kgdb.c
12533 --- linux-2.6.18-53.1.14/drivers/serial/8250_kgdb.c 1970-01-01 03:00:00.000000000 +0300
12534 +++ linux-2.6.18-53.1.14.kgdb/drivers/serial/8250_kgdb.c 2008-06-10 15:37:43.000000000 +0400
12537 + * 8250 interface for kgdb.
12539 + * This is a merging of many different drivers, and all of the people have
12540 + * had an impact in some form or another:
12542 + * 2004-2005 (c) MontaVista Software, Inc.
12543 + * 2005-2006 (c) Wind River Systems, Inc.
12545 + * Amit Kale <amitkale@emsyssoft.com>, David Grothe <dave@gcom.com>,
12546 + * Scott Foehner <sfoehner@engr.sgi.com>, George Anzinger <george@mvista.com>,
12547 + * Robert Walsh <rjwalsh@durables.org>, wangdi <wangdi@clusterfs.com>,
12548 + * San Mehat, Tom Rini <trini@mvista.com>,
12549 + * Jason Wessel <jason.wessel@windriver.com>
12552 +#include <linux/config.h>
12553 +#include <linux/kernel.h>
12554 +#include <linux/init.h>
12555 +#include <linux/kgdb.h>
12556 +#include <linux/interrupt.h>
12557 +#include <linux/tty.h>
12558 +#include <linux/serial.h>
12559 +#include <linux/serial_reg.h>
12560 +#include <linux/serialP.h>
12561 +#include <linux/ioport.h>
12563 +#include <asm/io.h>
12564 +#include <asm/serial.h> /* For BASE_BAUD and SERIAL_PORT_DFNS */
12568 +#define GDB_BUF_SIZE 512 /* power of 2, please */
12570 +MODULE_DESCRIPTION("KGDB driver for the 8250");
12571 +MODULE_LICENSE("GPL");
12572 +/* These will conflict with early_param otherwise. */
12573 +#ifdef CONFIG_KGDB_8250_MODULE
12574 +static char config[256];
12575 +module_param_string(kgdb8250, config, 256, 0);
12576 +MODULE_PARM_DESC(kgdb8250,
12577 + " kgdb8250=<io or mmio>,<address>,<baud rate>,<irq>\n");
12578 +static struct kgdb_io local_kgdb_io_ops;
12579 +#endif /* CONFIG_KGDB_8250_MODULE */
12581 +/* Speed of the UART. */
12582 +static int kgdb8250_baud;
12584 +/* Flag for if we need to call request_mem_region */
12585 +static int kgdb8250_needs_request_mem_region;
12587 +static char kgdb8250_buf[GDB_BUF_SIZE];
12588 +static atomic_t kgdb8250_buf_in_cnt;
12589 +static int kgdb8250_buf_out_inx;
12591 +/* Old-style serial definitions, if existant, and a counter. */
12592 +#ifdef CONFIG_KGDB_SIMPLE_SERIAL
12593 +static int __initdata should_copy_rs_table = 1;
12594 +static struct serial_state old_rs_table[] __initdata = {
12595 +#ifdef SERIAL_PORT_DFNS
12601 +/* Our internal table of UARTS. */
12602 +#define UART_NR CONFIG_SERIAL_8250_NR_UARTS
12603 +static struct uart_port kgdb8250_ports[UART_NR];
12605 +static struct uart_port *current_port;
12607 +/* Base of the UART. */
12608 +static void *kgdb8250_addr;
12610 +/* Forward declarations. */
12611 +static int kgdb8250_uart_init(void);
12612 +static int __init kgdb_init_io(void);
12613 +static int __init kgdb8250_opt(char *str);
12615 +/* These are much shorter calls to ioread8/iowrite8 that take into
12616 + * account our shifts, etc. */
12617 +static inline unsigned int kgdb_ioread(u8 mask)
12619 + return ioread8(kgdb8250_addr + (mask << current_port->regshift));
12622 +static inline void kgdb_iowrite(u8 val, u8 mask)
12624 + iowrite8(val, kgdb8250_addr + (mask << current_port->regshift));
12628 + * Wait until the interface can accept a char, then write it.
12630 +static void kgdb_put_debug_char(u8 chr)
12632 + while (!(kgdb_ioread(UART_LSR) & UART_LSR_THRE)) ;
12634 + kgdb_iowrite(chr, UART_TX);
12638 + * Get a byte from the hardware data buffer and return it
12640 +static int read_data_bfr(void)
12642 + char it = kgdb_ioread(UART_LSR);
12644 + if (it & UART_LSR_DR)
12645 + return kgdb_ioread(UART_RX);
12648 + * If we have a framing error assume somebody messed with
12649 + * our uart. Reprogram it and send '-' both ways...
12652 + kgdb8250_uart_init();
12653 + kgdb_put_debug_char('-');
12661 + * Get a char if available, return -1 if nothing available.
12662 + * Empty the receive buffer first, then look at the interface hardware.
12664 +static int kgdb_get_debug_char(void)
12668 + /* intr routine has q'd chars */
12669 + if (atomic_read(&kgdb8250_buf_in_cnt) != 0) {
12670 + retchr = kgdb8250_buf[kgdb8250_buf_out_inx++];
12671 + kgdb8250_buf_out_inx &= (GDB_BUF_SIZE - 1);
12672 + atomic_dec(&kgdb8250_buf_in_cnt);
12677 + retchr = read_data_bfr();
12678 + } while (retchr < 0);
12684 + * This is the receiver interrupt routine for the GDB stub.
12685 + * All that we need to do is verify that the interrupt happened on the
12686 + * line we're in charge of. If this is true, schedule a breakpoint and
12689 +static irqreturn_t
12690 +kgdb8250_interrupt(int irq, void *dev_id, struct pt_regs *regs)
12692 + if (kgdb_ioread(UART_IIR) & UART_IIR_RDI) {
12693 + /* Throw away the data if another I/O routine is active. */
12694 + if (kgdb_io_ops.read_char != kgdb_get_debug_char &&
12695 + (kgdb_ioread(UART_LSR) & UART_LSR_DR))
12696 + kgdb_ioread(UART_RX);
12701 + return IRQ_HANDLED;
12705 + * Initializes the UART.
12707 + * 0 on success, 1 on failure.
12710 +kgdb8250_uart_init (void)
12712 + unsigned int ier, base_baud = current_port->uartclk ?
12713 + current_port->uartclk / 16 : BASE_BAUD;
12715 + /* test uart existance */
12716 + if(kgdb_ioread(UART_LSR) == 0xff)
12719 + /* disable interrupts */
12720 + kgdb_iowrite(0, UART_IER);
12722 +#if defined(CONFIG_ARCH_OMAP1510)
12723 + /* Workaround to enable 115200 baud on OMAP1510 internal ports */
12724 + if (cpu_is_omap1510() && is_omap_port((void *)kgdb8250_addr)) {
12725 + if (kgdb8250_baud == 115200) {
12727 + kgdb8250_baud = 1;
12728 + kgdb_iowrite(1, UART_OMAP_OSC_12M_SEL);
12730 + kgdb_iowrite(0, UART_OMAP_OSC_12M_SEL);
12734 + kgdb_iowrite(UART_LCR_DLAB, UART_LCR);
12737 + kgdb_iowrite((base_baud / kgdb8250_baud) & 0xff, UART_DLL);
12738 + kgdb_iowrite((base_baud / kgdb8250_baud) >> 8, UART_DLM);
12740 + /* reset DLAB, set LCR */
12741 + kgdb_iowrite(UART_LCR_WLEN8, UART_LCR);
12743 + /* set DTR and RTS */
12744 + kgdb_iowrite(UART_MCR_OUT2 | UART_MCR_DTR | UART_MCR_RTS, UART_MCR);
12747 + kgdb_iowrite(UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR
12748 + | UART_FCR_CLEAR_XMIT | UART_FCR_TRIGGER_8,
12751 + /* clear pending interrupts */
12752 + kgdb_ioread(UART_IIR);
12753 + kgdb_ioread(UART_RX);
12754 + kgdb_ioread(UART_LSR);
12755 + kgdb_ioread(UART_MSR);
12757 + /* turn on RX interrupt only */
12758 + kgdb_iowrite(UART_IER_RDI, UART_IER);
12761 + * Borrowed from the main 8250 driver.
12762 + * Try writing and reading the UART_IER_UUE bit (b6).
12763 + * If it works, this is probably one of the Xscale platform's
12764 + * internal UARTs.
12765 + * We're going to explicitly set the UUE bit to 0 before
12766 + * trying to write and read a 1 just to make sure it's not
12767 + * already a 1 and maybe locked there before we even start start.
12769 + ier = kgdb_ioread(UART_IER);
12770 + kgdb_iowrite(ier & ~UART_IER_UUE, UART_IER);
12771 + if (!(kgdb_ioread(UART_IER) & UART_IER_UUE)) {
12773 + * OK it's in a known zero state, try writing and reading
12774 + * without disturbing the current state of the other bits.
12776 + kgdb_iowrite(ier | UART_IER_UUE, UART_IER);
12777 + if (kgdb_ioread(UART_IER) & UART_IER_UUE)
12779 + * It's an Xscale.
12781 + ier |= UART_IER_UUE | UART_IER_RTOIE;
12783 + kgdb_iowrite(ier, UART_IER);
12788 + * Copy the old serial_state table to our uart_port table if we haven't
12789 + * had values specifically configured in. We need to make sure this only
12792 +static void __init kgdb8250_copy_rs_table(void)
12794 +#ifdef CONFIG_KGDB_SIMPLE_SERIAL
12797 + if (!should_copy_rs_table)
12800 + for (i = 0; i < ARRAY_SIZE(old_rs_table); i++) {
12801 + kgdb8250_ports[i].iobase = old_rs_table[i].port;
12802 + kgdb8250_ports[i].irq = irq_canonicalize(old_rs_table[i].irq);
12803 + kgdb8250_ports[i].uartclk = old_rs_table[i].baud_base * 16;
12804 + kgdb8250_ports[i].membase = old_rs_table[i].iomem_base;
12805 + kgdb8250_ports[i].iotype = old_rs_table[i].io_type;
12806 + kgdb8250_ports[i].regshift = old_rs_table[i].iomem_reg_shift;
12807 + kgdb8250_ports[i].line = i;
12810 + should_copy_rs_table = 0;
12815 + * Hookup our IRQ line now that it is safe to do so, after we grab any
12816 + * memory regions we might need to. If we haven't been initialized yet,
12817 + * go ahead and copy the old_rs_table in.
12819 +static void __init kgdb8250_late_init(void)
12821 + /* Try and copy the old_rs_table. */
12822 + kgdb8250_copy_rs_table();
12824 +#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
12825 + /* Take the port away from the main driver. */
12826 + serial8250_unregister_by_port(current_port);
12828 + /* Now reinit the port as the above has disabled things. */
12829 + kgdb8250_uart_init();
12831 + /* We may need to call request_mem_region() first. */
12832 + if (kgdb8250_needs_request_mem_region)
12833 + request_mem_region(current_port->mapbase,
12834 + 8 << current_port->regshift, "kgdb");
12835 + if (request_irq(current_port->irq, kgdb8250_interrupt, SA_SHIRQ,
12836 + "GDB-stub", current_port) < 0)
12837 + printk(KERN_ERR "KGDB failed to request the serial IRQ (%d)\n",
12838 + current_port->irq);
12841 +static __init int kgdb_init_io(void)
12843 + /* Give us the basic table of uarts. */
12844 + kgdb8250_copy_rs_table();
12846 + /* We're either a module and parse a config string, or we have a
12847 + * semi-static config. */
12848 +#ifdef CONFIG_KGDB_8250_MODULE
12849 + if (strlen(config)) {
12850 + if (kgdb8250_opt(config))
12853 + printk(KERN_ERR "kgdb8250: argument error, usage: "
12854 + "kgdb8250=<io or mmio>,<address>,<baud rate>,<irq>\n");
12857 +#elif defined(CONFIG_KGDB_SIMPLE_SERIAL)
12858 + kgdb8250_baud = CONFIG_KGDB_BAUDRATE;
12860 + /* Setup our pointer to the serial port now. */
12861 + current_port = &kgdb8250_ports[CONFIG_KGDB_PORT_NUM];
12863 + if (kgdb8250_opt(CONFIG_KGDB_8250_CONF_STRING))
12868 + /* Internal driver setup. */
12869 + switch (current_port->iotype) {
12871 + if (current_port->mapbase)
12872 + kgdb8250_needs_request_mem_region = 1;
12873 + if (current_port->flags & UPF_IOREMAP) {
12874 + current_port->membase = ioremap(current_port->mapbase,
12875 + 8 << current_port->regshift);
12876 + if (!current_port->membase)
12877 + return -EIO; /* Failed. */
12879 + kgdb8250_addr = current_port->membase;
12883 + kgdb8250_addr = ioport_map(current_port->iobase,
12884 + 8 << current_port->regshift);
12885 + if (!kgdb8250_addr)
12886 + return -EIO; /* Failed. */
12889 + if (kgdb8250_uart_init() == -1) {
12890 + printk(KERN_ERR "kgdb8250: init failed\n");
12893 +#ifdef CONFIG_KGDB_8250_MODULE
12894 + /* Attach the kgdb irq. When this is built into the kernel, it
12895 + * is called as a part of late_init sequence.
12897 + kgdb8250_late_init();
12898 + if (kgdb_register_io_module(&local_kgdb_io_ops))
12901 + printk(KERN_INFO "kgdb8250: debugging enabled\n");
12902 +#endif /* CONFIG_KGD_8250_MODULE */
12907 +#ifdef CONFIG_KGDB_8250_MODULE
12908 +/* If it is a module the kgdb_io_ops should be a static which
12909 + * is passed to the KGDB I/O initialization
12911 +static struct kgdb_io local_kgdb_io_ops = {
12912 +#else /* ! CONFIG_KGDB_8250_MODULE */
12913 +struct kgdb_io kgdb_io_ops = {
12914 +#endif /* ! CONFIG_KGD_8250_MODULE */
12915 + .read_char = kgdb_get_debug_char,
12916 + .write_char = kgdb_put_debug_char,
12917 + .init = kgdb_init_io,
12918 + .late_init = kgdb8250_late_init,
12922 + * kgdb8250_add_port - Define a serial port for use with KGDB
12923 + * @i: The index of the port being added
12924 + * @serial_req: The &struct uart_port describing the port
12926 + * On platforms where we must register the serial device
12927 + * dynamically, this is the best option if a platform also normally
12928 + * calls early_serial_setup().
12930 +void __init kgdb8250_add_port(int i, struct uart_port *serial_req)
12932 + /* Make sure we've got the built-in data before we override. */
12933 + kgdb8250_copy_rs_table();
12935 + /* Copy the whole thing over. */
12936 + if (current_port != &kgdb8250_ports[i])
12937 + memcpy(&kgdb8250_ports[i], serial_req, sizeof(struct uart_port));
12941 + * kgdb8250_add_platform_port - Define a serial port for use with KGDB
12942 + * @i: The index of the port being added
12943 + * @p: The &struct plat_serial8250_port describing the port
12945 + * On platforms where we must register the serial device
12946 + * dynamically, this is the best option if a platform normally
12947 + * handles uart setup with an array of &struct plat_serial8250_port.
12949 +void __init kgdb8250_add_platform_port(int i, struct plat_serial8250_port *p)
12951 + /* Make sure we've got the built-in data before we override. */
12952 + kgdb8250_copy_rs_table();
12954 + kgdb8250_ports[i].iobase = p->iobase;
12955 + kgdb8250_ports[i].membase = p->membase;
12956 + kgdb8250_ports[i].irq = p->irq;
12957 + kgdb8250_ports[i].uartclk = p->uartclk;
12958 + kgdb8250_ports[i].regshift = p->regshift;
12959 + kgdb8250_ports[i].iotype = p->iotype;
12960 + kgdb8250_ports[i].flags = p->flags;
12961 + kgdb8250_ports[i].mapbase = p->mapbase;
12965 + * Syntax for this cmdline option is:
12966 + * kgdb8250=<io or mmio>,<address>,<baud rate>,<irq>"
12968 +static int __init kgdb8250_opt(char *str)
12970 + /* We'll fill out and use the first slot. */
12971 + current_port = &kgdb8250_ports[0];
12973 + if (!strncmp(str, "io", 2)) {
12974 + current_port->iotype = UPIO_PORT;
12976 + } else if (!strncmp(str, "mmap", 4)) {
12977 + current_port->iotype = UPIO_MEM;
12978 + current_port->flags |= UPF_IOREMAP;
12980 + } else if (!strncmp(str, "mmio", 4)) {
12981 + current_port->iotype = UPIO_MEM;
12982 + current_port->flags &= ~UPF_IOREMAP;
12991 + if (current_port->iotype == UPIO_PORT)
12992 + current_port->iobase = simple_strtoul(str, &str, 16);
12994 + if (current_port->flags & UPF_IOREMAP)
12995 + current_port->mapbase =
12996 + (unsigned long) simple_strtoul(str, &str, 16);
12998 + current_port->membase =
12999 + (void *) simple_strtoul(str, &str, 16);
13006 + kgdb8250_baud = simple_strtoul(str, &str, 10);
13007 + if (!kgdb8250_baud)
13014 + current_port->irq = simple_strtoul(str, &str, 10);
13016 +#ifdef CONFIG_KGDB_SIMPLE_SERIAL
13017 + should_copy_rs_table = 0;
13023 + printk(KERN_ERR "Invalid syntax for option kgdb8250=\n");
13027 +#ifdef CONFIG_KGDB_8250_MODULE
13028 +static void cleanup_kgdb8250(void)
13030 + kgdb_unregister_io_module(&local_kgdb_io_ops);
13032 + /* Clean up the irq and memory */
13033 + free_irq(current_port->irq, current_port);
13035 + if (kgdb8250_needs_request_mem_region)
13036 + release_mem_region(current_port->mapbase,
13037 + 8 << current_port->regshift);
13038 + /* Hook up the serial port back to what it was previously
13041 +#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
13042 + /* Give the port back to the 8250 driver. */
13043 + serial8250_register_port(current_port);
13047 +module_init(kgdb_init_io);
13048 +module_exit(cleanup_kgdb8250);
13049 +#else /* ! CONFIG_KGDB_8250_MODULE */
13050 +early_param("kgdb8250", kgdb8250_opt);
13051 +#endif /* ! CONFIG_KGDB_8250_MODULE */
13052 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/drivers/serial/Kconfig linux-2.6.18-53.1.14.kgdb/drivers/serial/Kconfig
13053 --- linux-2.6.18-53.1.14/drivers/serial/Kconfig 2008-03-06 05:54:47.000000000 +0300
13054 +++ linux-2.6.18-53.1.14.kgdb/drivers/serial/Kconfig 2008-06-10 15:37:43.000000000 +0400
13055 @@ -107,7 +107,7 @@ config SERIAL_8250_CS
13057 config SERIAL_8250_NR_UARTS
13058 int "Maximum number of 8250/16550 serial ports"
13059 - depends on SERIAL_8250
13060 + depends on SERIAL_8250 || KGDB_8250
13063 Set this to the number of serial ports you want the driver
13064 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/drivers/serial/Makefile linux-2.6.18-53.1.14.kgdb/drivers/serial/Makefile
13065 --- linux-2.6.18-53.1.14/drivers/serial/Makefile 2008-03-06 05:54:47.000000000 +0300
13066 +++ linux-2.6.18-53.1.14.kgdb/drivers/serial/Makefile 2008-06-10 15:38:14.000000000 +0400
13067 @@ -47,6 +47,7 @@ obj-$(CONFIG_SERIAL_IMX) += imx.o
13068 obj-$(CONFIG_SERIAL_MPC52xx) += mpc52xx_uart.o
13069 obj-$(CONFIG_SERIAL_ICOM) += icom.o
13070 obj-$(CONFIG_SERIAL_M32R_SIO) += m32r_sio.o
13071 +obj-$(CONFIG_KGDB_MPSC) += mpsc_kgdb.o
13072 obj-$(CONFIG_SERIAL_MPSC) += mpsc.o
13073 obj-$(CONFIG_ETRAX_SERIAL) += crisv10.o
13074 obj-$(CONFIG_SERIAL_JSM) += jsm/
13075 @@ -57,3 +58,4 @@ obj-$(CONFIG_SERIAL_SGI_IOC3) += ioc3_se
13076 obj-$(CONFIG_SERIAL_AT91) += at91_serial.o
13077 obj-$(CONFIG_SERIAL_NETX) += netx-serial.o
13078 obj-$(CONFIG_SERIAL_OF_PLATFORM) += of_serial.o
13079 +obj-$(CONFIG_KGDB_8250) += 8250_kgdb.o
13080 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/drivers/serial/amba-pl011.c linux-2.6.18-53.1.14.kgdb/drivers/serial/amba-pl011.c
13081 --- linux-2.6.18-53.1.14/drivers/serial/amba-pl011.c 2006-09-20 07:42:06.000000000 +0400
13082 +++ linux-2.6.18-53.1.14.kgdb/drivers/serial/amba-pl011.c 2008-06-10 15:38:56.000000000 +0400
13083 @@ -340,7 +340,7 @@ static int pl011_startup(struct uart_por
13087 - retval = request_irq(uap->port.irq, pl011_int, 0, "uart-pl011", uap);
13088 + retval = request_irq(uap->port.irq, pl011_int, SA_SHIRQ, "uart-pl011", uap);
13092 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/drivers/serial/cpm_uart/Makefile linux-2.6.18-53.1.14.kgdb/drivers/serial/cpm_uart/Makefile
13093 --- linux-2.6.18-53.1.14/drivers/serial/cpm_uart/Makefile 2006-09-20 07:42:06.000000000 +0400
13094 +++ linux-2.6.18-53.1.14.kgdb/drivers/serial/cpm_uart/Makefile 2008-06-10 15:38:14.000000000 +0400
13095 @@ -7,5 +7,6 @@ obj-$(CONFIG_SERIAL_CPM) += cpm_uart.o
13096 # Select the correct platform objects.
13097 cpm_uart-objs-$(CONFIG_CPM2) += cpm_uart_cpm2.o
13098 cpm_uart-objs-$(CONFIG_8xx) += cpm_uart_cpm1.o
13099 +cpm_uart-objs-$(CONFIG_KGDB_CPM_UART) += cpm_uart_kgdb.o
13101 cpm_uart-objs := cpm_uart_core.o $(cpm_uart-objs-y)
13102 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/drivers/serial/cpm_uart/cpm_uart.h linux-2.6.18-53.1.14.kgdb/drivers/serial/cpm_uart/cpm_uart.h
13103 --- linux-2.6.18-53.1.14/drivers/serial/cpm_uart/cpm_uart.h 2008-03-06 05:54:12.000000000 +0300
13104 +++ linux-2.6.18-53.1.14.kgdb/drivers/serial/cpm_uart/cpm_uart.h 2008-06-10 15:38:14.000000000 +0400
13107 #define SCC_WAIT_CLOSING 100
13109 +#ifdef CONFIG_KGDB_CPM_UART
13111 +/* Speed of the debug UART. */
13112 +#if defined(CONFIG_KGDB_9600BAUD)
13113 +#define KGDB_BAUD B9600
13114 +#elif defined(CONFIG_KGDB_19200BAUD)
13115 +#define KGDB_BAUD B19200
13116 +#elif defined(CONFIG_KGDB_38400BAUD)
13117 +#define KGDB_BAUD B38400
13118 +#elif defined(CONFIG_KGDB_57600BAUD)
13119 +#define KGDB_BAUD B57600
13121 +#define KGDB_BAUD B115200 /* Start with this if not given */
13124 +#ifdef CONFIG_KGDB_CPM_UART_SCC1
13125 +#define KGDB_PINFO_INDEX UART_SCC1
13126 +#elif CONFIG_KGDB_CPM_UART_SCC2
13127 +#define KGDB_PINFO_INDEX UART_SCC2
13128 +#elif CONFIG_KGDB_CPM_UART_SCC3
13129 +#define KGDB_PINFO_INDEX UART_SCC3
13130 +#elif CONFIG_KGDB_CPM_UART_SCC4
13131 +#define KGDB_PINFO_INDEX UART_SCC4
13132 +#elif CONFIG_KGDB_CPM_UART_SMC1
13133 +#define KGDB_PINFO_INDEX UART_SMC1
13134 +#elif CONFIG_KGDB_CPM_UART_SMC2
13135 +#define KGDB_PINFO_INDEX UART_SMC2
13137 +#error The S(M)CC for kgdb console is undefined
13140 +#endif /* CONFIG_KGDB_CPM_UART */
13142 struct uart_cpm_port {
13143 struct uart_port port;
13145 @@ -86,6 +119,9 @@ extern int cpm_uart_port_map[UART_NR];
13146 extern int cpm_uart_nr;
13147 extern struct uart_cpm_port cpm_uart_ports[UART_NR];
13149 +void cpm_uart_early_write(int index, const char *s, u_int count);
13150 +int cpm_uart_early_setup(int index,int early);
13152 /* these are located in their respective files */
13153 void cpm_line_cr_cmd(int line, int cmd);
13154 int cpm_uart_init_portdesc(void);
13155 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/drivers/serial/cpm_uart/cpm_uart_core.c linux-2.6.18-53.1.14.kgdb/drivers/serial/cpm_uart/cpm_uart_core.c
13156 --- linux-2.6.18-53.1.14/drivers/serial/cpm_uart/cpm_uart_core.c 2006-09-20 07:42:06.000000000 +0400
13157 +++ linux-2.6.18-53.1.14.kgdb/drivers/serial/cpm_uart/cpm_uart_core.c 2008-06-10 15:38:14.000000000 +0400
13158 @@ -1070,22 +1070,17 @@ int cpm_uart_drv_get_platform_data(struc
13162 -#ifdef CONFIG_SERIAL_CPM_CONSOLE
13164 - * Print a string to the serial port trying not to disturb
13165 - * any possible real use of the port...
13167 - * Note that this is called with interrupts already disabled
13169 -static void cpm_uart_console_write(struct console *co, const char *s,
13170 +void cpm_uart_early_write(int index, const char *s,
13173 - struct uart_cpm_port *pinfo =
13174 - &cpm_uart_ports[cpm_uart_port_map[co->index]];
13175 + struct uart_cpm_port *pinfo;
13177 volatile cbd_t *bdp, *bdbase;
13178 volatile unsigned char *cp;
13180 + BUG_ON(index>UART_NR);
13181 + pinfo = &cpm_uart_ports[index];
13183 /* Get the address of the host memory buffer.
13185 bdp = pinfo->tx_cur;
13186 @@ -1149,16 +1144,11 @@ static void cpm_uart_console_write(struc
13187 pinfo->tx_cur = (volatile cbd_t *) bdp;
13191 -static int __init cpm_uart_console_setup(struct console *co, char *options)
13192 +int cpm_uart_early_setup(int index, int early)
13195 struct uart_port *port;
13196 struct uart_cpm_port *pinfo;
13197 - int baud = 38400;
13199 - int parity = 'n';
13203 struct fs_uart_platform_info *pdata;
13204 struct platform_device* pdev = early_uart_get_pdev(co->index);
13205 @@ -1169,8 +1159,9 @@ static int __init cpm_uart_console_setup
13206 cpm_uart_init_portdesc();
13209 + BUG_ON(index>UART_NR);
13211 - (struct uart_port *)&cpm_uart_ports[cpm_uart_port_map[co->index]];
13212 + (struct uart_port *)&cpm_uart_ports[index];
13213 pinfo = (struct uart_cpm_port *)port;
13215 if (pinfo->set_lineif)
13216 @@ -1184,19 +1175,6 @@ static int __init cpm_uart_console_setup
13217 cpm_uart_drv_get_platform_data(pdev, 1);
13220 - pinfo->flags |= FLAG_CONSOLE;
13223 - uart_parse_options(options, &baud, &parity, &bits, &flow);
13225 - bd_t *bd = (bd_t *) __res;
13227 - if (bd->bi_baudrate)
13228 - baud = bd->bi_baudrate;
13233 if (IS_SMC(pinfo)) {
13234 pinfo->smcp->smc_smcm &= ~(SMCM_RX | SMCM_TX);
13235 pinfo->smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN);
13236 @@ -1204,8 +1182,7 @@ static int __init cpm_uart_console_setup
13237 pinfo->sccp->scc_sccm &= ~(UART_SCCM_TX | UART_SCCM_RX);
13238 pinfo->sccp->scc_gsmrl &= ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
13241 - ret = cpm_uart_allocbuf(pinfo, 1);
13242 + ret = cpm_uart_allocbuf(pinfo, early);
13246 @@ -1217,6 +1194,56 @@ static int __init cpm_uart_console_setup
13248 cpm_uart_init_scc(pinfo);
13253 +#ifdef CONFIG_SERIAL_CPM_CONSOLE
13255 + * Print a string to the serial port trying not to disturb
13256 + * any possible real use of the port...
13258 + * Note that this is called with interrupts already disabled
13261 +static void cpm_uart_console_write(struct console *co, const char *s,
13264 + cpm_uart_early_write(cpm_uart_port_map[co->index],s,count);
13268 + * Setup console. Be careful is called early !
13270 +static int __init cpm_uart_console_setup(struct console *co, char *options)
13272 + struct uart_port *port;
13273 + struct uart_cpm_port *pinfo;
13274 + int baud = 115200;
13276 + int parity = 'n';
13281 + (struct uart_port *)&cpm_uart_ports[cpm_uart_port_map[co->index]];
13282 + pinfo = (struct uart_cpm_port *)port;
13284 + pinfo->flags |= FLAG_CONSOLE;
13287 + uart_parse_options(options, &baud, &parity, &bits, &flow);
13289 + bd_t *bd = (bd_t *) __res;
13291 + if (bd->bi_baudrate)
13292 + baud = bd->bi_baudrate;
13297 + ret = cpm_uart_early_setup(cpm_uart_port_map[co->index], 1);
13300 uart_set_options(port, co, baud, parity, bits, flow);
13303 @@ -1364,6 +1391,12 @@ static int cpm_uart_init(void) {
13305 for (i = 0; i < cpm_uart_nr; i++) {
13306 int con = cpm_uart_port_map[i];
13308 +#ifdef CONFIG_KGDB_CPM_UART
13309 + /* We are not interested in ports yet utilized by kgdb */
13310 + if(con == KGDB_PINFO_INDEX)
13313 cpm_uart_ports[con].port.line = i;
13314 cpm_uart_ports[con].port.flags = UPF_BOOT_AUTOCONF;
13315 uart_add_one_port(&cpm_reg, &cpm_uart_ports[con].port);
13316 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/drivers/serial/cpm_uart/cpm_uart_cpm1.c linux-2.6.18-53.1.14.kgdb/drivers/serial/cpm_uart/cpm_uart_cpm1.c
13317 --- linux-2.6.18-53.1.14/drivers/serial/cpm_uart/cpm_uart_cpm1.c 2006-09-20 07:42:06.000000000 +0400
13318 +++ linux-2.6.18-53.1.14.kgdb/drivers/serial/cpm_uart/cpm_uart_cpm1.c 2008-06-10 15:38:14.000000000 +0400
13319 @@ -52,6 +52,7 @@ void cpm_line_cr_cmd(int line, int cmd)
13322 volatile cpm8xx_t *cp = cpmp;
13323 + unsigned *bcsr_io;
13327 @@ -94,12 +95,35 @@ void scc1_lineif(struct uart_cpm_port *p
13329 /* XXX SCC1: insert port configuration here */
13332 +#if defined (CONFIG_MPC885ADS) || defined (CONFIG_MPC86XADS)
13333 + bcsr_io = ioremap(BCSR1, sizeof(unsigned long));
13335 + if (bcsr_io == NULL) {
13336 + printk(KERN_CRIT "Could not remap BCSR\n");
13339 + out_be32(bcsr_io, in_be32(bcsr_io) & ~BCSR1_RS232EN_1);
13340 + iounmap(bcsr_io);
13344 void scc2_lineif(struct uart_cpm_port *pinfo)
13346 /* XXX SCC2: insert port configuration here */
13348 + unsigned *bcsr_io;
13350 +#if defined (CONFIG_MPC885ADS) || defined (CONFIG_MPC86XADS)
13351 + bcsr_io = ioremap(BCSR1, sizeof(unsigned long));
13353 + if (bcsr_io == NULL) {
13354 + printk(KERN_CRIT "Could not remap BCSR\n");
13357 + out_be32(bcsr_io, in_be32(bcsr_io) & ~BCSR1_RS232EN_2);
13358 + iounmap(bcsr_io);
13362 void scc3_lineif(struct uart_cpm_port *pinfo)
13363 @@ -188,6 +212,10 @@ int cpm_uart_init_portdesc(void)
13365 pr_debug("CPM uart[-]:init portdesc\n");
13367 + /* Check if we have called this yet. This may happen if early kgdb
13368 + breakpoint is on */
13372 #ifdef CONFIG_SERIAL_CPM_SMC1
13373 cpm_uart_ports[UART_SMC1].smcp = &cpmp->cp_smc[0];
13374 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/drivers/serial/cpm_uart/cpm_uart_cpm2.c linux-2.6.18-53.1.14.kgdb/drivers/serial/cpm_uart/cpm_uart_cpm2.c
13375 --- linux-2.6.18-53.1.14/drivers/serial/cpm_uart/cpm_uart_cpm2.c 2006-09-20 07:42:06.000000000 +0400
13376 +++ linux-2.6.18-53.1.14.kgdb/drivers/serial/cpm_uart/cpm_uart_cpm2.c 2008-06-10 15:38:14.000000000 +0400
13377 @@ -256,6 +256,10 @@ int cpm_uart_init_portdesc(void)
13379 pr_debug("CPM uart[-]:init portdesc\n");
13381 + /* Check if we have called this yet. This may happen if early kgdb
13382 + breakpoint is on */
13386 #ifdef CONFIG_SERIAL_CPM_SMC1
13387 cpm_uart_ports[UART_SMC1].smcp = (smc_t *) & cpm2_immr->im_smc[0];
13388 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/drivers/serial/cpm_uart/cpm_uart_kgdb.c linux-2.6.18-53.1.14.kgdb/drivers/serial/cpm_uart/cpm_uart_kgdb.c
13389 --- linux-2.6.18-53.1.14/drivers/serial/cpm_uart/cpm_uart_kgdb.c 1970-01-01 03:00:00.000000000 +0300
13390 +++ linux-2.6.18-53.1.14.kgdb/drivers/serial/cpm_uart/cpm_uart_kgdb.c 2008-06-10 15:38:14.000000000 +0400
13393 + * drivers/serial/cpm_uart/cpm_uart_kgdb.c
13395 + * CPM UART interface for kgdb.
13397 + * Author: Vitaly Bordug <vbordug@ru.mvista.com>
13399 + * Used some bits from drivers/serial/kgdb_8250.c as a template
13401 + * 2005 (c) MontaVista Software, Inc. This file is licensed under
13402 + * the terms of the GNU General Public License version 2. This program
13403 + * is licensed "as is" without any warranty of any kind, whether express
13407 +#include <linux/kgdb.h>
13408 +#include <linux/config.h>
13409 +#include <linux/kernel.h>
13410 +#include <linux/init.h>
13411 +#include <linux/interrupt.h>
13412 +#include <linux/tty.h>
13413 +#include <linux/serial.h>
13414 +#include <linux/serial_core.h>
13415 +#include <linux/serial_reg.h>
13417 +#include <asm/io.h>
13418 +#include <asm/serial.h> /* For BASE_BAUD and SERIAL_PORT_DFNS */
13420 +#include "cpm_uart.h"
13422 +#define GDB_BUF_SIZE 512 /* power of 2, please */
13425 +static char kgdb_buf[GDB_BUF_SIZE], *kgdbp;
13426 +static int kgdb_chars;
13428 +/* Forward declarations. */
13431 + * Receive character from the serial port. This only works well
13432 + * before the port is initialize for real use.
13434 +static int kgdb_wait_key(char *obuf)
13436 + struct uart_cpm_port *pinfo;
13439 + volatile cbd_t *bdp;
13442 + pinfo = &cpm_uart_ports[KGDB_PINFO_INDEX];
13444 + /* Get the address of the host memory buffer.
13446 + bdp = pinfo->rx_cur;
13447 + while (bdp->cbd_sc & BD_SC_EMPTY);
13449 + /* If the buffer address is in the CPM DPRAM, don't
13452 + cp = cpm2cpu_addr(bdp->cbd_bufaddr);
13455 + i = c = bdp->cbd_datlen;
13463 + bdp->cbd_sc |= BD_SC_EMPTY;
13465 + if (bdp->cbd_sc & BD_SC_WRAP) {
13466 + bdp = pinfo->rx_bd_base;
13470 + pinfo->rx_cur = (cbd_t *)bdp;
13477 + * Wait until the interface can accept a char, then write it.
13480 +kgdb_put_debug_char(int chr)
13482 + static char ch[2];
13484 + cpm_uart_early_write(KGDB_PINFO_INDEX, ch, 1);
13489 + * Get a char if available, return -1 if nothing available.
13490 + * Empty the receive buffer first, then look at the interface hardware.
13493 +kgdb_get_debug_char(void)
13495 + if (kgdb_chars<=0) {
13496 + kgdb_chars = kgdb_wait_key(kgdb_buf);
13497 + kgdbp = kgdb_buf;
13501 + return (*kgdbp++);
13504 +static void termios_set_options(int index,
13505 + int baud, int parity, int bits, int flow)
13507 + struct termios termios;
13508 + struct uart_port *port;
13509 + struct uart_cpm_port *pinfo;
13511 + BUG_ON(index>UART_NR);
13514 + (struct uart_port *)&cpm_uart_ports[index];
13515 + pinfo = (struct uart_cpm_port *)port;
13518 + * Ensure that the serial console lock is initialised
13521 + spin_lock_init(&port->lock);
13523 + memset(&termios, 0, sizeof(struct termios));
13525 + termios.c_cflag = CREAD | HUPCL | CLOCAL;
13527 + termios.c_cflag |= baud;
13530 + termios.c_cflag |= CS7;
13532 + termios.c_cflag |= CS8;
13534 + switch (parity) {
13535 + case 'o': case 'O':
13536 + termios.c_cflag |= PARODD;
13538 + case 'e': case 'E':
13539 + termios.c_cflag |= PARENB;
13544 + termios.c_cflag |= CRTSCTS;
13546 + port->ops->set_termios(port, &termios, NULL);
13551 + * 0 on success, 1 on failure.
13553 +static int kgdb_init(void)
13555 + struct uart_port *port;
13556 + struct uart_cpm_port *pinfo;
13558 + int use_bootmem = 0; /* use dma by default */
13563 + cpm_uart_init_portdesc();
13565 + port = (struct uart_port *)&cpm_uart_ports[KGDB_PINFO_INDEX];
13566 + pinfo = (struct uart_cpm_port *)port;
13568 + if (cpm_uart_early_setup(KGDB_PINFO_INDEX, use_bootmem))
13571 + termios_set_options(KGDB_PINFO_INDEX, KGDB_BAUD,'n',8,'n');
13572 + if (IS_SMC(pinfo))
13573 + pinfo->smcp->smc_smcm |= SMCM_TX;
13575 + pinfo->sccp->scc_sccm |= UART_SCCM_TX;
13581 +struct kgdb_io kgdb_io_ops = {
13582 + .read_char = kgdb_get_debug_char,
13583 + .write_char = kgdb_put_debug_char,
13584 + .init = kgdb_init,
13587 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/drivers/serial/mpsc.c linux-2.6.18-53.1.14.kgdb/drivers/serial/mpsc.c
13588 --- linux-2.6.18-53.1.14/drivers/serial/mpsc.c 2006-09-20 07:42:06.000000000 +0400
13589 +++ linux-2.6.18-53.1.14.kgdb/drivers/serial/mpsc.c 2008-06-10 15:38:14.000000000 +0400
13590 @@ -242,6 +242,11 @@ struct mpsc_port_info *mpsc_device_remov
13591 #define MPSC_RCRR 0x0004
13592 #define MPSC_TCRR 0x0008
13594 +/* MPSC Interrupt registers (offset from MV64x60_SDMA_INTR_OFFSET) */
13595 +#define MPSC_INTR_CAUSE 0x0004
13596 +#define MPSC_INTR_MASK 0x0084
13597 +#define MPSC_INTR_CAUSE_RCC (1<<6)
13599 /* Serial DMA Controller Interface Registers */
13600 #define SDMA_SDC 0x0000
13601 #define SDMA_SDCM 0x0008
13602 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/drivers/serial/mpsc_kgdb.c linux-2.6.18-53.1.14.kgdb/drivers/serial/mpsc_kgdb.c
13603 --- linux-2.6.18-53.1.14/drivers/serial/mpsc_kgdb.c 1970-01-01 03:00:00.000000000 +0300
13604 +++ linux-2.6.18-53.1.14.kgdb/drivers/serial/mpsc_kgdb.c 2008-06-10 15:38:14.000000000 +0400
13607 + * drivers/serial/mpsc_kgdb.c
13609 + * KGDB driver for the Marvell MultiProtocol Serial Controller (MPCS)
13611 + * Based on the polled boot loader driver by Ajit Prem (ajit.prem@motorola.com)
13613 + * Author: Randy Vinson <rvinson@mvista.com>
13615 + * 2005 (c) MontaVista Software, Inc.
13616 + * This program is free software; you can redistribute it and/or modify it
13617 + * under the terms of the GNU General Public License as published by the
13618 + * Free Software Foundation; either version 2 of the License, or (at your
13619 + * option) any later version.
13622 +#include <linux/config.h>
13623 +#include <linux/kgdb.h>
13624 +#include <linux/mv643xx.h>
13625 +#include <linux/device.h>
13626 +#include <asm/mv64x60.h>
13627 +#include <asm/serial.h>
13628 +#include <asm/io.h>
13629 +#include <asm/delay.h>
13633 +/* Speed of the UART. */
13634 +static int kgdbmpsc_baud = CONFIG_KGDB_BAUDRATE;
13636 +/* Index of the UART, matches ttyMX naming. */
13637 +static int kgdbmpsc_ttyMM = CONFIG_KGDB_PORT_NUM;
13639 +#define MPSC_INTR_REG_SELECT(x) ((x) + (8 * kgdbmpsc_ttyMM))
13641 +static int kgdbmpsc_init(void);
13643 +static struct platform_device mpsc_dev, shared_dev;
13645 +static void __iomem *mpsc_base;
13646 +static void __iomem *brg_base;
13647 +static void __iomem *routing_base;
13648 +static void __iomem *sdma_base;
13650 +static unsigned int mpsc_irq;
13652 +static void kgdb_write_debug_char(int c)
13656 + data = readl(mpsc_base + MPSC_MPCR);
13657 + writeb(c, mpsc_base + MPSC_CHR_1);
13659 + data = readl(mpsc_base + MPSC_CHR_2);
13660 + data |= MPSC_CHR_2_TTCS;
13661 + writel(data, mpsc_base + MPSC_CHR_2);
13664 + while (readl(mpsc_base + MPSC_CHR_2) & MPSC_CHR_2_TTCS) ;
13667 +static int kgdb_get_debug_char(void)
13671 + while (!(readl(sdma_base + MPSC_INTR_REG_SELECT(MPSC_INTR_CAUSE)) &
13672 + MPSC_INTR_CAUSE_RCC)) ;
13674 + c = readb(mpsc_base + MPSC_CHR_10 + (1 << 1));
13676 + writeb(c, mpsc_base + MPSC_CHR_10 + (1 << 1));
13678 + writel(~MPSC_INTR_CAUSE_RCC, sdma_base +
13679 + MPSC_INTR_REG_SELECT(MPSC_INTR_CAUSE));
13684 + * This is the receiver interrupt routine for the GDB stub.
13685 + * All that we need to do is verify that the interrupt happened on the
13686 + * line we're in charge of. If this is true, schedule a breakpoint and
13689 +static irqreturn_t
13690 +kgdbmpsc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
13692 + if (irq != mpsc_irq)
13695 + * If there is some other CPU in KGDB then this is a
13696 + * spurious interrupt. so return without even checking a byte
13698 + if (atomic_read(&debugger_active))
13701 + if (readl(sdma_base + MPSC_INTR_REG_SELECT(MPSC_INTR_CAUSE)) &
13702 + MPSC_INTR_CAUSE_RCC)
13705 + return IRQ_HANDLED;
13708 +static int __init kgdbmpsc_init(void)
13710 + struct mpsc_pdata *pdata;
13713 + if (!brg_base || !mpsc_base || !routing_base || !sdma_base)
13716 + /* Set MPSC Routing to enable both ports */
13717 + writel(0x0, routing_base + MPSC_MRR);
13719 + /* MPSC 0/1 Rx & Tx get clocks BRG0/1 */
13720 + writel(0x00000100, routing_base + MPSC_RCRR);
13721 + writel(0x00000100, routing_base + MPSC_TCRR);
13723 + /* Disable all MPSC interrupts and clear any pending interrupts */
13724 + writel(0, sdma_base + MPSC_INTR_REG_SELECT(MPSC_INTR_MASK));
13725 + writel(0, sdma_base + MPSC_INTR_REG_SELECT(MPSC_INTR_CAUSE));
13727 + pdata = (struct mpsc_pdata *)mpsc_dev.dev.platform_data;
13729 + /* cdv = (clock/(2*16*baud rate)) for 16X mode. */
13730 + cdv = ((pdata->brg_clk_freq / (32 * kgdbmpsc_baud)) - 1);
13731 + writel((pdata->brg_clk_src << 18) | (1 << 16) | cdv,
13732 + brg_base + BRG_BCR);
13734 + /* Put MPSC into UART mode, no null modem, 16x clock mode */
13735 + writel(0x000004c4, mpsc_base + MPSC_MMCRL);
13736 + writel(0x04400400, mpsc_base + MPSC_MMCRH);
13738 + writel(0, mpsc_base + MPSC_CHR_1);
13739 + writel(0, mpsc_base + MPSC_CHR_9);
13740 + writel(0, mpsc_base + MPSC_CHR_10);
13741 + writel(4, mpsc_base + MPSC_CHR_3);
13742 + writel(0x20000000, mpsc_base + MPSC_CHR_4);
13743 + writel(0x9000, mpsc_base + MPSC_CHR_5);
13744 + writel(0, mpsc_base + MPSC_CHR_6);
13745 + writel(0, mpsc_base + MPSC_CHR_7);
13746 + writel(0, mpsc_base + MPSC_CHR_8);
13748 + /* 8 data bits, 1 stop bit */
13749 + writel((3 << 12), mpsc_base + MPSC_MPCR);
13751 + /* Enter "hunt" mode */
13752 + writel((1 << 31), mpsc_base + MPSC_CHR_2);
13758 +static void __iomem *__init
13759 +kgdbmpsc_map_resource(struct platform_device *pd, int type, int num)
13761 + void __iomem *base = NULL;
13762 + struct resource *r;
13764 + if ((r = platform_get_resource(pd, IORESOURCE_MEM, num)))
13765 + base = ioremap(r->start, r->end - r->start + 1);
13769 +static void __iomem *__init
13770 +kgdbmpsc_unmap_resource(struct platform_device *pd, int type, int num,
13771 + void __iomem * base)
13778 +static void __init
13779 +kgdbmpsc_reserve_resource(struct platform_device *pd, int type, int num)
13781 + struct resource *r;
13783 + if ((r = platform_get_resource(pd, IORESOURCE_MEM, num)))
13784 + request_mem_region(r->start, r->end - r->start + 1, "kgdb");
13787 +static int __init kgdbmpsc_local_init(void)
13789 + if (!mpsc_dev.num_resources || !shared_dev.num_resources)
13790 + return 1; /* failure */
13792 + mpsc_base = kgdbmpsc_map_resource(&mpsc_dev, IORESOURCE_MEM,
13793 + MPSC_BASE_ORDER);
13794 + brg_base = kgdbmpsc_map_resource(&mpsc_dev, IORESOURCE_MEM,
13795 + MPSC_BRG_BASE_ORDER);
13797 + /* get the platform data for the shared registers and get them mapped */
13798 + routing_base = kgdbmpsc_map_resource(&shared_dev,
13800 + MPSC_ROUTING_BASE_ORDER);
13802 + kgdbmpsc_map_resource(&shared_dev, IORESOURCE_MEM,
13803 + MPSC_SDMA_INTR_BASE_ORDER);
13805 + mpsc_irq = platform_get_irq(&mpsc_dev, 1);
13807 + if (mpsc_base && brg_base && routing_base && sdma_base)
13808 + return 0; /* success */
13810 + return 1; /* failure */
13813 +static void __init kgdbmpsc_local_exit(void)
13816 + sdma_base = kgdbmpsc_unmap_resource(&shared_dev, IORESOURCE_MEM,
13817 + MPSC_SDMA_INTR_BASE_ORDER,
13819 + if (routing_base)
13820 + routing_base = kgdbmpsc_unmap_resource(&shared_dev,
13822 + MPSC_ROUTING_BASE_ORDER,
13825 + brg_base = kgdbmpsc_unmap_resource(&mpsc_dev, IORESOURCE_MEM,
13826 + MPSC_BRG_BASE_ORDER,
13829 + mpsc_base = kgdbmpsc_unmap_resource(&mpsc_dev, IORESOURCE_MEM,
13830 + MPSC_BASE_ORDER, mpsc_base);
13833 +static void __init kgdbmpsc_update_pdata(struct platform_device *pdev)
13836 + snprintf(pdev->dev.bus_id, BUS_ID_SIZE, "%s%u", pdev->name, pdev->id);
13839 +static int __init kgdbmpsc_pdev_init(void)
13841 + struct platform_device *pdev;
13843 + /* get the platform data for the specified port. */
13844 + pdev = mv64x60_early_get_pdev_data(MPSC_CTLR_NAME, kgdbmpsc_ttyMM, 1);
13846 + memcpy(&mpsc_dev, pdev, sizeof(struct platform_device));
13847 + if (platform_notify) {
13848 + kgdbmpsc_update_pdata(&mpsc_dev);
13849 + platform_notify(&mpsc_dev.dev);
13852 + /* get the platform data for the shared registers. */
13853 + pdev = mv64x60_early_get_pdev_data(MPSC_SHARED_NAME, 0, 0);
13855 + memcpy(&shared_dev, pdev,
13856 + sizeof(struct platform_device));
13857 + if (platform_notify) {
13858 + kgdbmpsc_update_pdata(&shared_dev);
13859 + platform_notify(&shared_dev.dev);
13866 +postcore_initcall(kgdbmpsc_pdev_init);
13868 +static int __init kgdbmpsc_init_io(void)
13871 + kgdbmpsc_pdev_init();
13873 + if (kgdbmpsc_local_init()) {
13874 + kgdbmpsc_local_exit();
13878 + if (kgdbmpsc_init() == -1)
13883 +static void __init kgdbmpsc_hookup_irq(void)
13885 + unsigned int msk;
13886 + if (!request_irq(mpsc_irq, kgdbmpsc_interrupt, 0, "kgdb mpsc", NULL)) {
13887 + /* Enable interrupt */
13888 + msk = readl(sdma_base + MPSC_INTR_REG_SELECT(MPSC_INTR_MASK));
13889 + msk |= MPSC_INTR_CAUSE_RCC;
13890 + writel(msk, sdma_base + MPSC_INTR_REG_SELECT(MPSC_INTR_MASK));
13892 + kgdbmpsc_reserve_resource(&mpsc_dev, IORESOURCE_MEM,
13893 + MPSC_BASE_ORDER);
13894 + kgdbmpsc_reserve_resource(&mpsc_dev, IORESOURCE_MEM,
13895 + MPSC_BRG_BASE_ORDER);
13899 +struct kgdb_io kgdb_io_ops = {
13900 + .read_char = kgdb_get_debug_char,
13901 + .write_char = kgdb_write_debug_char,
13902 + .init = kgdbmpsc_init_io,
13903 + .late_init = kgdbmpsc_hookup_irq,
13905 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/drivers/serial/pxa.c linux-2.6.18-53.1.14.kgdb/drivers/serial/pxa.c
13906 --- linux-2.6.18-53.1.14/drivers/serial/pxa.c 2006-09-20 07:42:06.000000000 +0400
13907 +++ linux-2.6.18-53.1.14.kgdb/drivers/serial/pxa.c 2008-06-10 15:38:56.000000000 +0400
13909 #include <linux/tty.h>
13910 #include <linux/tty_flip.h>
13911 #include <linux/serial_core.h>
13912 +#ifdef CONFIG_KGDB_CONSOLE
13913 +#include <linux/kgdb.h>
13916 #include <asm/io.h>
13917 #include <asm/hardware.h>
13918 @@ -692,6 +695,8 @@ serial_pxa_console_init(void)
13919 console_initcall(serial_pxa_console_init);
13921 #define PXA_CONSOLE &serial_pxa_console
13922 +#elif defined(CONFIG_KGDB_CONSOLE)
13923 +#define PXA_CONSOLE &kgdbcons
13925 #define PXA_CONSOLE NULL
13927 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/drivers/serial/serial_core.c linux-2.6.18-53.1.14.kgdb/drivers/serial/serial_core.c
13928 --- linux-2.6.18-53.1.14/drivers/serial/serial_core.c 2008-03-06 05:54:07.000000000 +0300
13929 +++ linux-2.6.18-53.1.14.kgdb/drivers/serial/serial_core.c 2008-06-10 15:37:43.000000000 +0400
13931 #include <linux/serial.h> /* for serial_state and serial_icounter_struct */
13932 #include <linux/delay.h>
13933 #include <linux/mutex.h>
13934 +#include <linux/kgdb.h>
13936 #include <asm/irq.h>
13937 #include <asm/uaccess.h>
13938 @@ -65,6 +66,12 @@ static struct lock_class_key port_lock_k
13939 #define uart_console(port) (0)
13942 +#ifdef CONFIG_KGDB_CONSOLE
13943 +#define uart_kgdb(port) (port->cons && !strcmp(port->cons->name, "kgdb"))
13945 +#define uart_kgdb(port) (0)
13948 static void uart_change_speed(struct uart_state *state, struct termios *old_termios);
13949 static void uart_wait_until_sent(struct tty_struct *tty, int timeout);
13950 static void uart_change_pm(struct uart_state *state, int pm_state);
13951 @@ -1673,6 +1680,9 @@ static int uart_line_info(char *buf, str
13952 port->iotype == UPIO_MEM ? port->mapbase :
13953 (unsigned long) port->iobase,
13955 + if (port->iotype == UPIO_MEM)
13956 + ret += sprintf(buf+ret, " membase 0x%08lX",
13957 + (unsigned long) port->membase);
13959 if (port->type == PORT_UNKNOWN) {
13961 @@ -2043,7 +2053,8 @@ uart_report_port(struct uart_driver *drv
13964 snprintf(address, sizeof(address),
13965 - "MMIO 0x%lx", port->mapbase);
13966 + "MMIO map 0x%lx mem 0x%lx", port->mapbase,
13967 + (unsigned long) port->membase);
13970 strlcpy(address, "*unknown*", sizeof(address));
13971 @@ -2095,9 +2106,9 @@ uart_configure_port(struct uart_driver *
13974 * Power down all ports by default, except the
13975 - * console if we have one.
13976 + * console (real or kgdb) if we have one.
13978 - if (!uart_console(port))
13979 + if (!uart_console(port) && !uart_kgdb(port))
13980 uart_change_pm(state, 3);
13983 @@ -2289,6 +2300,12 @@ int uart_add_one_port(struct uart_driver
13985 port->flags &= ~UPF_DEAD;
13987 +#if defined(CONFIG_KGDB_8250)
13988 + /* Add any 8250-like ports we find later. */
13989 + if (port->type <= PORT_MAX_8250)
13990 + kgdb8250_add_port(port->line, port);
13994 mutex_unlock(&state->mutex);
13995 mutex_unlock(&port_mutex);
13996 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/drivers/serial/serial_txx9.c linux-2.6.18-53.1.14.kgdb/drivers/serial/serial_txx9.c
13997 --- linux-2.6.18-53.1.14/drivers/serial/serial_txx9.c 2006-09-20 07:42:06.000000000 +0400
13998 +++ linux-2.6.18-53.1.14.kgdb/drivers/serial/serial_txx9.c 2008-06-10 15:38:24.000000000 +0400
13999 @@ -1164,6 +1164,96 @@ static struct pci_driver serial_txx9_pci
14000 MODULE_DEVICE_TABLE(pci, serial_txx9_pci_tbl);
14001 #endif /* ENABLE_SERIAL_TXX9_PCI */
14003 +/******************************************************************************/
14004 +/* BEG: KDBG Routines */
14005 +/******************************************************************************/
14007 +#ifdef CONFIG_KGDB
14008 +int kgdb_init_count = 0;
14010 +void txx9_sio_kgdb_hook(unsigned int port, unsigned int baud_rate)
14012 + static struct resource kgdb_resource;
14014 + struct uart_txx9_port *up = &serial_txx9_ports[port];
14016 + /* prevent initialization by driver */
14017 + kgdb_resource.name = "serial_txx9(debug)";
14018 + kgdb_resource.start = (unsigned long)up->port.membase;
14019 + kgdb_resource.end = (unsigned long)(up->port.membase + 36 - 1);
14020 + kgdb_resource.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
14022 + ret = request_resource(&iomem_resource, &kgdb_resource);
14023 + if(ret == -EBUSY)
14024 + printk(" serial_txx9(debug): request_resource failed\n");
14029 +txx9_sio_kdbg_init( unsigned int port_number )
14031 + if (port_number == 1) {
14032 + txx9_sio_kgdb_hook(port_number, 38400);
14034 + printk("Bad Port Number [%u] != [1]\n",port_number);
14040 +txx9_sio_kdbg_rd( void )
14042 + unsigned int status,ch;
14043 + struct uart_txx9_port *up = &serial_txx9_ports[1];
14045 + if (kgdb_init_count == 0) {
14046 + txx9_sio_kdbg_init(1);
14047 + kgdb_init_count = 1;
14051 + status = sio_in(up, TXX9_SIDISR);
14052 + if ( status & 0x1f ) {
14053 + ch = sio_in(up, TXX9_SIRFIFO );
14062 +txx9_sio_kdbg_wr( u8 ch )
14064 + unsigned int status;
14065 + struct uart_txx9_port *up = &serial_txx9_ports[1];
14067 + if (kgdb_init_count == 0) {
14068 + txx9_sio_kdbg_init(1);
14069 + kgdb_init_count = 1;
14073 + status = sio_in(up, TXX9_SICISR);
14074 + if (status & TXX9_SICISR_TRDY) {
14075 + if ( ch == '\n' ) {
14076 + txx9_sio_kdbg_wr( '\r' );
14078 + sio_out(up, TXX9_SITFIFO, (u32)ch );
14086 +#endif /* CONFIG_KGDB */
14089 +/******************************************************************************/
14090 +/* END: KDBG Routines */
14091 +/******************************************************************************/
14093 static int __init serial_txx9_init(void)
14096 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/drivers/serial/sh-sci.c linux-2.6.18-53.1.14.kgdb/drivers/serial/sh-sci.c
14097 --- linux-2.6.18-53.1.14/drivers/serial/sh-sci.c 2006-09-20 07:42:06.000000000 +0400
14098 +++ linux-2.6.18-53.1.14.kgdb/drivers/serial/sh-sci.c 2008-06-10 15:38:50.000000000 +0400
14100 #include <linux/console.h>
14101 #include <linux/bitops.h>
14102 #include <linux/generic_serial.h>
14103 +#include <linux/kgdb.h>
14105 #ifdef CONFIG_CPU_FREQ
14106 #include <linux/notifier.h>
14107 @@ -67,14 +68,16 @@
14109 #include "sh-sci.h"
14111 -#ifdef CONFIG_SH_KGDB
14112 -#include <asm/kgdb.h>
14114 -static int kgdb_get_char(struct sci_port *port);
14115 -static void kgdb_put_char(struct sci_port *port, char c);
14116 -static void kgdb_handle_error(struct sci_port *port);
14117 -static struct sci_port *kgdb_sci_port;
14118 -#endif /* CONFIG_SH_KGDB */
14119 +#ifdef CONFIG_KGDB_SH_SCI
14120 +/* Speed of the UART. */
14121 +static int kgdbsci_baud = CONFIG_KGDB_BAUDRATE
14123 +/* Index of the UART, matches ttySCX naming. */
14124 +static int kgdbsci_ttySC = CONFIG_KGDB_PORT_NUM;
14126 +/* Make life easier on us. */
14127 +#define KGDBPORT sci_ports[kgdbsci_ttySC]
14128 +#endif /* CONFIG_KGDB_SH_SCI */
14130 #ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
14131 static struct sci_port *serial_console_port = 0;
14132 @@ -87,20 +90,17 @@ static void sci_start_rx(struct uart_por
14133 static void sci_stop_rx(struct uart_port *port);
14134 static int sci_request_irq(struct sci_port *port);
14135 static void sci_free_irq(struct sci_port *port);
14136 +static void sci_set_termios(struct uart_port *port, struct termios *termios,
14137 + struct termios *old);
14138 +static int kgdbsci_init(void);
14140 static struct sci_port sci_ports[];
14141 static struct uart_driver sci_uart_driver;
14143 #define SCI_NPORTS sci_uart_driver.nr
14145 -#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
14147 -static void handle_error(struct uart_port *port)
14148 -{ /* Clear error flags */
14149 - sci_out(port, SCxSR, SCxSR_ERROR_CLEAR(port));
14152 -static int get_char(struct uart_port *port)
14153 +#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_KGDB_SH_SCI)
14154 +static int get_char_for_gdb(struct uart_port *port)
14156 unsigned long flags;
14157 unsigned short status;
14158 @@ -110,7 +110,8 @@ static int get_char(struct uart_port *po
14160 status = sci_in(port, SCxSR);
14161 if (status & SCxSR_ERRORS(port)) {
14162 - handle_error(port);
14163 + /* Clear error flags. */
14164 + sci_out(port, SCxSR, SCxSR_ERROR_CLEAR(port));
14167 } while (!(status & SCxSR_RDxF(port)));
14168 @@ -121,21 +122,7 @@ static int get_char(struct uart_port *po
14173 -/* Taken from sh-stub.c of GDB 4.18 */
14174 -static const char hexchars[] = "0123456789abcdef";
14176 -static __inline__ char highhex(int x)
14178 - return hexchars[(x >> 4) & 0xf];
14181 -static __inline__ char lowhex(int x)
14183 - return hexchars[x & 0xf];
14186 -#endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_SH_KGDB */
14187 +#endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_KGDB_SH_SCI */
14190 * Send the packet in buffer. The host gets one chance to read it.
14191 @@ -167,21 +154,14 @@ static void put_string(struct sci_port *
14192 const unsigned char *p = buffer;
14195 -#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
14196 +#ifdef CONFIG_SH_STANDARD_BIOS
14199 + const char hexchars[] = "0123456789abcdef";
14201 -#ifdef CONFIG_SH_STANDARD_BIOS
14202 /* This call only does a trap the first time it is
14203 * called, and so is safe to do here unconditionally
14205 - usegdb |= sh_bios_in_gdb_mode();
14207 -#ifdef CONFIG_SH_KGDB
14208 - usegdb |= (kgdb_in_gdb_mode && (port == kgdb_sci_port));
14212 + if (sh_bios_in_gdb_mode()) {
14213 /* $<packet info>#<checksum>. */
14216 @@ -193,18 +173,18 @@ static void put_string(struct sci_port *
14222 + h = hexchars[c >> 4];
14223 + l = hexchars[c % 16];
14228 put_char(port, '#');
14229 - put_char(port, highhex(checksum));
14230 - put_char(port, lowhex(checksum));
14231 + put_char(port, hexchars[checksum >> 4]);
14232 + put_char(port, hexchars[checksum % 16]);
14233 } while (get_char(port) != '+');
14235 -#endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_SH_KGDB */
14236 +#endif /* CONFIG_SH_STANDARD_BIOS */
14237 for (i=0; i<count; i++) {
14239 put_char(port, '\r');
14240 @@ -214,90 +194,163 @@ static void put_string(struct sci_port *
14241 #endif /* CONFIG_SERIAL_SH_SCI_CONSOLE */
14244 -#ifdef CONFIG_SH_KGDB
14246 -/* Is the SCI ready, ie is there a char waiting? */
14247 -static int kgdb_is_char_ready(struct sci_port *port)
14248 +#ifdef CONFIG_KGDB_SH_SCI
14249 +static int kgdbsci_read_char(void)
14251 - unsigned short status = sci_in(port, SCxSR);
14253 - if (status & (SCxSR_ERRORS(port) | SCxSR_BRK(port)))
14254 - kgdb_handle_error(port);
14256 - return (status & SCxSR_RDxF(port));
14257 + return get_char_for_gdb(&KGDBPORT.port);
14260 -/* Write a char */
14261 -static void kgdb_put_char(struct sci_port *port, char c)
14262 +/* Called from kgdbstub.c to put a character, just a wrapper */
14263 +static void kgdbsci_write_char(int c)
14265 unsigned short status;
14268 - status = sci_in(port, SCxSR);
14269 - while (!(status & SCxSR_TDxE(port)));
14270 + status = sci_in(&KGDBPORT.port, SCxSR);
14271 + while (!(status & SCxSR_TDxE(&KGDBPORT.port)));
14273 - sci_out(port, SCxTDR, c);
14274 - sci_in(port, SCxSR); /* Dummy read */
14275 - sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port));
14276 + sci_out(&KGDBPORT.port, SCxTDR, c);
14277 + sci_in(&KGDBPORT.port, SCxSR); /* Dummy read */
14278 + sci_out(&KGDBPORT.port, SCxSR, SCxSR_TDxE_CLEAR(&KGDBPORT.port));
14281 -/* Get a char if there is one, else ret -1 */
14282 -static int kgdb_get_char(struct sci_port *port)
14283 +#ifndef CONFIG_SERIAL_SH_SCI_CONSOLE
14284 +/* If we don't have console, we never hookup IRQs. But we need to
14285 + * hookup one so that we can interrupt the system.
14287 +static irqreturn_t kgdbsci_rx_interrupt(int irq, void *ptr,
14288 + struct pt_regs *regs)
14291 + struct uart_port *port = ptr;
14293 - if (kgdb_is_char_ready(port) == 0)
14296 - c = sci_in(port, SCxRDR);
14297 - sci_in(port, SCxSR); /* Dummy read */
14298 + if (!(sci_in(port, SCxSR) & SCxSR_RDxF(port)))
14301 + if (kgdb_io_ops.init != kgdbsci_init) {
14302 + /* Throw away the data if another I/O routine is active */
14303 + get_char_for_gdb(&KGDBPORT.port);
14305 + /* We've got an interrupt, so go ahead and call breakpoint() */
14308 + sci_in(port, SCxSR); /* dummy read */
14309 sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port));
14313 + return IRQ_HANDLED;
14316 -/* Called from kgdbstub.c to get a character, i.e. is blocking */
14317 -static int kgdb_sci_getchar(void)
14318 +static irqreturn_t kgdbsci_mpxed_interrupt(int irq, void *ptr,
14319 + struct pt_regs *regs)
14323 - /* Keep trying to read a character, this could be neater */
14324 - while ((c = kgdb_get_char(kgdb_sci_port)) < 0);
14325 + unsigned short ssr_status, scr_status;
14326 + struct uart_port *port = ptr;
14330 + ssr_status = sci_in(port,SCxSR);
14331 + scr_status = sci_in(port,SCSCR);
14333 -/* Called from kgdbstub.c to put a character, just a wrapper */
14334 -static void kgdb_sci_putchar(int c)
14336 + /* Rx Interrupt */
14337 + if ((ssr_status&0x0002) && (scr_status&0x0040))
14338 + kgdbsci_rx_interrupt(irq, ptr, regs);
14340 - kgdb_put_char(kgdb_sci_port, c);
14341 + return IRQ_HANDLED;
14344 -/* Clear any errors on the SCI */
14345 -static void kgdb_handle_error(struct sci_port *port)
14346 +static void __init kgdbsci_lateinit(void)
14348 - sci_out(port, SCxSR, SCxSR_ERROR_CLEAR(port)); /* Clear error flags */
14349 + if (KGDBPORT.irqs[0] == KGDBPORT.irqs[1]) {
14350 + if (!KGDBPORT.irqs[0]) {
14351 + printk(KERN_ERR "kgdbsci: Cannot allocate irq.\n");
14354 + if (request_irq(KGDBPORT.irqs[0], kgdbsci_mpxed_interrupt,
14355 + SA_INTERRUPT, "kgdbsci",
14356 + &KGDBPORT.port)) {
14357 + printk(KERN_ERR "kgdbsci: Cannot allocate irq.\n");
14361 + if (KGDBPORT.irqs[1])
14362 + request_irq(KGDBPORT.irqs[1],
14363 + kgdbsci_rx_interrupt, SA_INTERRUPT,
14364 + "kgdbsci", &KGDBPORT.port);
14369 -/* Breakpoint if there's a break sent on the serial port */
14370 -static void kgdb_break_interrupt(int irq, void *ptr, struct pt_regs *regs)
14372 + * We use the normal init routine to setup the port, so we can't be
14373 + * in here too early.
14375 +static int kgdbsci_init(void)
14377 - struct sci_port *port = ptr;
14378 - unsigned short status = sci_in(port, SCxSR);
14380 - if (status & SCxSR_BRK(port)) {
14381 + struct termios termios;
14383 - /* Break into the debugger if a break is detected */
14385 + memset(&termios, 0, sizeof(struct termios));
14388 - sci_out(port, SCxSR, SCxSR_BREAK_CLEAR(port));
14389 + termios.c_cflag = CREAD | HUPCL | CLOCAL | CS8;
14390 + switch (kgdbsci_baud) {
14392 + termios.c_cflag |= B9600;
14395 + termios.c_cflag |= B19200;
14398 + termios.c_cflag |= B38400;
14401 + termios.c_cflag |= B57600;
14404 + termios.c_cflag |= B115200;
14407 + sci_set_termios(&KGDBPORT.port, &termios, NULL);
14412 -#endif /* CONFIG_SH_KGDB */
14413 +struct kgdb_io kgdb_io_ops = {
14414 + .read_char = kgdbsci_read_char,
14415 + .write_char = kgdbsci_write_char,
14416 + .init = kgdbsci_init,
14417 +#ifndef CONFIG_SERIAL_SH_SCI_CONSOLE
14418 + .late_init = kgdbsci_lateinit,
14419 +#else /* ! CONFIG_SERIAL_SH_SCI_CONSOLE */
14420 + .late_init = NULL,
14421 +#endif /* ! CONFIG_SERIAL_SH_SCI_CONSOLE */
14422 + .pre_exception = NULL,
14423 + .post_exception = NULL
14427 + * Syntax for this cmdline option is "kgdbsci=ttyno,baudrate".
14430 +kgdbsci_opt(char *str)
14432 + /* We might have anywhere from 1 to 3 ports. */
14433 + if (*str < '0' || *str > SCI_NPORTS + '0')
14435 + kgdbsci_ttySC = *str - '0';
14440 + kgdbsci_baud = simple_strtoul(str, &str, 10);
14441 + if (kgdbsci_baud != 9600 && kgdbsci_baud != 19200 &&
14442 + kgdbsci_baud != 38400 && kgdbsci_baud != 57600 &&
14443 + kgdbsci_baud != 115200)
14449 + printk(KERN_ERR "Invalid syntax for option kgdbsci=\n");
14452 +__setup("kgdbsci", kgdbsci_opt);
14453 +#endif /* CONFIG_KGDB_SH_SCI */
14455 #if defined(__H8300S__)
14456 enum { sci_disable, sci_enable };
14457 @@ -555,6 +608,16 @@ static inline void sci_receive_chars(str
14461 +#ifdef CONFIG_KGDB_SH_SCI
14462 + /* We assume that a ^C on the port KGDB
14463 + * is using means that KGDB wants to
14464 + * interrupt the running system.
14466 + if (port->line == KGDBPORT.port.line &&
14471 /* Store data and status */
14472 if (status&SCxSR_FER(port)) {
14474 @@ -1618,6 +1681,7 @@ static int __init sci_console_init(void)
14475 console_initcall(sci_console_init);
14476 #endif /* CONFIG_SERIAL_SH_SCI_CONSOLE */
14479 #ifdef CONFIG_SH_KGDB
14481 * FIXME: Most of this can go away.. at the moment, we rely on
14482 @@ -1663,30 +1727,9 @@ int __init kgdb_console_setup(struct con
14483 return uart_set_options(port, co, baud, parity, bits, flow);
14485 #endif /* CONFIG_SH_KGDB */
14488 -#ifdef CONFIG_SH_KGDB_CONSOLE
14489 -static struct console kgdb_console = {
14491 - .write = kgdb_console_write,
14492 - .setup = kgdb_console_setup,
14493 - .flags = CON_PRINTBUFFER | CON_ENABLED,
14495 - .data = &sci_uart_driver,
14498 -/* Register the KGDB console so we get messages (d'oh!) */
14499 -static int __init kgdb_console_init(void)
14501 - register_console(&kgdb_console);
14505 -console_initcall(kgdb_console_init);
14506 -#endif /* CONFIG_SH_KGDB_CONSOLE */
14508 -#if defined(CONFIG_SH_KGDB_CONSOLE)
14509 -#define SCI_CONSOLE &kgdb_console
14510 -#elif defined(CONFIG_SERIAL_SH_SCI_CONSOLE)
14511 +#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
14512 #define SCI_CONSOLE &serial_console
14514 #define SCI_CONSOLE 0
14515 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/include/asm-arm/kgdb.h linux-2.6.18-53.1.14.kgdb/include/asm-arm/kgdb.h
14516 --- linux-2.6.18-53.1.14/include/asm-arm/kgdb.h 1970-01-01 03:00:00.000000000 +0300
14517 +++ linux-2.6.18-53.1.14.kgdb/include/asm-arm/kgdb.h 2008-06-10 15:39:01.000000000 +0400
14520 + * include/asm-arm/kgdb.h
14522 + * ARM KGDB support
14524 + * Author: Deepak Saxena <dsaxena@mvista.com>
14526 + * Copyright (C) 2002 MontaVista Software Inc.
14530 +#ifndef __ASM_KGDB_H__
14531 +#define __ASM_KGDB_H__
14533 +#include <linux/config.h>
14534 +#include <asm/ptrace.h>
14535 +#include <asm-generic/kgdb.h>
14539 + * GDB assumes that we're a user process being debugged, so
14540 + * it will send us an SWI command to write into memory as the
14541 + * debug trap. When an SWI occurs, the next instruction addr is
14542 + * placed into R14_svc before jumping to the vector trap.
14543 + * This doesn't work for kernel debugging as we are already in SVC
14544 + * we would loose the kernel's LR, which is a bad thing. This
14547 + * By doing this as an undefined instruction trap, we force a mode
14548 + * switch from SVC to UND mode, allowing us to save full kernel state.
14550 + * We also define a KGDB_COMPILED_BREAK which can be used to compile
14551 + * in breakpoints. This is important for things like sysrq-G and for
14552 + * the initial breakpoint from trap_init().
14554 + * Note to ARM HW designers: Add real trap support like SH && PPC to
14555 + * make our lives much much simpler. :)
14557 +#define BREAK_INSTR_SIZE 4
14558 +#define GDB_BREAKINST 0xef9f0001
14559 +#define KGDB_BREAKINST 0xe7ffdefe
14560 +#define KGDB_COMPILED_BREAK 0xe7ffdeff
14561 +#define CACHE_FLUSH_IS_SAFE 1
14563 +#ifndef __ASSEMBLY__
14565 +#define BREAKPOINT() asm(".word 0xe7ffdeff")
14568 +extern void kgdb_handle_bus_error(void);
14569 +extern int kgdb_fault_expected;
14570 +#endif /* !__ASSEMBLY__ */
14573 + * From Amit S. Kale:
14575 + * In the register packet, words 0-15 are R0 to R10, FP, IP, SP, LR, PC. But
14576 + * Register 16 isn't cpsr. GDB passes CPSR in word 25. There are 9 words in
14577 + * between which are unused. Passing only 26 words to gdb is sufficient.
14578 + * GDB can figure out that floating point registers are not passed.
14579 + * GDB_MAX_REGS should be 26.
14581 +#define GDB_MAX_REGS (26)
14583 +#define KGDB_MAX_NO_CPUS 1
14584 +#define BUFMAX 400
14585 +#define NUMREGBYTES (GDB_MAX_REGS << 2)
14586 +#define NUMCRITREGBYTES (32 << 2)
14604 +#define _CPSR (GDB_MAX_REGS - 1)
14606 +/* So that we can denote the end of a frame for tracing, in the simple
14608 +#define CFI_END_FRAME(func) __CFI_END_FRAME(_PC,_SP,func)
14610 +#endif /* __ASM_KGDB_H__ */
14611 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/include/asm-arm/system.h linux-2.6.18-53.1.14.kgdb/include/asm-arm/system.h
14612 --- linux-2.6.18-53.1.14/include/asm-arm/system.h 2006-09-20 07:42:06.000000000 +0400
14613 +++ linux-2.6.18-53.1.14.kgdb/include/asm-arm/system.h 2008-06-10 15:38:56.000000000 +0400
14614 @@ -444,6 +444,47 @@ static inline unsigned long __xchg(unsig
14615 extern void disable_hlt(void);
14616 extern void enable_hlt(void);
14618 +#define __HAVE_ARCH_CMPXCHG 1
14620 +#include <asm/types.h>
14622 +static inline unsigned long __cmpxchg_u32(volatile int *m, unsigned long old,
14623 + unsigned long new)
14626 + unsigned long flags;
14628 + local_irq_save(flags);
14630 + if (retval == old)
14632 + local_irq_restore(flags); /* implies memory barrier */
14637 +/* This function doesn't exist, so you'll get a linker error
14638 + if something tries to do an invalid cmpxchg(). */
14639 +extern void __cmpxchg_called_with_bad_pointer(void);
14641 +static inline unsigned long __cmpxchg(volatile void * ptr, unsigned long old,
14642 + unsigned long new, int size)
14646 + return __cmpxchg_u32(ptr, old, new);
14648 + __cmpxchg_called_with_bad_pointer();
14652 +#define cmpxchg(ptr,o,n) \
14654 + __typeof__(*(ptr)) _o_ = (o); \
14655 + __typeof__(*(ptr)) _n_ = (n); \
14656 + (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \
14657 + (unsigned long)_n_, sizeof(*(ptr))); \
14659 #endif /* __ASSEMBLY__ */
14661 #define arch_align_stack(x) (x)
14662 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/include/asm-generic/kgdb.h linux-2.6.18-53.1.14.kgdb/include/asm-generic/kgdb.h
14663 --- linux-2.6.18-53.1.14/include/asm-generic/kgdb.h 1970-01-01 03:00:00.000000000 +0300
14664 +++ linux-2.6.18-53.1.14.kgdb/include/asm-generic/kgdb.h 2008-06-10 15:39:01.000000000 +0400
14667 + * include/asm-generic/kgdb.h
14669 + * This provides the assembly level information so that KGDB can provide
14670 + * a GDB that has been patched with enough information to know to stop
14671 + * trying to unwind the function.
14673 + * Author: Tom Rini <trini@kernel.crashing.org>
14675 + * 2005 (c) MontaVista Software, Inc. This file is licensed under the terms
14676 + * of the GNU General Public License version 2. This program is licensed
14677 + * "as is" without any warranty of any kind, whether express or implied.
14680 +#ifndef __ASM_GENERIC_KGDB_H__
14681 +#define __ASM_GENERIC_KGDB_H__
14683 +#include <linux/dwarf2-lang.h>
14684 +#ifdef __ASSEMBLY__
14685 +#ifdef CONFIG_KGDB
14686 +/* This MUST be put at the end of a given assembly function */
14687 +#define __CFI_END_FRAME(pc,sp,func) \
14688 +CAT3(.Lend_,func,:) \
14689 + CFI_preamble(func,pc,0x1,-DATA_ALIGN_FACTOR) \
14690 + CFA_define_reference(sp, 0) \
14691 + CFA_undefine_reg(pc) \
14692 + CFI_postamble() \
14693 + FDE_preamble(func,func,CAT3(.Lend,_,func)) \
14696 +#define __CFI_END_FRAME(pc,sp,fn)
14697 +#endif /* CONFIG_KGDB */
14698 +#endif /* __ASSEMBLY__ */
14699 +#endif /* __ASM_GENERIC_KGDB_H__ */
14700 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/include/asm-i386/kdebug.h linux-2.6.18-53.1.14.kgdb/include/asm-i386/kdebug.h
14701 --- linux-2.6.18-53.1.14/include/asm-i386/kdebug.h 2006-09-20 07:42:06.000000000 +0400
14702 +++ linux-2.6.18-53.1.14.kgdb/include/asm-i386/kdebug.h 2008-06-10 15:38:03.000000000 +0400
14703 @@ -39,6 +39,7 @@ enum die_val {
14707 + DIE_PAGE_FAULT_NO_CONTEXT,
14710 static inline int notify_die(enum die_val val, const char *str,
14711 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/include/asm-i386/kgdb.h linux-2.6.18-53.1.14.kgdb/include/asm-i386/kgdb.h
14712 --- linux-2.6.18-53.1.14/include/asm-i386/kgdb.h 1970-01-01 03:00:00.000000000 +0300
14713 +++ linux-2.6.18-53.1.14.kgdb/include/asm-i386/kgdb.h 2008-06-10 15:39:01.000000000 +0400
14716 +#ifndef _ASM_KGDB_H_
14717 +#define _ASM_KGDB_H_
14720 + * Copyright (C) 2001-2004 Amit S. Kale
14723 +#include <asm-generic/kgdb.h>
14726 + * Note that this register image is in a different order than
14727 + * the register image that Linux produces at interrupt time.
14729 + * Linux's register image is defined by struct pt_regs in ptrace.h.
14730 + * Just why GDB uses a different order is a historical mystery.
14751 +/* So that we can denote the end of a frame for tracing, in the simple
14753 +#define CFI_END_FRAME(func) __CFI_END_FRAME(_EIP,_ESP,func)
14755 +#ifndef __ASSEMBLY__
14756 +/************************************************************************/
14757 +/* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/
14758 +/* at least NUMREGBYTES*2 are needed for register packets */
14759 +/* Longer buffer is needed to list all threads */
14760 +#define BUFMAX 1024
14762 +/* Number of bytes of registers. */
14763 +#define NUMREGBYTES 64
14764 +/* Number of bytes of registers we need to save for a setjmp/longjmp. */
14765 +#define NUMCRITREGBYTES 24
14767 +#define BREAKPOINT() asm(" int $3");
14768 +#define BREAK_INSTR_SIZE 1
14769 +#define CACHE_FLUSH_IS_SAFE 1
14770 +#endif /* !__ASSEMBLY__ */
14771 +#endif /* _ASM_KGDB_H_ */
14772 +#endif /* __KERNEL__ */
14773 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/include/asm-ia64/kdebug.h linux-2.6.18-53.1.14.kgdb/include/asm-ia64/kdebug.h
14774 --- linux-2.6.18-53.1.14/include/asm-ia64/kdebug.h 2006-09-20 07:42:06.000000000 +0400
14775 +++ linux-2.6.18-53.1.14.kgdb/include/asm-ia64/kdebug.h 2008-06-10 15:38:32.000000000 +0400
14776 @@ -72,6 +72,7 @@ enum die_val {
14780 + DIE_PAGE_FAULT_NO_CONTEXT,
14783 static inline int notify_die(enum die_val val, char *str, struct pt_regs *regs,
14784 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/include/asm-ia64/kgdb.h linux-2.6.18-53.1.14.kgdb/include/asm-ia64/kgdb.h
14785 --- linux-2.6.18-53.1.14/include/asm-ia64/kgdb.h 1970-01-01 03:00:00.000000000 +0300
14786 +++ linux-2.6.18-53.1.14.kgdb/include/asm-ia64/kgdb.h 2008-06-10 15:38:32.000000000 +0400
14789 +#ifndef _ASM_KGDB_H_
14790 +#define _ASM_KGDB_H_
14793 + * Copyright (C) 2001-2004 Amit S. Kale
14796 +#include <linux/threads.h>
14798 +/************************************************************************/
14799 +/* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/
14800 +/* at least NUMREGBYTES*2 are needed for register packets */
14801 +/* Longer buffer is needed to list all threads */
14802 +#define BUFMAX 1024
14804 +/* Number of bytes of registers. We set this to 0 so that certain GDB
14805 + * packets will fail, forcing the use of others, which are more friendly
14807 +#define NUMREGBYTES 0
14809 +#define NUMCRITREGBYTES (70*8)
14810 +#define JMP_REGS_ALIGNMENT __attribute__ ((aligned (16)))
14812 +#define BREAKNUM 0x00003333300LL
14813 +#define KGDBBREAKNUM 0x6665UL
14814 +#define BREAKPOINT() asm volatile ("break.m 0x6665")
14815 +#define BREAK_INSTR_SIZE 16
14816 +#define CACHE_FLUSH_IS_SAFE 1
14819 +extern volatile int kgdb_hwbreak_sstep[NR_CPUS];
14820 +extern void smp_send_nmi_allbutself(void);
14821 +extern void kgdb_wait_ipi(struct pt_regs *);
14822 +#endif /* _ASM_KGDB_H_ */
14823 +#endif /* __KERNEL__ */
14824 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/include/asm-mips/kdebug.h linux-2.6.18-53.1.14.kgdb/include/asm-mips/kdebug.h
14825 --- linux-2.6.18-53.1.14/include/asm-mips/kdebug.h 1970-01-01 03:00:00.000000000 +0300
14826 +++ linux-2.6.18-53.1.14.kgdb/include/asm-mips/kdebug.h 2008-06-10 15:38:24.000000000 +0400
14830 + * Copyright (C) 2004 MontaVista Software Inc.
14831 + * Author: Manish Lachwani, mlachwani@mvista.com or manish@koffee-break.com
14833 + * This program is free software; you can redistribute it and/or modify it
14834 + * under the terms of the GNU General Public License as published by the
14835 + * Free Software Foundation; either version 2 of the License, or (at your
14836 + * option) any later version.
14839 +#ifndef _MIPS_KDEBUG_H
14840 +#define _MIPS_KDEBUG_H
14842 +#include <linux/notifier.h>
14847 + struct pt_regs *regs;
14852 +int register_die_notifier(struct notifier_block *nb);
14853 +extern struct notifier_block *mips_die_chain;
14865 + * trap number can be computed from regs and signr can be computed using
14866 + * compute_signal()
14868 +static inline int notify_die(enum die_val val,char *str,struct pt_regs *regs,long err)
14870 + struct die_args args = { .regs=regs, .str=str, .err=err };
14871 + return notifier_call_chain(&mips_die_chain, val, &args);
14874 +#endif /* _MIPS_KDEBUG_H */
14875 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/include/asm-mips/kgdb.h linux-2.6.18-53.1.14.kgdb/include/asm-mips/kgdb.h
14876 --- linux-2.6.18-53.1.14/include/asm-mips/kgdb.h 1970-01-01 03:00:00.000000000 +0300
14877 +++ linux-2.6.18-53.1.14.kgdb/include/asm-mips/kgdb.h 2008-06-10 15:39:01.000000000 +0400
14880 +#ifndef _ASM_KGDB_H_
14881 +#define _ASM_KGDB_H_
14883 +#ifndef __ASSEMBLY__
14884 +#if (_MIPS_ISA == _MIPS_ISA_MIPS1) || (_MIPS_ISA == _MIPS_ISA_MIPS2)
14885 +typedef u32 gdb_reg_t;
14886 +#elif (_MIPS_ISA == _MIPS_ISA_MIPS3) || (_MIPS_ISA == _MIPS_ISA_MIPS4)
14887 +typedef u64 gdb_reg_t;
14890 +#endif /* _MIPS_ISA */
14892 +#include <asm-generic/kgdb.h>
14894 +#ifndef __ASSEMBLY__
14895 +#define BUFMAX 2048
14896 +#define NUMREGBYTES (90*sizeof(gdb_reg_t))
14897 +#define NUMCRITREGBYTES (12*sizeof(gdb_reg_t))
14898 +#define BREAK_INSTR_SIZE 4
14899 +#define BREAKPOINT() __asm__ __volatile__( \
14900 + ".globl breakinst\n\t" \
14901 + ".set\tnoreorder\n\t" \
14903 + "breakinst:\tbreak\n\t" \
14906 +#define CACHE_FLUSH_IS_SAFE 0
14908 +extern int kgdb_early_setup;
14910 +#endif /* !__ASSEMBLY__ */
14911 +#endif /* _ASM_KGDB_H_ */
14912 +#endif /* __KERNEL__ */
14913 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/include/asm-powerpc/kgdb.h linux-2.6.18-53.1.14.kgdb/include/asm-powerpc/kgdb.h
14914 --- linux-2.6.18-53.1.14/include/asm-powerpc/kgdb.h 1970-01-01 03:00:00.000000000 +0300
14915 +++ linux-2.6.18-53.1.14.kgdb/include/asm-powerpc/kgdb.h 2008-06-10 15:39:01.000000000 +0400
14918 + * include/asm-powerpc/kgdb.h
14920 + * The PowerPC (32/64) specific defines / externs for KGDB. Based on
14921 + * the previous 32bit and 64bit specific files, which had the following
14924 + * PPC64 Mods (C) 2005 Frank Rowand (frowand@mvista.com)
14925 + * PPC Mods (C) 2004 Tom Rini (trini@mvista.com)
14926 + * PPC Mods (C) 2003 John Whitney (john.whitney@timesys.com)
14927 + * PPC Mods (C) 1998 Michael Tesch (tesch@cs.wisc.edu)
14930 + * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
14931 + * Author: Tom Rini <trini@kernel.crashing.org>
14933 + * 2006 (c) MontaVista Software, Inc. This file is licensed under
14934 + * the terms of the GNU General Public License version 2. This program
14935 + * is licensed "as is" without any warranty of any kind, whether express
14939 +#ifndef __POWERPC_KGDB_H__
14940 +#define __POWERPC_KGDB_H__
14942 +#include <asm-generic/kgdb.h>
14943 +#ifndef __ASSEMBLY__
14945 +#define BREAK_INSTR_SIZE 4
14946 +#define BUFMAX ((NUMREGBYTES * 2) + 512)
14947 +#define OUTBUFMAX ((NUMREGBYTES * 2) + 512)
14948 +#define BREAKPOINT() asm(".long 0x7d821008"); /* twge r2, r2 */
14949 +#define CACHE_FLUSH_IS_SAFE 1
14951 +/* The number bytes of registers we have to save depends on a few
14952 + * things. For 64bit we default to not including vector registers and
14953 + * vector state registers. */
14954 +#ifdef CONFIG_PPC64
14956 + * 64 bit (8 byte) registers:
14957 + * 32 gpr, 32 fpr, nip, msr, link, ctr
14958 + * 32 bit (4 byte) registers:
14959 + * ccr, xer, fpscr
14961 +#define NUMREGBYTES ((68 * 8) + (3 * 4))
14963 +/* The following adds in vector registers and vector state registers. */
14964 +/* 128 bit (16 byte) registers:
14966 + * 64 bit (8 byte) registers:
14967 + * 32 gpr, 32 fpr, nip, msr, link, ctr
14968 + * 32 bit (4 byte) registers:
14969 + * ccr, xer, fpscr, vscr, vrsave
14971 +#define NUMREGBYTES ((128 * 16) + (68 * 8) + (5 * 4))
14973 +#define NUMCRITREGBYTES 184
14974 +#else /* CONFIG_PPC32 */
14975 +/* On non-E500 family PPC32 we determine the size by picking the last
14976 + * register we need, but on E500 we skip sections so we list what we
14977 + * need to store, and add it up. */
14978 +#ifndef CONFIG_E500
14979 +#define MAXREG (PT_FPSCR+1)
14981 +/* 32 GPRs (8 bytes), nip, msr, ccr, link, ctr, xer, acc (8 bytes), spefscr*/
14982 +#define MAXREG ((32*2)+6+2+1)
14984 +#define NUMREGBYTES (MAXREG * sizeof(int))
14985 +/* CR/LR, R1, R2, R13-R31 inclusive. */
14986 +#define NUMCRITREGBYTES (23 * sizeof(int))
14987 +#endif /* 32/64 */
14988 +#endif /* !(__ASSEMBLY__) */
14989 +#endif /* !__POWERPC_KGDB_H__ */
14990 +#endif /* __KERNEL__ */
14991 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/include/asm-ppc/kgdb.h linux-2.6.18-53.1.14.kgdb/include/asm-ppc/kgdb.h
14992 --- linux-2.6.18-53.1.14/include/asm-ppc/kgdb.h 2006-09-20 07:42:06.000000000 +0400
14993 +++ linux-2.6.18-53.1.14.kgdb/include/asm-ppc/kgdb.h 2008-06-10 15:38:14.000000000 +0400
14996 - * kgdb.h: Defines and declarations for serial line source level
14997 - * remote debugging of the Linux kernel using gdb.
14999 - * PPC Mods (C) 1998 Michael Tesch (tesch@cs.wisc.edu)
15001 - * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
15004 -#ifndef _PPC_KGDB_H
15005 -#define _PPC_KGDB_H
15007 +#ifndef __PPC_KGDB_H__
15008 +#define __PPC_KGDB_H__
15009 +#include <asm-powerpc/kgdb.h>
15010 #ifndef __ASSEMBLY__
15012 -/* Things specific to the gen550 backend. */
15015 -extern void gen550_progress(char *, unsigned short);
15016 -extern void gen550_kgdb_map_scc(void);
15017 -extern void gen550_init(int, struct uart_port *);
15019 -/* Things specific to the pmac backend. */
15020 -extern void zs_kgdb_hook(int tty_num);
15022 -/* To init the kgdb engine. (called by serial hook)*/
15023 -extern void set_debug_traps(void);
15025 -/* To enter the debugger explicitly. */
15026 -extern void breakpoint(void);
15028 -/* For taking exceptions
15029 + /* For taking exceptions
15030 * these are defined in traps.c
15032 -extern int (*debugger)(struct pt_regs *regs);
15034 +extern void (*debugger)(struct pt_regs *regs);
15035 extern int (*debugger_bpt)(struct pt_regs *regs);
15036 extern int (*debugger_sstep)(struct pt_regs *regs);
15037 extern int (*debugger_iabr_match)(struct pt_regs *regs);
15038 extern int (*debugger_dabr_match)(struct pt_regs *regs);
15039 extern void (*debugger_fault_handler)(struct pt_regs *regs);
15041 -/* What we bring to the party */
15042 -int kgdb_bpt(struct pt_regs *regs);
15043 -int kgdb_sstep(struct pt_regs *regs);
15044 -void kgdb(struct pt_regs *regs);
15045 -int kgdb_iabr_match(struct pt_regs *regs);
15046 -int kgdb_dabr_match(struct pt_regs *regs);
15049 - * external low-level support routines (ie macserial.c)
15051 -extern void kgdb_interruptible(int); /* control interrupts from serial */
15052 -extern void putDebugChar(char); /* write a single character */
15053 -extern char getDebugChar(void); /* read and return a single char */
15055 -#endif /* !(__ASSEMBLY__) */
15056 -#endif /* !(_PPC_KGDB_H) */
15057 +#endif /* !__ASSEMBLY__ */
15058 +#endif /* __PPC_KGDB_H__ */
15059 #endif /* __KERNEL__ */
15060 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/include/asm-ppc/machdep.h linux-2.6.18-53.1.14.kgdb/include/asm-ppc/machdep.h
15061 --- linux-2.6.18-53.1.14/include/asm-ppc/machdep.h 2006-09-20 07:42:06.000000000 +0400
15062 +++ linux-2.6.18-53.1.14.kgdb/include/asm-ppc/machdep.h 2008-06-10 15:38:14.000000000 +0400
15063 @@ -72,9 +72,7 @@ struct machdep_calls {
15064 unsigned long (*find_end_of_memory)(void);
15065 void (*setup_io_mappings)(void);
15067 - void (*early_serial_map)(void);
15068 void (*progress)(char *, unsigned short);
15069 - void (*kgdb_map_scc)(void);
15071 unsigned char (*nvram_read_val)(int addr);
15072 void (*nvram_write_val)(int addr, unsigned char val);
15073 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/include/asm-ppc/mv64x60.h linux-2.6.18-53.1.14.kgdb/include/asm-ppc/mv64x60.h
15074 --- linux-2.6.18-53.1.14/include/asm-ppc/mv64x60.h 2006-09-20 07:42:06.000000000 +0400
15075 +++ linux-2.6.18-53.1.14.kgdb/include/asm-ppc/mv64x60.h 2008-06-10 15:38:14.000000000 +0400
15076 @@ -348,6 +348,8 @@ u32 mv64x60_calc_mem_size(struct mv64x60
15078 void mv64x60_progress_init(u32 base);
15079 void mv64x60_mpsc_progress(char *s, unsigned short hex);
15080 +struct platform_device * mv64x60_early_get_pdev_data(const char *name,
15081 + int id, int remove);
15083 extern struct mv64x60_32bit_window
15084 gt64260_32bit_windows[MV64x60_32BIT_WIN_COUNT];
15085 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/include/asm-ppc/mv64x60_defs.h linux-2.6.18-53.1.14.kgdb/include/asm-ppc/mv64x60_defs.h
15086 --- linux-2.6.18-53.1.14/include/asm-ppc/mv64x60_defs.h 2006-09-20 07:42:06.000000000 +0400
15087 +++ linux-2.6.18-53.1.14.kgdb/include/asm-ppc/mv64x60_defs.h 2008-06-10 15:38:14.000000000 +0400
15089 #define MV64x60_IRQ_I2C 37
15090 #define MV64x60_IRQ_BRG 39
15091 #define MV64x60_IRQ_MPSC_0 40
15092 -#define MV64x60_IRQ_MPSC_1 42
15093 +#define MV64360_IRQ_MPSC_1 41
15094 +#define GT64260_IRQ_MPSC_1 42
15095 #define MV64x60_IRQ_COMM 43
15096 #define MV64x60_IRQ_P0_GPP_0_7 56
15097 #define MV64x60_IRQ_P0_GPP_8_15 57
15098 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/include/asm-sh/kgdb.h linux-2.6.18-53.1.14.kgdb/include/asm-sh/kgdb.h
15099 --- linux-2.6.18-53.1.14/include/asm-sh/kgdb.h 2006-09-20 07:42:06.000000000 +0400
15100 +++ linux-2.6.18-53.1.14.kgdb/include/asm-sh/kgdb.h 2008-06-10 15:39:01.000000000 +0400
15102 * May be copied or modified under the terms of the GNU General Public
15103 * License. See linux/COPYING for more information.
15105 - * Based on original code by Glenn Engel, Jim Kingdon,
15106 - * David Grothe <dave@gcom.com>, Tigran Aivazian, <tigran@sco.com> and
15107 - * Amit S. Kale <akale@veritas.com>
15108 + * Based on a file that was modified or based on files by: Glenn Engel,
15109 + * Jim Kingdon, David Grothe <dave@gcom.com>, Tigran Aivazian <tigran@sco.com>,
15110 + * Amit S. Kale <akale@veritas.com>, sh-stub.c from Ben Lee and
15111 + * Steve Chamberlain, Henry Bell <henry.bell@st.com>
15113 - * Super-H port based on sh-stub.c (Ben Lee and Steve Chamberlain) by
15114 - * Henry Bell <henry.bell@st.com>
15116 - * Header file for low-level support for remote debug using GDB.
15117 + * Maintainer: Tom Rini <trini@kernel.crashing.org>
15124 -#include <asm/ptrace.h>
15127 +#include <asm-generic/kgdb.h>
15128 +/* Based on sh-gdb.c from gdb-6.1, Glenn
15129 + Engel at HP Ben Lee and Steve Chamberlain */
15130 +#define NUMREGBYTES 112 /* 92 */
15131 +#define NUMCRITREGBYTES (9 << 2)
15132 +#define BUFMAX 400
15134 -/* Same as pt_regs but has vbr in place of syscall_nr */
15135 +#ifndef __ASSEMBLY__
15137 unsigned long regs[16];
15140 - unsigned long sr;
15142 + unsigned long vbr;
15143 unsigned long mach;
15144 unsigned long macl;
15145 - unsigned long vbr;
15149 -extern char kgdb_in_gdb_mode;
15150 -extern int kgdb_done_init;
15151 -extern int kgdb_enabled;
15152 -extern int kgdb_nofault; /* Ignore bus errors (in gdb mem access) */
15153 -extern int kgdb_halt; /* Execute initial breakpoint at startup */
15154 -extern char in_nmi; /* Debounce flag to prevent NMI reentry*/
15157 -extern int kgdb_portnum;
15158 -extern int kgdb_baud;
15159 -extern char kgdb_parity;
15160 -extern char kgdb_bits;
15161 -extern int kgdb_console_setup(struct console *, char *);
15163 -/* Init and interface stuff */
15164 -extern int kgdb_init(void);
15165 -extern int (*kgdb_serial_setup)(void);
15166 -extern int (*kgdb_getchar)(void);
15167 -extern void (*kgdb_putchar)(int);
15169 -struct kgdb_sermap {
15172 - int (*setup_fn)(struct console *, char *);
15173 - struct kgdb_sermap *next;
15174 + unsigned long sr;
15176 -extern void kgdb_register_sermap(struct kgdb_sermap *map);
15177 -extern struct kgdb_sermap *kgdb_porttype;
15179 -/* Trap functions */
15180 -typedef void (kgdb_debug_hook_t)(struct pt_regs *regs);
15181 -typedef void (kgdb_bus_error_hook_t)(void);
15182 -extern kgdb_debug_hook_t *kgdb_debug_hook;
15183 -extern kgdb_bus_error_hook_t *kgdb_bus_err_hook;
15185 -extern void breakpoint(void);
15189 -void kgdb_console_write(struct console *co, const char *s, unsigned count);
15190 -void kgdb_console_init(void);
15192 -/* Prototypes for jmp fns */
15194 -typedef int jmp_buf[_JBLEN];
15195 -extern void longjmp(jmp_buf __jmpb, int __retval);
15196 -extern int setjmp(jmp_buf __jmpb);
15198 -/* Variadic macro to print our own message to the console */
15199 -#define KGDB_PRINTK(...) printk("KGDB: " __VA_ARGS__)
15201 -/* Forced breakpoint */
15202 -#define BREAKPOINT() do { \
15203 - if (kgdb_enabled) { \
15204 - asm volatile("trapa #0xff"); \
15207 +#define BREAKPOINT() asm("trapa #0xff");
15208 +#define BREAK_INSTR_SIZE 2
15209 +#define CACHE_FLUSH_IS_SAFE 1
15211 /* KGDB should be able to flush all kernel text space */
15212 #if defined(CONFIG_CPU_SH4)
15213 @@ -102,30 +48,5 @@ extern int setjmp(jmp_buf __jmpb);
15215 #define kgdb_flush_icache_range(start, end) do { } while (0)
15218 -/* Kernel assert macros */
15219 -#ifdef CONFIG_KGDB_KERNEL_ASSERTS
15221 -/* Predefined conditions */
15222 -#define KA_VALID_ERRNO(errno) ((errno) > 0 && (errno) <= EMEDIUMTYPE)
15223 -#define KA_VALID_PTR_ERR(ptr) KA_VALID_ERRNO(-PTR_ERR(ptr))
15224 -#define KA_VALID_KPTR(ptr) (!(ptr) || \
15225 - ((void *)(ptr) >= (void *)PAGE_OFFSET && \
15226 - (void *)(ptr) < ERR_PTR(-EMEDIUMTYPE)))
15227 -#define KA_VALID_PTRORERR(errptr) \
15228 - (KA_VALID_KPTR(errptr) || KA_VALID_PTR_ERR(errptr))
15229 -#define KA_HELD_GKL() (current->lock_depth >= 0)
15231 -/* The actual assert */
15232 -#define KGDB_ASSERT(condition, message) do { \
15233 - if (!(condition) && (kgdb_enabled)) { \
15234 - KGDB_PRINTK("Assertion failed at %s:%d: %s\n", \
15235 - __FILE__, __LINE__, message);\
15240 -#define KGDB_ASSERT(condition, message)
15243 +#endif /* !__ASSEMBLY__ */
15245 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/include/asm-sh/system.h linux-2.6.18-53.1.14.kgdb/include/asm-sh/system.h
15246 --- linux-2.6.18-53.1.14/include/asm-sh/system.h 2006-09-20 07:42:06.000000000 +0400
15247 +++ linux-2.6.18-53.1.14.kgdb/include/asm-sh/system.h 2008-06-10 15:38:50.000000000 +0400
15249 * Copyright (C) 2002 Paul Mundt
15252 +#include <asm/types.h>
15255 * switch_to() should switch tasks to task nr n, first
15256 @@ -260,6 +261,45 @@ static __inline__ unsigned long __xchg(u
15260 +static inline unsigned long __cmpxchg_u32(volatile int * m, unsigned long old,
15261 + unsigned long new)
15264 + unsigned long flags;
15266 + local_irq_save(flags);
15268 + if (retval == old)
15270 + local_irq_restore(flags); /* implies memory barrier */
15274 +/* This function doesn't exist, so you'll get a linker error
15275 + * if something tries to do an invalid cmpxchg(). */
15276 +extern void __cmpxchg_called_with_bad_pointer(void);
15278 +#define __HAVE_ARCH_CMPXCHG 1
15280 +static inline unsigned long __cmpxchg(volatile void * ptr, unsigned long old,
15281 + unsigned long new, int size)
15285 + return __cmpxchg_u32(ptr, old, new);
15287 + __cmpxchg_called_with_bad_pointer();
15291 +#define cmpxchg(ptr,o,n) \
15293 + __typeof__(*(ptr)) _o_ = (o); \
15294 + __typeof__(*(ptr)) _n_ = (n); \
15295 + (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \
15296 + (unsigned long)_n_, sizeof(*(ptr))); \
15300 * disable hlt during certain critical i/o operations
15302 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/include/asm-x86_64/kdebug.h linux-2.6.18-53.1.14.kgdb/include/asm-x86_64/kdebug.h
15303 --- linux-2.6.18-53.1.14/include/asm-x86_64/kdebug.h 2006-09-20 07:42:06.000000000 +0400
15304 +++ linux-2.6.18-53.1.14.kgdb/include/asm-x86_64/kdebug.h 2008-06-10 15:38:41.000000000 +0400
15305 @@ -34,6 +34,7 @@ enum die_val {
15309 + DIE_PAGE_FAULT_NO_CONTEXT,
15312 static inline int notify_die(enum die_val val, const char *str,
15313 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/include/asm-x86_64/kgdb.h linux-2.6.18-53.1.14.kgdb/include/asm-x86_64/kgdb.h
15314 --- linux-2.6.18-53.1.14/include/asm-x86_64/kgdb.h 1970-01-01 03:00:00.000000000 +0300
15315 +++ linux-2.6.18-53.1.14.kgdb/include/asm-x86_64/kgdb.h 2008-06-10 15:39:01.000000000 +0400
15318 +#ifndef _ASM_KGDB_H_
15319 +#define _ASM_KGDB_H_
15322 + * Copyright (C) 2001-2004 Amit S. Kale
15325 +#include <asm-generic/kgdb.h>
15328 + * Note that this register image is in a different order than
15329 + * the register image that Linux produces at interrupt time.
15331 + * Linux's register image is defined by struct pt_regs in ptrace.h.
15332 + * Just why GDB uses a different order is a historical mystery.
15353 +/* Number of bytes of registers. */
15354 +#define NUMREGBYTES ((_PS+1)*8)
15355 +#define NUMCRITREGBYTES (8 * 8) /* 8 registers. */
15357 +/* Help GDB to know when to stop backtracing. */
15358 +#define CFI_END_FRAME(func) __CFI_END_FRAME(_PC,_RSP,func)
15359 +#ifndef __ASSEMBLY__
15360 +/* BUFMAX defines the maximum number of characters in inbound/outbound
15361 + * buffers at least NUMREGBYTES*2 are needed for register packets, and
15362 + * a longer buffer is needed to list all threads. */
15363 +#define BUFMAX 1024
15364 +#define BREAKPOINT() asm(" int $3");
15365 +#define CHECK_EXCEPTION_STACK() ((&__get_cpu_var(init_tss))[0].ist[0])
15366 +#define BREAK_INSTR_SIZE 1
15367 +#define CACHE_FLUSH_IS_SAFE 1
15368 +#endif /* !__ASSEMBLY__ */
15369 +#endif /* _ASM_KGDB_H_ */
15370 +#endif /* __KERNEL__ */
15371 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/include/asm-x86_64/system.h linux-2.6.18-53.1.14.kgdb/include/asm-x86_64/system.h
15372 --- linux-2.6.18-53.1.14/include/asm-x86_64/system.h 2008-03-06 05:54:38.000000000 +0300
15373 +++ linux-2.6.18-53.1.14.kgdb/include/asm-x86_64/system.h 2008-06-10 15:38:44.000000000 +0400
15376 /* Save restore flags to clear handle leaking NT */
15377 #define switch_to(prev,next,last) \
15378 - asm volatile(SAVE_CONTEXT \
15379 + asm volatile(".globl __switch_to_begin\n\t" \
15380 + "__switch_to_begin:\n\t" \
15382 "movq %%rsp,%P[threadrsp](%[prev])\n\t" /* save RSP */ \
15383 "movq %P[threadrsp](%[next]),%%rsp\n\t" /* restore RSP */ \
15384 "call __switch_to\n\t" \
15386 "movq %%rax,%%rdi\n\t" \
15387 "jc ret_from_fork\n\t" \
15389 + ".globl __switch_to_end\n\t" \
15390 + "__switch_to_end:\n\t" \
15392 : [next] "S" (next), [prev] "D" (prev), \
15393 [threadrsp] "i" (offsetof(struct task_struct, thread.rsp)), \
15394 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/include/linux/dwarf2-lang.h linux-2.6.18-53.1.14.kgdb/include/linux/dwarf2-lang.h
15395 --- linux-2.6.18-53.1.14/include/linux/dwarf2-lang.h 1970-01-01 03:00:00.000000000 +0300
15396 +++ linux-2.6.18-53.1.14.kgdb/include/linux/dwarf2-lang.h 2008-06-10 15:39:01.000000000 +0400
15398 +#ifndef DWARF2_LANG
15399 +#define DWARF2_LANG
15402 + * This is free software; you can redistribute it and/or modify it under
15403 + * the terms of the GNU General Public License as published by the Free
15404 + * Software Foundation; either version 2, or (at your option) any later
15408 + * This file defines macros that allow generation of DWARF debug records
15409 + * for asm files. This file is platform independent. Register numbers
15410 + * (which are about the only thing that is platform dependent) are to be
15411 + * supplied by a platform defined file.
15414 + * We need this to work for both asm and C. In asm we are using the
15415 + * old comment trick to concatenate while C uses the new ANSI thing.
15416 + * Here we have concat macro... The multi level thing is to allow and
15417 + * macros used in the names to be resolved prior to the cat (at which
15418 + * time they are no longer the same string).
15420 +#define CAT3(a,b,c) _CAT3(a,b,c)
15421 +#define _CAT3(a,b,c) __CAT3(a,b,c)
15423 +#define __CAT3(a,b,c) a/**/b/**/c
15425 +#define __CAT3(a,b,c) a##b##c
15427 +#ifdef __ASSEMBLY__
15429 +#define IFN_C(a) a
15431 +#define QUOTE_THIS(a) a
15432 +#define DWARF_preamble .section .debug_frame,"",%progbits;
15437 +#define QUOTE_THIS(a) _QUOTE_THIS(a)
15438 +#define _QUOTE_THIS(a) #a
15439 +/* Don't let CPP see the " and , \042=" \054=, */
15440 +#define DWARF_preamble .section .debug_frame \054\042\042\054%progbits
15443 +#ifdef CONFIG_64BIT
15444 +#define DATA_ALIGN_FACTOR 8
15445 +#define ADDR_LOC .quad
15447 +#define DATA_ALIGN_FACTOR 4
15448 +#define ADDR_LOC .long
15451 +#include <linux/dwarf2-defs.h>
15453 + * This macro starts a debug frame section. The debug_frame describes
15454 + * where to find the registers that the enclosing function saved on
15457 + * ORD is use by the label generator and should be the same as what is
15458 + * passed to CFI_postamble.
15460 + * pc, pc register gdb ordinal.
15462 + * code_align this is the factor used to define locations or regions
15463 + * where the given definitions apply. If you use labels to define these
15464 + * this should be 1.
15466 + * data_align this is the factor used to define register offsets. If
15467 + * you use struct offset, this should be the size of the register in
15468 + * bytes or the negative of that. This is how it is used: you will
15469 + * define a register as the reference register, say the stack pointer,
15470 + * then you will say where a register is located relative to this
15471 + * reference registers value, say 40 for register 3 (the gdb register
15472 + * number). The <40> will be multiplied by <data_align> to define the
15473 + * byte offset of the given register (3, in this example). So if your
15474 + * <40> is the byte offset and the reference register points at the
15475 + * begining, you would want 1 for the data_offset. If <40> was the 40th
15476 + * 4-byte element in that structure you would want 4. And if your
15477 + * reference register points at the end of the structure you would want
15478 + * a negative data_align value(and you would have to do other math as
15482 +#define CFI_preamble(ORD, pc, code_align, data_align) \
15483 + DWARF_preamble NL \
15484 + .align DATA_ALIGN_FACTOR NL \
15485 + .globl CAT3(frame,_,ORD) NL \
15486 +CAT3(frame,_,ORD): NL \
15489 + .long DW_CIE_ID NL \
15490 + .byte DW_CIE_VERSION NL \
15492 + .uleb128 code_align NL \
15493 + .sleb128 data_align NL \
15497 + * After the above macro and prior to the CFI_postamble, you need to
15498 + * define the initial state. This starts with defining the reference
15499 + * register and, usually the pc. Here are some helper macros:
15502 +#define CFA_define_reference(reg, offset) \
15503 + .byte DW_CFA_def_cfa NL \
15504 + .uleb128 reg NL \
15505 + .uleb128 (offset) NL
15507 +#define CFA_define_offset(reg, offset) \
15508 + .byte (DW_CFA_offset + reg) NL \
15509 + .uleb128 (offset) NL
15511 +#define CFA_restore(reg) \
15512 + .byte (DW_CFA_restore + reg) NL
15514 +#define CFI_postamble() \
15515 + .align DATA_ALIGN_FACTOR NL \
15520 + * So now your code pushs stuff on the stack, you need a new location
15521 + * and the rules for what to do. This starts a running description of
15522 + * the call frame. You need to describe what changes with respect to
15523 + * the call registers as the location of the pc moves through the code.
15524 + * The following builds an FDE (fram descriptor entry?). Like the
15525 + * above, it has a preamble and a postamble. It also is tied to the CFI
15527 + * The preamble macro is tied to the CFI thru the first parameter. The
15528 + * second is the code start address and then the code end address+1.
15530 +#define FDE_preamble(ORD, initial_address, end_address) \
15531 + DWARF_preamble NL \
15532 + .align DATA_ALIGN_FACTOR NL \
15535 + .long CAT3(frame,_,ORD) NL \
15536 + ADDR_LOC initial_address NL \
15537 + ADDR_LOC (end_address - initial_address) NL
15539 +#define FDE_postamble() \
15540 + .align DATA_ALIGN_FACTOR NL \
15545 + * That done, you can now add registers, subtract registers, move the
15546 + * reference and even change the reference. You can also define a new
15547 + * area of code the info applies to. For discontinuous bits you should
15548 + * start a new FDE. You may have as many as you like.
15552 + * To advance the stack address by <bytes> (0x3f max)
15555 +#define CFA_advance_loc(bytes) \
15556 + .byte DW_CFA_advance_loc+bytes NL
15559 + * This one is good for 0xff or 255
15561 +#define CFA_advance_loc1(bytes) \
15562 + .byte DW_CFA_advance_loc1 NL \
15565 +#define CFA_undefine_reg(reg) \
15566 + .byte DW_CFA_undefined NL \
15569 + * With the above you can define all the register locations. But
15570 + * suppose the reference register moves... Takes the new offset NOT an
15571 + * increment. This is how esp is tracked if it is not saved.
15574 +#define CFA_define_cfa_offset(offset) \
15575 + .byte DW_CFA_def_cfa_offset NL \
15576 + .uleb128 (offset) NL
15578 + * Or suppose you want to use a different reference register...
15580 +#define CFA_define_cfa_register(reg) \
15581 + .byte DW_CFA_def_cfa_register NL \
15585 + * If you want to mess with the stack pointer, here is the expression.
15586 + * The stack starts empty.
15588 +#define CFA_def_cfa_expression \
15589 + .byte DW_CFA_def_cfa_expression NL \
15590 + .uleb128 20f-10f NL \
15593 + * This expression is to be used for other regs. The stack starts with the
15597 +#define CFA_expression(reg) \
15598 + .byte DW_CFA_expression NL \
15599 + .uleb128 reg NL \
15600 + .uleb128 20f-10f NL \
15603 + * Here we do the expression stuff. You should code the above followed
15604 + * by expression OPs followed by CFA_expression_end.
15608 +#define CFA_expression_end \
15611 +#define CFA_exp_OP_const4s(a) \
15612 + .byte DW_OP_const4s NL \
15615 +#define CFA_exp_OP_swap .byte DW_OP_swap NL
15616 +#define CFA_exp_OP_dup .byte DW_OP_dup NL
15617 +#define CFA_exp_OP_drop .byte DW_OP_drop NL
15619 + * All these work on the top two elements on the stack, replacing them
15620 + * with the result. Top comes first where it matters. True is 1, false 0.
15622 +#define CFA_exp_OP_deref .byte DW_OP_deref NL
15623 +#define CFA_exp_OP_and .byte DW_OP_and NL
15624 +#define CFA_exp_OP_div .byte DW_OP_div NL
15625 +#define CFA_exp_OP_minus .byte DW_OP_minus NL
15626 +#define CFA_exp_OP_mod .byte DW_OP_mod NL
15627 +#define CFA_exp_OP_neg .byte DW_OP_neg NL
15628 +#define CFA_exp_OP_plus .byte DW_OP_plus NL
15629 +#define CFA_exp_OP_not .byte DW_OP_not NL
15630 +#define CFA_exp_OP_or .byte DW_OP_or NL
15631 +#define CFA_exp_OP_xor .byte DW_OP_xor NL
15632 +#define CFA_exp_OP_le .byte DW_OP_le NL
15633 +#define CFA_exp_OP_ge .byte DW_OP_ge NL
15634 +#define CFA_exp_OP_eq .byte DW_OP_eq NL
15635 +#define CFA_exp_OP_lt .byte DW_OP_lt NL
15636 +#define CFA_exp_OP_gt .byte DW_OP_gt NL
15637 +#define CFA_exp_OP_ne .byte DW_OP_ne NL
15639 + * These take a parameter as noted
15642 + * Unconditional skip to loc. loc is a label (loc:)
15644 +#define CFA_exp_OP_skip(loc) \
15645 + .byte DW_OP_skip NL \
15646 + .hword loc-.-2 NL
15648 + * Conditional skip to loc (TOS != 0, TOS--) (loc is a label)
15650 +#define CFA_exp_OP_bra(loc) \
15651 + .byte DW_OP_bra NL \
15652 + .hword loc-.-2 NL
15655 + * TOS += no (an unsigned number)
15657 +#define CFA_exp_OP_plus_uconst(no) \
15658 + .byte DW_OP_plus_uconst NL \
15662 + * ++TOS = no (a unsigned number)
15664 +#define CFA_exp_OP_constu(no) \
15665 + .byte DW_OP_constu NL \
15668 + * ++TOS = no (a signed number)
15670 +#define CFA_exp_OP_consts(no) \
15671 + .byte DW_OP_consts NL \
15674 + * ++TOS = no (an unsigned byte)
15676 +#define CFA_exp_OP_const1u(no) \
15677 + .byte DW_OP_const1u NL \
15682 + * ++TOS = no (a address)
15684 +#define CFA_exp_OP_addr(no) \
15685 + .byte DW_OP_addr NL \
15689 + * Push current frames value for "reg" + offset
15690 + * We take advantage of the opcode assignments to make this a litteral reg
15691 + * rather than use the DW_OP_bregx opcode.
15694 +#define CFA_exp_OP_breg(reg,offset) \
15695 + .byte DW_OP_breg0+reg NL \
15696 + .sleb128 offset NL
15698 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/include/linux/dwarf2.h linux-2.6.18-53.1.14.kgdb/include/linux/dwarf2.h
15699 --- linux-2.6.18-53.1.14/include/linux/dwarf2.h 1970-01-01 03:00:00.000000000 +0300
15700 +++ linux-2.6.18-53.1.14.kgdb/include/linux/dwarf2.h 2008-06-10 15:39:01.000000000 +0400
15702 +/* Declarations and definitions of codes relating to the DWARF2 symbolic
15703 + debugging information format.
15704 + Copyright (C) 1992, 1993, 1995, 1996, 1997, 1999, 2000, 2001, 2002,
15705 + 2003 Free Software Foundation, Inc.
15707 + Written by Gary Funck (gary@intrepid.com) The Ada Joint Program
15708 + Office (AJPO), Florida State Unviversity and Silicon Graphics Inc.
15709 + provided support for this effort -- June 21, 1995.
15711 + Derived from the DWARF 1 implementation written by Ron Guilmette
15712 + (rfg@netcom.com), November 1990.
15714 + This file is part of GCC.
15716 + GCC is free software; you can redistribute it and/or modify it under
15717 + the terms of the GNU General Public License as published by the Free
15718 + Software Foundation; either version 2, or (at your option) any later
15721 + GCC is distributed in the hope that it will be useful, but WITHOUT
15722 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15723 + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15724 + License for more details.
15726 + You should have received a copy of the GNU General Public License
15727 + along with GCC; see the file COPYING. If not, write to the Free
15728 + Software Foundation, 59 Temple Place - Suite 330, Boston, MA
15729 + 02111-1307, USA. */
15731 +/* This file is derived from the DWARF specification (a public document)
15732 + Revision 2.0.0 (July 27, 1993) developed by the UNIX International
15733 + Programming Languages Special Interest Group (UI/PLSIG) and distributed
15734 + by UNIX International. Copies of this specification are available from
15735 + UNIX International, 20 Waterview Boulevard, Parsippany, NJ, 07054.
15737 + This file also now contains definitions from the DWARF 3 specification. */
15739 +/* This file is shared between GCC and GDB, and should not contain
15742 +#ifndef _ELF_DWARF2_H
15743 +#define _ELF_DWARF2_H
15745 +/* Structure found in the .debug_line section. */
15748 + unsigned char li_length [4];
15749 + unsigned char li_version [2];
15750 + unsigned char li_prologue_length [4];
15751 + unsigned char li_min_insn_length [1];
15752 + unsigned char li_default_is_stmt [1];
15753 + unsigned char li_line_base [1];
15754 + unsigned char li_line_range [1];
15755 + unsigned char li_opcode_base [1];
15757 +DWARF2_External_LineInfo;
15761 + unsigned long li_length;
15762 + unsigned short li_version;
15763 + unsigned int li_prologue_length;
15764 + unsigned char li_min_insn_length;
15765 + unsigned char li_default_is_stmt;
15766 + int li_line_base;
15767 + unsigned char li_line_range;
15768 + unsigned char li_opcode_base;
15770 +DWARF2_Internal_LineInfo;
15772 +/* Structure found in .debug_pubnames section. */
15775 + unsigned char pn_length [4];
15776 + unsigned char pn_version [2];
15777 + unsigned char pn_offset [4];
15778 + unsigned char pn_size [4];
15780 +DWARF2_External_PubNames;
15784 + unsigned long pn_length;
15785 + unsigned short pn_version;
15786 + unsigned long pn_offset;
15787 + unsigned long pn_size;
15789 +DWARF2_Internal_PubNames;
15791 +/* Structure found in .debug_info section. */
15794 + unsigned char cu_length [4];
15795 + unsigned char cu_version [2];
15796 + unsigned char cu_abbrev_offset [4];
15797 + unsigned char cu_pointer_size [1];
15799 +DWARF2_External_CompUnit;
15803 + unsigned long cu_length;
15804 + unsigned short cu_version;
15805 + unsigned long cu_abbrev_offset;
15806 + unsigned char cu_pointer_size;
15808 +DWARF2_Internal_CompUnit;
15812 + unsigned char ar_length [4];
15813 + unsigned char ar_version [2];
15814 + unsigned char ar_info_offset [4];
15815 + unsigned char ar_pointer_size [1];
15816 + unsigned char ar_segment_size [1];
15818 +DWARF2_External_ARange;
15822 + unsigned long ar_length;
15823 + unsigned short ar_version;
15824 + unsigned long ar_info_offset;
15825 + unsigned char ar_pointer_size;
15826 + unsigned char ar_segment_size;
15828 +DWARF2_Internal_ARange;
15831 +/* Tag names and codes. */
15834 + DW_TAG_padding = 0x00,
15835 + DW_TAG_array_type = 0x01,
15836 + DW_TAG_class_type = 0x02,
15837 + DW_TAG_entry_point = 0x03,
15838 + DW_TAG_enumeration_type = 0x04,
15839 + DW_TAG_formal_parameter = 0x05,
15840 + DW_TAG_imported_declaration = 0x08,
15841 + DW_TAG_label = 0x0a,
15842 + DW_TAG_lexical_block = 0x0b,
15843 + DW_TAG_member = 0x0d,
15844 + DW_TAG_pointer_type = 0x0f,
15845 + DW_TAG_reference_type = 0x10,
15846 + DW_TAG_compile_unit = 0x11,
15847 + DW_TAG_string_type = 0x12,
15848 + DW_TAG_structure_type = 0x13,
15849 + DW_TAG_subroutine_type = 0x15,
15850 + DW_TAG_typedef = 0x16,
15851 + DW_TAG_union_type = 0x17,
15852 + DW_TAG_unspecified_parameters = 0x18,
15853 + DW_TAG_variant = 0x19,
15854 + DW_TAG_common_block = 0x1a,
15855 + DW_TAG_common_inclusion = 0x1b,
15856 + DW_TAG_inheritance = 0x1c,
15857 + DW_TAG_inlined_subroutine = 0x1d,
15858 + DW_TAG_module = 0x1e,
15859 + DW_TAG_ptr_to_member_type = 0x1f,
15860 + DW_TAG_set_type = 0x20,
15861 + DW_TAG_subrange_type = 0x21,
15862 + DW_TAG_with_stmt = 0x22,
15863 + DW_TAG_access_declaration = 0x23,
15864 + DW_TAG_base_type = 0x24,
15865 + DW_TAG_catch_block = 0x25,
15866 + DW_TAG_const_type = 0x26,
15867 + DW_TAG_constant = 0x27,
15868 + DW_TAG_enumerator = 0x28,
15869 + DW_TAG_file_type = 0x29,
15870 + DW_TAG_friend = 0x2a,
15871 + DW_TAG_namelist = 0x2b,
15872 + DW_TAG_namelist_item = 0x2c,
15873 + DW_TAG_packed_type = 0x2d,
15874 + DW_TAG_subprogram = 0x2e,
15875 + DW_TAG_template_type_param = 0x2f,
15876 + DW_TAG_template_value_param = 0x30,
15877 + DW_TAG_thrown_type = 0x31,
15878 + DW_TAG_try_block = 0x32,
15879 + DW_TAG_variant_part = 0x33,
15880 + DW_TAG_variable = 0x34,
15881 + DW_TAG_volatile_type = 0x35,
15883 + DW_TAG_dwarf_procedure = 0x36,
15884 + DW_TAG_restrict_type = 0x37,
15885 + DW_TAG_interface_type = 0x38,
15886 + DW_TAG_namespace = 0x39,
15887 + DW_TAG_imported_module = 0x3a,
15888 + DW_TAG_unspecified_type = 0x3b,
15889 + DW_TAG_partial_unit = 0x3c,
15890 + DW_TAG_imported_unit = 0x3d,
15891 + /* SGI/MIPS Extensions. */
15892 + DW_TAG_MIPS_loop = 0x4081,
15893 + /* HP extensions. See: ftp://ftp.hp.com/pub/lang/tools/WDB/wdb-4.0.tar.gz . */
15894 + DW_TAG_HP_array_descriptor = 0x4090,
15895 + /* GNU extensions. */
15896 + DW_TAG_format_label = 0x4101, /* For FORTRAN 77 and Fortran 90. */
15897 + DW_TAG_function_template = 0x4102, /* For C++. */
15898 + DW_TAG_class_template = 0x4103, /* For C++. */
15899 + DW_TAG_GNU_BINCL = 0x4104,
15900 + DW_TAG_GNU_EINCL = 0x4105,
15901 + /* Extensions for UPC. See: http://upc.gwu.edu/~upc. */
15902 + DW_TAG_upc_shared_type = 0x8765,
15903 + DW_TAG_upc_strict_type = 0x8766,
15904 + DW_TAG_upc_relaxed_type = 0x8767,
15905 + /* PGI (STMicroelectronics) extensions. No documentation available. */
15906 + DW_TAG_PGI_kanji_type = 0xA000,
15907 + DW_TAG_PGI_interface_block = 0xA020
15910 +#define DW_TAG_lo_user 0x4080
15911 +#define DW_TAG_hi_user 0xffff
15913 +/* Flag that tells whether entry has a child or not. */
15914 +#define DW_children_no 0
15915 +#define DW_children_yes 1
15917 +/* Form names and codes. */
15920 + DW_FORM_addr = 0x01,
15921 + DW_FORM_block2 = 0x03,
15922 + DW_FORM_block4 = 0x04,
15923 + DW_FORM_data2 = 0x05,
15924 + DW_FORM_data4 = 0x06,
15925 + DW_FORM_data8 = 0x07,
15926 + DW_FORM_string = 0x08,
15927 + DW_FORM_block = 0x09,
15928 + DW_FORM_block1 = 0x0a,
15929 + DW_FORM_data1 = 0x0b,
15930 + DW_FORM_flag = 0x0c,
15931 + DW_FORM_sdata = 0x0d,
15932 + DW_FORM_strp = 0x0e,
15933 + DW_FORM_udata = 0x0f,
15934 + DW_FORM_ref_addr = 0x10,
15935 + DW_FORM_ref1 = 0x11,
15936 + DW_FORM_ref2 = 0x12,
15937 + DW_FORM_ref4 = 0x13,
15938 + DW_FORM_ref8 = 0x14,
15939 + DW_FORM_ref_udata = 0x15,
15940 + DW_FORM_indirect = 0x16
15943 +/* Attribute names and codes. */
15944 +enum dwarf_attribute
15946 + DW_AT_sibling = 0x01,
15947 + DW_AT_location = 0x02,
15948 + DW_AT_name = 0x03,
15949 + DW_AT_ordering = 0x09,
15950 + DW_AT_subscr_data = 0x0a,
15951 + DW_AT_byte_size = 0x0b,
15952 + DW_AT_bit_offset = 0x0c,
15953 + DW_AT_bit_size = 0x0d,
15954 + DW_AT_element_list = 0x0f,
15955 + DW_AT_stmt_list = 0x10,
15956 + DW_AT_low_pc = 0x11,
15957 + DW_AT_high_pc = 0x12,
15958 + DW_AT_language = 0x13,
15959 + DW_AT_member = 0x14,
15960 + DW_AT_discr = 0x15,
15961 + DW_AT_discr_value = 0x16,
15962 + DW_AT_visibility = 0x17,
15963 + DW_AT_import = 0x18,
15964 + DW_AT_string_length = 0x19,
15965 + DW_AT_common_reference = 0x1a,
15966 + DW_AT_comp_dir = 0x1b,
15967 + DW_AT_const_value = 0x1c,
15968 + DW_AT_containing_type = 0x1d,
15969 + DW_AT_default_value = 0x1e,
15970 + DW_AT_inline = 0x20,
15971 + DW_AT_is_optional = 0x21,
15972 + DW_AT_lower_bound = 0x22,
15973 + DW_AT_producer = 0x25,
15974 + DW_AT_prototyped = 0x27,
15975 + DW_AT_return_addr = 0x2a,
15976 + DW_AT_start_scope = 0x2c,
15977 + DW_AT_stride_size = 0x2e,
15978 + DW_AT_upper_bound = 0x2f,
15979 + DW_AT_abstract_origin = 0x31,
15980 + DW_AT_accessibility = 0x32,
15981 + DW_AT_address_class = 0x33,
15982 + DW_AT_artificial = 0x34,
15983 + DW_AT_base_types = 0x35,
15984 + DW_AT_calling_convention = 0x36,
15985 + DW_AT_count = 0x37,
15986 + DW_AT_data_member_location = 0x38,
15987 + DW_AT_decl_column = 0x39,
15988 + DW_AT_decl_file = 0x3a,
15989 + DW_AT_decl_line = 0x3b,
15990 + DW_AT_declaration = 0x3c,
15991 + DW_AT_discr_list = 0x3d,
15992 + DW_AT_encoding = 0x3e,
15993 + DW_AT_external = 0x3f,
15994 + DW_AT_frame_base = 0x40,
15995 + DW_AT_friend = 0x41,
15996 + DW_AT_identifier_case = 0x42,
15997 + DW_AT_macro_info = 0x43,
15998 + DW_AT_namelist_items = 0x44,
15999 + DW_AT_priority = 0x45,
16000 + DW_AT_segment = 0x46,
16001 + DW_AT_specification = 0x47,
16002 + DW_AT_static_link = 0x48,
16003 + DW_AT_type = 0x49,
16004 + DW_AT_use_location = 0x4a,
16005 + DW_AT_variable_parameter = 0x4b,
16006 + DW_AT_virtuality = 0x4c,
16007 + DW_AT_vtable_elem_location = 0x4d,
16008 + /* DWARF 3 values. */
16009 + DW_AT_allocated = 0x4e,
16010 + DW_AT_associated = 0x4f,
16011 + DW_AT_data_location = 0x50,
16012 + DW_AT_stride = 0x51,
16013 + DW_AT_entry_pc = 0x52,
16014 + DW_AT_use_UTF8 = 0x53,
16015 + DW_AT_extension = 0x54,
16016 + DW_AT_ranges = 0x55,
16017 + DW_AT_trampoline = 0x56,
16018 + DW_AT_call_column = 0x57,
16019 + DW_AT_call_file = 0x58,
16020 + DW_AT_call_line = 0x59,
16021 + /* SGI/MIPS extensions. */
16022 + DW_AT_MIPS_fde = 0x2001,
16023 + DW_AT_MIPS_loop_begin = 0x2002,
16024 + DW_AT_MIPS_tail_loop_begin = 0x2003,
16025 + DW_AT_MIPS_epilog_begin = 0x2004,
16026 + DW_AT_MIPS_loop_unroll_factor = 0x2005,
16027 + DW_AT_MIPS_software_pipeline_depth = 0x2006,
16028 + DW_AT_MIPS_linkage_name = 0x2007,
16029 + DW_AT_MIPS_stride = 0x2008,
16030 + DW_AT_MIPS_abstract_name = 0x2009,
16031 + DW_AT_MIPS_clone_origin = 0x200a,
16032 + DW_AT_MIPS_has_inlines = 0x200b,
16033 + /* HP extensions. */
16034 + DW_AT_HP_block_index = 0x2000,
16035 + DW_AT_HP_unmodifiable = 0x2001, /* Same as DW_AT_MIPS_fde. */
16036 + DW_AT_HP_actuals_stmt_list = 0x2010,
16037 + DW_AT_HP_proc_per_section = 0x2011,
16038 + DW_AT_HP_raw_data_ptr = 0x2012,
16039 + DW_AT_HP_pass_by_reference = 0x2013,
16040 + DW_AT_HP_opt_level = 0x2014,
16041 + DW_AT_HP_prof_version_id = 0x2015,
16042 + DW_AT_HP_opt_flags = 0x2016,
16043 + DW_AT_HP_cold_region_low_pc = 0x2017,
16044 + DW_AT_HP_cold_region_high_pc = 0x2018,
16045 + DW_AT_HP_all_variables_modifiable = 0x2019,
16046 + DW_AT_HP_linkage_name = 0x201a,
16047 + DW_AT_HP_prof_flags = 0x201b, /* In comp unit of procs_info for -g. */
16048 + /* GNU extensions. */
16049 + DW_AT_sf_names = 0x2101,
16050 + DW_AT_src_info = 0x2102,
16051 + DW_AT_mac_info = 0x2103,
16052 + DW_AT_src_coords = 0x2104,
16053 + DW_AT_body_begin = 0x2105,
16054 + DW_AT_body_end = 0x2106,
16055 + DW_AT_GNU_vector = 0x2107,
16056 + /* VMS extensions. */
16057 + DW_AT_VMS_rtnbeg_pd_address = 0x2201,
16058 + /* UPC extension. */
16059 + DW_AT_upc_threads_scaled = 0x3210,
16060 + /* PGI (STMicroelectronics) extensions. */
16061 + DW_AT_PGI_lbase = 0x3a00,
16062 + DW_AT_PGI_soffset = 0x3a01,
16063 + DW_AT_PGI_lstride = 0x3a02
16066 +#define DW_AT_lo_user 0x2000 /* Implementation-defined range start. */
16067 +#define DW_AT_hi_user 0x3ff0 /* Implementation-defined range end. */
16069 +/* Location atom names and codes. */
16070 +enum dwarf_location_atom
16072 + DW_OP_addr = 0x03,
16073 + DW_OP_deref = 0x06,
16074 + DW_OP_const1u = 0x08,
16075 + DW_OP_const1s = 0x09,
16076 + DW_OP_const2u = 0x0a,
16077 + DW_OP_const2s = 0x0b,
16078 + DW_OP_const4u = 0x0c,
16079 + DW_OP_const4s = 0x0d,
16080 + DW_OP_const8u = 0x0e,
16081 + DW_OP_const8s = 0x0f,
16082 + DW_OP_constu = 0x10,
16083 + DW_OP_consts = 0x11,
16084 + DW_OP_dup = 0x12,
16085 + DW_OP_drop = 0x13,
16086 + DW_OP_over = 0x14,
16087 + DW_OP_pick = 0x15,
16088 + DW_OP_swap = 0x16,
16089 + DW_OP_rot = 0x17,
16090 + DW_OP_xderef = 0x18,
16091 + DW_OP_abs = 0x19,
16092 + DW_OP_and = 0x1a,
16093 + DW_OP_div = 0x1b,
16094 + DW_OP_minus = 0x1c,
16095 + DW_OP_mod = 0x1d,
16096 + DW_OP_mul = 0x1e,
16097 + DW_OP_neg = 0x1f,
16098 + DW_OP_not = 0x20,
16100 + DW_OP_plus = 0x22,
16101 + DW_OP_plus_uconst = 0x23,
16102 + DW_OP_shl = 0x24,
16103 + DW_OP_shr = 0x25,
16104 + DW_OP_shra = 0x26,
16105 + DW_OP_xor = 0x27,
16106 + DW_OP_bra = 0x28,
16113 + DW_OP_skip = 0x2f,
16114 + DW_OP_lit0 = 0x30,
16115 + DW_OP_lit1 = 0x31,
16116 + DW_OP_lit2 = 0x32,
16117 + DW_OP_lit3 = 0x33,
16118 + DW_OP_lit4 = 0x34,
16119 + DW_OP_lit5 = 0x35,
16120 + DW_OP_lit6 = 0x36,
16121 + DW_OP_lit7 = 0x37,
16122 + DW_OP_lit8 = 0x38,
16123 + DW_OP_lit9 = 0x39,
16124 + DW_OP_lit10 = 0x3a,
16125 + DW_OP_lit11 = 0x3b,
16126 + DW_OP_lit12 = 0x3c,
16127 + DW_OP_lit13 = 0x3d,
16128 + DW_OP_lit14 = 0x3e,
16129 + DW_OP_lit15 = 0x3f,
16130 + DW_OP_lit16 = 0x40,
16131 + DW_OP_lit17 = 0x41,
16132 + DW_OP_lit18 = 0x42,
16133 + DW_OP_lit19 = 0x43,
16134 + DW_OP_lit20 = 0x44,
16135 + DW_OP_lit21 = 0x45,
16136 + DW_OP_lit22 = 0x46,
16137 + DW_OP_lit23 = 0x47,
16138 + DW_OP_lit24 = 0x48,
16139 + DW_OP_lit25 = 0x49,
16140 + DW_OP_lit26 = 0x4a,
16141 + DW_OP_lit27 = 0x4b,
16142 + DW_OP_lit28 = 0x4c,
16143 + DW_OP_lit29 = 0x4d,
16144 + DW_OP_lit30 = 0x4e,
16145 + DW_OP_lit31 = 0x4f,
16146 + DW_OP_reg0 = 0x50,
16147 + DW_OP_reg1 = 0x51,
16148 + DW_OP_reg2 = 0x52,
16149 + DW_OP_reg3 = 0x53,
16150 + DW_OP_reg4 = 0x54,
16151 + DW_OP_reg5 = 0x55,
16152 + DW_OP_reg6 = 0x56,
16153 + DW_OP_reg7 = 0x57,
16154 + DW_OP_reg8 = 0x58,
16155 + DW_OP_reg9 = 0x59,
16156 + DW_OP_reg10 = 0x5a,
16157 + DW_OP_reg11 = 0x5b,
16158 + DW_OP_reg12 = 0x5c,
16159 + DW_OP_reg13 = 0x5d,
16160 + DW_OP_reg14 = 0x5e,
16161 + DW_OP_reg15 = 0x5f,
16162 + DW_OP_reg16 = 0x60,
16163 + DW_OP_reg17 = 0x61,
16164 + DW_OP_reg18 = 0x62,
16165 + DW_OP_reg19 = 0x63,
16166 + DW_OP_reg20 = 0x64,
16167 + DW_OP_reg21 = 0x65,
16168 + DW_OP_reg22 = 0x66,
16169 + DW_OP_reg23 = 0x67,
16170 + DW_OP_reg24 = 0x68,
16171 + DW_OP_reg25 = 0x69,
16172 + DW_OP_reg26 = 0x6a,
16173 + DW_OP_reg27 = 0x6b,
16174 + DW_OP_reg28 = 0x6c,
16175 + DW_OP_reg29 = 0x6d,
16176 + DW_OP_reg30 = 0x6e,
16177 + DW_OP_reg31 = 0x6f,
16178 + DW_OP_breg0 = 0x70,
16179 + DW_OP_breg1 = 0x71,
16180 + DW_OP_breg2 = 0x72,
16181 + DW_OP_breg3 = 0x73,
16182 + DW_OP_breg4 = 0x74,
16183 + DW_OP_breg5 = 0x75,
16184 + DW_OP_breg6 = 0x76,
16185 + DW_OP_breg7 = 0x77,
16186 + DW_OP_breg8 = 0x78,
16187 + DW_OP_breg9 = 0x79,
16188 + DW_OP_breg10 = 0x7a,
16189 + DW_OP_breg11 = 0x7b,
16190 + DW_OP_breg12 = 0x7c,
16191 + DW_OP_breg13 = 0x7d,
16192 + DW_OP_breg14 = 0x7e,
16193 + DW_OP_breg15 = 0x7f,
16194 + DW_OP_breg16 = 0x80,
16195 + DW_OP_breg17 = 0x81,
16196 + DW_OP_breg18 = 0x82,
16197 + DW_OP_breg19 = 0x83,
16198 + DW_OP_breg20 = 0x84,
16199 + DW_OP_breg21 = 0x85,
16200 + DW_OP_breg22 = 0x86,
16201 + DW_OP_breg23 = 0x87,
16202 + DW_OP_breg24 = 0x88,
16203 + DW_OP_breg25 = 0x89,
16204 + DW_OP_breg26 = 0x8a,
16205 + DW_OP_breg27 = 0x8b,
16206 + DW_OP_breg28 = 0x8c,
16207 + DW_OP_breg29 = 0x8d,
16208 + DW_OP_breg30 = 0x8e,
16209 + DW_OP_breg31 = 0x8f,
16210 + DW_OP_regx = 0x90,
16211 + DW_OP_fbreg = 0x91,
16212 + DW_OP_bregx = 0x92,
16213 + DW_OP_piece = 0x93,
16214 + DW_OP_deref_size = 0x94,
16215 + DW_OP_xderef_size = 0x95,
16216 + DW_OP_nop = 0x96,
16217 + /* DWARF 3 extensions. */
16218 + DW_OP_push_object_address = 0x97,
16219 + DW_OP_call2 = 0x98,
16220 + DW_OP_call4 = 0x99,
16221 + DW_OP_call_ref = 0x9a,
16222 + /* GNU extensions. */
16223 + DW_OP_GNU_push_tls_address = 0xe0,
16224 + /* HP extensions. */
16225 + DW_OP_HP_unknown = 0xe0, /* Ouch, the same as GNU_push_tls_address. */
16226 + DW_OP_HP_is_value = 0xe1,
16227 + DW_OP_HP_fltconst4 = 0xe2,
16228 + DW_OP_HP_fltconst8 = 0xe3,
16229 + DW_OP_HP_mod_range = 0xe4,
16230 + DW_OP_HP_unmod_range = 0xe5,
16231 + DW_OP_HP_tls = 0xe6
16234 +#define DW_OP_lo_user 0xe0 /* Implementation-defined range start. */
16235 +#define DW_OP_hi_user 0xff /* Implementation-defined range end. */
16237 +/* Type encodings. */
16240 + DW_ATE_void = 0x0,
16241 + DW_ATE_address = 0x1,
16242 + DW_ATE_boolean = 0x2,
16243 + DW_ATE_complex_float = 0x3,
16244 + DW_ATE_float = 0x4,
16245 + DW_ATE_signed = 0x5,
16246 + DW_ATE_signed_char = 0x6,
16247 + DW_ATE_unsigned = 0x7,
16248 + DW_ATE_unsigned_char = 0x8,
16250 + DW_ATE_imaginary_float = 0x9,
16251 + /* HP extensions. */
16252 + DW_ATE_HP_float80 = 0x80, /* Floating-point (80 bit). */
16253 + DW_ATE_HP_complex_float80 = 0x81, /* Complex floating-point (80 bit). */
16254 + DW_ATE_HP_float128 = 0x82, /* Floating-point (128 bit). */
16255 + DW_ATE_HP_complex_float128 = 0x83, /* Complex floating-point (128 bit). */
16256 + DW_ATE_HP_floathpintel = 0x84, /* Floating-point (82 bit IA64). */
16257 + DW_ATE_HP_imaginary_float80 = 0x85,
16258 + DW_ATE_HP_imaginary_float128 = 0x86
16261 +#define DW_ATE_lo_user 0x80
16262 +#define DW_ATE_hi_user 0xff
16264 +/* Array ordering names and codes. */
16265 +enum dwarf_array_dim_ordering
16267 + DW_ORD_row_major = 0,
16268 + DW_ORD_col_major = 1
16271 +/* Access attribute. */
16272 +enum dwarf_access_attribute
16274 + DW_ACCESS_public = 1,
16275 + DW_ACCESS_protected = 2,
16276 + DW_ACCESS_private = 3
16280 +enum dwarf_visibility_attribute
16282 + DW_VIS_local = 1,
16283 + DW_VIS_exported = 2,
16284 + DW_VIS_qualified = 3
16288 +enum dwarf_virtuality_attribute
16290 + DW_VIRTUALITY_none = 0,
16291 + DW_VIRTUALITY_virtual = 1,
16292 + DW_VIRTUALITY_pure_virtual = 2
16295 +/* Case sensitivity. */
16296 +enum dwarf_id_case
16298 + DW_ID_case_sensitive = 0,
16299 + DW_ID_up_case = 1,
16300 + DW_ID_down_case = 2,
16301 + DW_ID_case_insensitive = 3
16304 +/* Calling convention. */
16305 +enum dwarf_calling_convention
16307 + DW_CC_normal = 0x1,
16308 + DW_CC_program = 0x2,
16309 + DW_CC_nocall = 0x3
16312 +#define DW_CC_lo_user 0x40
16313 +#define DW_CC_hi_user 0xff
16315 +/* Inline attribute. */
16316 +enum dwarf_inline_attribute
16318 + DW_INL_not_inlined = 0,
16319 + DW_INL_inlined = 1,
16320 + DW_INL_declared_not_inlined = 2,
16321 + DW_INL_declared_inlined = 3
16324 +/* Discriminant lists. */
16325 +enum dwarf_discrim_list
16327 + DW_DSC_label = 0,
16331 +/* Line number opcodes. */
16332 +enum dwarf_line_number_ops
16334 + DW_LNS_extended_op = 0,
16336 + DW_LNS_advance_pc = 2,
16337 + DW_LNS_advance_line = 3,
16338 + DW_LNS_set_file = 4,
16339 + DW_LNS_set_column = 5,
16340 + DW_LNS_negate_stmt = 6,
16341 + DW_LNS_set_basic_block = 7,
16342 + DW_LNS_const_add_pc = 8,
16343 + DW_LNS_fixed_advance_pc = 9,
16345 + DW_LNS_set_prologue_end = 10,
16346 + DW_LNS_set_epilogue_begin = 11,
16347 + DW_LNS_set_isa = 12
16350 +/* Line number extended opcodes. */
16351 +enum dwarf_line_number_x_ops
16353 + DW_LNE_end_sequence = 1,
16354 + DW_LNE_set_address = 2,
16355 + DW_LNE_define_file = 3,
16356 + /* HP extensions. */
16357 + DW_LNE_HP_negate_is_UV_update = 0x11,
16358 + DW_LNE_HP_push_context = 0x12,
16359 + DW_LNE_HP_pop_context = 0x13,
16360 + DW_LNE_HP_set_file_line_column = 0x14,
16361 + DW_LNE_HP_set_routine_name = 0x15,
16362 + DW_LNE_HP_set_sequence = 0x16,
16363 + DW_LNE_HP_negate_post_semantics = 0x17,
16364 + DW_LNE_HP_negate_function_exit = 0x18,
16365 + DW_LNE_HP_negate_front_end_logical = 0x19,
16366 + DW_LNE_HP_define_proc = 0x20
16369 +/* Call frame information. */
16370 +enum dwarf_call_frame_info
16372 + DW_CFA_advance_loc = 0x40,
16373 + DW_CFA_offset = 0x80,
16374 + DW_CFA_restore = 0xc0,
16375 + DW_CFA_nop = 0x00,
16376 + DW_CFA_set_loc = 0x01,
16377 + DW_CFA_advance_loc1 = 0x02,
16378 + DW_CFA_advance_loc2 = 0x03,
16379 + DW_CFA_advance_loc4 = 0x04,
16380 + DW_CFA_offset_extended = 0x05,
16381 + DW_CFA_restore_extended = 0x06,
16382 + DW_CFA_undefined = 0x07,
16383 + DW_CFA_same_value = 0x08,
16384 + DW_CFA_register = 0x09,
16385 + DW_CFA_remember_state = 0x0a,
16386 + DW_CFA_restore_state = 0x0b,
16387 + DW_CFA_def_cfa = 0x0c,
16388 + DW_CFA_def_cfa_register = 0x0d,
16389 + DW_CFA_def_cfa_offset = 0x0e,
16391 + DW_CFA_def_cfa_expression = 0x0f,
16392 + DW_CFA_expression = 0x10,
16393 + DW_CFA_offset_extended_sf = 0x11,
16394 + DW_CFA_def_cfa_sf = 0x12,
16395 + DW_CFA_def_cfa_offset_sf = 0x13,
16396 + /* SGI/MIPS specific. */
16397 + DW_CFA_MIPS_advance_loc8 = 0x1d,
16398 + /* GNU extensions. */
16399 + DW_CFA_GNU_window_save = 0x2d,
16400 + DW_CFA_GNU_args_size = 0x2e,
16401 + DW_CFA_GNU_negative_offset_extended = 0x2f
16404 +#define DW_CIE_ID 0xffffffff
16405 +#define DW_CIE_VERSION 1
16407 +#define DW_CFA_extended 0
16408 +#define DW_CFA_lo_user 0x1c
16409 +#define DW_CFA_hi_user 0x3f
16411 +#define DW_CHILDREN_no 0x00
16412 +#define DW_CHILDREN_yes 0x01
16414 +#define DW_ADDR_none 0
16416 +/* Source language names and codes. */
16417 +enum dwarf_source_language
16419 + DW_LANG_C89 = 0x0001,
16420 + DW_LANG_C = 0x0002,
16421 + DW_LANG_Ada83 = 0x0003,
16422 + DW_LANG_C_plus_plus = 0x0004,
16423 + DW_LANG_Cobol74 = 0x0005,
16424 + DW_LANG_Cobol85 = 0x0006,
16425 + DW_LANG_Fortran77 = 0x0007,
16426 + DW_LANG_Fortran90 = 0x0008,
16427 + DW_LANG_Pascal83 = 0x0009,
16428 + DW_LANG_Modula2 = 0x000a,
16429 + DW_LANG_Java = 0x000b,
16431 + DW_LANG_C99 = 0x000c,
16432 + DW_LANG_Ada95 = 0x000d,
16433 + DW_LANG_Fortran95 = 0x000e,
16435 + DW_LANG_Mips_Assembler = 0x8001,
16437 + DW_LANG_Upc = 0x8765
16440 +#define DW_LANG_lo_user 0x8000 /* Implementation-defined range start. */
16441 +#define DW_LANG_hi_user 0xffff /* Implementation-defined range start. */
16443 +/* Names and codes for macro information. */
16444 +enum dwarf_macinfo_record_type
16446 + DW_MACINFO_define = 1,
16447 + DW_MACINFO_undef = 2,
16448 + DW_MACINFO_start_file = 3,
16449 + DW_MACINFO_end_file = 4,
16450 + DW_MACINFO_vendor_ext = 255
16453 +/* @@@ For use with GNU frame unwind information. */
16455 +#define DW_EH_PE_absptr 0x00
16456 +#define DW_EH_PE_omit 0xff
16458 +#define DW_EH_PE_uleb128 0x01
16459 +#define DW_EH_PE_udata2 0x02
16460 +#define DW_EH_PE_udata4 0x03
16461 +#define DW_EH_PE_udata8 0x04
16462 +#define DW_EH_PE_sleb128 0x09
16463 +#define DW_EH_PE_sdata2 0x0A
16464 +#define DW_EH_PE_sdata4 0x0B
16465 +#define DW_EH_PE_sdata8 0x0C
16466 +#define DW_EH_PE_signed 0x08
16468 +#define DW_EH_PE_pcrel 0x10
16469 +#define DW_EH_PE_textrel 0x20
16470 +#define DW_EH_PE_datarel 0x30
16471 +#define DW_EH_PE_funcrel 0x40
16472 +#define DW_EH_PE_aligned 0x50
16474 +#define DW_EH_PE_indirect 0x80
16476 +#endif /* _ELF_DWARF2_H */
16477 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/include/linux/kgdb.h linux-2.6.18-53.1.14.kgdb/include/linux/kgdb.h
16478 --- linux-2.6.18-53.1.14/include/linux/kgdb.h 1970-01-01 03:00:00.000000000 +0300
16479 +++ linux-2.6.18-53.1.14.kgdb/include/linux/kgdb.h 2008-06-10 15:39:21.000000000 +0400
16482 + * include/linux/kgdb.h
16484 + * This provides the hooks and functions that KGDB needs to share between
16485 + * the core, I/O and arch-specific portions.
16487 + * Author: Amit Kale <amitkale@linsyssoft.com> and
16488 + * Tom Rini <trini@kernel.crashing.org>
16490 + * 2001-2004 (c) Amit S. Kale and 2003-2005 (c) MontaVista Software, Inc.
16491 + * This file is licensed under the terms of the GNU General Public License
16492 + * version 2. This program is licensed "as is" without any warranty of any
16493 + * kind, whether express or implied.
16499 +#include <asm/atomic.h>
16501 +#ifdef CONFIG_KGDB
16502 +#include <asm/kgdb.h>
16503 +#include <linux/serial_8250.h>
16504 +#include <linux/linkage.h>
16505 +#include <linux/init.h>
16507 +#ifndef CHECK_EXCEPTION_STACK
16508 +#define CHECK_EXCEPTION_STACK() 1
16511 +struct tasklet_struct;
16513 +struct task_struct;
16516 +#ifdef CONFIG_KGDB_CONSOLE
16517 +extern struct console kgdbcons;
16520 +/* To enter the debugger explicitly. */
16521 +extern void breakpoint(void);
16522 +extern int kgdb_connected;
16523 +extern int kgdb_may_fault;
16524 +extern struct tasklet_struct kgdb_tasklet_breakpoint;
16526 +extern atomic_t kgdb_setting_breakpoint;
16527 +extern atomic_t cpu_doing_single_step;
16528 +extern atomic_t kgdb_sync_softlockup[NR_CPUS];
16530 +extern struct task_struct *kgdb_usethread, *kgdb_contthread;
16532 +enum kgdb_bptype {
16533 + bp_breakpoint = '0',
16534 + bp_hardware_breakpoint,
16535 + bp_write_watchpoint,
16536 + bp_read_watchpoint,
16537 + bp_access_watchpoint
16540 +enum kgdb_bpstate {
16547 +struct kgdb_bkpt {
16548 + unsigned long bpt_addr;
16549 + unsigned char saved_instr[BREAK_INSTR_SIZE];
16550 + enum kgdb_bptype type;
16551 + enum kgdb_bpstate state;
16554 +/* The maximum number of KGDB I/O modules that can be loaded */
16555 +#define MAX_KGDB_IO_HANDLERS 3
16557 +#ifndef MAX_BREAKPOINTS
16558 +#define MAX_BREAKPOINTS 1000
16561 +#define KGDB_HW_BREAKPOINT 1
16563 +/* Required functions. */
16565 + * regs_to_gdb_regs - Convert ptrace regs to GDB regs
16566 + * @gdb_regs: A pointer to hold the registers in the order GDB wants.
16567 + * @regs: The &struct pt_regs of the current process.
16569 + * Convert the pt_regs in @regs into the format for registers that
16570 + * GDB expects, stored in @gdb_regs.
16572 +extern void regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs);
16575 + * sleeping_regs_to_gdb_regs - Convert ptrace regs to GDB regs
16576 + * @gdb_regs: A pointer to hold the registers in the order GDB wants.
16577 + * @p: The &struct task_struct of the desired process.
16579 + * Convert the register values of the sleeping process in @p to
16580 + * the format that GDB expects.
16581 + * This function is called when kgdb does not have access to the
16582 + * &struct pt_regs and therefore it should fill the gdb registers
16583 + * @gdb_regs with what has been saved in &struct thread_struct
16584 + * thread field during switch_to.
16586 +extern void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs,
16587 + struct task_struct *p);
16590 + * gdb_regs_to_regs - Convert GDB regs to ptrace regs.
16591 + * @gdb_regs: A pointer to hold the registers we've recieved from GDB.
16592 + * @regs: A pointer to a &struct pt_regs to hold these values in.
16594 + * Convert the GDB regs in @gdb_regs into the pt_regs, and store them
16597 +extern void gdb_regs_to_regs(unsigned long *gdb_regs, struct pt_regs *regs);
16600 + * kgdb_arch_handle_exception - Handle architecture specific GDB packets.
16601 + * @vector: The error vector of the exception that happened.
16602 + * @signo: The signal number of the exception that happened.
16603 + * @err_code: The error code of the exception that happened.
16604 + * @remcom_in_buffer: The buffer of the packet we have read.
16605 + * @remcom_out_buffer: The buffer, of %BUFMAX to write a packet into.
16606 + * @regs: The &struct pt_regs of the current process.
16608 + * This function MUST handle the 'c' and 's' command packets,
16609 + * as well packets to set / remove a hardware breakpoint, if used.
16610 + * If there are additional packets which the hardware needs to handle,
16611 + * they are handled here. The code should return -1 if it wants to
16612 + * process more packets, and a %0 or %1 if it wants to exit from the
16615 +extern int kgdb_arch_handle_exception(int vector, int signo, int err_code,
16616 + char *remcom_in_buffer,
16617 + char *remcom_out_buffer,
16618 + struct pt_regs *regs);
16620 +#ifndef JMP_REGS_ALIGNMENT
16621 +#define JMP_REGS_ALIGNMENT
16624 +extern unsigned long kgdb_fault_jmp_regs[];
16627 + * kgdb_fault_setjmp - Store state in case we fault.
16628 + * @curr_context: An array to store state into.
16630 + * Certain functions may try and access memory, and in doing so may
16631 + * cause a fault. When this happens, we trap it, restore state to
16632 + * this call, and let ourself know that something bad has happened.
16634 +extern asmlinkage int kgdb_fault_setjmp(unsigned long *curr_context);
16637 + * kgdb_fault_longjmp - Restore state when we have faulted.
16638 + * @curr_context: The previously stored state.
16640 + * When something bad does happen, this function is called to
16641 + * restore the known good state, and set the return value to 1, so
16642 + * we know something bad happened.
16644 +extern asmlinkage void kgdb_fault_longjmp(unsigned long *curr_context);
16646 +/* Optional functions. */
16647 +extern int kgdb_arch_init(void);
16648 +extern void kgdb_disable_hw_debug(struct pt_regs *regs);
16649 +extern void kgdb_post_master_code(struct pt_regs *regs, int e_vector,
16651 +extern void kgdb_roundup_cpus(unsigned long flags);
16652 +extern int kgdb_set_hw_break(unsigned long addr);
16653 +extern int kgdb_remove_hw_break(unsigned long addr);
16654 +extern void kgdb_remove_all_hw_break(void);
16655 +extern void kgdb_correct_hw_break(void);
16656 +extern void kgdb_shadowinfo(struct pt_regs *regs, char *buffer,
16657 + unsigned threadid);
16658 +extern struct task_struct *kgdb_get_shadow_thread(struct pt_regs *regs,
16660 +extern struct pt_regs *kgdb_shadow_regs(struct pt_regs *regs, int threadid);
16661 +extern int kgdb_validate_break_address(unsigned long addr);
16662 +extern int kgdb_arch_set_breakpoint(unsigned long addr, char *saved_instr);
16663 +extern int kgdb_arch_remove_breakpoint(unsigned long addr, char *bundle);
16666 + * struct kgdb_arch - Desribe architecture specific values.
16667 + * @gdb_bpt_instr: The instruction to trigger a breakpoint.
16668 + * @flags: Flags for the breakpoint, currently just %KGDB_HW_BREAKPOINT.
16669 + * @shadowth: A value of %1 indicates we shadow information on processes.
16670 + * @set_breakpoint: Allow an architecture to specify how to set a software
16672 + * @remove_breakpoint: Allow an architecture to specify how to remove a
16673 + * software breakpoint.
16674 + * @set_hw_breakpoint: Allow an architecture to specify how to set a hardware
16676 + * @remove_hw_breakpoint: Allow an architecture to specify how to remove a
16677 + * hardware breakpoint.
16679 + * The @shadowth flag is an option to shadow information not retrievable by
16680 + * gdb otherwise. This is deprecated in favor of a binutils which supports
16683 +struct kgdb_arch {
16684 + unsigned char gdb_bpt_instr[BREAK_INSTR_SIZE];
16685 + unsigned long flags;
16686 + unsigned shadowth;
16687 + int (*set_breakpoint) (unsigned long, char *);
16688 + int (*remove_breakpoint)(unsigned long, char *);
16689 + int (*set_hw_breakpoint)(unsigned long, int, enum kgdb_bptype);
16690 + int (*remove_hw_breakpoint)(unsigned long, int, enum kgdb_bptype);
16693 +/* Thread reference */
16694 +typedef unsigned char threadref[8];
16697 + * struct kgdb_io - Desribe the interface for an I/O driver to talk with KGDB.
16698 + * @read_char: Pointer to a function that will return one char.
16699 + * @write_char: Pointer to a function that will write one char.
16700 + * @flush: Pointer to a function that will flush any pending writes.
16701 + * @init: Pointer to a function that will initialize the device.
16702 + * @late_init: Pointer to a function that will do any setup that has
16703 + * other dependencies.
16704 + * @pre_exception: Pointer to a function that will do any prep work for
16705 + * the I/O driver.
16706 + * @post_exception: Pointer to a function that will do any cleanup work
16707 + * for the I/O driver.
16709 + * The @init and @late_init function pointers allow for an I/O driver
16710 + * such as a serial driver to fully initialize the port with @init and
16711 + * be called very early, yet safely call request_irq() later in the boot
16714 + * @init is allowed to return a non-0 return value to indicate failure.
16715 + * If this is called early on, then KGDB will try again when it would call
16716 + * @late_init. If it has failed later in boot as well, the user will be
16720 + int (*read_char) (void);
16721 + void (*write_char) (u8);
16722 + void (*flush) (void);
16723 + int (*init) (void);
16724 + void (*late_init) (void);
16725 + void (*pre_exception) (void);
16726 + void (*post_exception) (void);
16729 +extern struct kgdb_io kgdb_io_ops;
16730 +extern struct kgdb_arch arch_kgdb_ops;
16731 +extern int kgdb_initialized;
16733 +extern int kgdb_register_io_module(struct kgdb_io *local_kgdb_io_ops);
16734 +extern void kgdb_unregister_io_module(struct kgdb_io *local_kgdb_io_ops);
16736 +extern void __init kgdb8250_add_port(int i, struct uart_port *serial_req);
16737 +extern void __init kgdb8250_add_platform_port(int i, struct plat_serial8250_port *serial_req);
16739 +extern int kgdb_hex2long(char **ptr, long *long_val);
16740 +extern char *kgdb_mem2hex(char *mem, char *buf, int count);
16741 +extern char *kgdb_hex2mem(char *buf, char *mem, int count);
16742 +extern int kgdb_get_mem(char *addr, unsigned char *buf, int count);
16743 +extern int kgdb_set_mem(char *addr, unsigned char *buf, int count);
16745 +int kgdb_isremovedbreak(unsigned long addr);
16746 +int kgdb_skipexception(int exception, struct pt_regs *regs);
16748 +extern int kgdb_handle_exception(int ex_vector, int signo, int err_code,
16749 + struct pt_regs *regs);
16750 +extern void kgdb_nmihook(int cpu, void *regs);
16751 +extern int debugger_step;
16752 +extern atomic_t debugger_active;
16753 +extern struct kgdb_arch *kgdb_ops;
16755 +/* Stubs for when KGDB is not set. */
16756 +static const atomic_t debugger_active = ATOMIC_INIT(0);
16757 +#endif /* CONFIG_KGDB */
16758 +#endif /* _KGDB_H_ */
16759 +#endif /* __KERNEL__ */
16760 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/include/linux/module.h linux-2.6.18-53.1.14.kgdb/include/linux/module.h
16761 --- linux-2.6.18-53.1.14/include/linux/module.h 2008-03-06 05:54:41.000000000 +0300
16762 +++ linux-2.6.18-53.1.14.kgdb/include/linux/module.h 2008-06-10 15:39:15.000000000 +0400
16763 @@ -229,8 +229,17 @@ enum module_state
16765 MODULE_STATE_COMING,
16766 MODULE_STATE_GOING,
16767 + MODULE_STATE_GONE,
16770 +#ifdef CONFIG_KGDB
16771 +#define MAX_SECTNAME 31
16772 +struct mod_section {
16774 + char name[MAX_SECTNAME + 1];
16778 /* Similar stuff for section attributes. */
16779 #define MODULE_SECT_NAME_LEN 32
16780 struct module_sect_attr
16781 @@ -258,6 +267,13 @@ struct module
16782 /* Unique handle for this module */
16783 char name[MODULE_NAME_LEN];
16785 +#ifdef CONFIG_KGDB
16786 + /* keep kgdb info at the begining so that gdb doesn't have a chance to
16787 + * miss out any fields */
16788 + unsigned long num_sections;
16789 + struct mod_section *mod_sections;
16793 struct module_kobject mkobj;
16794 struct module_param_attrs *param_attrs;
16795 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/include/linux/netpoll.h linux-2.6.18-53.1.14.kgdb/include/linux/netpoll.h
16796 --- linux-2.6.18-53.1.14/include/linux/netpoll.h 2006-09-20 07:42:06.000000000 +0400
16797 +++ linux-2.6.18-53.1.14.kgdb/include/linux/netpoll.h 2008-06-10 15:37:49.000000000 +0400
16798 @@ -17,7 +17,7 @@ struct netpoll;
16800 struct net_device *dev;
16801 char dev_name[16], *name;
16802 - void (*rx_hook)(struct netpoll *, int, char *, int);
16803 + void (*rx_hook)(struct netpoll *, int, char *, int, struct sk_buff *);
16804 void (*drop)(struct sk_buff *skb);
16805 u32 local_ip, remote_ip;
16806 u16 local_port, remote_port;
16807 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/include/linux/serial_8250.h linux-2.6.18-53.1.14.kgdb/include/linux/serial_8250.h
16808 --- linux-2.6.18-53.1.14/include/linux/serial_8250.h 2006-09-20 07:42:06.000000000 +0400
16809 +++ linux-2.6.18-53.1.14.kgdb/include/linux/serial_8250.h 2008-06-10 15:37:43.000000000 +0400
16810 @@ -56,6 +56,7 @@ struct uart_port;
16812 int serial8250_register_port(struct uart_port *);
16813 void serial8250_unregister_port(int line);
16814 +void serial8250_unregister_by_port(struct uart_port *port);
16815 void serial8250_suspend_port(int line);
16816 void serial8250_resume_port(int line);
16818 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/kernel/Makefile linux-2.6.18-53.1.14.kgdb/kernel/Makefile
16819 --- linux-2.6.18-53.1.14/kernel/Makefile 2008-03-06 05:54:50.000000000 +0300
16820 +++ linux-2.6.18-53.1.14.kgdb/kernel/Makefile 2008-06-10 15:37:25.000000000 +0400
16821 @@ -42,6 +42,7 @@ obj-$(CONFIG_STOP_MACHINE) += stop_machi
16822 obj-$(CONFIG_AUDIT) += audit.o auditfilter.o
16823 obj-$(CONFIG_AUDITSYSCALL) += auditsc.o audit_tree.o
16824 obj-$(CONFIG_KPROBES) += kprobes.o
16825 +obj-$(CONFIG_KGDB) += kgdb.o kgdbarchlib.o
16826 obj-$(CONFIG_SYSFS) += ksysfs.o
16827 obj-$(CONFIG_DETECT_SOFTLOCKUP) += softlockup.o
16828 obj-$(CONFIG_GENERIC_HARDIRQS) += irq/
16829 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/kernel/kgdb.c linux-2.6.18-53.1.14.kgdb/kernel/kgdb.c
16830 --- linux-2.6.18-53.1.14/kernel/kgdb.c 1970-01-01 03:00:00.000000000 +0300
16831 +++ linux-2.6.18-53.1.14.kgdb/kernel/kgdb.c 2008-06-10 15:39:21.000000000 +0400
16836 + * Maintainer: Tom Rini <trini@kernel.crashing.org>
16838 + * Copyright (C) 2000-2001 VERITAS Software Corporation.
16839 + * Copyright (C) 2002-2004 Timesys Corporation
16840 + * Copyright (C) 2003-2004 Amit S. Kale <amitkale@linsyssoft.com>
16841 + * Copyright (C) 2004 Pavel Machek <pavel@suse.cz>
16842 + * Copyright (C) 2004-2005 Tom Rini <trini@kernel.crashing.org>
16843 + * Copyright (C) 2004-2006 LinSysSoft Technologies Pvt. Ltd.
16844 + * Copyright (C) 2005 Wind River Systems, Inc.
16846 + * Contributors at various stages not listed above:
16847 + * Jason Wessel ( jason.wessel@windriver.com )
16848 + * George Anzinger <george@mvista.com>
16849 + * Anurekh Saxena (anurekh.saxena@timesys.com)
16850 + * Lake Stevens Instrument Division (Glenn Engel)
16851 + * Jim Kingdon, Cygnus Support.
16853 + * Original KGDB stub: David Grothe <dave@gcom.com>,
16854 + * Tigran Aivazian <tigran@sco.com>
16856 + * This file is licensed under the terms of the GNU General Public License
16857 + * version 2. This program is licensed "as is" without any warranty of any
16858 + * kind, whether express or implied.
16861 +#include <linux/string.h>
16862 +#include <linux/kernel.h>
16863 +#include <linux/interrupt.h>
16864 +#include <linux/sched.h>
16865 +#include <linux/smp.h>
16866 +#include <linux/spinlock.h>
16867 +#include <linux/delay.h>
16868 +#include <linux/mm.h>
16869 +#include <linux/threads.h>
16870 +#include <linux/reboot.h>
16871 +#include <asm/system.h>
16872 +#include <asm/ptrace.h>
16873 +#include <asm/uaccess.h>
16874 +#include <linux/kgdb.h>
16875 +#include <asm/atomic.h>
16876 +#include <linux/notifier.h>
16877 +#include <linux/module.h>
16878 +#include <asm/cacheflush.h>
16879 +#include <linux/init.h>
16880 +#include <linux/sysrq.h>
16881 +#include <linux/console.h>
16882 +#include <linux/sched.h>
16883 +#include <asm/byteorder.h>
16885 +extern int pid_max;
16886 +/* How many times to count all of the waiting CPUs */
16887 +#define ROUNDUP_WAIT 640000 /* Arbitrary, increase if needed. */
16888 +#define BUF_THREAD_ID_SIZE 16
16891 + * kgdb_initialized with a value of 1 indicates that kgdb is setup and is
16892 + * all ready to serve breakpoints and other kernel exceptions. A value of
16893 + * -1 indicates that we have tried to initialize early, and need to try
16896 +int kgdb_initialized;
16897 +/* Is a host GDB connected to us? */
16898 +int kgdb_connected;
16899 +/* Could we be about to try and access a bad memory location? If so we
16900 + * also need to flag this has happend. */
16901 +int kgdb_may_fault;
16902 +/* All the KGDB handlers are installed */
16903 +int kgdb_from_module_registered = 0;
16905 +/* We provide a kgdb_io_ops structure that may be overriden. */
16906 +struct kgdb_io __attribute__ ((weak)) kgdb_io_ops;
16908 +static struct kgdb_io kgdb_io_ops_prev[MAX_KGDB_IO_HANDLERS];
16909 +static int kgdb_io_handler_cnt = 0;
16911 +/* Export the following symbols for use with kernel modules */
16912 +EXPORT_SYMBOL(kgdb_io_ops);
16913 +EXPORT_SYMBOL(kgdb_tasklet_breakpoint);
16914 +EXPORT_SYMBOL(kgdb_connected);
16915 +EXPORT_SYMBOL(kgdb_register_io_module);
16916 +EXPORT_SYMBOL(kgdb_unregister_io_module);
16917 +EXPORT_SYMBOL(debugger_active);
16920 + * Holds information about breakpoints in a kernel. These breakpoints are
16921 + * added and removed by gdb.
16923 +struct kgdb_bkpt kgdb_break[MAX_BREAKPOINTS];
16925 +static const char hexchars[] = "0123456789abcdef";
16927 +static spinlock_t slavecpulocks[NR_CPUS];
16928 +static atomic_t procindebug[NR_CPUS];
16929 +atomic_t kgdb_setting_breakpoint;
16930 +EXPORT_SYMBOL(kgdb_setting_breakpoint);
16931 +struct task_struct *kgdb_usethread, *kgdb_contthread;
16933 +int debugger_step;
16934 +atomic_t debugger_active;
16936 +/* Our I/O buffers. */
16937 +static char remcom_in_buffer[BUFMAX];
16938 +static char remcom_out_buffer[BUFMAX];
16939 +/* Storage for the registers, in GDB format. */
16940 +static unsigned long gdb_regs[(NUMREGBYTES + sizeof(unsigned long) - 1) /
16941 + sizeof(unsigned long)];
16942 +/* Storage of registers for handling a fault. */
16943 +unsigned long kgdb_fault_jmp_regs[NUMCRITREGBYTES / sizeof(unsigned long)]
16944 + JMP_REGS_ALIGNMENT;
16945 +static int kgdb_notify_reboot(struct notifier_block *this,
16946 + unsigned long code ,void *x);
16947 +struct debuggerinfo_struct {
16948 + void *debuggerinfo;
16949 + struct task_struct *task;
16950 +} kgdb_info[NR_CPUS];
16952 +/* to keep track of the CPU which is doing the single stepping*/
16953 +atomic_t cpu_doing_single_step = ATOMIC_INIT(-1);
16955 +atomic_t kgdb_sync_softlockup[NR_CPUS] = {ATOMIC_INIT(0)};
16957 +/* reboot notifier block */
16958 +static struct notifier_block kgdb_reboot_notifier = {
16959 + .notifier_call = kgdb_notify_reboot,
16961 + .priority = INT_MAX,
16964 +static int hex(char ch)
16966 + if ((ch >= 'a') && (ch <= 'f'))
16967 + return (ch - 'a' + 10);
16968 + if ((ch >= '0') && (ch <= '9'))
16969 + return (ch - '0');
16970 + if ((ch >= 'A') && (ch <= 'F'))
16971 + return (ch - 'A' + 10);
16975 +/* scan for the sequence $<data>#<checksum> */
16976 +static void get_packet(char *buffer)
16978 + unsigned char checksum;
16979 + unsigned char xmitcsum;
16982 + if (!kgdb_io_ops.read_char)
16985 + /* Spin and wait around for the start character, ignore all
16986 + * other characters */
16987 + while ((ch = (kgdb_io_ops.read_char())) != '$') ;
16988 + kgdb_connected = 1;
16994 + /* now, read until a # or end of buffer is found */
16995 + while (count < (BUFMAX - 1)) {
16996 + ch = kgdb_io_ops.read_char();
16999 + checksum = checksum + ch;
17000 + buffer[count] = ch;
17001 + count = count + 1;
17003 + buffer[count] = 0;
17006 + xmitcsum = hex(kgdb_io_ops.read_char()) << 4;
17007 + xmitcsum += hex(kgdb_io_ops.read_char());
17009 + if (checksum != xmitcsum)
17010 + /* failed checksum */
17011 + kgdb_io_ops.write_char('-');
17013 + /* successful transfer */
17014 + kgdb_io_ops.write_char('+');
17015 + if (kgdb_io_ops.flush)
17016 + kgdb_io_ops.flush();
17018 + } while (checksum != xmitcsum);
17022 + * Send the packet in buffer.
17023 + * Check for gdb connection if asked for.
17025 +static void put_packet(char *buffer)
17027 + unsigned char checksum;
17031 + if (!kgdb_io_ops.write_char)
17033 + /* $<packet info>#<checksum>. */
17035 + kgdb_io_ops.write_char('$');
17039 + while ((ch = buffer[count])) {
17040 + kgdb_io_ops.write_char(ch);
17045 + kgdb_io_ops.write_char('#');
17046 + kgdb_io_ops.write_char(hexchars[checksum >> 4]);
17047 + kgdb_io_ops.write_char(hexchars[checksum % 16]);
17048 + if (kgdb_io_ops.flush)
17049 + kgdb_io_ops.flush();
17051 + /* Now see what we get in reply. */
17052 + ch = kgdb_io_ops.read_char();
17055 + ch = kgdb_io_ops.read_char();
17057 + /* If we get an ACK, we are done. */
17061 + /* If we get the start of another packet, this means
17062 + * that GDB is attempting to reconnect. We will NAK
17063 + * the packet being sent, and stop trying to send this
17066 + kgdb_io_ops.write_char('-');
17067 + if (kgdb_io_ops.flush)
17068 + kgdb_io_ops.flush();
17075 + * convert the memory pointed to by mem into hex, placing result in buf
17076 + * return a pointer to the last char put in buf (null). May return an error.
17078 +char *kgdb_mem2hex(char *mem, char *buf, int count)
17080 + kgdb_may_fault = 1;
17081 + if ((kgdb_fault_setjmp(kgdb_fault_jmp_regs)) != 0) {
17082 + kgdb_may_fault = 0;
17083 + return ERR_PTR(-EINVAL);
17085 + /* Accessing some registers in a single load instruction is
17086 + * required to avoid bad side effects for some I/O registers.
17088 + if ((count == 2) && (((long)mem & 1) == 0)) {
17089 + unsigned short tmp_s = *(unsigned short *)mem;
17091 +#ifdef __BIG_ENDIAN
17092 + *buf++ = hexchars[(tmp_s >> 12) & 0xf];
17093 + *buf++ = hexchars[(tmp_s >> 8) & 0xf];
17094 + *buf++ = hexchars[(tmp_s >> 4) & 0xf];
17095 + *buf++ = hexchars[tmp_s & 0xf];
17097 + *buf++ = hexchars[(tmp_s >> 4) & 0xf];
17098 + *buf++ = hexchars[tmp_s & 0xf];
17099 + *buf++ = hexchars[(tmp_s >> 12) & 0xf];
17100 + *buf++ = hexchars[(tmp_s >> 8) & 0xf];
17102 + } else if ((count == 4) && (((long)mem & 3) == 0)) {
17103 + unsigned long tmp_l = *(unsigned int *)mem;
17105 +#ifdef __BIG_ENDIAN
17106 + *buf++ = hexchars[(tmp_l >> 28) & 0xf];
17107 + *buf++ = hexchars[(tmp_l >> 24) & 0xf];
17108 + *buf++ = hexchars[(tmp_l >> 20) & 0xf];
17109 + *buf++ = hexchars[(tmp_l >> 16) & 0xf];
17110 + *buf++ = hexchars[(tmp_l >> 12) & 0xf];
17111 + *buf++ = hexchars[(tmp_l >> 8) & 0xf];
17112 + *buf++ = hexchars[(tmp_l >> 4) & 0xf];
17113 + *buf++ = hexchars[tmp_l & 0xf];
17115 + *buf++ = hexchars[(tmp_l >> 4) & 0xf];
17116 + *buf++ = hexchars[tmp_l & 0xf];
17117 + *buf++ = hexchars[(tmp_l >> 12) & 0xf];
17118 + *buf++ = hexchars[(tmp_l >> 8) & 0xf];
17119 + *buf++ = hexchars[(tmp_l >> 20) & 0xf];
17120 + *buf++ = hexchars[(tmp_l >> 16) & 0xf];
17121 + *buf++ = hexchars[(tmp_l >> 28) & 0xf];
17122 + *buf++ = hexchars[(tmp_l >> 24) & 0xf];
17124 +#ifdef CONFIG_64BIT
17125 + } else if ((count == 8) && (((long)mem & 7) == 0)) {
17126 + unsigned long long tmp_ll = *(unsigned long long *)mem;
17128 +#ifdef __BIG_ENDIAN
17129 + *buf++ = hexchars[(tmp_ll >> 60) & 0xf];
17130 + *buf++ = hexchars[(tmp_ll >> 56) & 0xf];
17131 + *buf++ = hexchars[(tmp_ll >> 52) & 0xf];
17132 + *buf++ = hexchars[(tmp_ll >> 48) & 0xf];
17133 + *buf++ = hexchars[(tmp_ll >> 44) & 0xf];
17134 + *buf++ = hexchars[(tmp_ll >> 40) & 0xf];
17135 + *buf++ = hexchars[(tmp_ll >> 36) & 0xf];
17136 + *buf++ = hexchars[(tmp_ll >> 32) & 0xf];
17137 + *buf++ = hexchars[(tmp_ll >> 28) & 0xf];
17138 + *buf++ = hexchars[(tmp_ll >> 24) & 0xf];
17139 + *buf++ = hexchars[(tmp_ll >> 20) & 0xf];
17140 + *buf++ = hexchars[(tmp_ll >> 16) & 0xf];
17141 + *buf++ = hexchars[(tmp_ll >> 12) & 0xf];
17142 + *buf++ = hexchars[(tmp_ll >> 8) & 0xf];
17143 + *buf++ = hexchars[(tmp_ll >> 4) & 0xf];
17144 + *buf++ = hexchars[tmp_ll & 0xf];
17146 + *buf++ = hexchars[(tmp_ll >> 4) & 0xf];
17147 + *buf++ = hexchars[tmp_ll & 0xf];
17148 + *buf++ = hexchars[(tmp_ll >> 12) & 0xf];
17149 + *buf++ = hexchars[(tmp_ll >> 8) & 0xf];
17150 + *buf++ = hexchars[(tmp_ll >> 20) & 0xf];
17151 + *buf++ = hexchars[(tmp_ll >> 16) & 0xf];
17152 + *buf++ = hexchars[(tmp_ll >> 28) & 0xf];
17153 + *buf++ = hexchars[(tmp_ll >> 24) & 0xf];
17154 + *buf++ = hexchars[(tmp_ll >> 36) & 0xf];
17155 + *buf++ = hexchars[(tmp_ll >> 32) & 0xf];
17156 + *buf++ = hexchars[(tmp_ll >> 44) & 0xf];
17157 + *buf++ = hexchars[(tmp_ll >> 40) & 0xf];
17158 + *buf++ = hexchars[(tmp_ll >> 52) & 0xf];
17159 + *buf++ = hexchars[(tmp_ll >> 48) & 0xf];
17160 + *buf++ = hexchars[(tmp_ll >> 60) & 0xf];
17161 + *buf++ = hexchars[(tmp_ll >> 56) & 0xf];
17165 + while (count-- > 0) {
17166 + unsigned char ch = *mem++;
17167 + *buf++ = hexchars[ch >> 4];
17168 + *buf++ = hexchars[ch & 0xf];
17171 + kgdb_may_fault = 0;
17177 + * Copy the binary array pointed to by buf into mem. Fix $, #, and
17178 + * 0x7d escaped with 0x7d. Return a pointer to the character after
17179 + * the last byte written.
17181 +static char *kgdb_ebin2mem(char *buf, char *mem, int count)
17183 + kgdb_may_fault = 1;
17184 + if ((kgdb_fault_setjmp(kgdb_fault_jmp_regs)) != 0) {
17185 + kgdb_may_fault = 0;
17186 + return ERR_PTR(-EINVAL);
17188 + for (; count > 0; count--, buf++) {
17189 + if (*buf == 0x7d)
17190 + *mem++ = *(++buf) ^ 0x20;
17194 + kgdb_may_fault = 0;
17199 + * convert the hex array pointed to by buf into binary to be placed in mem
17200 + * return a pointer to the character AFTER the last byte written
17201 + * May return an error.
17203 +char *kgdb_hex2mem(char *buf, char *mem, int count)
17205 + kgdb_may_fault = 1;
17206 + if ((kgdb_fault_setjmp(kgdb_fault_jmp_regs)) != 0) {
17207 + kgdb_may_fault = 0;
17208 + return ERR_PTR(-EINVAL);
17210 + if ((count == 2) && (((long)mem & 1) == 0)) {
17211 + unsigned short tmp_s = 0;
17212 +#ifdef __BIG_ENDIAN
17213 + tmp_s |= hex(*buf++) << 12;
17214 + tmp_s |= hex(*buf++) << 8;
17215 + tmp_s |= hex(*buf++) << 4;
17216 + tmp_s |= hex(*buf++);
17218 + tmp_s |= hex(*buf++) << 4;
17219 + tmp_s |= hex(*buf++);
17220 + tmp_s |= hex(*buf++) << 12;
17221 + tmp_s |= hex(*buf++) << 8;
17223 + *(unsigned short *)mem = tmp_s;
17225 + } else if ((count == 4) && (((long)mem & 3) == 0)) {
17226 + unsigned long tmp_l = 0;
17227 +#ifdef __BIG_ENDIAN
17228 + tmp_l |= hex(*buf++) << 28;
17229 + tmp_l |= hex(*buf++) << 24;
17230 + tmp_l |= hex(*buf++) << 20;
17231 + tmp_l |= hex(*buf++) << 16;
17232 + tmp_l |= hex(*buf++) << 12;
17233 + tmp_l |= hex(*buf++) << 8;
17234 + tmp_l |= hex(*buf++) << 4;
17235 + tmp_l |= hex(*buf++);
17237 + tmp_l |= hex(*buf++) << 4;
17238 + tmp_l |= hex(*buf++);
17239 + tmp_l |= hex(*buf++) << 12;
17240 + tmp_l |= hex(*buf++) << 8;
17241 + tmp_l |= hex(*buf++) << 20;
17242 + tmp_l |= hex(*buf++) << 16;
17243 + tmp_l |= hex(*buf++) << 28;
17244 + tmp_l |= hex(*buf++) << 24;
17246 + *(unsigned long *)mem = tmp_l;
17250 + for (i = 0; i < count; i++) {
17251 + unsigned char ch = hex(*buf++) << 4;
17252 + ch |= hex(*buf++);
17256 + kgdb_may_fault = 0;
17261 + * While we find nice hex chars, build a long_val.
17262 + * Return number of chars processed.
17264 +int kgdb_hex2long(char **ptr, long *long_val)
17266 + int hex_val, num = 0;
17271 + hex_val = hex(**ptr);
17272 + if (hex_val >= 0) {
17273 + *long_val = (*long_val << 4) | hex_val;
17284 +/* Write memory due to an 'M' or 'X' packet. */
17285 +static char *write_mem_msg(int binary)
17287 + char *ptr = &remcom_in_buffer[1];
17288 + unsigned long addr, length;
17290 + if (kgdb_hex2long(&ptr, &addr) > 0 && *(ptr++) == ',' &&
17291 + kgdb_hex2long(&ptr, &length) > 0 && *(ptr++) == ':') {
17293 + ptr = kgdb_ebin2mem(ptr, (char *)addr, length);
17295 + ptr = kgdb_hex2mem(ptr, (char *)addr, length);
17296 + if (CACHE_FLUSH_IS_SAFE)
17297 + flush_icache_range(addr, addr + length + 1);
17303 + return ERR_PTR(-EINVAL);
17306 +static inline char *pack_hex_byte(char *pkt, int byte)
17308 + *pkt++ = hexchars[(byte >> 4) & 0xf];
17309 + *pkt++ = hexchars[(byte & 0xf)];
17313 +static inline void error_packet(char *pkt, int error)
17317 + pkt[1] = hexchars[(error / 10)];
17318 + pkt[2] = hexchars[(error % 10)];
17322 +static char *pack_threadid(char *pkt, threadref * id)
17325 + unsigned char *altid;
17327 + altid = (unsigned char *)id;
17328 + limit = pkt + BUF_THREAD_ID_SIZE;
17329 + while (pkt < limit)
17330 + pkt = pack_hex_byte(pkt, *altid++);
17335 +void int_to_threadref(threadref * id, int value)
17337 + unsigned char *scan;
17340 + scan = (unsigned char *)id;
17343 + *scan++ = (value >> 24) & 0xff;
17344 + *scan++ = (value >> 16) & 0xff;
17345 + *scan++ = (value >> 8) & 0xff;
17346 + *scan++ = (value & 0xff);
17349 +static struct task_struct *getthread(struct pt_regs *regs, int tid)
17351 + if (last_pid == 0)
17354 + if (num_online_cpus() &&
17355 + (tid >= pid_max + num_online_cpus() + kgdb_ops->shadowth))
17358 + if (kgdb_ops->shadowth && (tid >= pid_max + num_online_cpus()))
17359 + return kgdb_get_shadow_thread(regs, tid - pid_max -
17360 + num_online_cpus());
17362 + if (tid >= pid_max)
17363 + return idle_task(tid - pid_max);
17368 + return find_task_by_pid(tid);
17372 +static void kgdb_wait(struct pt_regs *regs)
17374 + unsigned long flags;
17377 + local_irq_save(flags);
17378 + processor = smp_processor_id();
17379 + kgdb_info[processor].debuggerinfo = regs;
17380 + kgdb_info[processor].task = current;
17381 + atomic_set(&procindebug[processor], 1);
17382 + atomic_set(&kgdb_sync_softlockup[smp_processor_id()], 1);
17384 + /* Wait till master processor goes completely into the debugger.
17385 + * FIXME: this looks racy */
17386 + while (!atomic_read(&procindebug[atomic_read(&debugger_active) - 1])) {
17387 + int i = 10; /* an arbitrary number */
17393 + /* Wait till master processor is done with debugging */
17394 + spin_lock(&slavecpulocks[processor]);
17396 + /* This has been taken from x86 kgdb implementation and
17397 + * will be needed by architectures that have SMP support
17399 + kgdb_correct_hw_break();
17401 + kgdb_info[processor].debuggerinfo = NULL;
17402 + kgdb_info[processor].task = NULL;
17404 + /* Signal the master processor that we are done */
17405 + atomic_set(&procindebug[processor], 0);
17406 + spin_unlock(&slavecpulocks[processor]);
17407 + local_irq_restore(flags);
17411 +int kgdb_get_mem(char *addr, unsigned char *buf, int count)
17413 + kgdb_may_fault = 1;
17414 + if ((kgdb_fault_setjmp(kgdb_fault_jmp_regs)) != 0) {
17415 + kgdb_may_fault = 0;
17419 + if ((unsigned long)addr < TASK_SIZE)
17421 + *buf++ = *addr++;
17424 + kgdb_may_fault = 0;
17428 +int kgdb_set_mem(char *addr, unsigned char *buf, int count)
17430 + kgdb_may_fault = 1;
17431 + if ((kgdb_fault_setjmp(kgdb_fault_jmp_regs)) != 0) {
17432 + kgdb_may_fault = 0;
17436 + if ((unsigned long)addr < TASK_SIZE)
17438 + *addr++ = *buf++;
17441 + kgdb_may_fault = 0;
17444 +int kgdb_activate_sw_breakpoints(void)
17448 + unsigned long addr;
17449 + for (i = 0; i < MAX_BREAKPOINTS; i++) {
17450 + if (kgdb_break[i].state != bp_set)
17452 + addr = kgdb_break[i].bpt_addr;
17453 + if ((error = kgdb_arch_set_breakpoint(addr,
17454 + kgdb_break[i].saved_instr)))
17457 + if (CACHE_FLUSH_IS_SAFE) {
17458 + if (current->mm && addr < TASK_SIZE)
17459 + flush_cache_range(current->mm->mmap_cache,
17460 + addr, addr + BREAK_INSTR_SIZE);
17462 + flush_icache_range(addr, addr +
17463 + BREAK_INSTR_SIZE);
17466 + kgdb_break[i].state = bp_active;
17471 +static int kgdb_set_sw_break(unsigned long addr)
17473 + int i, breakno = -1;
17475 + if ((error = kgdb_validate_break_address(addr)) < 0)
17477 + for (i = 0; i < MAX_BREAKPOINTS; i++) {
17478 + if ((kgdb_break[i].state == bp_set) &&
17479 + (kgdb_break[i].bpt_addr == addr))
17482 + for (i = 0; i < MAX_BREAKPOINTS; i++) {
17483 + if (kgdb_break[i].state == bp_removed &&
17484 + kgdb_break[i].bpt_addr == addr) {
17490 + if (breakno == -1) {
17491 + for (i = 0; i < MAX_BREAKPOINTS; i++) {
17492 + if (kgdb_break[i].state == bp_none) {
17498 + if (breakno == -1)
17501 + kgdb_break[breakno].state = bp_set;
17502 + kgdb_break[breakno].type = bp_breakpoint;
17503 + kgdb_break[breakno].bpt_addr = addr;
17508 +int kgdb_deactivate_sw_breakpoints(void)
17512 + unsigned long addr;
17513 + for (i = 0; i < MAX_BREAKPOINTS; i++) {
17514 + if (kgdb_break[i].state != bp_active)
17516 + addr = kgdb_break[i].bpt_addr;
17517 + if ((error = kgdb_arch_remove_breakpoint(addr,
17518 + kgdb_break[i].saved_instr)))
17521 + if (CACHE_FLUSH_IS_SAFE && current->mm &&
17522 + addr < TASK_SIZE)
17523 + flush_cache_range(current->mm->mmap_cache,
17524 + addr, addr + BREAK_INSTR_SIZE);
17525 + else if (CACHE_FLUSH_IS_SAFE)
17526 + flush_icache_range(addr,
17527 + addr + BREAK_INSTR_SIZE);
17528 + kgdb_break[i].state = bp_set;
17533 +static int kgdb_remove_sw_break(unsigned long addr)
17537 + for (i = 0; i < MAX_BREAKPOINTS; i++) {
17538 + if ((kgdb_break[i].state == bp_set) &&
17539 + (kgdb_break[i].bpt_addr == addr)) {
17540 + kgdb_break[i].state = bp_removed;
17547 +int kgdb_isremovedbreak(unsigned long addr)
17550 + for (i = 0; i < MAX_BREAKPOINTS; i++) {
17551 + if ((kgdb_break[i].state == bp_removed) &&
17552 + (kgdb_break[i].bpt_addr == addr)) {
17559 +int remove_all_break(void)
17563 + unsigned long addr;
17565 + /* Clear memory breakpoints. */
17566 + for (i = 0; i < MAX_BREAKPOINTS; i++) {
17567 + if (kgdb_break[i].state != bp_set)
17569 + addr = kgdb_break[i].bpt_addr;
17570 + if ((error = kgdb_arch_remove_breakpoint(addr,
17571 + kgdb_break[i].saved_instr)))
17573 + kgdb_break[i].state = bp_removed;
17576 + /* Clear hardware breakpoints. */
17577 + kgdb_remove_all_hw_break();
17582 +static inline int shadow_pid(int realpid)
17587 + return pid_max + smp_processor_id();
17590 +static char gdbmsgbuf[BUFMAX + 1];
17591 +static void kgdb_msg_write(const char *s, int len)
17598 + gdbmsgbuf[0] = 'O';
17600 + /* Fill and send buffers... */
17601 + while (len > 0) {
17602 + bufptr = gdbmsgbuf + 1;
17604 + /* Calculate how many this time */
17605 + if ((len << 1) > (BUFMAX - 2))
17606 + wcount = (BUFMAX - 2) >> 1;
17610 + /* Pack in hex chars */
17611 + for (i = 0; i < wcount; i++)
17612 + bufptr = pack_hex_byte(bufptr, s[i]);
17619 + /* Write packet */
17620 + put_packet(gdbmsgbuf);
17625 + * This function does all command procesing for interfacing to gdb.
17627 + * Locking hierarchy:
17628 + * interface locks, if any (begin_session)
17629 + * kgdb lock (debugger_active)
17631 + * Note that since we can be in here prior to our cpumask being filled
17632 + * out, we err on the side of caution and loop over NR_CPUS instead
17633 + * of a for_each_online_cpu.
17636 +int kgdb_handle_exception(int ex_vector, int signo, int err_code,
17637 + struct pt_regs *linux_regs)
17639 + unsigned long length, addr;
17641 + unsigned long flags;
17645 + struct task_struct *thread = NULL;
17647 + int numshadowth = num_online_cpus() + kgdb_ops->shadowth;
17648 + long kgdb_usethreadid = 0;
17649 + int error = 0, all_cpus_synced = 0;
17650 + struct pt_regs *shadowregs;
17651 + int processor = smp_processor_id();
17652 + void *local_debuggerinfo;
17654 + /* Panic on recursive debugger calls. */
17655 + if (atomic_read(&debugger_active) == smp_processor_id() + 1)
17660 + /* Call the I/O drivers pre_exception routine if the I/O
17661 + * driver defined one
17663 + if (kgdb_io_ops.pre_exception)
17664 + kgdb_io_ops.pre_exception();
17667 + * Interrupts will be restored by the 'trap return' code, except when
17668 + * single stepping.
17670 + local_irq_save(flags);
17672 + /* Hold debugger_active */
17673 + procid = smp_processor_id();
17675 + while (cmpxchg(&atomic_read(&debugger_active), 0, (procid + 1)) != 0) {
17676 + int i = 25; /* an arbitrary number */
17681 + if (atomic_read(&cpu_doing_single_step) != -1 &&
17682 + atomic_read(&cpu_doing_single_step) != procid)
17686 + atomic_set(&kgdb_sync_softlockup[smp_processor_id()], 1);
17689 + * Don't enter if the last instance of the exception handler wanted to
17690 + * come into the debugger again.
17692 + if (atomic_read(&cpu_doing_single_step) != -1 &&
17693 + atomic_read(&cpu_doing_single_step) != procid) {
17694 + atomic_set(&debugger_active, 0);
17695 + local_irq_restore(flags);
17696 + goto acquirelock;
17700 + * Don't enter if we have hit a removed breakpoint.
17702 + if (kgdb_skipexception(ex_vector, linux_regs))
17703 + goto kgdb_restore;
17705 + kgdb_info[processor].debuggerinfo = linux_regs;
17706 + kgdb_info[processor].task = current;
17708 + kgdb_disable_hw_debug(linux_regs);
17710 + if (!debugger_step || !kgdb_contthread)
17711 + for (i = 0; i < NR_CPUS; i++)
17712 + spin_lock(&slavecpulocks[i]);
17714 + /* Make sure we get the other CPUs */
17715 + if (!debugger_step || !kgdb_contthread)
17716 + kgdb_roundup_cpus(flags);
17718 + /* spin_lock code is good enough as a barrier so we don't
17719 + * need one here */
17720 + atomic_set(&procindebug[processor], 1);
17722 + /* Wait a reasonable time for the other CPUs to be notified and
17723 + * be waiting for us. Very early on this could be imperfect
17724 + * as num_online_cpus() could be 0.*/
17725 + for (i = 0; i < ROUNDUP_WAIT; i++) {
17726 + int cpu, num = 0;
17727 + for (cpu = 0; cpu < NR_CPUS; cpu++) {
17728 + if (atomic_read(&procindebug[cpu]))
17731 + if (num >= num_online_cpus()) {
17732 + all_cpus_synced = 1;
17737 + /* Clear the out buffer. */
17738 + memset(remcom_out_buffer, 0, sizeof(remcom_out_buffer));
17740 + /* Master processor is completely in the debugger */
17741 + kgdb_post_master_code(linux_regs, ex_vector, err_code);
17742 + kgdb_deactivate_sw_breakpoints();
17743 + debugger_step = 0;
17744 + kgdb_contthread = NULL;
17746 + if (kgdb_connected) {
17747 + /* If we're still unable to roundup all of the CPUs,
17748 + * send an 'O' packet informing the user again. */
17749 + if (!all_cpus_synced)
17750 + kgdb_msg_write("Not all CPUs have been synced for "
17752 + /* Reply to host that an exception has occurred */
17753 + ptr = remcom_out_buffer;
17755 + *ptr++ = hexchars[(signo >> 4) % 16];
17756 + *ptr++ = hexchars[signo % 16];
17757 + ptr += strlen(strcpy(ptr, "thread:"));
17758 + int_to_threadref(&thref, shadow_pid(current->pid));
17759 + ptr = pack_threadid(ptr, &thref);
17762 + put_packet(remcom_out_buffer);
17765 + kgdb_usethread = kgdb_info[processor].task;
17766 + kgdb_usethreadid = shadow_pid(kgdb_info[processor].task->pid);
17768 + while (kgdb_io_ops.read_char) {
17772 + /* Clear the out buffer. */
17773 + memset(remcom_out_buffer, 0, sizeof(remcom_out_buffer));
17775 + get_packet(remcom_in_buffer);
17777 + switch (remcom_in_buffer[0]) {
17779 + /* We know that this packet is only sent
17780 + * during initial connect. So to be safe,
17781 + * we clear out our breakpoints now incase
17782 + * GDB is reconnecting. */
17783 + remove_all_break();
17784 + /* Also, if we haven't been able to roundup all
17785 + * CPUs, send an 'O' packet informing the user
17786 + * as much. Only need to do this once. */
17787 + if (!all_cpus_synced)
17788 + kgdb_msg_write("Not all CPUs have been "
17789 + "synced for KGDB\n", 39);
17790 + remcom_out_buffer[0] = 'S';
17791 + remcom_out_buffer[1] = hexchars[signo >> 4];
17792 + remcom_out_buffer[2] = hexchars[signo % 16];
17795 + case 'g': /* return the value of the CPU registers */
17796 + thread = kgdb_usethread;
17799 + thread = kgdb_info[processor].task;
17800 + local_debuggerinfo =
17801 + kgdb_info[processor].debuggerinfo;
17803 + local_debuggerinfo = NULL;
17804 + for (i = 0; i < NR_CPUS; i++) {
17805 + /* Try to find the task on some other
17806 + * or possibly this node if we do not
17807 + * find the matching task then we try
17808 + * to approximate the results.
17810 + if (thread == kgdb_info[i].task)
17811 + local_debuggerinfo =
17812 + kgdb_info[i].debuggerinfo;
17816 + /* All threads that don't have debuggerinfo should be
17817 + * in __schedule() sleeping, since all other CPUs
17818 + * are in kgdb_wait, and thus have debuggerinfo. */
17819 + if (kgdb_ops->shadowth &&
17820 + kgdb_usethreadid >= pid_max + num_online_cpus()) {
17821 + shadowregs = kgdb_shadow_regs(linux_regs,
17822 + kgdb_usethreadid -
17826 + if (!shadowregs) {
17827 + error_packet(remcom_out_buffer,
17831 + regs_to_gdb_regs(gdb_regs, shadowregs);
17832 + } else if (local_debuggerinfo)
17833 + regs_to_gdb_regs(gdb_regs, local_debuggerinfo);
17835 + /* Pull stuff saved during
17836 + * switch_to; nothing else is
17837 + * accessible (or even particularly relevant).
17838 + * This should be enough for a stack trace. */
17839 + sleeping_thread_to_gdb_regs(gdb_regs, thread);
17841 + kgdb_mem2hex((char *)gdb_regs, remcom_out_buffer,
17845 + /* set the value of the CPU registers - return OK */
17847 + kgdb_hex2mem(&remcom_in_buffer[1], (char *)gdb_regs,
17850 + if (kgdb_usethread && kgdb_usethread != current)
17851 + error_packet(remcom_out_buffer, -EINVAL);
17853 + gdb_regs_to_regs(gdb_regs, linux_regs);
17854 + strcpy(remcom_out_buffer, "OK");
17858 + /* mAA..AA,LLLL Read LLLL bytes at address AA..AA */
17860 + ptr = &remcom_in_buffer[1];
17861 + if (kgdb_hex2long(&ptr, &addr) > 0 && *ptr++ == ',' &&
17862 + kgdb_hex2long(&ptr, &length) > 0) {
17863 + if (IS_ERR(ptr = kgdb_mem2hex((char *)addr,
17864 + remcom_out_buffer,
17866 + error_packet(remcom_out_buffer,
17869 + error_packet(remcom_out_buffer, -EINVAL);
17872 + /* MAA..AA,LLLL: Write LLLL bytes at address AA..AA */
17874 + if (IS_ERR(ptr = write_mem_msg(0)))
17875 + error_packet(remcom_out_buffer, PTR_ERR(ptr));
17877 + strcpy(remcom_out_buffer, "OK");
17879 + /* XAA..AA,LLLL: Write LLLL bytes at address AA..AA */
17881 + if (IS_ERR(ptr = write_mem_msg(1)))
17882 + error_packet(remcom_out_buffer, PTR_ERR(ptr));
17884 + strcpy(remcom_out_buffer, "OK");
17887 + /* kill or detach. KGDB should treat this like a
17891 + if ((error = remove_all_break()) < 0) {
17892 + error_packet(remcom_out_buffer, error);
17894 + strcpy(remcom_out_buffer, "OK");
17895 + kgdb_connected = 0;
17897 + put_packet(remcom_out_buffer);
17898 + goto default_handle;
17901 + /* Don't care about error from remove_all_break */
17902 + remove_all_break();
17903 + kgdb_connected = 0;
17904 + goto default_handle;
17908 + /* For now, only honor R0 */
17909 + if (strcmp(remcom_in_buffer, "R0") == 0) {
17910 + printk(KERN_CRIT "Executing reboot\n");
17911 + strcpy(remcom_out_buffer, "OK");
17912 + put_packet(remcom_out_buffer);
17913 + emergency_sync();
17914 + /* Execution should not return from
17915 + * machine_restart()
17917 + machine_restart(NULL);
17918 + kgdb_connected = 0;
17919 + goto default_handle;
17924 + switch (remcom_in_buffer[1]) {
17927 + if (memcmp(remcom_in_buffer + 2, "ThreadInfo",
17929 + error_packet(remcom_out_buffer,
17935 + * If we have not yet completed in
17936 + * pidhash_init() there isn't much we
17939 + if (last_pid == 0) {
17940 + if (remcom_in_buffer[1] == 'f')
17941 + strcpy(remcom_out_buffer,
17942 + "m0000000000000001");
17946 + if (remcom_in_buffer[1] == 'f') {
17949 + remcom_out_buffer[0] = 'm';
17950 + ptr = remcom_out_buffer + 1;
17951 + for (i = 0; i < 17 && threadid < pid_max +
17952 + numshadowth; threadid++) {
17953 + thread = getthread(linux_regs,
17956 + int_to_threadref(&thref,
17958 + pack_threadid(ptr, &thref);
17968 + /* Current thread id */
17969 + strcpy(remcom_out_buffer, "QC");
17971 + threadid = shadow_pid(current->pid);
17973 + int_to_threadref(&thref, threadid);
17974 + pack_threadid(remcom_out_buffer + 2, &thref);
17977 + if (memcmp(remcom_in_buffer + 1,
17978 + "ThreadExtraInfo,", 16)) {
17979 + error_packet(remcom_out_buffer,
17984 + ptr = remcom_in_buffer + 17;
17985 + kgdb_hex2long(&ptr, &threadid);
17986 + if (!getthread(linux_regs, threadid)) {
17987 + error_packet(remcom_out_buffer,
17991 + if (threadid < pid_max) {
17992 + kgdb_mem2hex(getthread(linux_regs,
17994 + remcom_out_buffer, 16);
17995 + } else if (threadid >= pid_max +
17996 + num_online_cpus()) {
17997 + kgdb_shadowinfo(linux_regs,
17998 + remcom_out_buffer,
17999 + threadid - pid_max -
18000 + num_online_cpus());
18002 + static char tmpstr[23 +
18003 + BUF_THREAD_ID_SIZE];
18004 + sprintf(tmpstr, "Shadow task %d"
18006 + (int)(threadid - pid_max));
18007 + kgdb_mem2hex(tmpstr, remcom_out_buffer,
18014 + /* task related */
18016 + switch (remcom_in_buffer[1]) {
18018 + ptr = &remcom_in_buffer[2];
18019 + kgdb_hex2long(&ptr, &threadid);
18020 + thread = getthread(linux_regs, threadid);
18021 + if (!thread && threadid > 0) {
18022 + error_packet(remcom_out_buffer,
18026 + kgdb_usethread = thread;
18027 + kgdb_usethreadid = threadid;
18028 + strcpy(remcom_out_buffer, "OK");
18032 + ptr = &remcom_in_buffer[2];
18033 + kgdb_hex2long(&ptr, &threadid);
18035 + kgdb_contthread = NULL;
18037 + thread = getthread(linux_regs,
18039 + if (!thread && threadid > 0) {
18040 + error_packet(remcom_out_buffer,
18044 + kgdb_contthread = thread;
18046 + strcpy(remcom_out_buffer, "OK");
18051 + /* Query thread status */
18053 + ptr = &remcom_in_buffer[1];
18054 + kgdb_hex2long(&ptr, &threadid);
18055 + thread = getthread(linux_regs, threadid);
18057 + strcpy(remcom_out_buffer, "OK");
18059 + error_packet(remcom_out_buffer, -EINVAL);
18061 + /* Since GDB-5.3, it's been drafted that '0' is a software
18062 + * breakpoint, '1' is a hardware breakpoint, so let's do
18067 + bpt_type = &remcom_in_buffer[1];
18068 + ptr = &remcom_in_buffer[2];
18070 + if (kgdb_ops->set_hw_breakpoint && *bpt_type >= '1') {
18071 + /* Unsupported */
18072 + if (*bpt_type > '4')
18074 + } else if (*bpt_type != '0' && *bpt_type != '1')
18075 + /* Unsupported. */
18077 + /* Test if this is a hardware breakpoint, and
18078 + * if we support it. */
18079 + if (*bpt_type == '1' &&
18080 + !kgdb_ops->flags & KGDB_HW_BREAKPOINT)
18081 + /* Unsupported. */
18084 + if (*(ptr++) != ',') {
18085 + error_packet(remcom_out_buffer, -EINVAL);
18087 + } else if (kgdb_hex2long(&ptr, &addr)) {
18088 + if (*(ptr++) != ',' ||
18089 + !kgdb_hex2long(&ptr, &length)) {
18090 + error_packet(remcom_out_buffer,
18095 + error_packet(remcom_out_buffer, -EINVAL);
18099 + if (remcom_in_buffer[0] == 'Z' && *bpt_type == '0')
18100 + error = kgdb_set_sw_break(addr);
18101 + else if (remcom_in_buffer[0] == 'Z' && *bpt_type == '1')
18102 + error = kgdb_set_hw_break(addr);
18103 + else if (remcom_in_buffer[0] == 'z' && *bpt_type == '0')
18104 + error = kgdb_remove_sw_break(addr);
18105 + else if (remcom_in_buffer[0] == 'z' && *bpt_type == '1')
18106 + error = kgdb_remove_hw_break(addr);
18107 + else if (remcom_in_buffer[0] == 'Z')
18108 + error = kgdb_ops->set_hw_breakpoint(addr,
18111 + else if (remcom_in_buffer[0] == 'z')
18112 + error = kgdb_ops->remove_hw_breakpoint(addr,
18118 + strcpy(remcom_out_buffer, "OK");
18120 + error_packet(remcom_out_buffer, error);
18125 + if (kgdb_contthread && kgdb_contthread != current) {
18126 + /* Can't switch threads in kgdb */
18127 + error_packet(remcom_out_buffer, -EINVAL);
18130 + kgdb_activate_sw_breakpoints();
18131 + /* Followthrough to default processing */
18134 + error = kgdb_arch_handle_exception(ex_vector, signo,
18136 + remcom_in_buffer,
18137 + remcom_out_buffer,
18140 + if (error >= 0 || remcom_in_buffer[0] == 'D' ||
18141 + remcom_in_buffer[0] == 'k')
18146 + /* reply to the request */
18147 + put_packet(remcom_out_buffer);
18151 + /* Call the I/O driver's post_exception routine if the I/O
18152 + * driver defined one.
18154 + if (kgdb_io_ops.post_exception)
18155 + kgdb_io_ops.post_exception();
18157 + kgdb_info[processor].debuggerinfo = NULL;
18158 + kgdb_info[processor].task = NULL;
18159 + atomic_set(&procindebug[processor], 0);
18161 + if (!debugger_step || !kgdb_contthread) {
18162 + for (i = 0; i < NR_CPUS; i++)
18163 + spin_unlock(&slavecpulocks[i]);
18164 + /* Wait till all the processors have quit
18165 + * from the debugger. */
18166 + for (i = 0; i < NR_CPUS; i++) {
18167 + while (atomic_read(&procindebug[i])) {
18168 + int j = 10; /* an arbitrary number */
18177 + /* This delay has a real purpose. The problem is that if you
18178 + * are single-stepping, you are sending an NMI to all the
18179 + * other processors to stop them. Interrupts come in, but
18180 + * don't get handled. Then you let them go just long enough
18181 + * to get into their interrupt routines and use up some stack.
18182 + * You stop them again, and then do the same thing. After a
18183 + * while you blow the stack on the other processors. This
18184 + * delay gives some time for interrupts to be cleared out on
18185 + * the other processors.
18187 + if (debugger_step)
18191 + /* Free debugger_active */
18192 + atomic_set(&debugger_active, 0);
18193 + local_irq_restore(flags);
18199 + * GDB places a breakpoint at this function to know dynamically
18200 + * loaded objects. It's not defined static so that only one instance with this
18201 + * name exists in the kernel.
18204 +int module_event(struct notifier_block *self, unsigned long val, void *data)
18209 +static struct notifier_block kgdb_module_load_nb = {
18210 + .notifier_call = module_event,
18213 +void kgdb_nmihook(int cpu, void *regs)
18216 + if (!atomic_read(&procindebug[cpu]) && atomic_read(&debugger_active) != (cpu + 1))
18217 + kgdb_wait((struct pt_regs *)regs);
18222 + * This is called when a panic happens. All we need to do is
18225 +static int kgdb_panic_notify(struct notifier_block *self, unsigned long cmd,
18233 +static struct notifier_block kgdb_panic_notifier = {
18234 + .notifier_call = kgdb_panic_notify,
18238 + * Initialization that needs to be done in either of our entry points.
18240 +static void __init kgdb_internal_init(void)
18244 + /* Initialize our spinlocks. */
18245 + for (i = 0; i < NR_CPUS; i++)
18246 + spin_lock_init(&slavecpulocks[i]);
18248 + for (i = 0; i < MAX_BREAKPOINTS; i++)
18249 + kgdb_break[i].state = bp_none;
18251 + /* Initialize the I/O handles */
18252 + memset(&kgdb_io_ops_prev, 0, sizeof(kgdb_io_ops_prev));
18254 + /* We can't do much if this fails */
18255 + register_module_notifier(&kgdb_module_load_nb);
18257 + kgdb_initialized = 1;
18260 +static void kgdb_register_for_panic(void)
18262 + /* Register for panics(). */
18263 + /* The registration is done in the kgdb_register_for_panic
18264 + * routine because KGDB should not try to handle a panic when
18265 + * there are no kgdb_io_ops setup. It is assumed that the
18266 + * kgdb_io_ops are setup at the time this method is called.
18268 + if (!kgdb_from_module_registered) {
18269 + atomic_notifier_chain_register(&panic_notifier_list,
18270 + &kgdb_panic_notifier);
18271 + kgdb_from_module_registered = 1;
18275 +static void kgdb_unregister_for_panic(void)
18277 + /* When this routine is called KGDB should unregister from the
18278 + * panic handler and clean up, making sure it is not handling any
18279 + * break exceptions at the time.
18281 + if (kgdb_from_module_registered) {
18282 + kgdb_from_module_registered = 0;
18283 + atomic_notifier_chain_unregister(&panic_notifier_list,
18284 + &kgdb_panic_notifier);
18288 +int kgdb_register_io_module(struct kgdb_io *local_kgdb_io_ops)
18291 + if (kgdb_connected) {
18292 + printk(KERN_ERR "kgdb: Cannot load I/O module while KGDB "
18297 + /* Save the old values so they can be restored */
18298 + if (kgdb_io_handler_cnt >= MAX_KGDB_IO_HANDLERS) {
18299 + printk(KERN_ERR "kgdb: No more I/O handles available.\n");
18303 + /* Check to see if there is an existing driver and if so save its
18304 + * values. Also check to make sure the same driver was not trying
18305 + * to re-register.
18307 + if (kgdb_io_ops.read_char != NULL &&
18308 + kgdb_io_ops.read_char != local_kgdb_io_ops->read_char) {
18309 + memcpy(&kgdb_io_ops_prev[kgdb_io_handler_cnt],
18310 + &kgdb_io_ops, sizeof(struct kgdb_io));
18311 + kgdb_io_handler_cnt++;
18314 + /* Initialize the io values for this module */
18315 + memcpy(&kgdb_io_ops, local_kgdb_io_ops, sizeof(struct kgdb_io));
18317 + /* Make the call to register kgdb if is not initialized */
18318 + kgdb_register_for_panic();
18323 +void kgdb_unregister_io_module(struct kgdb_io *local_kgdb_io_ops)
18327 + /* Unregister KGDB if there were no other prior io hooks, else
18328 + * restore the io hooks.
18330 + if (kgdb_io_handler_cnt > 0 && kgdb_io_ops_prev[0].read_char != NULL) {
18331 + /* First check if the hook that is in use is the one being
18333 + if (kgdb_io_ops.read_char == local_kgdb_io_ops->read_char) {
18334 + /* Set 'i' to the value of where the list should be
18336 + i = kgdb_io_handler_cnt - 1;
18337 + memcpy(&kgdb_io_ops, &kgdb_io_ops_prev[i],
18338 + sizeof(struct kgdb_io));
18340 + /* Simple case to remove an entry for an I/O handler
18341 + * that is not in use */
18342 + for (i = 0; i < kgdb_io_handler_cnt; i++) {
18343 + if (kgdb_io_ops_prev[i].read_char ==
18344 + local_kgdb_io_ops->read_char)
18349 + /* Shift all the entries in the handler array so it is
18350 + * ordered from oldest to newest.
18352 + kgdb_io_handler_cnt--;
18353 + for (; i < kgdb_io_handler_cnt; i++) {
18354 + memcpy(&kgdb_io_ops_prev[i], &kgdb_io_ops_prev[i + 1],
18355 + sizeof(struct kgdb_io));
18357 + /* Handle the case if we are on the last element and set it
18359 + memset(&kgdb_io_ops_prev[kgdb_io_handler_cnt], 0,
18360 + sizeof(struct kgdb_io));
18362 + if (kgdb_connected)
18363 + printk(KERN_ERR "kgdb: WARNING: I/O method changed "
18364 + "while kgdb was connected state.\n");
18366 + /* KGDB is no longer able to communicate out, so
18367 + * unregister our hooks and reset state. */
18368 + kgdb_unregister_for_panic();
18369 + if (kgdb_connected) {
18370 + printk(KERN_CRIT "kgdb: I/O module was unloaded while "
18371 + "a debugging session was running. "
18372 + "KGDB will be reset.\n");
18373 + if (remove_all_break() < 0)
18374 + printk(KERN_CRIT "kgdb: Reset failed.\n");
18375 + kgdb_connected = 0;
18377 + memset(&kgdb_io_ops, 0, sizeof(struct kgdb_io));
18382 + * There are times we need to call a tasklet to cause a breakpoint
18383 + * as calling breakpoint() at that point might be fatal. We have to
18384 + * check that the exception stack is setup, as tasklets may be scheduled
18385 + * prior to this. When that happens, it is up to the architecture to
18386 + * schedule this when it is safe to run.
18388 +static void kgdb_tasklet_bpt(unsigned long ing)
18390 + if(CHECK_EXCEPTION_STACK())
18394 +DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
18397 + * This function can be called very early, either via early_param() or
18398 + * an explicit breakpoint() early on.
18400 +static void __init kgdb_early_entry(void)
18403 + * Don't try and do anything until the architecture is able to
18404 + * setup the exception stack. In this case, it is up to the
18405 + * architecture to hook in and look at us when they are ready.
18407 + if(!CHECK_EXCEPTION_STACK()) {
18408 + kgdb_initialized = -1;
18409 + tasklet_schedule(&kgdb_tasklet_breakpoint);
18413 + /* Let the architecture do any setup that it needs to. */
18414 + kgdb_arch_init();
18416 + /* Now try the I/O. */
18417 + /* For early entry kgdb_io_ops.init must be defined */
18418 + if (!kgdb_io_ops.init || kgdb_io_ops.init()) {
18419 + /* Try again later. */
18420 + kgdb_initialized = -1;
18425 + kgdb_internal_init();
18427 + /* KGDB can assume that if kgdb_io_ops.init was defined that the
18428 + * panic registion should be performed at this time. This means
18429 + * kgdb_io_ops.init did not come from a kernel module and was
18430 + * initialized statically by a built in.
18432 + if (kgdb_io_ops.init)
18433 + kgdb_register_for_panic();
18437 + * This function will always be invoked to make sure that KGDB will grab
18438 + * what it needs to so that if something happens while the system is
18439 + * running, KGDB will get involved. If kgdb_early_entry() has already
18440 + * been invoked, there is little we need to do.
18442 +static int __init kgdb_late_entry(void)
18444 + int need_break = 0;
18446 + /* If kgdb_initialized is -1 then we were passed kgdbwait. */
18447 + if (kgdb_initialized == -1)
18451 + * If we haven't tried to initialize KGDB yet, we need to call
18452 + * kgdb_arch_init before moving onto the I/O.
18454 + if (!kgdb_initialized)
18455 + kgdb_arch_init();
18457 + if (kgdb_initialized != 1) {
18458 + if (kgdb_io_ops.init && kgdb_io_ops.init()) {
18459 + /* When KGDB allows I/O via modules and the core
18460 + * I/O init fails KGDB must default to defering the
18461 + * I/O setup, and appropriately print an error about
18464 + printk(KERN_ERR "kgdb: Could not setup core I/O "
18466 + printk(KERN_INFO "kgdb: Defering I/O setup to kernel "
18468 + memset(&kgdb_io_ops, 0, sizeof(struct kgdb_io));
18471 + kgdb_internal_init();
18473 + /* KGDB can assume that if kgdb_io_ops.init was defined that
18474 + * panic registion should be performed at this time. This means
18475 + * kgdb_io_ops.init did not come from a kernel module and was
18476 + * initialized statically by a built in.
18478 + if (kgdb_io_ops.init)
18479 + kgdb_register_for_panic();
18482 + /* Registering to reboot notifier list*/
18483 + register_reboot_notifier(&kgdb_reboot_notifier);
18485 + /* Now do any late init of the I/O. */
18486 + if (kgdb_io_ops.late_init)
18487 + kgdb_io_ops.late_init();
18489 + if (need_break) {
18490 + printk(KERN_CRIT "kgdb: Waiting for connection from remote"
18498 +late_initcall(kgdb_late_entry);
18501 + * This function will generate a breakpoint exception. It is used at the
18502 + * beginning of a program to sync up with a debugger and can be used
18503 + * otherwise as a quick means to stop program execution and "break" into
18506 +void breakpoint(void)
18508 + if (kgdb_initialized != 1) {
18509 + kgdb_early_entry();
18510 + if (kgdb_initialized == 1)
18511 + printk(KERN_CRIT "Waiting for connection from remote "
18514 + printk(KERN_CRIT "KGDB cannot initialize I/O yet.\n");
18519 + atomic_set(&kgdb_setting_breakpoint, 1);
18523 + atomic_set(&kgdb_setting_breakpoint, 0);
18526 +EXPORT_SYMBOL(breakpoint);
18528 +#ifdef CONFIG_MAGIC_SYSRQ
18529 +static void sysrq_handle_gdb(int key, struct pt_regs *pt_regs,
18530 + struct tty_struct *tty)
18532 + printk("Entering GDB stub\n");
18535 +static struct sysrq_key_op sysrq_gdb_op = {
18536 + .handler = sysrq_handle_gdb,
18537 + .help_msg = "Gdb",
18538 + .action_msg = "GDB",
18541 +static int gdb_register_sysrq(void)
18543 + printk("Registering GDB sysrq handler\n");
18544 + register_sysrq_key('g', &sysrq_gdb_op);
18548 +module_init(gdb_register_sysrq);
18551 +static int kgdb_notify_reboot(struct notifier_block *this,
18552 + unsigned long code, void *x)
18555 + unsigned long flags;
18557 + /* If we're debugging, or KGDB has not connected, don't try
18559 + if (!kgdb_connected || atomic_read(&debugger_active) != 0)
18561 + if ((code == SYS_RESTART) || (code == SYS_HALT) || (code == SYS_POWER_OFF)){
18562 + local_irq_save(flags);
18563 + put_packet("X00");
18564 + local_irq_restore(flags);
18566 + return NOTIFY_DONE;
18569 +#ifdef CONFIG_KGDB_CONSOLE
18570 +void kgdb_console_write(struct console *co, const char *s, unsigned count)
18572 + unsigned long flags;
18574 + /* If we're debugging, or KGDB has not connected, don't try
18576 + if (!kgdb_connected || atomic_read(&debugger_active) != 0)
18579 + local_irq_save(flags);
18580 + kgdb_msg_write(s, count);
18581 + local_irq_restore(flags);
18584 +struct console kgdbcons = {
18586 + .write = kgdb_console_write,
18587 + .flags = CON_PRINTBUFFER | CON_ENABLED,
18589 +static int __init kgdb_console_init(void)
18591 + register_console(&kgdbcons);
18595 +console_initcall(kgdb_console_init);
18598 +static int __init opt_kgdb_enter(char *str)
18600 + /* We've already done this by an explicit breakpoint() call. */
18601 + if (kgdb_initialized)
18604 + /* Call breakpoint() which will take care of init. */
18610 +early_param("kgdbwait", opt_kgdb_enter);
18611 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/kernel/kgdbarchlib.c linux-2.6.18-53.1.14.kgdb/kernel/kgdbarchlib.c
18612 --- linux-2.6.18-53.1.14/kernel/kgdbarchlib.c 1970-01-01 03:00:00.000000000 +0300
18613 +++ linux-2.6.18-53.1.14.kgdb/kernel/kgdbarchlib.c 2008-06-10 15:37:25.000000000 +0400
18615 +#include <linux/kgdb.h>
18617 +struct kgdb_arch *kgdb_ops = &arch_kgdb_ops;
18620 + * kgdb_arch_init - Perform any architecture specific initalization.
18623 + * The return value is ignored.
18625 + * This function will handle the initalization of any architecture
18626 + * specific hooks.
18628 +int __attribute__ ((weak))
18629 + kgdb_arch_init(void)
18635 + * kgdb_disable_hw_debug - Disable hardware debugging while we in kgdb.
18636 + * @regs: Current &struct pt_regs.
18638 + * This function will be called if the particular architecture must
18639 + * disable hardware debugging while it is processing gdb packets or
18640 + * handling exception.
18642 +void __attribute__ ((weak))
18643 + kgdb_disable_hw_debug(struct pt_regs *regs)
18648 + * Skip an int3 exception when it occurs after a breakpoint has been
18649 + * removed. Backtrack eip by 1 since the int3 would have caused it to
18650 + * increment by 1.
18652 +int __attribute__ ((weak))
18653 + kgdb_skipexception(int exception, struct pt_regs *regs)
18659 + * kgdb_set_hw_break - Set a hardware breakpoint at @addr.
18660 + * @addr: The address to set a hardware breakpoint at.
18662 +int __attribute__ ((weak))
18663 + kgdb_set_hw_break(unsigned long addr)
18669 + * kgdb_remove_hw_break - Remove a hardware breakpoint at @addr.
18670 + * @addr: The address to remove a hardware breakpoint from.
18672 +int __attribute__ ((weak))
18673 + kgdb_remove_hw_break(unsigned long addr)
18679 + * kgdb_remove_all_hw_break - Clear all hardware breakpoints.
18681 +void __attribute__ ((weak))
18682 + kgdb_remove_all_hw_break(void)
18687 + * kgdb_correct_hw_break - Correct hardware breakpoints.
18689 + * A hook to allow for changes to the hardware breakpoint, called
18690 + * after a single step (s) or continue (c) packet, and once we're about
18691 + * to let the kernel continue running.
18693 + * This is used to set the hardware breakpoint registers for all the
18694 + * slave cpus on an SMP configuration. This must be called after any
18695 + * changes are made to the hardware breakpoints (such as by a single
18696 + * step (s) or continue (c) packet. This is only required on
18697 + * architectures that support SMP and every processor has its own set
18698 + * of breakpoint registers.
18700 +void __attribute__ ((weak))
18701 + kgdb_correct_hw_break(void)
18706 + * kgdb_post_master_code - Save error vector/code numbers.
18707 + * @regs: Original pt_regs.
18708 + * @e_vector: Original error vector.
18709 + * @err_code: Original error code.
18711 + * This is needed on architectures which support SMP and KGDB.
18712 + * This function is called after all the slave cpus have been put
18713 + * to a know spin state and the master CPU has control over KGDB.
18716 +void __attribute__ ((weak))
18717 + kgdb_post_master_code(struct pt_regs *regs, int e_vector, int err_code)
18722 + * kgdb_roundup_cpus - Get other CPUs into a holding pattern
18723 + * @flags: Current IRQ state
18725 + * On SMP systems, we need to get the attention of the other CPUs
18726 + * and get them be in a known state. This should do what is needed
18727 + * to get the other CPUs to call kgdb_wait(). Note that on some arches,
18728 + * the NMI approach is not used for rounding up all the CPUs. For example,
18729 + * in case of MIPS, smp_call_function() is used to roundup CPUs. In
18730 + * this case, we have to make sure that interrupts are enabled before
18731 + * calling smp_call_function(). The argument to this function is
18732 + * the flags that will be used when restoring the interrupts. There is
18733 + * local_irq_save() call before kgdb_roundup_cpus().
18735 +void __attribute__ ((weak))
18736 + kgdb_roundup_cpus(unsigned long flags)
18741 + * kgdb_shadowinfo - Get shadowed information on @threadid.
18742 + * @regs: The &struct pt_regs of the current process.
18743 + * @buffer: A buffer of %BUFMAX size.
18744 + * @threadid: The thread id of the shadowed process to get information on.
18746 +void __attribute__ ((weak))
18747 + kgdb_shadowinfo(struct pt_regs *regs, char *buffer, unsigned threadid)
18752 + * kgdb_get_shadow_thread - Get the shadowed &task_struct of @threadid.
18753 + * @regs: The &struct pt_regs of the current thread.
18754 + * @threadid: The thread id of the shadowed process to get information on.
18757 + * This returns a pointer to the &struct task_struct of the shadowed
18758 + * thread, @threadid.
18760 +struct task_struct __attribute__ ((weak))
18761 + * kgdb_get_shadow_thread(struct pt_regs *regs, int threadid)
18767 + * kgdb_shadow_regs - Return the shadowed registers of @threadid.
18768 + * @regs: The &struct pt_regs of the current thread.
18769 + * @threadid: The thread id we want the &struct pt_regs for.
18772 + * The a pointer to the &struct pt_regs of the shadowed thread @threadid.
18774 +struct pt_regs __attribute__ ((weak))
18775 + * kgdb_shadow_regs(struct pt_regs *regs, int threadid)
18780 +int __attribute__ ((weak))
18781 + kgdb_validate_break_address(unsigned long addr)
18784 + char tmp_variable[BREAK_INSTR_SIZE];
18785 + error = kgdb_get_mem((char *)addr, tmp_variable, BREAK_INSTR_SIZE);
18789 +int __attribute__ ((weak))
18790 + kgdb_arch_set_breakpoint(unsigned long addr, char *saved_instr)
18793 + if ((error = kgdb_get_mem((char *)addr,
18794 + saved_instr, BREAK_INSTR_SIZE)) < 0)
18797 + if ((error = kgdb_set_mem((char *)addr, kgdb_ops->gdb_bpt_instr,
18798 + BREAK_INSTR_SIZE)) < 0)
18803 +int __attribute__ ((weak))
18804 + kgdb_arch_remove_breakpoint(unsigned long addr, char *bundle)
18808 + if ((error =kgdb_set_mem((char *)addr, (char *)bundle,
18809 + BREAK_INSTR_SIZE)) < 0)
18813 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/kernel/module.c linux-2.6.18-53.1.14.kgdb/kernel/module.c
18814 --- linux-2.6.18-53.1.14/kernel/module.c 2008-03-06 05:54:13.000000000 +0300
18815 +++ linux-2.6.18-53.1.14.kgdb/kernel/module.c 2008-06-10 15:39:15.000000000 +0400
18816 @@ -65,6 +65,7 @@ static DEFINE_SPINLOCK(modlist_lock);
18817 /* List of modules, protected by module_mutex AND modlist_lock */
18818 static DEFINE_MUTEX(module_mutex);
18819 static LIST_HEAD(modules);
18820 +static DECLARE_MUTEX(notify_mutex);
18822 static BLOCKING_NOTIFIER_HEAD(module_notify_list);
18824 @@ -701,6 +702,12 @@ sys_delete_module(const char __user *nam
18828 + down(¬ify_mutex);
18829 + blocking_notifier_call_chain(&module_notify_list, MODULE_STATE_GOING,
18831 + up(¬ify_mutex);
18834 /* Never wait if forced. */
18835 if (!forced && module_refcount(mod) != 0)
18836 wait_for_zero_refcount(mod);
18837 @@ -713,6 +720,11 @@ sys_delete_module(const char __user *nam
18841 + down(¬ify_mutex);
18842 + blocking_notifier_call_chain(&module_notify_list, MODULE_STATE_GONE,
18844 + up(¬ify_mutex);
18847 mutex_unlock(&module_mutex);
18849 @@ -1119,6 +1131,11 @@ static void free_module(struct module *m
18850 /* Arch-specific cleanup. */
18851 module_arch_cleanup(mod);
18853 +#ifdef CONFIG_KGDB
18855 + vfree(mod->mod_sections);
18858 /* Module unload stuff */
18859 module_unload_free(mod);
18861 @@ -1378,6 +1395,31 @@ static void setup_modinfo(struct module
18865 +#ifdef CONFIG_KGDB
18866 +int add_modsects (struct module *mod, Elf_Ehdr *hdr, Elf_Shdr *sechdrs, const
18867 + char *secstrings)
18871 + mod->num_sections = hdr->e_shnum - 1;
18872 + mod->mod_sections = vmalloc((hdr->e_shnum - 1)*
18873 + sizeof (struct mod_section));
18875 + if (mod->mod_sections == NULL) {
18879 + for (i = 1; i < hdr->e_shnum; i++) {
18880 + mod->mod_sections[i - 1].address = (void *)sechdrs[i].sh_addr;
18881 + strncpy(mod->mod_sections[i - 1].name, secstrings +
18882 + sechdrs[i].sh_name, MAX_SECTNAME);
18883 + mod->mod_sections[i - 1].name[MAX_SECTNAME] = '\0';
18890 #ifdef CONFIG_KALLSYMS
18891 int is_exported(const char *name, const struct module *mod)
18893 @@ -1796,6 +1838,12 @@ static struct module *load_module(void _
18895 add_kallsyms(mod, sechdrs, symindex, strindex, secstrings);
18897 +#ifdef CONFIG_KGDB
18898 + if ((err = add_modsects(mod, hdr, sechdrs, secstrings)) < 0) {
18899 + goto nomodsectinfo;
18903 err = module_finalize(hdr, sechdrs, mod);
18906 @@ -1856,6 +1904,11 @@ static struct module *load_module(void _
18908 module_arch_cleanup(mod);
18911 +#ifdef CONFIG_KGDB
18913 + vfree(mod->mod_sections);
18915 module_unload_free(mod);
18916 module_free(mod, mod->module_init);
18918 @@ -1927,6 +1980,10 @@ sys_init_module(void __user *umod,
18919 /* Init routine failed: abort. Try to protect us from
18920 buggy refcounters. */
18921 mod->state = MODULE_STATE_GOING;
18922 + down(¬ify_mutex);
18923 + blocking_notifier_call_chain(&module_notify_list, MODULE_STATE_GOING,
18925 + up(¬ify_mutex);
18926 synchronize_sched();
18928 printk(KERN_ERR "%s: module is now stuck!\n",
18929 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/kernel/sched.c linux-2.6.18-53.1.14.kgdb/kernel/sched.c
18930 --- linux-2.6.18-53.1.14/kernel/sched.c 2008-03-06 05:54:44.000000000 +0300
18931 +++ linux-2.6.18-53.1.14.kgdb/kernel/sched.c 2008-06-10 15:37:25.000000000 +0400
18933 #include <linux/acct.h>
18934 #include <linux/kprobes.h>
18935 #include <linux/delayacct.h>
18936 +#include <linux/kgdb.h>
18937 #include <asm/tlb.h>
18939 #include <asm/unistd.h>
18940 @@ -6835,6 +6836,9 @@ void __might_sleep(char *file, int line)
18942 static unsigned long prev_jiffy; /* ratelimiting */
18944 + if (atomic_read(&debugger_active))
18947 if ((in_atomic() || irqs_disabled()) &&
18948 system_state == SYSTEM_RUNNING && !oops_in_progress) {
18949 if (time_before(jiffies, prev_jiffy + HZ) && prev_jiffy)
18950 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/kernel/softlockup.c linux-2.6.18-53.1.14.kgdb/kernel/softlockup.c
18951 --- linux-2.6.18-53.1.14/kernel/softlockup.c 2008-03-06 05:54:44.000000000 +0300
18952 +++ linux-2.6.18-53.1.14.kgdb/kernel/softlockup.c 2008-06-10 15:39:21.000000000 +0400
18954 #include <linux/kthread.h>
18955 #include <linux/notifier.h>
18956 #include <linux/module.h>
18957 +#include <linux/kgdb.h>
18959 static DEFINE_SPINLOCK(print_lock);
18961 @@ -37,6 +38,9 @@ static struct notifier_block panic_block
18962 void touch_softlockup_watchdog(void)
18964 __raw_get_cpu_var(touch_timestamp) = jiffies;
18965 +#ifdef CONFIG_KGDB
18966 + atomic_set(&kgdb_sync_softlockup[raw_smp_processor_id()], 0);
18969 EXPORT_SYMBOL(touch_softlockup_watchdog);
18971 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/kernel/timer.c linux-2.6.18-53.1.14.kgdb/kernel/timer.c
18972 --- linux-2.6.18-53.1.14/kernel/timer.c 2008-03-06 05:54:50.000000000 +0300
18973 +++ linux-2.6.18-53.1.14.kgdb/kernel/timer.c 2008-06-10 15:39:21.000000000 +0400
18975 #include <linux/cpu.h>
18976 #include <linux/syscalls.h>
18977 #include <linux/delay.h>
18978 +#include <linux/kgdb.h>
18980 #include <asm/uaccess.h>
18981 #include <asm/unistd.h>
18982 @@ -1385,7 +1386,11 @@ static void run_timer_softirq(struct sof
18984 void run_local_timers(void)
18986 + int this_cpu = smp_processor_id();
18987 raise_softirq(TIMER_SOFTIRQ);
18988 +#ifdef CONFIG_KGDB
18989 + if(!atomic_read(&kgdb_sync_softlockup[this_cpu]))
18994 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/lib/Kconfig.debug linux-2.6.18-53.1.14.kgdb/lib/Kconfig.debug
18995 --- linux-2.6.18-53.1.14/lib/Kconfig.debug 2008-03-06 05:54:32.000000000 +0300
18996 +++ linux-2.6.18-53.1.14.kgdb/lib/Kconfig.debug 2008-06-10 15:38:56.000000000 +0400
18997 @@ -324,7 +324,7 @@ config DEBUG_LIST
18999 config FRAME_POINTER
19000 bool "Compile the kernel with frame pointers"
19001 - depends on DEBUG_KERNEL && (X86 || CRIS || M68K || M68KNOMMU || FRV || UML || S390)
19002 + depends on DEBUG_KERNEL && (X86 || CRIS || M68K || M68KNOMMU || FRV || UML || S390 || SUPERH)
19003 default y if DEBUG_INFO && UML
19005 If you say Y here the resulting kernel image will be slightly larger
19006 @@ -377,3 +377,158 @@ config RCU_TORTURE_TEST
19007 at boot time (you probably don't).
19008 Say M if you want the RCU torture tests to build as a module.
19009 Say N if you are unsure.
19011 +config WANT_EXTRA_DEBUG_INFORMATION
19013 + select DEBUG_INFO
19014 + select FRAME_POINTER if X86 || SUPERH
19018 + bool "KGDB: kernel debugging with remote gdb"
19019 + select WANT_EXTRA_DEBUG_INFORMATION
19020 + depends on DEBUG_KERNEL && (ARM || X86 || MIPS || (SUPERH && !SUPERH64) || IA64 || X86_64 || PPC)
19022 + If you say Y here, it will be possible to remotely debug the
19023 + kernel using gdb. It is strongly suggested that you enable
19024 + DEBUG_INFO, and if available on your platform, FRAME_POINTER.
19025 + Documentation of kernel debugger available at
19026 + http://kgdb.sourceforge.net as well as in DocBook form
19027 + in Documentation/DocBook/. If unsure, say N.
19029 +config KGDB_CONSOLE
19030 + bool "KGDB: Console messages through gdb"
19033 + If you say Y here, console messages will appear through gdb.
19034 + Other consoles such as tty or ttyS will continue to work as usual.
19035 + Note, that if you use this in conjunction with KGDB_ETH, if the
19036 + ethernet driver runs into an error condition during use with KGDB
19037 + it is possible to hit an infinite recusrion, causing the kernel
19038 + to crash, and typically reboot. For this reason, it is preferable
19039 + to use NETCONSOLE in conjunction with KGDB_ETH instead of
19043 + prompt "Method for KGDB communication"
19045 + default KGDB_8250_NOMODULE
19046 + default KGDB_MPSC if SERIAL_MPSC
19047 + default KGDB_CPM_UART if (8xx || 8260)
19048 + default KGDB_SIBYTE if SIBYTE_SB1xxx_SOC
19050 + There are a number of different ways in which you can communicate
19051 + with KGDB. The most common is via serial, with the 8250 driver
19052 + (should your hardware have an 8250, or ns1655x style uart).
19053 + Another option is to use the NETPOLL framework and UDP, should
19054 + your ethernet card support this. Other options may exist.
19055 + You can elect to have one core I/O driver that is built into the
19056 + kernel for debugging as the kernel is booting, or using only
19059 +config KGDB_ONLY_MODULES
19060 + bool "KGDB: Use only kernel modules for I/O"
19061 + depends on MODULES
19063 + Use only kernel modules to configure KGDB I/O after the
19064 + kernel is booted.
19066 +config KGDB_8250_NOMODULE
19067 + bool "KGDB: On generic serial port (8250)"
19070 + Uses generic serial port (8250) to communicate with the host
19071 + GDB. This is independent of the normal (SERIAL_8250) driver
19072 + for this chipset.
19074 +config KGDBOE_NOMODULE
19075 + bool "KGDB: On ethernet - in kernel"
19078 + select NETPOLL_TRAP
19079 + select NETPOLL_RX
19081 + Uses the NETPOLL API to communicate with the host GDB via UDP.
19082 + In order for this to work, the ethernet interface specified must
19083 + support the NETPOLL API, and this must be initialized at boot.
19084 + See the documentation for syntax.
19087 + bool "KGDB on MV64x60 MPSC"
19088 + depends on SERIAL_MPSC
19090 + Uses a Marvell GT64260B or MV64x60 Multi-Purpose Serial
19091 + Controller (MPSC) channel. Note that the GT64260A is not
19094 +config KGDB_CPM_UART
19095 + bool "KGDB: On CPM UART"
19096 + depends on PPC && (CPM2 || 8xx)
19098 + Uses CPM UART to communicate with the host GDB.
19100 +config KGDB_SIBYTE
19101 + bool "KGDB: On the Broadcom SWARM serial port"
19102 + depends on MIPS && SIBYTE_SB1xxx_SOC
19106 + tristate "KGDB: On ethernet" if !KGDBOE_NOMODULE
19107 + depends on m && KGDB
19109 + select NETPOLL_TRAP
19110 + select NETPOLL_RX
19112 + Uses the NETPOLL API to communicate with the host GDB via UDP.
19113 + In order for this to work, the ethernet interface specified must
19114 + support the NETPOLL API, and this must be initialized at boot.
19115 + See the documentation for syntax.
19118 + tristate "KGDB: On generic serial port (8250)" if !KGDB_8250_NOMODULE
19119 + depends on m && KGDB_ONLY_MODULES
19121 + Uses generic serial port (8250) to communicate with the host
19122 + GDB. This is independent of the normal (SERIAL_8250) driver
19123 + for this chipset.
19125 +config KGDB_SIMPLE_SERIAL
19126 + bool "Simple selection of KGDB serial port"
19127 + depends on KGDB_8250_NOMODULE
19130 + If you say Y here, you will only have to pick the baud rate
19131 + and port number that you wish to use for KGDB. Note that this
19132 + only works on architectures that register known serial ports
19133 + early on. If you say N, you will have to provide, either here
19134 + or on the command line, the type (I/O or MMIO), IRQ and
19135 + address to use. If in doubt, say Y.
19137 +config KGDB_BAUDRATE
19138 + int "Debug serial port baud rate"
19139 + depends on (KGDB_8250 && KGDB_SIMPLE_SERIAL)
19142 + gdb and the kernel stub need to agree on the baud rate to be
19143 + used. Standard rates from 9600 to 115200 are allowed, and this
19144 + may be overridden via the commandline.
19146 +config KGDB_PORT_NUM
19147 + int "Serial port number for KGDB"
19148 + range 0 1 if KGDB_MPSC
19150 + depends on (KGDB_8250 && KGDB_SIMPLE_SERIAL) || KGDB_MPSC
19153 + Pick the port number (0 based) for KGDB to use.
19155 +config KGDB_8250_CONF_STRING
19156 + string "Configuration string for KGDB"
19157 + depends on KGDB_8250_NOMODULE && !KGDB_SIMPLE_SERIAL
19158 + default "io,2f8,115200,3" if X86
19160 + The format of this string should be <io or
19161 + mmio>,<address>,<baud rate>,<irq>. For example, to use the
19162 + serial port on an i386 box located at 0x2f8 and 115200 baud
19165 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/net/core/netpoll.c linux-2.6.18-53.1.14.kgdb/net/core/netpoll.c
19166 --- linux-2.6.18-53.1.14/net/core/netpoll.c 2008-03-06 05:54:27.000000000 +0300
19167 +++ linux-2.6.18-53.1.14.kgdb/net/core/netpoll.c 2008-06-10 15:37:49.000000000 +0400
19168 @@ -525,7 +525,8 @@ int __netpoll_rx(struct sk_buff *skb)
19170 np->rx_hook(np, ntohs(uh->source),
19172 - ulen - sizeof(struct udphdr));
19173 + ulen - sizeof(struct udphdr),
19178 diff -rupbBN -X ../client-cleanup/dontdiff linux-2.6.18-53.1.14/scripts/dwarfh.awk linux-2.6.18-53.1.14.kgdb/scripts/dwarfh.awk
19179 --- linux-2.6.18-53.1.14/scripts/dwarfh.awk 1970-01-01 03:00:00.000000000 +0300
19180 +++ linux-2.6.18-53.1.14.kgdb/scripts/dwarfh.awk 2008-06-10 15:39:01.000000000 +0400
19183 + print "#ifndef _ELF_DWARF_H"
19184 + print "/* Machine generated from dwarf2.h by scripts/dwarfh.awk */"
19187 + gsub(/,/, "", $3)
19188 + print "#define " $1 "\t " $3
19192 + while( index($0,"\\") == length($0)){