1 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/Documentation/DocBook/Makefile linux-2.6.18.kgdb/Documentation/DocBook/Makefile
2 --- linux-2.6.18/Documentation/DocBook/Makefile 2006-09-20 07:42:06.000000000 +0400
3 +++ linux-2.6.18.kgdb/Documentation/DocBook/Makefile 2008-06-10 16:18:58.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 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 -rupN -X ../client-cleanup/dontdiff linux-2.6.18/Documentation/DocBook/kgdb.tmpl linux-2.6.18.kgdb/Documentation/DocBook/kgdb.tmpl
14 --- linux-2.6.18/Documentation/DocBook/kgdb.tmpl 1970-01-01 03:00:00.000000000 +0300
15 +++ linux-2.6.18.kgdb/Documentation/DocBook/kgdb.tmpl 2008-06-10 16:19:47.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 -rupN -X ../client-cleanup/dontdiff linux-2.6.18/MAINTAINERS linux-2.6.18.kgdb/MAINTAINERS
268 --- linux-2.6.18/MAINTAINERS 2006-09-20 07:42:06.000000000 +0400
269 +++ linux-2.6.18.kgdb/MAINTAINERS 2008-06-10 16:18:58.000000000 +0400
270 @@ -1685,6 +1685,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 -rupN -X ../client-cleanup/dontdiff linux-2.6.18/Makefile linux-2.6.18.kgdb/Makefile
287 --- linux-2.6.18/Makefile 2006-09-20 07:42:06.000000000 +0400
288 +++ linux-2.6.18.kgdb/Makefile 2008-06-10 16:19:57.000000000 +0400
289 @@ -990,6 +990,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 @@ -1416,7 +1417,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 -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/arm/kernel/Makefile linux-2.6.18.kgdb/arch/arm/kernel/Makefile
311 --- linux-2.6.18/arch/arm/kernel/Makefile 2006-09-20 07:42:06.000000000 +0400
312 +++ linux-2.6.18.kgdb/arch/arm/kernel/Makefile 2008-06-10 16:19:51.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 -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/arm/kernel/entry-armv.S linux-2.6.18.kgdb/arch/arm/kernel/entry-armv.S
322 --- linux-2.6.18/arch/arm/kernel/entry-armv.S 2006-09-20 07:42:06.000000000 +0400
323 +++ linux-2.6.18.kgdb/arch/arm/kernel/entry-armv.S 2008-06-10 16:19:58.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 -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/arm/kernel/kgdb-jmp.S linux-2.6.18.kgdb/arch/arm/kernel/kgdb-jmp.S
341 --- linux-2.6.18/arch/arm/kernel/kgdb-jmp.S 1970-01-01 03:00:00.000000000 +0300
342 +++ linux-2.6.18.kgdb/arch/arm/kernel/kgdb-jmp.S 2008-06-10 16:19:51.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 -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/arm/kernel/kgdb.c linux-2.6.18.kgdb/arch/arm/kernel/kgdb.c
377 --- linux-2.6.18/arch/arm/kernel/kgdb.c 1970-01-01 03:00:00.000000000 +0300
378 +++ linux-2.6.18.kgdb/arch/arm/kernel/kgdb.c 2008-06-10 16:19:51.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 -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/arm/kernel/setup.c linux-2.6.18.kgdb/arch/arm/kernel/setup.c
589 --- linux-2.6.18/arch/arm/kernel/setup.c 2006-09-20 07:42:06.000000000 +0400
590 +++ linux-2.6.18.kgdb/arch/arm/kernel/setup.c 2008-06-10 16:19:51.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 -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/arm/kernel/traps.c linux-2.6.18.kgdb/arch/arm/kernel/traps.c
604 --- linux-2.6.18/arch/arm/kernel/traps.c 2006-09-20 07:42:06.000000000 +0400
605 +++ linux-2.6.18.kgdb/arch/arm/kernel/traps.c 2008-06-10 16:19:51.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 -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/arm/mach-ixp2000/core.c linux-2.6.18.kgdb/arch/arm/mach-ixp2000/core.c
645 --- linux-2.6.18/arch/arm/mach-ixp2000/core.c 2006-09-20 07:42:06.000000000 +0400
646 +++ linux-2.6.18.kgdb/arch/arm/mach-ixp2000/core.c 2008-06-10 16:19:51.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 -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/arm/mach-ixp2000/ixdp2x01.c linux-2.6.18.kgdb/arch/arm/mach-ixp2000/ixdp2x01.c
666 --- linux-2.6.18/arch/arm/mach-ixp2000/ixdp2x01.c 2006-09-20 07:42:06.000000000 +0400
667 +++ linux-2.6.18.kgdb/arch/arm/mach-ixp2000/ixdp2x01.c 2008-06-10 16:19:51.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 -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/arm/mach-ixp4xx/coyote-setup.c linux-2.6.18.kgdb/arch/arm/mach-ixp4xx/coyote-setup.c
689 --- linux-2.6.18/arch/arm/mach-ixp4xx/coyote-setup.c 2006-09-20 07:42:06.000000000 +0400
690 +++ linux-2.6.18.kgdb/arch/arm/mach-ixp4xx/coyote-setup.c 2008-06-10 16:19:51.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 -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/arm/mach-ixp4xx/ixdp425-setup.c linux-2.6.18.kgdb/arch/arm/mach-ixp4xx/ixdp425-setup.c
703 --- linux-2.6.18/arch/arm/mach-ixp4xx/ixdp425-setup.c 2006-09-20 07:42:06.000000000 +0400
704 +++ linux-2.6.18.kgdb/arch/arm/mach-ixp4xx/ixdp425-setup.c 2008-06-10 16:19:51.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 -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/arm/mach-omap1/serial.c linux-2.6.18.kgdb/arch/arm/mach-omap1/serial.c
746 --- linux-2.6.18/arch/arm/mach-omap1/serial.c 2006-09-20 07:42:06.000000000 +0400
747 +++ linux-2.6.18.kgdb/arch/arm/mach-omap1/serial.c 2008-06-10 16:19:51.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 -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/arm/mach-pxa/Makefile linux-2.6.18.kgdb/arch/arm/mach-pxa/Makefile
767 --- linux-2.6.18/arch/arm/mach-pxa/Makefile 2006-09-20 07:42:06.000000000 +0400
768 +++ linux-2.6.18.kgdb/arch/arm/mach-pxa/Makefile 2008-06-10 16:19:51.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 -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/arm/mach-pxa/kgdb-serial.c linux-2.6.18.kgdb/arch/arm/mach-pxa/kgdb-serial.c
778 --- linux-2.6.18/arch/arm/mach-pxa/kgdb-serial.c 1970-01-01 03:00:00.000000000 +0300
779 +++ linux-2.6.18.kgdb/arch/arm/mach-pxa/kgdb-serial.c 2008-06-10 16:19:51.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 -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/arm/mach-versatile/kgdb_serial.c linux-2.6.18.kgdb/arch/arm/mach-versatile/kgdb_serial.c
880 --- linux-2.6.18/arch/arm/mach-versatile/kgdb_serial.c 1970-01-01 03:00:00.000000000 +0300
881 +++ linux-2.6.18.kgdb/arch/arm/mach-versatile/kgdb_serial.c 2008-06-10 16:19:51.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 -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/arm/mm/extable.c linux-2.6.18.kgdb/arch/arm/mm/extable.c
1005 --- linux-2.6.18/arch/arm/mm/extable.c 2006-09-20 07:42:06.000000000 +0400
1006 +++ linux-2.6.18.kgdb/arch/arm/mm/extable.c 2008-06-10 16:19:51.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 -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/i386/kernel/Makefile linux-2.6.18.kgdb/arch/i386/kernel/Makefile
1029 --- linux-2.6.18/arch/i386/kernel/Makefile 2006-09-20 07:42:06.000000000 +0400
1030 +++ linux-2.6.18.kgdb/arch/i386/kernel/Makefile 2008-06-10 16:19:17.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 -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/i386/kernel/entry.S linux-2.6.18.kgdb/arch/i386/kernel/entry.S
1040 --- linux-2.6.18/arch/i386/kernel/entry.S 2006-09-20 07:42:06.000000000 +0400
1041 +++ linux-2.6.18.kgdb/arch/i386/kernel/entry.S 2008-06-10 16:19:58.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 @@ -664,7 +664,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 @@ -909,7 +909,7 @@ ENTRY(machine_check)
1064 -ENTRY(spurious_interrupt_bug)
1065 +KPROBE_ENTRY(spurious_interrupt_bug)
1068 CFI_ADJUST_CFA_OFFSET 4
1069 @@ -953,3 +953,108 @@ ENDPROC(arch_unwind_init_running)
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 -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/i386/kernel/head.S linux-2.6.18.kgdb/arch/i386/kernel/head.S
1179 --- linux-2.6.18/arch/i386/kernel/head.S 2006-09-20 07:42:06.000000000 +0400
1180 +++ linux-2.6.18.kgdb/arch/i386/kernel/head.S 2008-06-10 16:19:58.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 @@ -326,6 +327,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 -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/i386/kernel/kgdb-jmp.S linux-2.6.18.kgdb/arch/i386/kernel/kgdb-jmp.S
1201 --- linux-2.6.18/arch/i386/kernel/kgdb-jmp.S 1970-01-01 03:00:00.000000000 +0300
1202 +++ linux-2.6.18.kgdb/arch/i386/kernel/kgdb-jmp.S 2008-06-10 16:19:17.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 -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/i386/kernel/kgdb.c linux-2.6.18.kgdb/arch/i386/kernel/kgdb.c
1279 --- linux-2.6.18/arch/i386/kernel/kgdb.c 1970-01-01 03:00:00.000000000 +0300
1280 +++ linux-2.6.18.kgdb/arch/i386/kernel/kgdb.c 2008-06-10 16:20:15.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 -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/i386/kernel/process.c linux-2.6.18.kgdb/arch/i386/kernel/process.c
1646 --- linux-2.6.18/arch/i386/kernel/process.c 2006-09-20 07:42:06.000000000 +0400
1647 +++ linux-2.6.18.kgdb/arch/i386/kernel/process.c 2008-06-10 16:19:58.000000000 +0400
1648 @@ -328,7 +328,27 @@ __asm__(".section .text\n"
1652 + "kernel_thread_helper_end:\n\t"
1655 +#include <linux/dwarf2-lang.h>
1657 + /* This dwarf code tells gdb that this is the end of the unwind */
1658 + /* This uses the CFA set up for pc=1 located in entry.S */
1664 + CFI_preamble(dwarf_4,_PC,1,1)
1665 + CFA_define_reference(_ESP,0) /* Stack pointer */
1666 + CFA_undefine_reg(_EIP)
1669 + FDE_preamble(dwarf_4,kernel_thread_helper,kernel_thread_helper_end)
1675 * Create a kernel thread
1676 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/i386/kernel/setup.c linux-2.6.18.kgdb/arch/i386/kernel/setup.c
1677 --- linux-2.6.18/arch/i386/kernel/setup.c 2006-09-20 07:42:06.000000000 +0400
1678 +++ linux-2.6.18.kgdb/arch/i386/kernel/setup.c 2008-06-10 16:19:17.000000000 +0400
1679 @@ -148,6 +148,7 @@ EXPORT_SYMBOL(ist_info);
1680 struct e820map e820;
1682 extern void early_cpu_init(void);
1683 +extern void early_trap_init(void);
1684 extern void generic_apic_probe(char *);
1685 extern int root_mountflags;
1687 @@ -1444,6 +1445,7 @@ void __init setup_arch(char **cmdline_p)
1688 memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data));
1689 pre_setup_arch_hook();
1691 + early_trap_init();
1694 * FIXME: This isn't an official loader_type right
1695 @@ -1500,6 +1502,7 @@ void __init setup_arch(char **cmdline_p)
1696 data_resource.end = virt_to_phys(_edata)-1;
1698 parse_cmdline_early(cmdline_p);
1699 + parse_early_param();
1701 #ifdef CONFIG_EARLY_PRINTK
1703 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/i386/kernel/smpboot.c linux-2.6.18.kgdb/arch/i386/kernel/smpboot.c
1704 --- linux-2.6.18/arch/i386/kernel/smpboot.c 2006-09-20 07:42:06.000000000 +0400
1705 +++ linux-2.6.18.kgdb/arch/i386/kernel/smpboot.c 2008-06-10 16:19:58.000000000 +0400
1706 @@ -592,6 +592,9 @@ void __devinit initialize_secondary(void
1711 + "pushl end_of_stack_stop_unwind_function\n\t"
1715 :"r" (current->thread.esp),"r" (current->thread.eip));
1716 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/i386/kernel/traps.c linux-2.6.18.kgdb/arch/i386/kernel/traps.c
1717 --- linux-2.6.18/arch/i386/kernel/traps.c 2006-09-20 07:42:06.000000000 +0400
1718 +++ linux-2.6.18.kgdb/arch/i386/kernel/traps.c 2008-06-10 16:19:17.000000000 +0400
1719 @@ -863,6 +863,7 @@ fastcall void __kprobes do_debug(struct
1723 + notify_die(DIE_DEBUG, "debug2", regs, condition, error_code, SIGTRAP);
1727 @@ -1167,6 +1168,12 @@ static void __init set_task_gate(unsigne
1728 _set_gate(idt_table+n,5,0,0,(gdt_entry<<3));
1731 +/* Some traps need to be set early. */
1732 +void __init early_trap_init(void) {
1733 + set_intr_gate(1,&debug);
1734 + set_system_intr_gate(3, &int3); /* int3 can be called from all */
1735 + set_intr_gate(14,&page_fault);
1738 void __init trap_init(void)
1740 @@ -1183,10 +1190,8 @@ void __init trap_init(void)
1743 set_trap_gate(0,÷_error);
1744 - set_intr_gate(1,&debug);
1745 set_intr_gate(2,&nmi);
1746 - set_system_intr_gate(3, &int3); /* int3/4 can be called from all */
1747 - set_system_gate(4,&overflow);
1748 + set_system_gate(4,&overflow); /* int4/5 can be called from all */
1749 set_trap_gate(5,&bounds);
1750 set_trap_gate(6,&invalid_op);
1751 set_trap_gate(7,&device_not_available);
1752 @@ -1196,7 +1201,6 @@ void __init trap_init(void)
1753 set_trap_gate(11,&segment_not_present);
1754 set_trap_gate(12,&stack_segment);
1755 set_trap_gate(13,&general_protection);
1756 - set_intr_gate(14,&page_fault);
1757 set_trap_gate(15,&spurious_interrupt_bug);
1758 set_trap_gate(16,&coprocessor_error);
1759 set_trap_gate(17,&alignment_check);
1760 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/i386/mm/fault.c linux-2.6.18.kgdb/arch/i386/mm/fault.c
1761 --- linux-2.6.18/arch/i386/mm/fault.c 2006-09-20 07:42:06.000000000 +0400
1762 +++ linux-2.6.18.kgdb/arch/i386/mm/fault.c 2008-06-10 16:19:17.000000000 +0400
1763 @@ -539,6 +539,10 @@ no_context:
1764 if (is_prefetch(regs, address, error_code))
1767 + if (notify_die(DIE_PAGE_FAULT_NO_CONTEXT, "no context", regs,
1768 + error_code, 14, SIGSEGV) == NOTIFY_STOP)
1772 * Oops. The kernel tried to access some bad page. We'll have to
1773 * terminate things with extreme prejudice.
1774 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ia64/kernel/Makefile linux-2.6.18.kgdb/arch/ia64/kernel/Makefile
1775 --- linux-2.6.18/arch/ia64/kernel/Makefile 2006-09-20 07:42:06.000000000 +0400
1776 +++ linux-2.6.18.kgdb/arch/ia64/kernel/Makefile 2008-06-10 16:19:32.000000000 +0400
1777 @@ -31,6 +31,7 @@ obj-$(CONFIG_KPROBES) += kprobes.o jpro
1778 obj-$(CONFIG_IA64_UNCACHED_ALLOCATOR) += uncached.o
1779 obj-$(CONFIG_AUDIT) += audit.o
1780 mca_recovery-y += mca_drv.o mca_drv_asm.o
1781 +obj-$(CONFIG_KGDB) += kgdb.o kgdb-jmp.o
1783 # The gate DSO image is built using a special linker script.
1784 targets += gate.so gate-syms.o
1785 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ia64/kernel/entry.S linux-2.6.18.kgdb/arch/ia64/kernel/entry.S
1786 --- linux-2.6.18/arch/ia64/kernel/entry.S 2006-09-20 07:42:06.000000000 +0400
1787 +++ linux-2.6.18.kgdb/arch/ia64/kernel/entry.S 2008-06-10 16:20:23.000000000 +0400
1788 @@ -953,9 +953,9 @@ GLOBAL_ENTRY(ia64_leave_kernel)
1789 shr.u r18=r19,16 // get byte size of existing "dirty" partition
1791 mov r16=ar.bsp // get existing backing store pointer
1792 - addl r17=THIS_CPU(ia64_phys_stacked_size_p8),r0
1793 +(pUStk) addl r17=THIS_CPU(ia64_phys_stacked_size_p8),r0
1795 - ld4 r17=[r17] // r17 = cpu_data->phys_stacked_size_p8
1796 +(pUStk) ld4 r17=[r17] // r17 = cpu_data->phys_stacked_size_p8
1797 (pKStk) br.cond.dpnt skip_rbs_switch
1800 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ia64/kernel/ivt.S linux-2.6.18.kgdb/arch/ia64/kernel/ivt.S
1801 --- linux-2.6.18/arch/ia64/kernel/ivt.S 2006-09-20 07:42:06.000000000 +0400
1802 +++ linux-2.6.18.kgdb/arch/ia64/kernel/ivt.S 2008-06-10 16:20:23.000000000 +0400
1804 #include <asm/unistd.h>
1805 #include <asm/errno.h>
1808 +#define KGDB_ENABLE_PSR_DB mov r31=psr;; movl r30=IA64_PSR_DB;; \
1809 + or r31=r31,r30;; \
1810 + mov psr.l=r31;; srlz.i;;
1812 +#define KGDB_ENABLE_PSR_DB
1816 # define PSR_DEFAULT_BITS psr.ac
1818 @@ -519,6 +527,7 @@ ENTRY(page_fault)
1819 movl r14=ia64_leave_kernel
1822 + KGDB_ENABLE_PSR_DB
1825 adds out2=16,r12 // out2 = pointer to pt_regs
1826 @@ -863,6 +872,7 @@ ENTRY(interrupt)
1827 srlz.i // ensure everybody knows psr.ic is back on
1830 + KGDB_ENABLE_PSR_DB
1832 MCA_RECOVER_RANGE(interrupt)
1833 alloc r14=ar.pfs,0,0,2,0 // must be first in an insn group
1834 @@ -1110,6 +1120,7 @@ ENTRY(non_syscall)
1835 movl r15=ia64_leave_kernel
1838 + KGDB_ENABLE_PSR_DB
1841 br.call.sptk.many b6=ia64_bad_break // avoid WAW on CFM and ignore return addr
1842 @@ -1143,6 +1154,7 @@ ENTRY(dispatch_unaligned_handler)
1843 adds r3=8,r2 // set up second base pointer
1846 + KGDB_ENABLE_PSR_DB
1847 movl r14=ia64_leave_kernel
1850 @@ -1185,6 +1197,10 @@ ENTRY(dispatch_to_fault_handler)
1851 adds r3=8,r2 // set up second base pointer for SAVE_REST
1854 + cmp.eq p6,p0=29,out0
1855 +(p6) br.cond.spnt 1f;; // debug_vector
1856 + KGDB_ENABLE_PSR_DB
1858 movl r14=ia64_leave_kernel
1861 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ia64/kernel/kgdb-jmp.S linux-2.6.18.kgdb/arch/ia64/kernel/kgdb-jmp.S
1862 --- linux-2.6.18/arch/ia64/kernel/kgdb-jmp.S 1970-01-01 03:00:00.000000000 +0300
1863 +++ linux-2.6.18.kgdb/arch/ia64/kernel/kgdb-jmp.S 2008-06-10 16:19:32.000000000 +0400
1865 +/* setjmp() and longjmp() assembler support for kdb on ia64.
1867 + This code was copied from glibc CVS as of 2001-06-27 and modified where
1868 + necessary to fit the kernel.
1869 + Keith Owens <kaos@melbourne.sgi.com> 2001-06-27
1872 +/* Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
1873 + Contributed by David Mosberger-Tang <davidm@hpl.hp.com>.
1875 + The GNU C Library is free software; you can redistribute it and/or
1876 + modify it under the terms of the GNU Library General Public License as
1877 + published by the Free Software Foundation; either version 2 of the
1878 + License, or (at your option) any later version.
1880 + The GNU C Library is distributed in the hope that it will be useful,
1881 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1882 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1883 + Library General Public License for more details.
1885 + You should have received a copy of the GNU Library General Public
1886 + License along with the GNU C Library; see the file COPYING.LIB. If
1887 + not, write to the Free Software Foundation, Inc.,
1888 + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1891 +#include <asm/asmmacro.h>
1892 +GLOBAL_ENTRY(kgdb_fault_setjmp)
1893 + .prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(2)
1894 + alloc loc1=ar.pfs,2,2,2,0
1902 + st8.spill.nta [r2]=sp,16 // r12 (sp)
1904 + st8.spill.nta [r3]=gp,16 // r1 (gp)
1906 + st8.nta [r2]=r16,16 // save caller's unat
1907 + st8.nta [r3]=r17,16 // save fpsr
1911 + st8.spill.nta [r2]=r4,16 // r4
1913 + st8.spill.nta [r3]=r5,16 // r5
1916 + stf.spill.nta [r8]=f2,32
1917 + stf.spill.nta [r9]=f3,32
1921 + stf.spill.nta [r8]=f4,32
1922 + stf.spill.nta [r9]=f5,32
1925 + stf.spill.nta [r8]=f16,32
1926 + stf.spill.nta [r9]=f17,32
1929 + stf.spill.nta [r8]=f18,32
1930 + stf.spill.nta [r9]=f19,32
1933 + stf.spill.nta [r8]=f20,32
1934 + stf.spill.nta [r9]=f21,32
1937 + stf.spill.nta [r8]=f22,32
1938 + stf.spill.nta [r9]=f23,32
1941 + stf.spill.nta [r8]=f24,32
1942 + stf.spill.nta [r9]=f25,32
1945 + stf.spill.nta [r8]=f26,32
1946 + stf.spill.nta [r9]=f27,32
1949 + stf.spill.nta [r8]=f28,32
1950 + stf.spill.nta [r9]=f29,32
1952 + stf.spill.nta [r8]=f30
1953 + stf.spill.nta [r9]=f31
1956 + st8.spill.nta [r2]=r6,16 // r6
1958 + st8.spill.nta [r3]=r7,16 // r7
1962 + st8.nta [r2]=loc0,16 // b0
1963 + st8.nta [r3]=r17,16 // b1
1965 + st8.nta [r2]=r18,16 // b2
1966 + st8.nta [r3]=r19,16 // b3
1968 + st8.nta [r2]=r20,16 // b4
1969 + st8.nta [r3]=r21,16 // b5
1971 + st8.nta [r2]=loc1,16 // ar.pfs
1972 + st8.nta [r3]=r22,16 // ar.lc
1974 + st8.nta [r2]=r24,16 // pr
1975 + st8.nta [r3]=r23,16 // ar.bsp
1977 + st8.nta [r2]=r25 // ar.unat
1978 + st8.nta [r3]=in0 // &__jmp_buf
1982 + br.ret.sptk.few rp
1984 +#define pPos p6 /* is rotate count positive? */
1985 +#define pNeg p7 /* is rotate count negative? */
1986 +GLOBAL_ENTRY(kgdb_fault_longjmp)
1987 + alloc r8=ar.pfs,2,1,0,0
1989 + add r2=0x98,in0 // r2 <- &jmpbuf.orig_jmp_buf_addr
1991 + ld8 r8=[r2],-16 // r8 <- orig_jmp_buf_addr
1993 + and r11=~0x3,r27 // clear ar.rsc.mode
1995 + flushrs // flush dirty regs to backing store (must be first in insn grp)
1996 + ld8 r23=[r2],8 // r23 <- jmpbuf.ar_bsp
1997 + sub r8=r8,in0 // r8 <- &orig_jmpbuf - &jmpbuf
1999 + ld8 r25=[r2] // r25 <- jmpbuf.ar_unat
2000 + extr.u r8=r8,3,6 // r8 <- (&orig_jmpbuf - &jmpbuf)/8 & 0x3f
2002 + cmp.lt pNeg,pPos=r8,r0
2006 +(pNeg) add r16=64,r8
2007 +(pPos) sub r17=64,r8
2008 +(pNeg) sub r17=r0,r8
2010 + mov ar.rsc=r11 // put RSE in enforced lazy mode
2012 + add r3=8,in0 // r3 <- &jmpbuf.r1
2018 + mov ar.unat=r25 // setup ar.unat (NaT bits for r1, r4-r7, and r12)
2020 + ld8.fill.nta sp=[r2],16 // r12 (sp)
2021 + ld8.fill.nta gp=[r3],16 // r1 (gp)
2022 + dep r11=-1,r23,3,6 // r11 <- ia64_rse_rnat_addr(jmpbuf.ar_bsp)
2024 + ld8.nta r16=[r2],16 // caller's unat
2025 + ld8.nta r17=[r3],16 // fpsr
2027 + ld8.fill.nta r4=[r2],16 // r4
2028 + ld8.fill.nta r5=[r3],16 // r5 (gp)
2029 + cmp.geu p8,p0=r10,r11 // p8 <- (ar.bsp >= jmpbuf.ar_bsp)
2031 + ld8.fill.nta r6=[r2],16 // r6
2032 + ld8.fill.nta r7=[r3],16 // r7
2034 + mov ar.unat=r16 // restore caller's unat
2035 + mov ar.fpsr=r17 // restore fpsr
2037 + ld8.nta r16=[r2],16 // b0
2038 + ld8.nta r17=[r3],16 // b1
2040 +(p8) ld8 r26=[r11] // r26 <- *ia64_rse_rnat_addr(jmpbuf.ar_bsp)
2041 + mov ar.bspstore=r23 // restore ar.bspstore
2043 + ld8.nta r18=[r2],16 // b2
2044 + ld8.nta r19=[r3],16 // b3
2046 + ld8.nta r20=[r2],16 // b4
2047 + ld8.nta r21=[r3],16 // b5
2049 + ld8.nta r11=[r2],16 // ar.pfs
2050 + ld8.nta r22=[r3],56 // ar.lc
2052 + ld8.nta r24=[r2],32 // pr
2055 + ldf.fill.nta f2=[r2],32
2056 + ldf.fill.nta f3=[r3],32
2059 + ldf.fill.nta f4=[r2],32
2060 + ldf.fill.nta f5=[r3],32
2063 + ldf.fill.nta f16=[r2],32
2064 + ldf.fill.nta f17=[r3],32
2067 + ldf.fill.nta f18=[r2],32
2068 + ldf.fill.nta f19=[r3],32
2071 + ldf.fill.nta f20=[r2],32
2072 + ldf.fill.nta f21=[r3],32
2075 + ldf.fill.nta f22=[r2],32
2076 + ldf.fill.nta f23=[r3],32
2079 + ldf.fill.nta f24=[r2],32
2080 + ldf.fill.nta f25=[r3],32
2081 + cmp.eq p8,p9=0,in1
2083 + ldf.fill.nta f26=[r2],32
2084 + ldf.fill.nta f27=[r3],32
2087 + ldf.fill.nta f28=[r2],32
2088 + ldf.fill.nta f29=[r3],32
2090 + ldf.fill.nta f30=[r2]
2091 + ldf.fill.nta f31=[r3]
2094 + mov ar.rnat=r26 // restore ar.rnat
2096 + mov ar.rsc=r27 // restore ar.rsc
2099 + invala // virt. -> phys. regnum mapping may change
2101 + br.ret.sptk.few rp
2102 +END(kgdb_fault_longjmp)
2103 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ia64/kernel/kgdb.c linux-2.6.18.kgdb/arch/ia64/kernel/kgdb.c
2104 --- linux-2.6.18/arch/ia64/kernel/kgdb.c 1970-01-01 03:00:00.000000000 +0300
2105 +++ linux-2.6.18.kgdb/arch/ia64/kernel/kgdb.c 2008-06-10 16:19:32.000000000 +0400
2109 + * This program is free software; you can redistribute it and/or modify it
2110 + * under the terms of the GNU General Public License as published by the
2111 + * Free Software Foundation; either version 2, or (at your option) any
2114 + * This program is distributed in the hope that it will be useful, but
2115 + * WITHOUT ANY WARRANTY; without even the implied warranty of
2116 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2117 + * General Public License for more details.
2122 + * Copyright (C) 2000-2001 VERITAS Software Corporation.
2123 + * (c) Copyright 2005 Hewlett-Packard Development Company, L.P.
2124 + * Bob Picco <bob.picco@hp.com>
2127 + * Contributor: Lake Stevens Instrument Division$
2128 + * Written by: Glenn Engel $
2129 + * Updated by: Amit Kale<akale@veritas.com>
2130 + * Modified for 386 by Jim Kingdon, Cygnus Support.
2131 + * Origianl kgdb, compatibility with 2.1.xx kernel by David Grothe <dave@gcom.com>
2134 +#include <linux/string.h>
2135 +#include <linux/kernel.h>
2136 +#include <linux/sched.h>
2137 +#include <linux/smp.h>
2138 +#include <linux/spinlock.h>
2139 +#include <linux/delay.h>
2140 +#include <asm/system.h>
2141 +#include <asm/ptrace.h> /* for linux pt_regs struct */
2142 +#include <asm/unwind.h>
2143 +#include <asm/rse.h>
2144 +#include <linux/kgdb.h>
2145 +#include <linux/init.h>
2146 +#include <asm/cacheflush.h>
2147 +#include <asm/kdebug.h>
2149 +#define NUM_REGS 590
2150 +#define REGISTER_BYTES (NUM_REGS*8+128*8)
2151 +#define REGISTER_BYTE(N) (((N) * 8) \
2152 + + ((N) <= IA64_FR0_REGNUM ? \
2153 + 0 : 8 * (((N) > IA64_FR127_REGNUM) ? 128 : (N) - IA64_FR0_REGNUM)))
2154 +#define REGISTER_SIZE(N) \
2155 + (((N) >= IA64_FR0_REGNUM && (N) <= IA64_FR127_REGNUM) ? 16 : 8)
2156 +#define IA64_GR0_REGNUM 0
2157 +#define IA64_FR0_REGNUM 128
2158 +#define IA64_FR127_REGNUM (IA64_FR0_REGNUM+127)
2159 +#define IA64_PR0_REGNUM 256
2160 +#define IA64_BR0_REGNUM 320
2161 +#define IA64_VFP_REGNUM 328
2162 +#define IA64_PR_REGNUM 330
2163 +#define IA64_IP_REGNUM 331
2164 +#define IA64_PSR_REGNUM 332
2165 +#define IA64_CFM_REGNUM 333
2166 +#define IA64_AR0_REGNUM 334
2167 +#define IA64_NAT0_REGNUM 462
2168 +#define IA64_NAT31_REGNUM (IA64_NAT0_REGNUM+31)
2169 +#define IA64_NAT32_REGNUM (IA64_NAT0_REGNUM+32)
2170 +#define IA64_RSC_REGNUM (IA64_AR0_REGNUM+16)
2171 +#define IA64_BSP_REGNUM (IA64_AR0_REGNUM+17)
2172 +#define IA64_BSPSTORE_REGNUM (IA64_AR0_REGNUM+18)
2173 +#define IA64_RNAT_REGNUM (IA64_AR0_REGNUM+19)
2174 +#define IA64_FCR_REGNUM (IA64_AR0_REGNUM+21)
2175 +#define IA64_EFLAG_REGNUM (IA64_AR0_REGNUM+24)
2176 +#define IA64_CSD_REGNUM (IA64_AR0_REGNUM+25)
2177 +#define IA64_SSD_REGNUM (IA64_AR0_REGNUM+26)
2178 +#define IA64_CFLG_REGNUM (IA64_AR0_REGNUM+27)
2179 +#define IA64_FSR_REGNUM (IA64_AR0_REGNUM+28)
2180 +#define IA64_FIR_REGNUM (IA64_AR0_REGNUM+29)
2181 +#define IA64_FDR_REGNUM (IA64_AR0_REGNUM+30)
2182 +#define IA64_CCV_REGNUM (IA64_AR0_REGNUM+32)
2183 +#define IA64_UNAT_REGNUM (IA64_AR0_REGNUM+36)
2184 +#define IA64_FPSR_REGNUM (IA64_AR0_REGNUM+40)
2185 +#define IA64_ITC_REGNUM (IA64_AR0_REGNUM+44)
2186 +#define IA64_PFS_REGNUM (IA64_AR0_REGNUM+64)
2187 +#define IA64_LC_REGNUM (IA64_AR0_REGNUM+65)
2188 +#define IA64_EC_REGNUM (IA64_AR0_REGNUM+66)
2190 +#define REGISTER_INDEX(N) (REGISTER_BYTE(N) / sizeof (unsigned long))
2191 +#define BREAK_INSTR_ALIGN (~0xfULL)
2193 +#define ptoff(V) ((unsigned int) &((struct pt_regs *)0x0)->V)
2194 +struct reg_to_ptreg_index {
2196 + unsigned int ptregoff;
2199 +static struct reg_to_ptreg_index gr_reg_to_ptreg_index[] = {
2200 + {IA64_GR0_REGNUM + 1, ptoff(r1)},
2201 + {IA64_GR0_REGNUM + 2, ptoff(r2)},
2202 + {IA64_GR0_REGNUM + 3, ptoff(r3)},
2203 + {IA64_GR0_REGNUM + 8, ptoff(r8)},
2204 + {IA64_GR0_REGNUM + 9, ptoff(r9)},
2205 + {IA64_GR0_REGNUM + 10, ptoff(r10)},
2206 + {IA64_GR0_REGNUM + 11, ptoff(r11)},
2207 + {IA64_GR0_REGNUM + 12, ptoff(r12)},
2208 + {IA64_GR0_REGNUM + 13, ptoff(r13)},
2209 + {IA64_GR0_REGNUM + 14, ptoff(r14)},
2210 + {IA64_GR0_REGNUM + 15, ptoff(r15)},
2211 + {IA64_GR0_REGNUM + 16, ptoff(r16)},
2212 + {IA64_GR0_REGNUM + 17, ptoff(r17)},
2213 + {IA64_GR0_REGNUM + 18, ptoff(r18)},
2214 + {IA64_GR0_REGNUM + 19, ptoff(r19)},
2215 + {IA64_GR0_REGNUM + 20, ptoff(r20)},
2216 + {IA64_GR0_REGNUM + 21, ptoff(r21)},
2217 + {IA64_GR0_REGNUM + 22, ptoff(r22)},
2218 + {IA64_GR0_REGNUM + 23, ptoff(r23)},
2219 + {IA64_GR0_REGNUM + 24, ptoff(r24)},
2220 + {IA64_GR0_REGNUM + 25, ptoff(r25)},
2221 + {IA64_GR0_REGNUM + 26, ptoff(r26)},
2222 + {IA64_GR0_REGNUM + 27, ptoff(r27)},
2223 + {IA64_GR0_REGNUM + 28, ptoff(r28)},
2224 + {IA64_GR0_REGNUM + 29, ptoff(r29)},
2225 + {IA64_GR0_REGNUM + 30, ptoff(r30)},
2226 + {IA64_GR0_REGNUM + 31, ptoff(r31)},
2229 +static struct reg_to_ptreg_index br_reg_to_ptreg_index[] = {
2230 + {IA64_BR0_REGNUM, ptoff(b0)},
2231 + {IA64_BR0_REGNUM + 6, ptoff(b6)},
2232 + {IA64_BR0_REGNUM + 7, ptoff(b7)},
2235 +static struct reg_to_ptreg_index ar_reg_to_ptreg_index[] = {
2236 + {IA64_PFS_REGNUM, ptoff(ar_pfs)},
2237 + {IA64_UNAT_REGNUM, ptoff(ar_unat)},
2238 + {IA64_RNAT_REGNUM, ptoff(ar_rnat)},
2239 + {IA64_BSPSTORE_REGNUM, ptoff(ar_bspstore)},
2240 + {IA64_RSC_REGNUM, ptoff(ar_rsc)},
2241 + {IA64_CSD_REGNUM, ptoff(ar_csd)},
2242 + {IA64_SSD_REGNUM, ptoff(ar_ssd)},
2243 + {IA64_FPSR_REGNUM, ptoff(ar_fpsr)},
2244 + {IA64_CCV_REGNUM, ptoff(ar_ccv)},
2247 +extern atomic_t cpu_doing_single_step;
2249 +static int kgdb_gr_reg(int regnum, struct unw_frame_info *info,
2250 + unsigned long *reg, int rw)
2254 + if ((regnum >= IA64_GR0_REGNUM && regnum <= (IA64_GR0_REGNUM + 1)) ||
2255 + (regnum >= (IA64_GR0_REGNUM + 4) &&
2256 + regnum <= (IA64_GR0_REGNUM + 7)))
2257 + return !unw_access_gr(info, regnum - IA64_GR0_REGNUM,
2262 +static int kgdb_gr_ptreg(int regnum, struct pt_regs * ptregs,
2263 + struct unw_frame_info *info, unsigned long *reg, int rw)
2265 + int i, result = 1;
2268 + if (!((regnum >= (IA64_GR0_REGNUM + 2) &&
2269 + regnum <= (IA64_GR0_REGNUM + 3)) ||
2270 + (regnum >= (IA64_GR0_REGNUM + 8) &&
2271 + regnum <= (IA64_GR0_REGNUM + 15)) ||
2272 + (regnum >= (IA64_GR0_REGNUM + 16) &&
2273 + regnum <= (IA64_GR0_REGNUM + 31))))
2275 + else if (rw && ptregs) {
2276 + for (i = 0; i < ARRAY_SIZE(gr_reg_to_ptreg_index); i++)
2277 + if (gr_reg_to_ptreg_index[i].reg == regnum) {
2278 + *((unsigned long *)(((void *)ptregs) +
2279 + gr_reg_to_ptreg_index[i].ptregoff)) = *reg;
2282 + } else if (!rw && ptregs) {
2283 + for (i = 0; i < ARRAY_SIZE(gr_reg_to_ptreg_index); i++)
2284 + if (gr_reg_to_ptreg_index[i].reg == regnum) {
2285 + *reg = *((unsigned long *)
2286 + (((void *)ptregs) +
2287 + gr_reg_to_ptreg_index[i].ptregoff));
2291 + result = !unw_access_gr(info, regnum - IA64_GR0_REGNUM,
2296 +static int kgdb_br_reg(int regnum, struct pt_regs * ptregs,
2297 + struct unw_frame_info *info, unsigned long *reg, int rw)
2299 + int i, result = 1;
2301 + if (!(regnum >= IA64_BR0_REGNUM && regnum <= (IA64_BR0_REGNUM + 7)))
2305 + case IA64_BR0_REGNUM:
2306 + case IA64_BR0_REGNUM + 6:
2307 + case IA64_BR0_REGNUM + 7:
2309 + for (i = 0; i < ARRAY_SIZE(br_reg_to_ptreg_index); i++)
2310 + if (br_reg_to_ptreg_index[i].reg == regnum) {
2311 + *((unsigned long *)
2312 + (((void *)ptregs) +
2313 + br_reg_to_ptreg_index[i].ptregoff)) =
2318 + for (i = 0; i < ARRAY_SIZE(br_reg_to_ptreg_index); i++)
2319 + if (br_reg_to_ptreg_index[i].reg == regnum) {
2320 + *reg = *((unsigned long *)
2321 + (((void *)ptregs) +
2322 + br_reg_to_ptreg_index[i].
2327 + case IA64_BR0_REGNUM + 1:
2328 + case IA64_BR0_REGNUM + 2:
2329 + case IA64_BR0_REGNUM + 3:
2330 + case IA64_BR0_REGNUM + 4:
2331 + case IA64_BR0_REGNUM + 5:
2332 + result = !unw_access_br(info, regnum - IA64_BR0_REGNUM,
2340 +static int kgdb_fr_reg(int regnum, char *inbuffer, struct pt_regs * ptregs,
2341 + struct unw_frame_info *info, unsigned long *reg,
2342 + struct ia64_fpreg *freg, int rw)
2346 + if (!(regnum >= IA64_FR0_REGNUM && regnum <= (IA64_FR0_REGNUM + 127)))
2350 + case IA64_FR0_REGNUM + 6:
2351 + case IA64_FR0_REGNUM + 7:
2352 + case IA64_FR0_REGNUM + 8:
2353 + case IA64_FR0_REGNUM + 9:
2354 + case IA64_FR0_REGNUM + 10:
2355 + case IA64_FR0_REGNUM + 11:
2356 + case IA64_FR0_REGNUM + 12:
2358 + char *ptr = inbuffer;
2360 + freg->u.bits[0] = *reg;
2361 + kgdb_hex2long(&ptr, &freg->u.bits[1]);
2362 + *(&ptregs->f6 + (regnum - (IA64_FR0_REGNUM + 6))) =
2365 + } else if (!ptregs)
2366 + result = !unw_access_fr(info, regnum - IA64_FR0_REGNUM,
2370 + *(&ptregs->f6 + (regnum - (IA64_FR0_REGNUM + 6)));
2374 + result = !unw_access_fr(info, regnum - IA64_FR0_REGNUM,
2384 +static int kgdb_ar_reg(int regnum, struct pt_regs * ptregs,
2385 + struct unw_frame_info *info, unsigned long *reg, int rw)
2387 + int result = 0, i;
2389 + if (!(regnum >= IA64_AR0_REGNUM && regnum <= IA64_EC_REGNUM))
2392 + if (rw && ptregs) {
2393 + for (i = 0; i < ARRAY_SIZE(ar_reg_to_ptreg_index); i++)
2394 + if (ar_reg_to_ptreg_index[i].reg == regnum) {
2395 + *((unsigned long *) (((void *)ptregs) +
2396 + ar_reg_to_ptreg_index[i].ptregoff)) =
2401 + } else if (ptregs) {
2402 + for (i = 0; i < ARRAY_SIZE(ar_reg_to_ptreg_index); i++)
2403 + if (ar_reg_to_ptreg_index[i].reg == regnum) {
2404 + *reg = *((unsigned long *) (((void *)ptregs) +
2405 + ar_reg_to_ptreg_index[i].ptregoff));
2417 + case IA64_CSD_REGNUM:
2418 + result = !unw_access_ar(info, UNW_AR_CSD, reg, rw);
2420 + case IA64_SSD_REGNUM:
2421 + result = !unw_access_ar(info, UNW_AR_SSD, reg, rw);
2423 + case IA64_UNAT_REGNUM:
2424 + result = !unw_access_ar(info, UNW_AR_RNAT, reg, rw);
2426 + case IA64_RNAT_REGNUM:
2427 + result = !unw_access_ar(info, UNW_AR_RNAT, reg, rw);
2429 + case IA64_BSPSTORE_REGNUM:
2430 + result = !unw_access_ar(info, UNW_AR_RNAT, reg, rw);
2432 + case IA64_PFS_REGNUM:
2433 + result = !unw_access_ar(info, UNW_AR_RNAT, reg, rw);
2435 + case IA64_LC_REGNUM:
2436 + result = !unw_access_ar(info, UNW_AR_LC, reg, rw);
2438 + case IA64_EC_REGNUM:
2439 + result = !unw_access_ar(info, UNW_AR_EC, reg, rw);
2441 + case IA64_FPSR_REGNUM:
2442 + result = !unw_access_ar(info, UNW_AR_FPSR, reg, rw);
2444 + case IA64_RSC_REGNUM:
2445 + result = !unw_access_ar(info, UNW_AR_RSC, reg, rw);
2447 + case IA64_CCV_REGNUM:
2448 + result = !unw_access_ar(info, UNW_AR_CCV, reg, rw);
2457 +void kgdb_get_reg(char *outbuffer, int regnum, struct unw_frame_info *info,
2458 + struct pt_regs *ptregs)
2460 + unsigned long reg, size = 0, *mem = ®
2461 + struct ia64_fpreg freg;
2463 + if (kgdb_gr_reg(regnum, info, ®, 0) ||
2464 + kgdb_gr_ptreg(regnum, ptregs, info, ®, 0) ||
2465 + kgdb_br_reg(regnum, ptregs, info, ®, 0) ||
2466 + kgdb_ar_reg(regnum, ptregs, info, ®, 0))
2467 + size = sizeof(reg);
2468 + else if (kgdb_fr_reg(regnum, NULL, ptregs, info, ®, &freg, 0)) {
2469 + size = sizeof(freg);
2470 + mem = (unsigned long *)&freg;
2471 + } else if (regnum == IA64_IP_REGNUM) {
2473 + unw_get_ip(info, ®);
2474 + size = sizeof(reg);
2476 + reg = ptregs->cr_iip;
2477 + size = sizeof(reg);
2479 + } else if (regnum == IA64_CFM_REGNUM) {
2481 + unw_get_cfm(info, ®);
2483 + reg = ptregs->cr_ifs;
2484 + size = sizeof(reg);
2485 + } else if (regnum == IA64_PSR_REGNUM) {
2486 + if (!ptregs && kgdb_usethread)
2487 + ptregs = (struct pt_regs *)
2488 + ((unsigned long)kgdb_usethread +
2489 + IA64_STK_OFFSET) - 1;
2491 + reg = ptregs->cr_ipsr;
2492 + size = sizeof(reg);
2493 + } else if (regnum == IA64_PR_REGNUM) {
2497 + unw_access_pr(info, ®, 0);
2498 + size = sizeof(reg);
2499 + } else if (regnum == IA64_BSP_REGNUM) {
2500 + unw_get_bsp(info, ®);
2501 + size = sizeof(reg);
2505 + kgdb_mem2hex((char *) mem, outbuffer, size);
2506 + outbuffer[size*2] = 0;
2509 + strcpy(outbuffer, "E0");
2514 +void kgdb_put_reg(char *inbuffer, char *outbuffer, int regnum,
2515 + struct unw_frame_info *info, struct pt_regs *ptregs)
2517 + unsigned long reg;
2518 + struct ia64_fpreg freg;
2519 + char *ptr = inbuffer;
2521 + kgdb_hex2long(&ptr, ®);
2522 + strcpy(outbuffer, "OK");
2524 + if (kgdb_gr_reg(regnum, info, ®, 1) ||
2525 + kgdb_gr_ptreg(regnum, ptregs, info, ®, 1) ||
2526 + kgdb_br_reg(regnum, ptregs, info, ®, 1) ||
2527 + kgdb_fr_reg(regnum, inbuffer, ptregs, info, ®, &freg, 1) ||
2528 + kgdb_ar_reg(regnum, ptregs, info, ®, 1)) ;
2529 + else if (regnum == IA64_IP_REGNUM)
2530 + ptregs->cr_iip = reg;
2531 + else if (regnum == IA64_CFM_REGNUM)
2532 + ptregs->cr_ifs = reg;
2533 + else if (regnum == IA64_PSR_REGNUM)
2534 + ptregs->cr_ipsr = reg;
2535 + else if (regnum == IA64_PR_REGNUM)
2538 + strcpy(outbuffer, "E01");
2542 +void regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs)
2546 +void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p)
2550 +void gdb_regs_to_regs(unsigned long *gdb_regs, struct pt_regs *regs)
2555 +#define MAX_HW_BREAKPOINT (20)
2556 +long hw_break_total_dbr, hw_break_total_ibr;
2557 +#define HW_BREAKPOINT (hw_break_total_dbr + hw_break_total_ibr)
2558 +#define WATCH_INSTRUCTION 0x0
2559 +#define WATCH_WRITE 0x1
2560 +#define WATCH_READ 0x2
2561 +#define WATCH_ACCESS 0x3
2563 +#define HWCAP_DBR ((1 << WATCH_WRITE) | (1 << WATCH_READ))
2564 +#define HWCAP_IBR (1 << WATCH_INSTRUCTION)
2565 +struct hw_breakpoint {
2567 + unsigned long capable;
2568 + unsigned long type;
2569 + unsigned long mask;
2570 + unsigned long addr;
2573 +static struct hw_breakpoint hwbreaks[MAX_HW_BREAKPOINT];
2575 +enum instruction_type { A, I, M, F, B, L, X, u };
2577 +static enum instruction_type bundle_encoding[32][3] = {
2578 + {M, I, I}, /* 00 */
2579 + {M, I, I}, /* 01 */
2580 + {M, I, I}, /* 02 */
2581 + {M, I, I}, /* 03 */
2582 + {M, L, X}, /* 04 */
2583 + {M, L, X}, /* 05 */
2584 + {u, u, u}, /* 06 */
2585 + {u, u, u}, /* 07 */
2586 + {M, M, I}, /* 08 */
2587 + {M, M, I}, /* 09 */
2588 + {M, M, I}, /* 0A */
2589 + {M, M, I}, /* 0B */
2590 + {M, F, I}, /* 0C */
2591 + {M, F, I}, /* 0D */
2592 + {M, M, F}, /* 0E */
2593 + {M, M, F}, /* 0F */
2594 + {M, I, B}, /* 10 */
2595 + {M, I, B}, /* 11 */
2596 + {M, B, B}, /* 12 */
2597 + {M, B, B}, /* 13 */
2598 + {u, u, u}, /* 14 */
2599 + {u, u, u}, /* 15 */
2600 + {B, B, B}, /* 16 */
2601 + {B, B, B}, /* 17 */
2602 + {M, M, B}, /* 18 */
2603 + {M, M, B}, /* 19 */
2604 + {u, u, u}, /* 1A */
2605 + {u, u, u}, /* 1B */
2606 + {M, F, B}, /* 1C */
2607 + {M, F, B}, /* 1D */
2608 + {u, u, u}, /* 1E */
2609 + {u, u, u}, /* 1F */
2612 +int kgdb_validate_break_address(unsigned long addr)
2615 + char tmp_variable[BREAK_INSTR_SIZE];
2616 + error = kgdb_get_mem((char *)(addr & BREAK_INSTR_ALIGN), tmp_variable,
2617 + BREAK_INSTR_SIZE);
2621 +int kgdb_arch_set_breakpoint(unsigned long addr, char *saved_instr)
2623 + extern unsigned long _start[];
2624 + unsigned long slot = addr & BREAK_INSTR_ALIGN, bundle_addr;
2625 + unsigned long template;
2628 + unsigned long long template:5;
2629 + unsigned long long slot0:41;
2630 + unsigned long long slot1_p0:64 - 46;
2633 + unsigned long long slot1_p1:41 - (64 - 46);
2634 + unsigned long long slot2:41;
2639 + bundle_addr = addr & ~0xFULL;
2641 + if (bundle_addr == (unsigned long)_start)
2644 + ret = kgdb_get_mem((char *)bundle_addr, (char *)&bundle,
2645 + BREAK_INSTR_SIZE);
2652 + memcpy(saved_instr, &bundle, BREAK_INSTR_SIZE);
2653 + template = bundle.quad0.template;
2655 + if (slot == 1 && bundle_encoding[template][1] == L)
2660 + bundle.quad0.slot0 = BREAKNUM;
2663 + bundle.quad0.slot1_p0 = BREAKNUM;
2664 + bundle.quad1.slot1_p1 = (BREAKNUM >> (64 - 46));
2667 + bundle.quad1.slot2 = BREAKNUM;
2671 + return kgdb_set_mem((char *)bundle_addr, (char *)&bundle,
2672 + BREAK_INSTR_SIZE);
2675 +int kgdb_arch_remove_breakpoint(unsigned long addr, char *bundle)
2677 + extern unsigned long _start[];
2679 + addr = addr & BREAK_INSTR_ALIGN;
2680 + if (addr == (unsigned long)_start)
2682 + return kgdb_set_mem((char *)addr, (char *)bundle, BREAK_INSTR_SIZE);
2685 +static int hw_breakpoint_init;
2687 +void do_init_hw_break(void)
2692 + hw_breakpoint_init = 1;
2694 +#ifdef CONFIG_IA64_HP_SIM
2695 + hw_break_total_ibr = 8;
2696 + hw_break_total_dbr = 8;
2699 + status = ia64_pal_debug_info(&hw_break_total_ibr, &hw_break_total_dbr);
2703 + printk(KERN_INFO "do_init_hw_break: pal call failed %d\n",
2708 + if (HW_BREAKPOINT > MAX_HW_BREAKPOINT) {
2709 + printk(KERN_INFO "do_init_hw_break: %d exceeds max %d\n",
2710 + (int)HW_BREAKPOINT, (int)MAX_HW_BREAKPOINT);
2712 + while ((HW_BREAKPOINT > MAX_HW_BREAKPOINT)
2713 + && hw_break_total_ibr != 1)
2714 + hw_break_total_ibr--;
2715 + while (HW_BREAKPOINT > MAX_HW_BREAKPOINT)
2716 + hw_break_total_dbr--;
2719 + breakinfo = hwbreaks;
2721 + memset(breakinfo, 0, HW_BREAKPOINT * sizeof(struct hw_breakpoint));
2723 + for (i = 0; i < hw_break_total_dbr; i++)
2724 + breakinfo[i].capable = HWCAP_DBR;
2726 + for (; i < HW_BREAKPOINT; i++)
2727 + breakinfo[i].capable = HWCAP_IBR;
2732 +void kgdb_correct_hw_break(void)
2739 + for (breakno = 0; breakno < HW_BREAKPOINT; breakno++) {
2740 + if (breakinfo[breakno].enabled) {
2741 + if (breakinfo[breakno].capable & HWCAP_IBR) {
2742 + int ibreakno = breakno - hw_break_total_dbr;
2743 + ia64_set_ibr(ibreakno << 1,
2744 + breakinfo[breakno].addr);
2745 + ia64_set_ibr((ibreakno << 1) + 1,
2746 + (~breakinfo[breakno].mask &
2747 + ((1UL << 56UL) - 1)) |
2748 + (1UL << 56UL) | (1UL << 63UL));
2750 + ia64_set_dbr(breakno << 1,
2751 + breakinfo[breakno].addr);
2752 + ia64_set_dbr((breakno << 1) + 1,
2753 + (~breakinfo[breakno].
2754 + mask & ((1UL << 56UL) - 1)) |
2756 + (breakinfo[breakno].type << 62UL));
2759 + if (breakinfo[breakno].capable & HWCAP_IBR)
2760 + ia64_set_ibr(((breakno -
2761 + hw_break_total_dbr) << 1) + 1,
2764 + ia64_set_dbr((breakno << 1) + 1, 0);
2771 +int hardware_breakpoint(unsigned long addr, int length, int type, int action)
2773 + int breakno, found, watch;
2774 + unsigned long mask;
2775 + extern unsigned long _start[];
2777 + if (!hw_breakpoint_init)
2778 + do_init_hw_break();
2782 + else if (addr == (unsigned long)_start)
2785 + if (type == WATCH_ACCESS)
2788 + mask = 1UL << type;
2790 + for (watch = 0, found = 0, breakno = 0; breakno < HW_BREAKPOINT;
2793 + if (breakinfo[breakno].enabled
2794 + || !(breakinfo[breakno].capable & mask))
2796 + breakinfo[breakno].enabled = 1;
2797 + breakinfo[breakno].type = type;
2798 + breakinfo[breakno].mask = length - 1;
2799 + breakinfo[breakno].addr = addr;
2801 + } else if (breakinfo[breakno].enabled &&
2802 + ((length < 0 && breakinfo[breakno].addr == addr) ||
2803 + ((breakinfo[breakno].capable & mask) &&
2804 + (breakinfo[breakno].mask == (length - 1)) &&
2805 + (breakinfo[breakno].addr == addr)))) {
2806 + breakinfo[breakno].enabled = 0;
2807 + breakinfo[breakno].type = 0UL;
2811 + if (type != WATCH_ACCESS)
2813 + else if (found == 2)
2819 + if (type == WATCH_ACCESS && found == 1) {
2820 + breakinfo[watch].enabled = 0;
2828 +int kgdb_arch_set_hw_breakpoint(unsigned long addr, int len,
2829 + enum kgdb_bptype type)
2831 + return hardware_breakpoint(addr, len, type - '1', 1);
2834 +int kgdb_arch_remove_hw_breakpoint(unsigned long addr, int len,
2835 + enum kgdb_bptype type)
2837 + return hardware_breakpoint(addr, len, type - '1', 0);
2840 +int kgdb_remove_hw_break(unsigned long addr)
2842 + return hardware_breakpoint(addr, 8, WATCH_INSTRUCTION, 0);
2846 +void kgdb_remove_all_hw_break(void)
2850 + for (i = 0; i < HW_BREAKPOINT; i++)
2851 + memset(&breakinfo[i], 0, sizeof(struct hw_breakpoint));
2854 +int kgdb_set_hw_break(unsigned long addr)
2856 + return hardware_breakpoint(addr, 8, WATCH_INSTRUCTION, 1);
2859 +void kgdb_disable_hw_debug(struct pt_regs *regs)
2861 + unsigned long hw_breakpoint_status;
2863 + hw_breakpoint_status = ia64_getreg(_IA64_REG_PSR);
2864 + if (hw_breakpoint_status & IA64_PSR_DB)
2865 + ia64_setreg(_IA64_REG_PSR_L,
2866 + hw_breakpoint_status ^ IA64_PSR_DB);
2869 +volatile static struct smp_unw {
2870 + struct unw_frame_info *unw;
2871 + struct task_struct *task;
2872 +} smp_unw[NR_CPUS];
2874 +static int inline kgdb_get_blocked_state(struct task_struct *p,
2875 + struct unw_frame_info *unw)
2880 + unw_init_from_blocked_task(unw, p);
2883 + if (unw_unwind(unw) < 0)
2885 + unw_get_ip(unw, &ip);
2886 + if (!in_sched_functions(ip))
2888 + } while (count++ < 16);
2896 +static void inline kgdb_wait(struct pt_regs *regs)
2898 + unsigned long hw_breakpoint_status = ia64_getreg(_IA64_REG_PSR);
2899 + if (hw_breakpoint_status & IA64_PSR_DB)
2900 + ia64_setreg(_IA64_REG_PSR_L,
2901 + hw_breakpoint_status ^ IA64_PSR_DB);
2902 + kgdb_nmihook(smp_processor_id(), regs);
2903 + if (hw_breakpoint_status & IA64_PSR_DB)
2904 + ia64_setreg(_IA64_REG_PSR_L, hw_breakpoint_status);
2909 +static void inline normalize(struct unw_frame_info *running,
2910 + struct pt_regs *regs)
2915 + unw_get_sp(running, &sp);
2916 + if ((sp + 0x10) >= (unsigned long)regs)
2918 + } while (unw_unwind(running) >= 0);
2923 +static void kgdb_init_running(struct unw_frame_info *unw, void *data)
2925 + struct pt_regs *regs;
2928 + normalize(unw, regs);
2929 + smp_unw[smp_processor_id()].unw = unw;
2933 +void kgdb_wait_ipi(struct pt_regs *regs)
2935 + struct unw_frame_info unw;
2937 + smp_unw[smp_processor_id()].task = current;
2939 + if (user_mode(regs)) {
2940 + smp_unw[smp_processor_id()].unw = (struct unw_frame_info *)1;
2943 + if (current->state == TASK_RUNNING)
2944 + unw_init_running(kgdb_init_running, regs);
2946 + if (kgdb_get_blocked_state(current, &unw))
2947 + smp_unw[smp_processor_id()].unw =
2948 + (struct unw_frame_info *)1;
2950 + smp_unw[smp_processor_id()].unw = &unw;
2955 + smp_unw[smp_processor_id()].unw = NULL;
2959 +void kgdb_roundup_cpus(unsigned long flags)
2961 + if (num_online_cpus() > 1)
2962 + smp_send_nmi_allbutself();
2965 +static volatile int kgdb_hwbreak_sstep[NR_CPUS];
2967 +static int kgdb_notify(struct notifier_block *self, unsigned long cmd,
2970 + struct die_args *args = ptr;
2971 + struct pt_regs *regs = args->regs;
2972 + unsigned long err = args->err;
2976 + return NOTIFY_DONE;
2977 + case DIE_PAGE_FAULT_NO_CONTEXT:
2978 + if (atomic_read(&debugger_active) && kgdb_may_fault) {
2979 + kgdb_fault_longjmp(kgdb_fault_jmp_regs);
2980 + return NOTIFY_STOP;
2984 + if (user_mode(regs) || err == 0x80001)
2985 + return NOTIFY_DONE;
2988 + if (user_mode(regs))
2989 + return NOTIFY_DONE;
2990 + else if (err == 36 && kgdb_hwbreak_sstep[smp_processor_id()]) {
2991 + kgdb_hwbreak_sstep[smp_processor_id()] = 0;
2992 + regs->cr_ipsr &= ~IA64_PSR_SS;
2993 + return NOTIFY_STOP;
2995 + case DIE_MCA_MONARCH_PROCESS:
2996 + case DIE_INIT_MONARCH_PROCESS:
3000 + kgdb_handle_exception(args->trapnr, args->signr, args->err, regs);
3001 + return NOTIFY_STOP;
3004 +static struct notifier_block kgdb_notifier = {
3005 + .notifier_call = kgdb_notify,
3008 +int kgdb_arch_init(void)
3010 + atomic_notifier_chain_register(&ia64die_chain, &kgdb_notifier);
3014 +static void do_kgdb_handle_exception(struct unw_frame_info *, void *data);
3016 +struct kgdb_state {
3019 + unsigned long err_code;
3020 + struct pt_regs *regs;
3021 + struct unw_frame_info *unw;
3028 +static void inline kgdb_pc(struct pt_regs *regs, unsigned long pc)
3030 + regs->cr_iip = pc & ~0xf;
3031 + ia64_psr(regs)->ri = pc & 0x3;
3035 +int kgdb_arch_handle_exception(int e_vector, int signo,
3036 + int err_code, char *remcom_in_buffer,
3037 + char *remcom_out_buffer,
3038 + struct pt_regs *linux_regs)
3040 + struct kgdb_state info;
3042 + info.e_vector = e_vector;
3043 + info.signo = signo;
3044 + info.err_code = err_code;
3045 + info.unw = (void *)0;
3046 + info.inbuf = remcom_in_buffer;
3047 + info.outbuf = remcom_out_buffer;
3051 + if (remcom_in_buffer[0] == 'c' || remcom_in_buffer[0] == 's') {
3052 + info.regs = linux_regs;
3053 + do_kgdb_handle_exception(NULL, &info);
3054 + } else if (kgdb_usethread == current) {
3055 + info.regs = linux_regs;
3057 + unw_init_running(do_kgdb_handle_exception, &info);
3058 + } else if (kgdb_usethread->state != TASK_RUNNING) {
3059 + struct unw_frame_info unw_info;
3061 + if (kgdb_get_blocked_state(kgdb_usethread, &unw_info)) {
3066 + do_kgdb_handle_exception(&unw_info, &info);
3070 + for (i = 0; i < NR_CPUS; i++)
3071 + if (smp_unw[i].task == kgdb_usethread && smp_unw[i].unw
3072 + && smp_unw[i].unw != (struct unw_frame_info *)1) {
3074 + do_kgdb_handle_exception(smp_unw[i].unw, &info);
3083 + if (info.ret != -1 && remcom_in_buffer[0] == 'p') {
3084 + unsigned long bad = 0xbad4badbadbadbadUL;
3086 + printk("kgdb_arch_handle_exception: p packet bad (%s)\n",
3087 + remcom_in_buffer);
3088 + kgdb_mem2hex((char *)&bad, remcom_out_buffer, sizeof(bad));
3089 + remcom_out_buffer[sizeof(bad) * 2] = 0;
3096 + * This is done because I evidently made an incorrect 'p' encoding
3097 + * when my patch for gdb was committed. It was later corrected. This
3098 + * check supports both my wrong encoding of the register number and
3099 + * the correct encoding. Eventually this should be eliminated and
3100 + * kgdb_hex2long should be demarshalling the regnum.
3102 +static inline int check_packet(unsigned int regnum, char *packet)
3104 + static int check_done, swap;
3105 + unsigned long reglong;
3107 + if (likely(check_done)) {
3109 + kgdb_hex2long(&packet, ®long);
3110 + regnum = (int) reglong;
3114 + if (regnum > NUM_REGS) {
3115 + kgdb_hex2long(&packet, ®long);
3116 + regnum = (int) reglong;
3124 +static void do_kgdb_handle_exception(struct unw_frame_info *unw_info,
3129 + unsigned long newPC;
3130 + int e_vector, signo;
3131 + unsigned long err_code;
3132 + struct pt_regs *linux_regs;
3133 + struct kgdb_state *info;
3134 + char *remcom_in_buffer, *remcom_out_buffer;
3137 + info->unw = unw_info;
3138 + e_vector = info->e_vector;
3139 + signo = info->signo;
3140 + err_code = info->err_code;
3141 + remcom_in_buffer = info->inbuf;
3142 + remcom_out_buffer = info->outbuf;
3143 + linux_regs = info->regs;
3146 + normalize(unw_info, linux_regs);
3148 + switch (remcom_in_buffer[0]) {
3151 + unsigned int regnum;
3153 + kgdb_hex2mem(&remcom_in_buffer[1], (char *)®num,
3155 + regnum = check_packet(regnum, &remcom_in_buffer[1]);
3156 + if (regnum >= NUM_REGS) {
3157 + remcom_out_buffer[0] = 'E';
3158 + remcom_out_buffer[1] = 0;
3160 + kgdb_get_reg(remcom_out_buffer, regnum,
3161 + unw_info, linux_regs);
3166 + unsigned int regno;
3170 + ptr = &remcom_in_buffer[1];
3171 + if ((!kgdb_usethread || kgdb_usethread == current) &&
3172 + kgdb_hex2long(&ptr, &v) &&
3173 + *ptr++ == '=' && (v >= 0)) {
3174 + regno = (unsigned int)v;
3175 + regno = (regno >= NUM_REGS ? 0 : regno);
3176 + kgdb_put_reg(ptr, remcom_out_buffer, regno,
3177 + unw_info, linux_regs);
3179 + strcpy(remcom_out_buffer, "E01");
3184 + if (e_vector == TRAP_BRKPT && err_code == KGDBBREAKNUM) {
3185 + if (ia64_psr(linux_regs)->ri < 2)
3186 + kgdb_pc(linux_regs, linux_regs->cr_iip +
3187 + ia64_psr(linux_regs)->ri + 1);
3189 + kgdb_pc(linux_regs, linux_regs->cr_iip + 16);
3192 + /* try to read optional parameter, pc unchanged if no parm */
3193 + ptr = &remcom_in_buffer[1];
3194 + if (kgdb_hex2long(&ptr, &addr)) {
3195 + linux_regs->cr_iip = addr;
3197 + newPC = linux_regs->cr_iip;
3199 + /* clear the trace bit */
3200 + linux_regs->cr_ipsr &= ~IA64_PSR_SS;
3202 + atomic_set(&cpu_doing_single_step, -1);
3204 + /* set the trace bit if we're stepping or took a hardware break */
3205 + if (remcom_in_buffer[0] == 's' || e_vector == TRAP_HWBKPT) {
3206 + linux_regs->cr_ipsr |= IA64_PSR_SS;
3207 + debugger_step = 1;
3208 + if (kgdb_contthread)
3209 + atomic_set(&cpu_doing_single_step,
3210 + smp_processor_id());
3213 + kgdb_correct_hw_break();
3215 + /* if not hardware breakpoint, then reenable them */
3216 + if (e_vector != TRAP_HWBKPT)
3217 + linux_regs->cr_ipsr |= IA64_PSR_DB;
3219 + kgdb_hwbreak_sstep[smp_processor_id()] = 1;
3220 + linux_regs->cr_ipsr &= ~IA64_PSR_DB;
3232 +struct kgdb_arch arch_kgdb_ops = {
3233 + .set_hw_breakpoint = kgdb_arch_set_hw_breakpoint,
3234 + .remove_hw_breakpoint = kgdb_arch_remove_hw_breakpoint,
3235 + .gdb_bpt_instr = {0xcc},
3236 + .flags = KGDB_HW_BREAKPOINT,
3238 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ia64/kernel/process.c linux-2.6.18.kgdb/arch/ia64/kernel/process.c
3239 --- linux-2.6.18/arch/ia64/kernel/process.c 2006-09-20 07:42:06.000000000 +0400
3240 +++ linux-2.6.18.kgdb/arch/ia64/kernel/process.c 2008-06-10 16:20:23.000000000 +0400
3241 @@ -458,6 +458,9 @@ copy_thread (int nr, unsigned long clone
3243 child_ptregs->cr_ipsr = ((child_ptregs->cr_ipsr | IA64_PSR_BITS_TO_SET)
3244 & ~(IA64_PSR_BITS_TO_CLEAR | IA64_PSR_PP | IA64_PSR_UP));
3246 + child_ptregs->cr_ipsr |= IA64_PSR_DB;
3250 * NOTE: The calling convention considers all floating point
3251 @@ -686,6 +689,9 @@ kernel_thread (int (*fn)(void *), void *
3252 regs.pt.r11 = (unsigned long) arg; /* 2nd argument */
3253 /* Preserve PSR bits, except for bits 32-34 and 37-45, which we can't read. */
3254 regs.pt.cr_ipsr = ia64_getreg(_IA64_REG_PSR) | IA64_PSR_BN;
3256 + regs.pt.cr_ipsr |= IA64_PSR_DB;
3258 regs.pt.cr_ifs = 1UL << 63; /* mark as valid, empty frame */
3259 regs.sw.ar_fpsr = regs.pt.ar_fpsr = ia64_getreg(_IA64_REG_AR_FPSR);
3260 regs.sw.ar_bspstore = (unsigned long) current + IA64_RBS_OFFSET;
3261 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ia64/kernel/smp.c linux-2.6.18.kgdb/arch/ia64/kernel/smp.c
3262 --- linux-2.6.18/arch/ia64/kernel/smp.c 2006-09-20 07:42:06.000000000 +0400
3263 +++ linux-2.6.18.kgdb/arch/ia64/kernel/smp.c 2008-06-10 16:19:32.000000000 +0400
3265 #include <asm/tlbflush.h>
3266 #include <asm/unistd.h>
3267 #include <asm/mca.h>
3268 +#include <linux/kgdb.h>
3271 * Structure and data for smp_call_function(). This is designed to minimise static memory
3272 @@ -66,6 +67,9 @@ static volatile struct call_data_struct
3274 #define IPI_CALL_FUNC 0
3275 #define IPI_CPU_STOP 1
3277 +#define IPI_KGDB_INTERRUPT 2
3280 /* This needs to be cacheline aligned because it is written to by *other* CPUs. */
3281 static DEFINE_PER_CPU(u64, ipi_operation) ____cacheline_aligned;
3282 @@ -155,6 +159,11 @@ handle_IPI (int irq, void *dev_id, struc
3287 + case IPI_KGDB_INTERRUPT:
3288 + kgdb_wait_ipi(regs);
3293 printk(KERN_CRIT "Unknown IPI on CPU %d: %lu\n", this_cpu, which);
3294 @@ -305,6 +314,14 @@ smp_call_function_single (int cpuid, voi
3296 EXPORT_SYMBOL(smp_call_function_single);
3300 +smp_send_nmi_allbutself(void)
3302 + send_IPI_allbutself(IPI_KGDB_INTERRUPT);
3307 * this function sends a 'generic call function' IPI to all other CPUs
3309 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ia64/kernel/traps.c linux-2.6.18.kgdb/arch/ia64/kernel/traps.c
3310 --- linux-2.6.18/arch/ia64/kernel/traps.c 2006-09-20 07:42:06.000000000 +0400
3311 +++ linux-2.6.18.kgdb/arch/ia64/kernel/traps.c 2008-06-10 16:19:32.000000000 +0400
3312 @@ -200,8 +200,12 @@ __kprobes ia64_bad_break (unsigned long
3316 - if (break_num < 0x40000 || break_num > 0x100000)
3317 + if (break_num < 0x40000 || break_num > 0x100000) {
3318 + if (notify_die(DIE_BREAK, "bad break", regs,
3319 + break_num, TRAP_BRKPT, SIGTRAP) == NOTIFY_STOP)
3321 die_if_kernel("Bad break", regs, break_num);
3324 if (break_num < 0x80000) {
3325 sig = SIGILL; code = __ILL_BREAK;
3326 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ia64/kernel/unwind.c linux-2.6.18.kgdb/arch/ia64/kernel/unwind.c
3327 --- linux-2.6.18/arch/ia64/kernel/unwind.c 2006-09-20 07:42:06.000000000 +0400
3328 +++ linux-2.6.18.kgdb/arch/ia64/kernel/unwind.c 2008-06-10 16:20:23.000000000 +0400
3334 +#define KGDB_EARLY_SIZE 100
3335 +static struct unw_reg_state __initdata kgdb_reg_state[KGDB_EARLY_SIZE];
3336 +static struct unw_labeled_state __initdata kgdb_labeled_state[KGDB_EARLY_SIZE];
3337 +void __initdata *kgdb_reg_state_free, __initdata *kgdb_labeled_state_free;
3340 +kgdb_malloc_init(void)
3344 + kgdb_reg_state_free = kgdb_reg_state;
3345 + for (i = 1; i < KGDB_EARLY_SIZE; i++) {
3346 + *((unsigned long *) &kgdb_reg_state[i]) = (unsigned long) kgdb_reg_state_free;
3347 + kgdb_reg_state_free = &kgdb_reg_state[i];
3350 + kgdb_labeled_state_free = kgdb_labeled_state;
3351 + for (i = 1; i < KGDB_EARLY_SIZE; i++) {
3352 + *((unsigned long *) &kgdb_labeled_state[i]) =
3353 + (unsigned long) kgdb_labeled_state_free;
3354 + kgdb_labeled_state_free = &kgdb_labeled_state[i];
3359 +static void * __init
3360 +kgdb_malloc(void **mem)
3365 + *mem = *((void **) p);
3370 +kgdb_free(void **mem, void *p)
3372 + *((void **)p) = *mem;
3376 +#define alloc_reg_state() (!malloc_sizes[0].cs_cachep ? \
3377 + kgdb_malloc(&kgdb_reg_state_free) : \
3378 + kmalloc(sizeof(struct unw_reg_state), GFP_ATOMIC))
3379 +#define free_reg_state(usr) (!malloc_sizes[0].cs_cachep ? \
3380 + kgdb_free(&kgdb_reg_state_free, usr) : \
3382 +#define alloc_labeled_state() (!malloc_sizes[0].cs_cachep ? \
3383 + kgdb_malloc(&kgdb_labeled_state_free) : \
3384 + kmalloc(sizeof(struct unw_labeled_state), GFP_ATOMIC))
3385 +#define free_labeled_state(usr) (!malloc_sizes[0].cs_cachep ? \
3386 + kgdb_free(&kgdb_labeled_state_free, usr) : \
3390 #define alloc_reg_state() kmalloc(sizeof(struct unw_reg_state), GFP_ATOMIC)
3391 #define free_reg_state(usr) kfree(usr)
3392 #define alloc_labeled_state() kmalloc(sizeof(struct unw_labeled_state), GFP_ATOMIC)
3393 #define free_labeled_state(usr) kfree(usr)
3396 typedef unsigned long unw_word;
3397 typedef unsigned char unw_hash_index_t;
3398 @@ -238,6 +296,24 @@ static struct {
3404 + * This makes it safe to call breakpoint() very early
3405 + * in setup_arch providing:
3406 + * 1) breakpoint isn't called between lines in cpu_init
3407 + * where init_mm.mm_count is incremented and ia64_mmu_init
3408 + * is called. Otherwise the test below is invalid.
3409 + * 2) the memory examined doesn't result in tlbmiss.
3411 +static unsigned long inline kgdb_unimpl_va_mask(void)
3413 + if (atomic_read(&init_mm.mm_count) > 1)
3414 + return local_cpu_data->unimpl_va_mask;
3421 read_only (void *addr)
3423 @@ -1786,7 +1862,11 @@ run_script (struct unw_script *script, s
3428 + if ((s[val] & (kgdb_unimpl_va_mask() | 0x7)) != 0
3430 if ((s[val] & (local_cpu_data->unimpl_va_mask | 0x7)) != 0
3432 || s[val] < TASK_SIZE)
3434 UNW_DPRINT(0, "unwind.%s: rejecting bad psp=0x%lx\n",
3435 @@ -1821,7 +1901,11 @@ find_save_locs (struct unw_frame_info *i
3436 struct unw_script *scr;
3437 unsigned long flags = 0;
3440 + if ((info->ip & (kgdb_unimpl_va_mask() | 0xf)) || info->ip < TASK_SIZE) {
3442 if ((info->ip & (local_cpu_data->unimpl_va_mask | 0xf)) || info->ip < TASK_SIZE) {
3444 /* don't let obviously bad addresses pollute the cache */
3445 /* FIXME: should really be level 0 but it occurs too often. KAO */
3446 UNW_DPRINT(1, "unwind.%s: rejecting bad ip=0x%lx\n", __FUNCTION__, info->ip);
3447 @@ -2249,6 +2333,9 @@ unw_init (void)
3449 init_unwind_table(&unw.kernel_table, "kernel", KERNEL_START, (unsigned long) __gp,
3450 __start_unwind, __end_unwind);
3452 + kgdb_malloc_init();
3457 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ia64/mm/extable.c linux-2.6.18.kgdb/arch/ia64/mm/extable.c
3458 --- linux-2.6.18/arch/ia64/mm/extable.c 2006-09-20 07:42:06.000000000 +0400
3459 +++ linux-2.6.18.kgdb/arch/ia64/mm/extable.c 2008-06-10 16:19:32.000000000 +0400
3463 #include <linux/sort.h>
3464 +#include <linux/kgdb.h>
3466 #include <asm/uaccess.h>
3467 #include <asm/module.h>
3468 @@ -73,6 +74,11 @@ search_extable (const struct exception_t
3473 + if (atomic_read(&debugger_active) && kgdb_may_fault)
3474 + kgdb_fault_longjmp(kgdb_fault_jmp_regs);
3475 + /* Not reached. */
3480 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ia64/mm/fault.c linux-2.6.18.kgdb/arch/ia64/mm/fault.c
3481 --- linux-2.6.18/arch/ia64/mm/fault.c 2006-09-20 07:42:06.000000000 +0400
3482 +++ linux-2.6.18.kgdb/arch/ia64/mm/fault.c 2008-06-10 16:19:32.000000000 +0400
3483 @@ -266,6 +266,10 @@ ia64_do_page_fault (unsigned long addres
3487 + if (notify_die(DIE_PAGE_FAULT_NO_CONTEXT, "no context", regs,
3488 + isr, 14, SIGSEGV) == NOTIFY_STOP)
3491 if (address < PAGE_SIZE)
3492 printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference (address %016lx)\n", address);
3494 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/mips/Kconfig.debug linux-2.6.18.kgdb/arch/mips/Kconfig.debug
3495 --- linux-2.6.18/arch/mips/Kconfig.debug 2006-09-20 07:42:06.000000000 +0400
3496 +++ linux-2.6.18.kgdb/arch/mips/Kconfig.debug 2008-06-10 16:19:28.000000000 +0400
3497 @@ -37,25 +37,6 @@ config DEBUG_STACK_USAGE
3499 This option will slow down process creation somewhat.
3502 - bool "Remote GDB kernel debugging"
3503 - depends on DEBUG_KERNEL
3506 - If you say Y here, it will be possible to remotely debug the MIPS
3507 - kernel using gdb. This enlarges your kernel image disk size by
3508 - several megabytes and requires a machine with more than 16 MB,
3509 - better 32 MB RAM to avoid excessive linking time. This is only
3510 - useful for kernel hackers. If unsure, say N.
3513 - bool "Console output to GDB"
3516 - If you are using GDB for remote debugging over a serial port and
3517 - would like kernel messages to be formatted into GDB $O packets so
3518 - that GDB prints them as program output, say 'Y'.
3520 config SB1XXX_CORELIS
3521 bool "Corelis Debugger"
3522 depends on SIBYTE_SB1xxx_SOC
3523 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/mips/kernel/Makefile linux-2.6.18.kgdb/arch/mips/kernel/Makefile
3524 --- linux-2.6.18/arch/mips/kernel/Makefile 2006-09-20 07:42:06.000000000 +0400
3525 +++ linux-2.6.18.kgdb/arch/mips/kernel/Makefile 2008-06-10 16:19:28.000000000 +0400
3526 @@ -59,7 +59,8 @@ obj-$(CONFIG_MIPS32_COMPAT) += linux32.o
3527 obj-$(CONFIG_MIPS32_N32) += binfmt_elfn32.o scall64-n32.o signal_n32.o
3528 obj-$(CONFIG_MIPS32_O32) += binfmt_elfo32.o scall64-o32.o ptrace32.o
3530 -obj-$(CONFIG_KGDB) += gdb-low.o gdb-stub.o
3531 +obj-$(CONFIG_KGDB) += kgdb_handler.o kgdb.o kgdb-jmp.o \
3533 obj-$(CONFIG_PROC_FS) += proc.o
3535 obj-$(CONFIG_64BIT) += cpu-bugs64.o
3536 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/mips/kernel/gdb-low.S linux-2.6.18.kgdb/arch/mips/kernel/gdb-low.S
3537 --- linux-2.6.18/arch/mips/kernel/gdb-low.S 2006-09-20 07:42:06.000000000 +0400
3538 +++ linux-2.6.18.kgdb/arch/mips/kernel/gdb-low.S 1970-01-01 03:00:00.000000000 +0300
3541 - * gdb-low.S contains the low-level trap handler for the GDB stub.
3543 - * Copyright (C) 1995 Andreas Busse
3545 -#include <linux/sys.h>
3547 -#include <asm/asm.h>
3548 -#include <asm/errno.h>
3549 -#include <asm/irqflags.h>
3550 -#include <asm/mipsregs.h>
3551 -#include <asm/regdef.h>
3552 -#include <asm/stackframe.h>
3553 -#include <asm/gdb-stub.h>
3555 -#ifdef CONFIG_32BIT
3561 -#ifdef CONFIG_64BIT
3562 -#define DMFC0 dmfc0
3563 -#define DMTC0 dmtc0
3569 - * [jsun] We reserves about 2x GDB_FR_SIZE in stack. The lower (addressed)
3570 - * part is used to store registers and passed to exception handler.
3571 - * The upper part is reserved for "call func" feature where gdb client
3572 - * saves some of the regs, setups call frame and passes args.
3574 - * A trace shows about 200 bytes are used to store about half of all regs.
3575 - * The rest should be big enough for frame setup and passing args.
3579 - * The low level trap handler
3582 - NESTED(trap_low, GDB_FR_SIZE, sp)
3586 - mfc0 k0, CP0_STATUS
3587 - sll k0, 3 /* extract cu0 bit */
3592 - * Called from user mode, go somewhere else.
3594 - mfc0 k0, CP0_CAUSE
3596 -#ifdef CONFIG_64BIT
3599 - PTR_L k1, saved_vectors(k0)
3604 - PTR_SUBU sp, k1, GDB_FR_SIZE*2 # see comment above
3605 - LONG_S k0, GDB_FR_REG29(sp)
3606 - LONG_S $2, GDB_FR_REG2(sp)
3609 - * First save the CP0 and special registers
3612 - mfc0 v0, CP0_STATUS
3613 - LONG_S v0, GDB_FR_STATUS(sp)
3614 - mfc0 v0, CP0_CAUSE
3615 - LONG_S v0, GDB_FR_CAUSE(sp)
3617 - LONG_S v0, GDB_FR_EPC(sp)
3618 - DMFC0 v0, CP0_BADVADDR
3619 - LONG_S v0, GDB_FR_BADVADDR(sp)
3621 - LONG_S v0, GDB_FR_HI(sp)
3623 - LONG_S v0, GDB_FR_LO(sp)
3626 - * Now the integer registers
3629 - LONG_S zero, GDB_FR_REG0(sp) /* I know... */
3630 - LONG_S $1, GDB_FR_REG1(sp)
3631 - /* v0 already saved */
3632 - LONG_S $3, GDB_FR_REG3(sp)
3633 - LONG_S $4, GDB_FR_REG4(sp)
3634 - LONG_S $5, GDB_FR_REG5(sp)
3635 - LONG_S $6, GDB_FR_REG6(sp)
3636 - LONG_S $7, GDB_FR_REG7(sp)
3637 - LONG_S $8, GDB_FR_REG8(sp)
3638 - LONG_S $9, GDB_FR_REG9(sp)
3639 - LONG_S $10, GDB_FR_REG10(sp)
3640 - LONG_S $11, GDB_FR_REG11(sp)
3641 - LONG_S $12, GDB_FR_REG12(sp)
3642 - LONG_S $13, GDB_FR_REG13(sp)
3643 - LONG_S $14, GDB_FR_REG14(sp)
3644 - LONG_S $15, GDB_FR_REG15(sp)
3645 - LONG_S $16, GDB_FR_REG16(sp)
3646 - LONG_S $17, GDB_FR_REG17(sp)
3647 - LONG_S $18, GDB_FR_REG18(sp)
3648 - LONG_S $19, GDB_FR_REG19(sp)
3649 - LONG_S $20, GDB_FR_REG20(sp)
3650 - LONG_S $21, GDB_FR_REG21(sp)
3651 - LONG_S $22, GDB_FR_REG22(sp)
3652 - LONG_S $23, GDB_FR_REG23(sp)
3653 - LONG_S $24, GDB_FR_REG24(sp)
3654 - LONG_S $25, GDB_FR_REG25(sp)
3655 - LONG_S $26, GDB_FR_REG26(sp)
3656 - LONG_S $27, GDB_FR_REG27(sp)
3657 - LONG_S $28, GDB_FR_REG28(sp)
3658 - /* sp already saved */
3659 - LONG_S $30, GDB_FR_REG30(sp)
3660 - LONG_S $31, GDB_FR_REG31(sp)
3662 - CLI /* disable interrupts */
3666 - * Followed by the floating point registers
3668 - mfc0 v0, CP0_STATUS /* FPU enabled? */
3670 - andi v0, v0, (ST0_CU1 >> 16)
3672 - beqz v0,2f /* disabled, skip */
3675 - SDC1 $0, GDB_FR_FPR0(sp)
3676 - SDC1 $1, GDB_FR_FPR1(sp)
3677 - SDC1 $2, GDB_FR_FPR2(sp)
3678 - SDC1 $3, GDB_FR_FPR3(sp)
3679 - SDC1 $4, GDB_FR_FPR4(sp)
3680 - SDC1 $5, GDB_FR_FPR5(sp)
3681 - SDC1 $6, GDB_FR_FPR6(sp)
3682 - SDC1 $7, GDB_FR_FPR7(sp)
3683 - SDC1 $8, GDB_FR_FPR8(sp)
3684 - SDC1 $9, GDB_FR_FPR9(sp)
3685 - SDC1 $10, GDB_FR_FPR10(sp)
3686 - SDC1 $11, GDB_FR_FPR11(sp)
3687 - SDC1 $12, GDB_FR_FPR12(sp)
3688 - SDC1 $13, GDB_FR_FPR13(sp)
3689 - SDC1 $14, GDB_FR_FPR14(sp)
3690 - SDC1 $15, GDB_FR_FPR15(sp)
3691 - SDC1 $16, GDB_FR_FPR16(sp)
3692 - SDC1 $17, GDB_FR_FPR17(sp)
3693 - SDC1 $18, GDB_FR_FPR18(sp)
3694 - SDC1 $19, GDB_FR_FPR19(sp)
3695 - SDC1 $20, GDB_FR_FPR20(sp)
3696 - SDC1 $21, GDB_FR_FPR21(sp)
3697 - SDC1 $22, GDB_FR_FPR22(sp)
3698 - SDC1 $23, GDB_FR_FPR23(sp)
3699 - SDC1 $24, GDB_FR_FPR24(sp)
3700 - SDC1 $25, GDB_FR_FPR25(sp)
3701 - SDC1 $26, GDB_FR_FPR26(sp)
3702 - SDC1 $27, GDB_FR_FPR27(sp)
3703 - SDC1 $28, GDB_FR_FPR28(sp)
3704 - SDC1 $29, GDB_FR_FPR29(sp)
3705 - SDC1 $30, GDB_FR_FPR30(sp)
3706 - SDC1 $31, GDB_FR_FPR31(sp)
3709 - * FPU control registers
3712 - cfc1 v0, CP1_STATUS
3713 - LONG_S v0, GDB_FR_FSR(sp)
3714 - cfc1 v0, CP1_REVISION
3715 - LONG_S v0, GDB_FR_FIR(sp)
3718 - * Current stack frame ptr
3722 - LONG_S sp, GDB_FR_FRP(sp)
3725 - * CP0 registers (R4000/R4400 unused registers skipped)
3728 - mfc0 v0, CP0_INDEX
3729 - LONG_S v0, GDB_FR_CP0_INDEX(sp)
3730 - mfc0 v0, CP0_RANDOM
3731 - LONG_S v0, GDB_FR_CP0_RANDOM(sp)
3732 - DMFC0 v0, CP0_ENTRYLO0
3733 - LONG_S v0, GDB_FR_CP0_ENTRYLO0(sp)
3734 - DMFC0 v0, CP0_ENTRYLO1
3735 - LONG_S v0, GDB_FR_CP0_ENTRYLO1(sp)
3736 - DMFC0 v0, CP0_CONTEXT
3737 - LONG_S v0, GDB_FR_CP0_CONTEXT(sp)
3738 - mfc0 v0, CP0_PAGEMASK
3739 - LONG_S v0, GDB_FR_CP0_PAGEMASK(sp)
3740 - mfc0 v0, CP0_WIRED
3741 - LONG_S v0, GDB_FR_CP0_WIRED(sp)
3742 - DMFC0 v0, CP0_ENTRYHI
3743 - LONG_S v0, GDB_FR_CP0_ENTRYHI(sp)
3745 - LONG_S v0, GDB_FR_CP0_PRID(sp)
3750 - * Continue with the higher level handler
3755 - jal handle_exception
3759 - * Restore all writable registers, in reverse order
3764 - LONG_L v0, GDB_FR_CP0_ENTRYHI(sp)
3765 - LONG_L v1, GDB_FR_CP0_WIRED(sp)
3766 - DMTC0 v0, CP0_ENTRYHI
3767 - mtc0 v1, CP0_WIRED
3768 - LONG_L v0, GDB_FR_CP0_PAGEMASK(sp)
3769 - LONG_L v1, GDB_FR_CP0_ENTRYLO1(sp)
3770 - mtc0 v0, CP0_PAGEMASK
3771 - DMTC0 v1, CP0_ENTRYLO1
3772 - LONG_L v0, GDB_FR_CP0_ENTRYLO0(sp)
3773 - LONG_L v1, GDB_FR_CP0_INDEX(sp)
3774 - DMTC0 v0, CP0_ENTRYLO0
3775 - LONG_L v0, GDB_FR_CP0_CONTEXT(sp)
3776 - mtc0 v1, CP0_INDEX
3777 - DMTC0 v0, CP0_CONTEXT
3781 - * Next, the floating point registers
3783 - mfc0 v0, CP0_STATUS /* check if the FPU is enabled */
3785 - andi v0, v0, (ST0_CU1 >> 16)
3787 - beqz v0, 3f /* disabled, skip */
3790 - LDC1 $31, GDB_FR_FPR31(sp)
3791 - LDC1 $30, GDB_FR_FPR30(sp)
3792 - LDC1 $29, GDB_FR_FPR29(sp)
3793 - LDC1 $28, GDB_FR_FPR28(sp)
3794 - LDC1 $27, GDB_FR_FPR27(sp)
3795 - LDC1 $26, GDB_FR_FPR26(sp)
3796 - LDC1 $25, GDB_FR_FPR25(sp)
3797 - LDC1 $24, GDB_FR_FPR24(sp)
3798 - LDC1 $23, GDB_FR_FPR23(sp)
3799 - LDC1 $22, GDB_FR_FPR22(sp)
3800 - LDC1 $21, GDB_FR_FPR21(sp)
3801 - LDC1 $20, GDB_FR_FPR20(sp)
3802 - LDC1 $19, GDB_FR_FPR19(sp)
3803 - LDC1 $18, GDB_FR_FPR18(sp)
3804 - LDC1 $17, GDB_FR_FPR17(sp)
3805 - LDC1 $16, GDB_FR_FPR16(sp)
3806 - LDC1 $15, GDB_FR_FPR15(sp)
3807 - LDC1 $14, GDB_FR_FPR14(sp)
3808 - LDC1 $13, GDB_FR_FPR13(sp)
3809 - LDC1 $12, GDB_FR_FPR12(sp)
3810 - LDC1 $11, GDB_FR_FPR11(sp)
3811 - LDC1 $10, GDB_FR_FPR10(sp)
3812 - LDC1 $9, GDB_FR_FPR9(sp)
3813 - LDC1 $8, GDB_FR_FPR8(sp)
3814 - LDC1 $7, GDB_FR_FPR7(sp)
3815 - LDC1 $6, GDB_FR_FPR6(sp)
3816 - LDC1 $5, GDB_FR_FPR5(sp)
3817 - LDC1 $4, GDB_FR_FPR4(sp)
3818 - LDC1 $3, GDB_FR_FPR3(sp)
3819 - LDC1 $2, GDB_FR_FPR2(sp)
3820 - LDC1 $1, GDB_FR_FPR1(sp)
3821 - LDC1 $0, GDB_FR_FPR0(sp)
3824 - * Now the CP0 and integer registers
3828 -#ifdef CONFIG_MIPS_MT_SMTC
3829 - /* Read-modify write of Status must be atomic */
3830 - mfc0 t2, CP0_TCSTATUS
3831 - ori t1, t2, TCSTATUS_IXMT
3832 - mtc0 t1, CP0_TCSTATUS
3833 - andi t2, t2, TCSTATUS_IXMT
3838 -#endif /* CONFIG_MIPS_MT_SMTC */
3839 - mfc0 t0, CP0_STATUS
3842 - mtc0 t0, CP0_STATUS
3843 -#ifdef CONFIG_MIPS_MT_SMTC
3844 - andi t1, t1, VPECONTROL_TE
3849 - mfc0 t1, CP0_TCSTATUS
3850 - xori t1, t1, TCSTATUS_IXMT
3852 - mtc0 t1, CP0_TCSTATUS
3854 -#endif /* CONFIG_MIPS_MT_SMTC */
3855 - LONG_L v0, GDB_FR_STATUS(sp)
3856 - LONG_L v1, GDB_FR_EPC(sp)
3857 - mtc0 v0, CP0_STATUS
3859 - LONG_L v0, GDB_FR_HI(sp)
3860 - LONG_L v1, GDB_FR_LO(sp)
3863 - LONG_L $31, GDB_FR_REG31(sp)
3864 - LONG_L $30, GDB_FR_REG30(sp)
3865 - LONG_L $28, GDB_FR_REG28(sp)
3866 - LONG_L $27, GDB_FR_REG27(sp)
3867 - LONG_L $26, GDB_FR_REG26(sp)
3868 - LONG_L $25, GDB_FR_REG25(sp)
3869 - LONG_L $24, GDB_FR_REG24(sp)
3870 - LONG_L $23, GDB_FR_REG23(sp)
3871 - LONG_L $22, GDB_FR_REG22(sp)
3872 - LONG_L $21, GDB_FR_REG21(sp)
3873 - LONG_L $20, GDB_FR_REG20(sp)
3874 - LONG_L $19, GDB_FR_REG19(sp)
3875 - LONG_L $18, GDB_FR_REG18(sp)
3876 - LONG_L $17, GDB_FR_REG17(sp)
3877 - LONG_L $16, GDB_FR_REG16(sp)
3878 - LONG_L $15, GDB_FR_REG15(sp)
3879 - LONG_L $14, GDB_FR_REG14(sp)
3880 - LONG_L $13, GDB_FR_REG13(sp)
3881 - LONG_L $12, GDB_FR_REG12(sp)
3882 - LONG_L $11, GDB_FR_REG11(sp)
3883 - LONG_L $10, GDB_FR_REG10(sp)
3884 - LONG_L $9, GDB_FR_REG9(sp)
3885 - LONG_L $8, GDB_FR_REG8(sp)
3886 - LONG_L $7, GDB_FR_REG7(sp)
3887 - LONG_L $6, GDB_FR_REG6(sp)
3888 - LONG_L $5, GDB_FR_REG5(sp)
3889 - LONG_L $4, GDB_FR_REG4(sp)
3890 - LONG_L $3, GDB_FR_REG3(sp)
3891 - LONG_L $2, GDB_FR_REG2(sp)
3892 - LONG_L $1, GDB_FR_REG1(sp)
3893 -#if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
3894 - LONG_L k0, GDB_FR_EPC(sp)
3895 - LONG_L $29, GDB_FR_REG29(sp) /* Deallocate stack */
3899 - LONG_L sp, GDB_FR_REG29(sp) /* Deallocate stack */
3909 -LEAF(kgdb_read_byte)
3914 - .section __ex_table,"a"
3917 - END(kgdb_read_byte)
3919 -LEAF(kgdb_write_byte)
3923 - .section __ex_table,"a"
3926 - END(kgdb_write_byte)
3928 - .type kgdbfault@function
3931 -kgdbfault: li v0, -EFAULT
3934 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/mips/kernel/gdb-stub.c linux-2.6.18.kgdb/arch/mips/kernel/gdb-stub.c
3935 --- linux-2.6.18/arch/mips/kernel/gdb-stub.c 2006-09-20 07:42:06.000000000 +0400
3936 +++ linux-2.6.18.kgdb/arch/mips/kernel/gdb-stub.c 1970-01-01 03:00:00.000000000 +0300
3939 - * arch/mips/kernel/gdb-stub.c
3941 - * Originally written by Glenn Engel, Lake Stevens Instrument Division
3943 - * Contributed by HP Systems
3945 - * Modified for SPARC by Stu Grossman, Cygnus Support.
3947 - * Modified for Linux/MIPS (and MIPS in general) by Andreas Busse
3948 - * Send complaints, suggestions etc. to <andy@waldorf-gmbh.de>
3950 - * Copyright (C) 1995 Andreas Busse
3952 - * Copyright (C) 2003 MontaVista Software Inc.
3953 - * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
3957 - * To enable debugger support, two things need to happen. One, a
3958 - * call to set_debug_traps() is necessary in order to allow any breakpoints
3959 - * or error conditions to be properly intercepted and reported to gdb.
3960 - * Two, a breakpoint needs to be generated to begin communication. This
3961 - * is most easily accomplished by a call to breakpoint(). Breakpoint()
3962 - * simulates a breakpoint by executing a BREAK instruction.
3965 - * The following gdb commands are supported:
3967 - * command function Return value
3969 - * g return the value of the CPU registers hex data or ENN
3970 - * G set the value of the CPU registers OK or ENN
3972 - * mAA..AA,LLLL Read LLLL bytes at address AA..AA hex data or ENN
3973 - * MAA..AA,LLLL: Write LLLL bytes at address AA.AA OK or ENN
3975 - * c Resume at current address SNN ( signal NN)
3976 - * cAA..AA Continue at address AA..AA SNN
3978 - * s Step one instruction SNN
3979 - * sAA..AA Step one instruction from AA..AA SNN
3983 - * ? What was the last sigval ? SNN (signal NN)
3985 - * bBB..BB Set baud rate to BB..BB OK or BNN, then sets
3988 - * All commands and responses are sent with a packet which includes a
3989 - * checksum. A packet consists of
3991 - * $<packet info>#<checksum>.
3994 - * <packet info> :: <characters representing the command or response>
3995 - * <checksum> :: < two hex digits computed as modulo 256 sum of <packetinfo>>
3997 - * When a packet is received, it is first acknowledged with either '+' or '-'.
3998 - * '+' indicates a successful transfer. '-' indicates a failed transfer.
4003 - * $m0,10#2a +$00010203040506070809101112131415#42
4010 - * For reference -- the following are the steps that one
4011 - * company took (RidgeRun Inc) to get remote gdb debugging
4012 - * going. In this scenario the host machine was a PC and the
4013 - * target platform was a Galileo EVB64120A MIPS evaluation
4017 - * First download gdb-5.0.tar.gz from the internet.
4018 - * and then build/install the package.
4021 - * $ tar zxf gdb-5.0.tar.gz
4023 - * $ ./configure --target=mips-linux-elf
4026 - * $ which mips-linux-elf-gdb
4027 - * /usr/local/bin/mips-linux-elf-gdb
4030 - * Configure linux for remote debugging and build it.
4034 - * $ make menuconfig <go to "Kernel Hacking" and turn on remote debugging>
4038 - * Download the kernel to the remote target and start
4039 - * the kernel running. It will promptly halt and wait
4040 - * for the host gdb session to connect. It does this
4041 - * since the "Kernel Hacking" option has defined
4042 - * CONFIG_KGDB which in turn enables your calls
4044 - * set_debug_traps();
4048 - * Start the gdb session on the host.
4051 - * $ mips-linux-elf-gdb vmlinux
4052 - * (gdb) set remotebaud 115200
4053 - * (gdb) target remote /dev/ttyS1
4054 - * ...at this point you are connected to
4055 - * the remote target and can use gdb
4056 - * in the normal fasion. Setting
4057 - * breakpoints, single stepping,
4058 - * printing variables, etc.
4060 -#include <linux/string.h>
4061 -#include <linux/kernel.h>
4062 -#include <linux/signal.h>
4063 -#include <linux/sched.h>
4064 -#include <linux/mm.h>
4065 -#include <linux/console.h>
4066 -#include <linux/init.h>
4067 -#include <linux/smp.h>
4068 -#include <linux/spinlock.h>
4069 -#include <linux/slab.h>
4070 -#include <linux/reboot.h>
4072 -#include <asm/asm.h>
4073 -#include <asm/cacheflush.h>
4074 -#include <asm/mipsregs.h>
4075 -#include <asm/pgtable.h>
4076 -#include <asm/system.h>
4077 -#include <asm/gdb-stub.h>
4078 -#include <asm/inst.h>
4079 -#include <asm/smp.h>
4082 - * external low-level support routines
4085 -extern int putDebugChar(char c); /* write a single character */
4086 -extern char getDebugChar(void); /* read and return a single char */
4087 -extern void trap_low(void);
4090 - * breakpoint and test functions
4092 -extern void breakpoint(void);
4093 -extern void breakinst(void);
4094 -extern void async_breakpoint(void);
4095 -extern void async_breakinst(void);
4096 -extern void adel(void);
4099 - * local prototypes
4102 -static void getpacket(char *buffer);
4103 -static void putpacket(char *buffer);
4104 -static int computeSignal(int tt);
4105 -static int hex(unsigned char ch);
4106 -static int hexToInt(char **ptr, int *intValue);
4107 -static int hexToLong(char **ptr, long *longValue);
4108 -static unsigned char *mem2hex(char *mem, char *buf, int count, int may_fault);
4109 -void handle_exception(struct gdb_regs *regs);
4114 - * spin locks for smp case
4116 -static DEFINE_SPINLOCK(kgdb_lock);
4117 -static raw_spinlock_t kgdb_cpulock[NR_CPUS] = {
4118 - [0 ... NR_CPUS-1] = __RAW_SPIN_LOCK_UNLOCKED,
4122 - * BUFMAX defines the maximum number of characters in inbound/outbound buffers
4123 - * at least NUMREGBYTES*2 are needed for register packets
4125 -#define BUFMAX 2048
4127 -static char input_buffer[BUFMAX];
4128 -static char output_buffer[BUFMAX];
4129 -static int initialized; /* !0 means we've been initialized */
4130 -static int kgdb_started;
4131 -static const char hexchars[]="0123456789abcdef";
4133 -/* Used to prevent crashes in memory access. Note that they'll crash anyway if
4134 - we haven't set up fault handlers yet... */
4135 -int kgdb_read_byte(unsigned char *address, unsigned char *dest);
4136 -int kgdb_write_byte(unsigned char val, unsigned char *dest);
4139 - * Convert ch from a hex digit to an int
4141 -static int hex(unsigned char ch)
4143 - if (ch >= 'a' && ch <= 'f')
4145 - if (ch >= '0' && ch <= '9')
4147 - if (ch >= 'A' && ch <= 'F')
4153 - * scan for the sequence $<data>#<checksum>
4155 -static void getpacket(char *buffer)
4157 - unsigned char checksum;
4158 - unsigned char xmitcsum;
4165 - * wait around for the start character,
4166 - * ignore all other characters
4168 - while ((ch = (getDebugChar() & 0x7f)) != '$') ;
4175 - * now, read until a # or end of buffer is found
4177 - while (count < BUFMAX) {
4178 - ch = getDebugChar();
4181 - checksum = checksum + ch;
4182 - buffer[count] = ch;
4183 - count = count + 1;
4186 - if (count >= BUFMAX)
4189 - buffer[count] = 0;
4192 - xmitcsum = hex(getDebugChar() & 0x7f) << 4;
4193 - xmitcsum |= hex(getDebugChar() & 0x7f);
4195 - if (checksum != xmitcsum)
4196 - putDebugChar('-'); /* failed checksum */
4198 - putDebugChar('+'); /* successful transfer */
4201 - * if a sequence char is present,
4202 - * reply the sequence ID
4204 - if (buffer[2] == ':') {
4205 - putDebugChar(buffer[0]);
4206 - putDebugChar(buffer[1]);
4209 - * remove sequence chars from buffer
4211 - count = strlen(buffer);
4212 - for (i=3; i <= count; i++)
4213 - buffer[i-3] = buffer[i];
4218 - while (checksum != xmitcsum);
4222 - * send the packet in buffer.
4224 -static void putpacket(char *buffer)
4226 - unsigned char checksum;
4231 - * $<packet info>#<checksum>.
4235 - putDebugChar('$');
4239 - while ((ch = buffer[count]) != 0) {
4240 - if (!(putDebugChar(ch)))
4246 - putDebugChar('#');
4247 - putDebugChar(hexchars[checksum >> 4]);
4248 - putDebugChar(hexchars[checksum & 0xf]);
4251 - while ((getDebugChar() & 0x7f) != '+');
4256 - * Convert the memory pointed to by mem into hex, placing result in buf.
4257 - * Return a pointer to the last char put in buf (null), in case of mem fault,
4259 - * may_fault is non-zero if we are reading from arbitrary memory, but is currently
4262 -static unsigned char *mem2hex(char *mem, char *buf, int count, int may_fault)
4266 - while (count-- > 0) {
4267 - if (kgdb_read_byte(mem++, &ch) != 0)
4269 - *buf++ = hexchars[ch >> 4];
4270 - *buf++ = hexchars[ch & 0xf];
4279 - * convert the hex array pointed to by buf into binary to be placed in mem
4280 - * return a pointer to the character AFTER the last byte written
4281 - * may_fault is non-zero if we are reading from arbitrary memory, but is currently
4284 -static char *hex2mem(char *buf, char *mem, int count, int binary, int may_fault)
4289 - for (i=0; i<count; i++)
4294 - ch = 0x20 ^ *buf++;
4297 - ch = hex(*buf++) << 4;
4298 - ch |= hex(*buf++);
4300 - if (kgdb_write_byte(ch, mem++) != 0)
4308 - * This table contains the mapping between SPARC hardware trap types, and
4309 - * signals, which are primarily what GDB understands. It also indicates
4310 - * which hardware traps we need to commandeer when initializing the stub.
4312 -static struct hard_trap_info {
4313 - unsigned char tt; /* Trap type code for MIPS R3xxx and R4xxx */
4314 - unsigned char signo; /* Signal that we map this trap into */
4315 -} hard_trap_info[] = {
4316 - { 6, SIGBUS }, /* instruction bus error */
4317 - { 7, SIGBUS }, /* data bus error */
4318 - { 9, SIGTRAP }, /* break */
4319 - { 10, SIGILL }, /* reserved instruction */
4320 -/* { 11, SIGILL }, */ /* CPU unusable */
4321 - { 12, SIGFPE }, /* overflow */
4322 - { 13, SIGTRAP }, /* trap */
4323 - { 14, SIGSEGV }, /* virtual instruction cache coherency */
4324 - { 15, SIGFPE }, /* floating point exception */
4325 - { 23, SIGSEGV }, /* watch */
4326 - { 31, SIGSEGV }, /* virtual data cache coherency */
4327 - { 0, 0} /* Must be last */
4330 -/* Save the normal trap handlers for user-mode traps. */
4331 -void *saved_vectors[32];
4334 - * Set up exception handlers for tracing and breakpoints
4336 -void set_debug_traps(void)
4338 - struct hard_trap_info *ht;
4339 - unsigned long flags;
4342 - local_irq_save(flags);
4343 - for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
4344 - saved_vectors[ht->tt] = set_except_vector(ht->tt, trap_low);
4346 - putDebugChar('+'); /* 'hello world' */
4348 - * In case GDB is started before us, ack any packets
4349 - * (presumably "$?#xx") sitting there.
4351 - while((c = getDebugChar()) != '$');
4352 - while((c = getDebugChar()) != '#');
4353 - c = getDebugChar(); /* eat first csum byte */
4354 - c = getDebugChar(); /* eat second csum byte */
4355 - putDebugChar('+'); /* ack it */
4358 - local_irq_restore(flags);
4361 -void restore_debug_traps(void)
4363 - struct hard_trap_info *ht;
4364 - unsigned long flags;
4366 - local_irq_save(flags);
4367 - for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
4368 - set_except_vector(ht->tt, saved_vectors[ht->tt]);
4369 - local_irq_restore(flags);
4373 - * Convert the MIPS hardware trap type code to a Unix signal number.
4375 -static int computeSignal(int tt)
4377 - struct hard_trap_info *ht;
4379 - for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
4383 - return SIGHUP; /* default for things we don't know about */
4387 - * While we find nice hex chars, build an int.
4388 - * Return number of chars processed.
4390 -static int hexToInt(char **ptr, int *intValue)
4398 - hexValue = hex(**ptr);
4402 - *intValue = (*intValue << 4) | hexValue;
4408 - return (numChars);
4411 -static int hexToLong(char **ptr, long *longValue)
4419 - hexValue = hex(**ptr);
4423 - *longValue = (*longValue << 4) | hexValue;
4435 - * Print registers (on target console)
4436 - * Used only to debug the stub...
4438 -void show_gdbregs(struct gdb_regs * regs)
4441 - * Saved main processor registers
4443 - printk("$0 : %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
4444 - regs->reg0, regs->reg1, regs->reg2, regs->reg3,
4445 - regs->reg4, regs->reg5, regs->reg6, regs->reg7);
4446 - printk("$8 : %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
4447 - regs->reg8, regs->reg9, regs->reg10, regs->reg11,
4448 - regs->reg12, regs->reg13, regs->reg14, regs->reg15);
4449 - printk("$16: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
4450 - regs->reg16, regs->reg17, regs->reg18, regs->reg19,
4451 - regs->reg20, regs->reg21, regs->reg22, regs->reg23);
4452 - printk("$24: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
4453 - regs->reg24, regs->reg25, regs->reg26, regs->reg27,
4454 - regs->reg28, regs->reg29, regs->reg30, regs->reg31);
4457 - * Saved cp0 registers
4459 - printk("epc : %08lx\nStatus: %08lx\nCause : %08lx\n",
4460 - regs->cp0_epc, regs->cp0_status, regs->cp0_cause);
4462 -#endif /* dead code */
4465 - * We single-step by setting breakpoints. When an exception
4466 - * is handled, we need to restore the instructions hoisted
4467 - * when the breakpoints were set.
4469 - * This is where we save the original instructions.
4471 -static struct gdb_bp_save {
4472 - unsigned long addr;
4476 -#define BP 0x0000000d /* break opcode */
4479 - * Set breakpoint instructions for single stepping.
4481 -static void single_step(struct gdb_regs *regs)
4483 - union mips_instruction insn;
4484 - unsigned long targ;
4485 - int is_branch, is_cond, i;
4487 - targ = regs->cp0_epc;
4488 - insn.word = *(unsigned int *)targ;
4489 - is_branch = is_cond = 0;
4491 - switch (insn.i_format.opcode) {
4493 - * jr and jalr are in r_format format.
4496 - switch (insn.r_format.func) {
4499 - targ = *(®s->reg0 + insn.r_format.rs);
4506 - * This group contains:
4507 - * bltz_op, bgez_op, bltzl_op, bgezl_op,
4508 - * bltzal_op, bgezal_op, bltzall_op, bgezall_op.
4511 - is_branch = is_cond = 1;
4512 - targ += 4 + (insn.i_format.simmediate << 2);
4516 - * These are unconditional and in j_format.
4524 - targ |= (insn.j_format.target << 2);
4528 - * These are conditional.
4542 - is_branch = is_cond = 1;
4543 - targ += 4 + (insn.i_format.simmediate << 2);
4549 - if (is_cond && targ != (regs->cp0_epc + 8)) {
4550 - step_bp[i].addr = regs->cp0_epc + 8;
4551 - step_bp[i++].val = *(unsigned *)(regs->cp0_epc + 8);
4552 - *(unsigned *)(regs->cp0_epc + 8) = BP;
4554 - step_bp[i].addr = targ;
4555 - step_bp[i].val = *(unsigned *)targ;
4556 - *(unsigned *)targ = BP;
4558 - step_bp[0].addr = regs->cp0_epc + 4;
4559 - step_bp[0].val = *(unsigned *)(regs->cp0_epc + 4);
4560 - *(unsigned *)(regs->cp0_epc + 4) = BP;
4565 - * If asynchronously interrupted by gdb, then we need to set a breakpoint
4566 - * at the interrupted instruction so that we wind up stopped with a
4567 - * reasonable stack frame.
4569 -static struct gdb_bp_save async_bp;
4572 - * Swap the interrupted EPC with our asynchronous breakpoint routine.
4573 - * This is safer than stuffing the breakpoint in-place, since no cache
4574 - * flushes (or resulting smp_call_functions) are required. The
4575 - * assumption is that only one CPU will be handling asynchronous bp's,
4576 - * and only one can be active at a time.
4578 -extern spinlock_t smp_call_lock;
4580 -void set_async_breakpoint(unsigned long *epc)
4582 - /* skip breaking into userland */
4583 - if ((*epc & 0x80000000) == 0)
4587 - /* avoid deadlock if someone is make IPC */
4588 - if (spin_is_locked(&smp_call_lock))
4592 - async_bp.addr = *epc;
4593 - *epc = (unsigned long)async_breakpoint;
4596 -static void kgdb_wait(void *arg)
4599 - int cpu = smp_processor_id();
4601 - local_irq_save(flags);
4603 - __raw_spin_lock(&kgdb_cpulock[cpu]);
4604 - __raw_spin_unlock(&kgdb_cpulock[cpu]);
4606 - local_irq_restore(flags);
4610 - * GDB stub needs to call kgdb_wait on all processor with interrupts
4611 - * disabled, so it uses it's own special variant.
4613 -static int kgdb_smp_call_kgdb_wait(void)
4616 - struct call_data_struct data;
4617 - int i, cpus = num_online_cpus() - 1;
4618 - int cpu = smp_processor_id();
4621 - * Can die spectacularly if this CPU isn't yet marked online
4623 - BUG_ON(!cpu_online(cpu));
4628 - if (spin_is_locked(&smp_call_lock)) {
4630 - * Some other processor is trying to make us do something
4631 - * but we're not going to respond... give up
4637 - * We will continue here, accepting the fact that
4638 - * the kernel may deadlock if another CPU attempts
4639 - * to call smp_call_function now...
4642 - data.func = kgdb_wait;
4644 - atomic_set(&data.started, 0);
4647 - spin_lock(&smp_call_lock);
4648 - call_data = &data;
4651 - /* Send a message to all other CPUs and wait for them to respond */
4652 - for (i = 0; i < NR_CPUS; i++)
4653 - if (cpu_online(i) && i != cpu)
4654 - core_send_ipi(i, SMP_CALL_FUNCTION);
4656 - /* Wait for response */
4657 - /* FIXME: lock-up detection, backtrace on lock-up */
4658 - while (atomic_read(&data.started) != cpus)
4662 - spin_unlock(&smp_call_lock);
4669 - * This function does all command processing for interfacing to gdb. It
4670 - * returns 1 if you should skip the instruction at the trap address, 0
4673 -void handle_exception (struct gdb_regs *regs)
4675 - int trap; /* Trap type */
4680 - unsigned long *stack;
4687 - * acquire the big kgdb spinlock
4689 - if (!spin_trylock(&kgdb_lock)) {
4691 - * some other CPU has the lock, we should go back to
4692 - * receive the gdb_wait IPC
4698 - * If we're in async_breakpoint(), restore the real EPC from
4701 - if (regs->cp0_epc == (unsigned long)async_breakinst) {
4702 - regs->cp0_epc = async_bp.addr;
4703 - async_bp.addr = 0;
4707 - * acquire the CPU spinlocks
4709 - for (i = num_online_cpus()-1; i >= 0; i--)
4710 - if (__raw_spin_trylock(&kgdb_cpulock[i]) == 0)
4711 - panic("kgdb: couldn't get cpulock %d\n", i);
4714 - * force other cpus to enter kgdb
4716 - kgdb_smp_call_kgdb_wait();
4719 - * If we're in breakpoint() increment the PC
4721 - trap = (regs->cp0_cause & 0x7c) >> 2;
4722 - if (trap == 9 && regs->cp0_epc == (unsigned long)breakinst)
4723 - regs->cp0_epc += 4;
4726 - * If we were single_stepping, restore the opcodes hoisted
4727 - * for the breakpoint[s].
4729 - if (step_bp[0].addr) {
4730 - *(unsigned *)step_bp[0].addr = step_bp[0].val;
4731 - step_bp[0].addr = 0;
4733 - if (step_bp[1].addr) {
4734 - *(unsigned *)step_bp[1].addr = step_bp[1].val;
4735 - step_bp[1].addr = 0;
4739 - stack = (long *)regs->reg29; /* stack ptr */
4740 - sigval = computeSignal(trap);
4743 - * reply to host that an exception has occurred
4745 - ptr = output_buffer;
4748 - * Send trap type (converted to signal)
4751 - *ptr++ = hexchars[sigval >> 4];
4752 - *ptr++ = hexchars[sigval & 0xf];
4757 - *ptr++ = hexchars[REG_EPC >> 4];
4758 - *ptr++ = hexchars[REG_EPC & 0xf];
4760 - ptr = mem2hex((char *)®s->cp0_epc, ptr, sizeof(long), 0);
4764 - * Send frame pointer
4766 - *ptr++ = hexchars[REG_FP >> 4];
4767 - *ptr++ = hexchars[REG_FP & 0xf];
4769 - ptr = mem2hex((char *)®s->reg30, ptr, sizeof(long), 0);
4773 - * Send stack pointer
4775 - *ptr++ = hexchars[REG_SP >> 4];
4776 - *ptr++ = hexchars[REG_SP & 0xf];
4778 - ptr = mem2hex((char *)®s->reg29, ptr, sizeof(long), 0);
4782 - putpacket(output_buffer); /* send it off... */
4785 - * Wait for input from remote GDB
4788 - output_buffer[0] = 0;
4789 - getpacket(input_buffer);
4791 - switch (input_buffer[0])
4794 - output_buffer[0] = 'S';
4795 - output_buffer[1] = hexchars[sigval >> 4];
4796 - output_buffer[2] = hexchars[sigval & 0xf];
4797 - output_buffer[3] = 0;
4801 - * Detach debugger; let CPU run
4804 - putpacket(output_buffer);
4809 - /* toggle debug flag */
4813 - * Return the value of the CPU registers
4816 - ptr = output_buffer;
4817 - ptr = mem2hex((char *)®s->reg0, ptr, 32*sizeof(long), 0); /* r0...r31 */
4818 - ptr = mem2hex((char *)®s->cp0_status, ptr, 6*sizeof(long), 0); /* cp0 */
4819 - ptr = mem2hex((char *)®s->fpr0, ptr, 32*sizeof(long), 0); /* f0...31 */
4820 - ptr = mem2hex((char *)®s->cp1_fsr, ptr, 2*sizeof(long), 0); /* cp1 */
4821 - ptr = mem2hex((char *)®s->frame_ptr, ptr, 2*sizeof(long), 0); /* frp */
4822 - ptr = mem2hex((char *)®s->cp0_index, ptr, 16*sizeof(long), 0); /* cp0 */
4826 - * set the value of the CPU registers - return OK
4830 - ptr = &input_buffer[1];
4831 - hex2mem(ptr, (char *)®s->reg0, 32*sizeof(long), 0, 0);
4832 - ptr += 32*(2*sizeof(long));
4833 - hex2mem(ptr, (char *)®s->cp0_status, 6*sizeof(long), 0, 0);
4834 - ptr += 6*(2*sizeof(long));
4835 - hex2mem(ptr, (char *)®s->fpr0, 32*sizeof(long), 0, 0);
4836 - ptr += 32*(2*sizeof(long));
4837 - hex2mem(ptr, (char *)®s->cp1_fsr, 2*sizeof(long), 0, 0);
4838 - ptr += 2*(2*sizeof(long));
4839 - hex2mem(ptr, (char *)®s->frame_ptr, 2*sizeof(long), 0, 0);
4840 - ptr += 2*(2*sizeof(long));
4841 - hex2mem(ptr, (char *)®s->cp0_index, 16*sizeof(long), 0, 0);
4842 - strcpy(output_buffer,"OK");
4847 - * mAA..AA,LLLL Read LLLL bytes at address AA..AA
4850 - ptr = &input_buffer[1];
4852 - if (hexToLong(&ptr, &addr)
4854 - && hexToInt(&ptr, &length)) {
4855 - if (mem2hex((char *)addr, output_buffer, length, 1))
4857 - strcpy (output_buffer, "E03");
4859 - strcpy(output_buffer,"E01");
4863 - * XAA..AA,LLLL: Write LLLL escaped binary bytes at address AA.AA
4867 - /* fall through */
4870 - * MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK
4873 - ptr = &input_buffer[1];
4875 - if (hexToLong(&ptr, &addr)
4877 - && hexToInt(&ptr, &length)
4878 - && *ptr++ == ':') {
4879 - if (hex2mem(ptr, (char *)addr, length, bflag, 1))
4880 - strcpy(output_buffer, "OK");
4882 - strcpy(output_buffer, "E03");
4885 - strcpy(output_buffer, "E02");
4889 - * cAA..AA Continue at address AA..AA(optional)
4892 - /* try to read optional parameter, pc unchanged if no parm */
4894 - ptr = &input_buffer[1];
4895 - if (hexToLong(&ptr, &addr))
4896 - regs->cp0_epc = addr;
4898 - goto exit_kgdb_exception;
4902 - * kill the program; let us try to restart the machine
4903 - * Reset the whole machine.
4907 - machine_restart("kgdb restarts machine");
4911 - * Step to next instruction
4915 - * There is no single step insn in the MIPS ISA, so we
4916 - * use breakpoints and continue, instead.
4918 - single_step(regs);
4919 - goto exit_kgdb_exception;
4924 - * Set baud rate (bBB)
4925 - * FIXME: Needs to be written
4931 - extern void set_timer_3();
4933 - ptr = &input_buffer[1];
4934 - if (!hexToInt(&ptr, &baudrate))
4936 - strcpy(output_buffer,"B01");
4940 - /* Convert baud rate to uart clock divider */
4955 - strcpy(output_buffer,"B02");
4960 - putpacket("OK"); /* Ack before changing speed */
4961 - set_timer_3(baudrate); /* Set it */
4970 - * reply to the request
4973 - putpacket(output_buffer);
4980 - restore_debug_traps();
4982 -exit_kgdb_exception:
4983 - /* release locks so other CPUs can go */
4984 - for (i = num_online_cpus()-1; i >= 0; i--)
4985 - __raw_spin_unlock(&kgdb_cpulock[i]);
4986 - spin_unlock(&kgdb_lock);
4988 - __flush_cache_all();
4993 - * This function will generate a breakpoint exception. It is used at the
4994 - * beginning of a program to sync up with a debugger and can be used
4995 - * otherwise as a quick means to stop program execution and "break" into
4998 -void breakpoint(void)
5003 - __asm__ __volatile__(
5004 - ".globl breakinst\n\t"
5005 - ".set\tnoreorder\n\t"
5007 - "breakinst:\tbreak\n\t"
5013 -/* Nothing but the break; don't pollute any registers */
5014 -void async_breakpoint(void)
5016 - __asm__ __volatile__(
5017 - ".globl async_breakinst\n\t"
5018 - ".set\tnoreorder\n\t"
5020 - "async_breakinst:\tbreak\n\t"
5028 - __asm__ __volatile__(
5029 - ".globl\tadel\n\t"
5030 - "lui\t$8,0x8000\n\t"
5031 - "lw\t$9,1($8)\n\t"
5036 - * malloc is needed by gdb client in "call func()", even a private one
5037 - * will make gdb happy
5039 -static void * __attribute_used__ malloc(size_t size)
5041 - return kmalloc(size, GFP_ATOMIC);
5044 -static void __attribute_used__ free (void *where)
5049 -#ifdef CONFIG_GDB_CONSOLE
5051 -void gdb_putsn(const char *str, int l)
5055 - if (!kgdb_started)
5061 - int i = (l>8)?8:l;
5062 - mem2hex((char *)str, &outbuf[1], i, 0);
5063 - outbuf[(i*2)+1]=0;
5064 - putpacket(outbuf);
5070 -static void gdb_console_write(struct console *con, const char *s, unsigned n)
5075 -static struct console gdb_console = {
5077 - .write = gdb_console_write,
5078 - .flags = CON_PRINTBUFFER,
5082 -static int __init register_gdb_console(void)
5084 - register_console(&gdb_console);
5089 -console_initcall(register_gdb_console);
5092 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/mips/kernel/irq.c linux-2.6.18.kgdb/arch/mips/kernel/irq.c
5093 --- linux-2.6.18/arch/mips/kernel/irq.c 2006-09-20 07:42:06.000000000 +0400
5094 +++ linux-2.6.18.kgdb/arch/mips/kernel/irq.c 2008-06-10 16:19:28.000000000 +0400
5096 #include <asm/atomic.h>
5097 #include <asm/system.h>
5098 #include <asm/uaccess.h>
5099 +#include <asm/kgdb.h>
5101 +/* Keep track of if we've done certain initialization already or not. */
5102 +int kgdb_early_setup;
5105 * 'what should we do if we get a hw irq event on an illegal vector'.
5106 @@ -115,23 +119,13 @@ asmlinkage void spurious_interrupt(struc
5107 atomic_inc(&irq_err_count);
5111 -extern void breakpoint(void);
5112 -extern void set_debug_traps(void);
5114 -static int kgdb_flag = 1;
5115 -static int __init nokgdb(char *str)
5120 -__setup("nokgdb", nokgdb);
5123 void __init init_IRQ(void)
5127 + if (kgdb_early_setup)
5130 for (i = 0; i < NR_IRQS; i++) {
5131 irq_desc[i].status = IRQ_DISABLED;
5132 irq_desc[i].action = NULL;
5133 @@ -144,12 +138,12 @@ void __init init_IRQ(void)
5140 - printk("Wait for gdb client connection ...\n");
5141 - set_debug_traps();
5145 + * We have been called before kgdb_arch_init(). Hence,
5146 + * we dont want the traps to be reinitialized
5148 + if (kgdb_early_setup == 0)
5149 + kgdb_early_setup = 1;
5152 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/mips/kernel/kgdb-jmp.c linux-2.6.18.kgdb/arch/mips/kernel/kgdb-jmp.c
5153 --- linux-2.6.18/arch/mips/kernel/kgdb-jmp.c 1970-01-01 03:00:00.000000000 +0300
5154 +++ linux-2.6.18.kgdb/arch/mips/kernel/kgdb-jmp.c 2008-06-10 16:19:28.000000000 +0400
5157 + * arch/mips/kernel/kgdb-jmp.c
5159 + * Save and restore system registers so that within a limited frame we
5160 + * may have a fault and "jump back" to a known safe location.
5162 + * Author: Tom Rini <trini@kernel.crashing.org>
5163 + * Author: Manish Lachwani <mlachwani@mvista.com>
5165 + * Cribbed from glibc, which carries the following:
5166 + * Copyright (C) 1996, 1997, 2000, 2002, 2003 Free Software Foundation, Inc.
5167 + * Copyright (C) 2005 by MontaVista Software.
5169 + * This file is licensed under the terms of the GNU General Public License
5170 + * version 2. This program as licensed "as is" without any warranty of
5171 + * any kind, whether express or implied.
5174 +#include <linux/kgdb.h>
5175 +#include <asm/interrupt.h>
5177 +#ifdef CONFIG_MIPS64
5182 +int kgdb_fault_setjmp_aux(unsigned long *curr_context, int sp, int fp)
5184 + __asm__ __volatile__ ("sd $gp, %0" : : "m" (curr_context[0]));
5185 + __asm__ __volatile__ ("sd $16, %0" : : "m" (curr_context[1]));
5186 + __asm__ __volatile__ ("sd $17, %0" : : "m" (curr_context[2]));
5187 + __asm__ __volatile__ ("sd $18, %0" : : "m" (curr_context[3]));
5188 + __asm__ __volatile__ ("sd $19, %0" : : "m" (curr_context[4]));
5189 + __asm__ __volatile__ ("sd $20, %0" : : "m" (curr_context[5]));
5190 + __asm__ __volatile__ ("sd $21, %0" : : "m" (curr_context[6]));
5191 + __asm__ __volatile__ ("sd $22, %0" : : "m" (curr_context[7]));
5192 + __asm__ __volatile__ ("sd $23, %0" : : "m" (curr_context[8]));
5193 + __asm__ __volatile__ ("sd $31, %0" : : "m" (curr_context[9]));
5194 + curr_context[10] = (long *)sp;
5195 + curr_context[11] = (long *)fp;
5200 +void kgdb_fault_longjmp(unsigned long *curr_context)
5202 + unsigned long sp_val, fp_val;
5204 + __asm__ __volatile__ ("ld $gp, %0" : : "m" (curr_context[0]));
5205 + __asm__ __volatile__ ("ld $16, %0" : : "m" (curr_context[1]));
5206 + __asm__ __volatile__ ("ld $17, %0" : : "m" (curr_context[2]));
5207 + __asm__ __volatile__ ("ld $18, %0" : : "m" (curr_context[3]));
5208 + __asm__ __volatile__ ("ld $19, %0" : : "m" (curr_context[4]));
5209 + __asm__ __volatile__ ("ld $20, %0" : : "m" (curr_context[5]));
5210 + __asm__ __volatile__ ("ld $21, %0" : : "m" (curr_context[6]));
5211 + __asm__ __volatile__ ("ld $22, %0" : : "m" (curr_context[7]));
5212 + __asm__ __volatile__ ("ld $23, %0" : : "m" (curr_context[8]));
5213 + __asm__ __volatile__ ("ld $25, %0" : : "m" (curr_context[9]));
5214 + sp_val = curr_context[10];
5215 + fp_val = curr_context[11];
5216 + __asm__ __volatile__ ("ld $29, %0\n\t"
5217 + "ld $30, %1\n\t" : : "m" (sp_val), "m" (fp_val));
5219 + __asm__ __volatile__ ("dli $2, 1");
5220 + __asm__ __volatile__ ("j $25");
5229 +int kgdb_fault_setjmp_aux(unsigned long *curr_context, int sp, int fp)
5231 + __asm__ __volatile__("sw $gp, %0" : : "m" (curr_context[0]));
5232 + __asm__ __volatile__("sw $16, %0" : : "m" (curr_context[1]));
5233 + __asm__ __volatile__("sw $17, %0" : : "m" (curr_context[2]));
5234 + __asm__ __volatile__("sw $18, %0" : : "m" (curr_context[3]));
5235 + __asm__ __volatile__("sw $19, %0" : : "m" (curr_context[4]));
5236 + __asm__ __volatile__("sw $20, %0" : : "m" (curr_context[5]));
5237 + __asm__ __volatile__("sw $21, %0" : : "m" (curr_context[6]));
5238 + __asm__ __volatile__("sw $22, %0" : : "m" (curr_context[7]));
5239 + __asm__ __volatile__("sw $23, %0" : : "m" (curr_context[8]));
5240 + __asm__ __volatile__("sw $31, %0" : : "m" (curr_context[9]));
5241 + curr_context[10] = (long *)sp;
5242 + curr_context[11] = (long *)fp;
5247 +void kgdb_fault_longjmp(unsigned long *curr_context)
5249 + unsigned long sp_val, fp_val;
5251 + __asm__ __volatile__("lw $gp, %0" : : "m" (curr_context[0]));
5252 + __asm__ __volatile__("lw $16, %0" : : "m" (curr_context[1]));
5253 + __asm__ __volatile__("lw $17, %0" : : "m" (curr_context[2]));
5254 + __asm__ __volatile__("lw $18, %0" : : "m" (curr_context[3]));
5255 + __asm__ __volatile__("lw $19, %0" : : "m" (curr_context[4]));
5256 + __asm__ __volatile__("lw $20, %0" : : "m" (curr_context[5]));
5257 + __asm__ __volatile__("lw $21, %0" : : "m" (curr_context[6]));
5258 + __asm__ __volatile__("lw $22, %0" : : "m" (curr_context[7]));
5259 + __asm__ __volatile__("lw $23, %0" : : "m" (curr_context[8]));
5260 + __asm__ __volatile__("lw $25, %0" : : "m" (curr_context[9]));
5261 + sp_val = curr_context[10];
5262 + fp_val = curr_context[11];
5263 + __asm__ __volatile__("lw $29, %0\n\t"
5264 + "lw $30, %1\n\t" : : "m" (sp_val), "m" (fp_val));
5266 + __asm__ __volatile__("li $2, 1");
5267 + __asm__ __volatile__("jr $25");
5272 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/mips/kernel/kgdb-setjmp.S linux-2.6.18.kgdb/arch/mips/kernel/kgdb-setjmp.S
5273 --- linux-2.6.18/arch/mips/kernel/kgdb-setjmp.S 1970-01-01 03:00:00.000000000 +0300
5274 +++ linux-2.6.18.kgdb/arch/mips/kernel/kgdb-setjmp.S 2008-06-10 16:19:28.000000000 +0400
5277 + * arch/mips/kernel/kgdb-jmp.c
5279 + * Save and restore system registers so that within a limited frame we
5280 + * may have a fault and "jump back" to a known safe location.
5282 + * Copyright (C) 2005 by MontaVista Software.
5283 + * Author: Manish Lachwani (mlachwani@mvista.com)
5285 + * This file is licensed under the terms of the GNU General Public License
5286 + * version 2. This program as licensed "as is" without any warranty of
5287 + * any kind, whether express or implied.
5290 +#include <asm/asm.h>
5291 +#include <asm/mipsregs.h>
5292 +#include <asm/regdef.h>
5293 +#include <asm/stackframe.h>
5295 + .ent kgdb_fault_setjmp,0
5296 +ENTRY (kgdb_fault_setjmp)
5299 +#ifdef CONFIG_MIPS64
5302 + j kgdb_fault_setjmp_aux
5303 + .end kgdb_fault_setjmp
5304 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/mips/kernel/kgdb.c linux-2.6.18.kgdb/arch/mips/kernel/kgdb.c
5305 --- linux-2.6.18/arch/mips/kernel/kgdb.c 1970-01-01 03:00:00.000000000 +0300
5306 +++ linux-2.6.18.kgdb/arch/mips/kernel/kgdb.c 2008-06-10 16:19:28.000000000 +0400
5309 + * arch/mips/kernel/kgdb.c
5311 + * Originally written by Glenn Engel, Lake Stevens Instrument Division
5313 + * Contributed by HP Systems
5315 + * Modified for SPARC by Stu Grossman, Cygnus Support.
5317 + * Modified for Linux/MIPS (and MIPS in general) by Andreas Busse
5318 + * Send complaints, suggestions etc. to <andy@waldorf-gmbh.de>
5320 + * Copyright (C) 1995 Andreas Busse
5322 + * Copyright (C) 2003 MontaVista Software Inc.
5323 + * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
5325 + * Copyright (C) 2004-2005 MontaVista Software Inc.
5326 + * Author: Manish Lachwani, mlachwani@mvista.com or manish@koffee-break.com
5328 + * This file is licensed under the terms of the GNU General Public License
5329 + * version 2. This program is licensed "as is" without any warranty of any
5330 + * kind, whether express or implied.
5333 +#include <linux/string.h>
5334 +#include <linux/kernel.h>
5335 +#include <linux/sched.h>
5336 +#include <linux/smp.h>
5337 +#include <linux/spinlock.h>
5338 +#include <linux/delay.h>
5339 +#include <asm/system.h>
5340 +#include <asm/ptrace.h> /* for linux pt_regs struct */
5341 +#include <linux/kgdb.h>
5342 +#include <linux/init.h>
5343 +#include <asm/inst.h>
5344 +#include <asm/gdb-stub.h>
5345 +#include <asm/cacheflush.h>
5346 +#include <asm/kdebug.h>
5348 +static struct hard_trap_info {
5349 + unsigned char tt; /* Trap type code for MIPS R3xxx and R4xxx */
5350 + unsigned char signo; /* Signal that we map this trap into */
5351 +} hard_trap_info[] = {
5352 + { 6, SIGBUS }, /* instruction bus error */
5353 + { 7, SIGBUS }, /* data bus error */
5354 + { 9, SIGTRAP }, /* break */
5355 +/* { 11, SIGILL }, */ /* CPU unusable */
5356 + { 12, SIGFPE }, /* overflow */
5357 + { 13, SIGTRAP }, /* trap */
5358 + { 14, SIGSEGV }, /* virtual instruction cache coherency */
5359 + { 15, SIGFPE }, /* floating point exception */
5360 + { 23, SIGSEGV }, /* watch */
5361 + { 31, SIGSEGV }, /* virtual data cache coherency */
5362 + { 0, 0} /* Must be last */
5365 +/* Save the normal trap handlers for user-mode traps. */
5366 +void *saved_vectors[32];
5368 +extern void trap_low(void);
5369 +extern void breakinst(void);
5370 +extern void init_IRQ(void);
5372 +void kgdb_call_nmi_hook(void *ignored)
5374 + kgdb_nmihook(smp_processor_id(), (void *)0);
5377 +void kgdb_roundup_cpus(unsigned long flags)
5379 + local_irq_restore(flags);
5380 + smp_call_function(kgdb_call_nmi_hook, 0, 0, 0);
5381 + local_irq_save(flags);
5384 +static int compute_signal(int tt)
5386 + struct hard_trap_info *ht;
5388 + for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
5392 + return SIGHUP; /* default for things we don't know about */
5396 + * Set up exception handlers for tracing and breakpoints
5398 +void handle_exception(struct pt_regs *regs)
5400 + int trap = (regs->cp0_cause & 0x7c) >> 2;
5402 + if (fixup_exception(regs)) {
5406 + if (atomic_read(&debugger_active))
5407 + kgdb_nmihook(smp_processor_id(), regs);
5409 + if (atomic_read(&kgdb_setting_breakpoint))
5410 + if ((trap == 9) && (regs->cp0_epc == (unsigned long)breakinst))
5411 + regs->cp0_epc += 4;
5413 + kgdb_handle_exception(0, compute_signal(trap), 0, regs);
5415 + /* In SMP mode, __flush_cache_all does IPI */
5416 + __flush_cache_all();
5419 +void set_debug_traps(void)
5421 + struct hard_trap_info *ht;
5422 + unsigned long flags;
5424 + local_irq_save(flags);
5426 + for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
5427 + saved_vectors[ht->tt] = set_except_vector(ht->tt, trap_low);
5429 + local_irq_restore(flags);
5433 +/* This should be called before we exit kgdb_handle_exception() I believe.
5436 +void restore_debug_traps(void)
5438 + struct hard_trap_info *ht;
5439 + unsigned long flags;
5441 + local_irq_save(flags);
5442 + for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
5443 + set_except_vector(ht->tt, saved_vectors[ht->tt]);
5444 + local_irq_restore(flags);
5448 +void regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs)
5451 + gdb_reg_t *ptr = (gdb_reg_t*)gdb_regs;
5453 + for (reg = 0; reg < 32; reg++)
5454 + *(ptr++) = regs->regs[reg];
5456 + *(ptr++) = regs->cp0_status;
5457 + *(ptr++) = regs->lo;
5458 + *(ptr++) = regs->hi;
5459 + *(ptr++) = regs->cp0_badvaddr;
5460 + *(ptr++) = regs->cp0_cause;
5461 + *(ptr++) = regs->cp0_epc;
5466 +void gdb_regs_to_regs(unsigned long *gdb_regs, struct pt_regs *regs)
5470 + const gdb_reg_t *ptr = (gdb_reg_t*)gdb_regs;
5472 + for (reg = 0; reg < 32; reg++)
5473 + regs->regs[reg] = *(ptr++);
5475 + regs->cp0_status = *(ptr++);
5476 + regs->lo = *(ptr++);
5477 + regs->hi = *(ptr++);
5478 + regs->cp0_badvaddr = *(ptr++);
5479 + regs->cp0_cause = *(ptr++);
5480 + regs->cp0_epc = *(ptr++);
5486 + * Similar to regs_to_gdb_regs() except that process is sleeping and so
5487 + * we may not be able to get all the info.
5489 +void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p)
5492 + struct thread_info *ti = p->thread_info;
5493 + unsigned long ksp = (unsigned long)ti + THREAD_SIZE - 32;
5494 + struct pt_regs *regs = (struct pt_regs *)ksp - 1;
5495 + gdb_reg_t *ptr = (gdb_reg_t*)gdb_regs;
5497 + for (reg = 0; reg < 16; reg++)
5498 + *(ptr++) = regs->regs[reg];
5501 + for (reg = 16; reg < 24; reg++)
5502 + *(ptr++) = regs->regs[reg];
5504 + for (reg = 24; reg < 28; reg++)
5507 + /* GP, SP, FP, RA */
5508 + for (reg = 28; reg < 32; reg++)
5509 + *(ptr++) = regs->regs[reg];
5511 + *(ptr++) = regs->cp0_status;
5512 + *(ptr++) = regs->lo;
5513 + *(ptr++) = regs->hi;
5514 + *(ptr++) = regs->cp0_badvaddr;
5515 + *(ptr++) = regs->cp0_cause;
5516 + *(ptr++) = regs->cp0_epc;
5522 + * Calls linux_debug_hook before the kernel dies. If KGDB is enabled,
5523 + * then try to fall into the debugger
5525 +static int kgdb_mips_notify(struct notifier_block *self, unsigned long cmd,
5528 + struct die_args *args = (struct die_args *)ptr;
5529 + struct pt_regs *regs = args->regs;
5530 + int trap = (regs->cp0_cause & 0x7c) >> 2;
5532 + /* See if KGDB is interested. */
5533 + if (user_mode(regs))
5534 + /* Userpace events, ignore. */
5535 + return NOTIFY_DONE;
5537 + kgdb_handle_exception(trap, compute_signal(trap), 0, regs);
5541 +static struct notifier_block kgdb_notifier = {
5542 + .notifier_call = kgdb_mips_notify,
5546 + * Handle the 's' and 'c' commands
5548 +int kgdb_arch_handle_exception(int vector, int signo, int err_code,
5549 + char *remcom_in_buffer, char *remcom_out_buffer,
5550 + struct pt_regs *regs)
5553 + unsigned long address;
5554 + int cpu = smp_processor_id();
5556 + switch (remcom_in_buffer[0]) {
5559 + /* handle the optional parameter */
5560 + ptr = &remcom_in_buffer[1];
5561 + if (kgdb_hex2long(&ptr, &address))
5562 + regs->cp0_epc = address;
5564 + atomic_set(&cpu_doing_single_step, -1);
5565 + if (remcom_in_buffer[0] == 's')
5566 + if (kgdb_contthread)
5567 + atomic_set(&cpu_doing_single_step, cpu);
5575 +struct kgdb_arch arch_kgdb_ops = {
5576 +#ifdef CONFIG_CPU_LITTLE_ENDIAN
5577 + .gdb_bpt_instr = {0xd},
5579 + .gdb_bpt_instr = {0x00, 0x00, 0x00, 0x0d},
5584 + * We use kgdb_early_setup so that functions we need to call now don't
5585 + * cause trouble when called again later.
5587 +int kgdb_arch_init(void)
5589 + /* Board-specifics. */
5590 + /* Force some calls to happen earlier. */
5591 + if (kgdb_early_setup == 0) {
5594 + kgdb_early_setup = 1;
5597 + /* Set our traps. */
5598 + /* This needs to be done more finely grained again, paired in
5599 + * a before/after in kgdb_handle_exception(...) -- Tom */
5600 + set_debug_traps();
5601 + notifier_chain_register(&mips_die_chain, &kgdb_notifier);
5605 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/mips/kernel/kgdb_handler.S linux-2.6.18.kgdb/arch/mips/kernel/kgdb_handler.S
5606 --- linux-2.6.18/arch/mips/kernel/kgdb_handler.S 1970-01-01 03:00:00.000000000 +0300
5607 +++ linux-2.6.18.kgdb/arch/mips/kernel/kgdb_handler.S 2008-06-10 16:19:28.000000000 +0400
5610 + * arch/mips/kernel/kgdb_handler.S
5612 + * Copyright (C) 2004-2005 MontaVista Software Inc.
5613 + * Author: Manish Lachwani, mlachwani@mvista.com or manish@koffee-break.com
5615 + * This file is licensed under the terms of the GNU General Public
5616 + * version 2. This program is licensed "as is" without any warranty of any
5617 + * kind, whether express or implied.
5621 + * Trap Handler for the new KGDB framework. The main KGDB handler is
5622 + * handle_exception that will be called from here
5626 +#include <linux/config.h>
5627 +#include <linux/sys.h>
5629 +#include <asm/asm.h>
5630 +#include <asm/errno.h>
5631 +#include <asm/mipsregs.h>
5632 +#include <asm/regdef.h>
5633 +#include <asm/stackframe.h>
5636 + NESTED(trap_low, PT_SIZE, sp)
5641 + * Check for privileged instructions in user mode. For
5642 + * this, check the cu0 bit in the CPU status register.
5644 + mfc0 k0, CP0_STATUS
5650 + * GDB userland from within KGDB. If a user mode address
5651 + * then jump to the saved exception handler
5653 + mfc0 k1, CP0_CAUSE
5655 + PTR_L k0, saved_vectors(k1)
5663 + jal handle_exception
5664 + j ret_from_exception
5666 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/mips/kernel/traps.c linux-2.6.18.kgdb/arch/mips/kernel/traps.c
5667 --- linux-2.6.18/arch/mips/kernel/traps.c 2006-09-20 07:42:06.000000000 +0400
5668 +++ linux-2.6.18.kgdb/arch/mips/kernel/traps.c 2008-06-10 16:19:28.000000000 +0400
5670 * Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
5671 * Copyright (C) 2000, 01 MIPS Technologies, Inc.
5672 * Copyright (C) 2002, 2003, 2004, 2005 Maciej W. Rozycki
5674 + * KGDB specific changes - Manish Lachwani (mlachwani@mvista.com)
5676 #include <linux/init.h>
5677 #include <linux/mm.h>
5679 #include <linux/spinlock.h>
5680 #include <linux/kallsyms.h>
5681 #include <linux/bootmem.h>
5682 +#include <linux/kgdb.h>
5684 #include <asm/bootinfo.h>
5685 #include <asm/branch.h>
5687 #include <asm/mmu_context.h>
5688 #include <asm/watch.h>
5689 #include <asm/types.h>
5690 +#include <asm/kdebug.h>
5692 extern asmlinkage void handle_int(void);
5693 extern asmlinkage void handle_tlbm(void);
5694 @@ -78,6 +82,21 @@ void (*board_bind_eic_interrupt)(int irq
5696 #define MODULE_RANGE (8*1024*1024)
5698 +struct notifier_block *mips_die_chain;
5699 +static spinlock_t die_notifier_lock = SPIN_LOCK_UNLOCKED;
5701 +int register_die_notifier(struct notifier_block *nb)
5704 + unsigned long flags;
5706 + spin_lock_irqsave(&die_notifier_lock, flags);
5707 + err = notifier_chain_register(&mips_die_chain, nb);
5708 + spin_unlock_irqrestore(&die_notifier_lock, flags);
5714 * This routine abuses get_user()/put_user() to reference pointers
5715 * with at least a bit of error checking ...
5716 @@ -1387,6 +1406,11 @@ void __init trap_init(void)
5717 extern char except_vec4;
5720 +#if defined(CONFIG_KGDB)
5721 + if (kgdb_early_setup)
5722 + return; /* Already done */
5725 if (cpu_has_veic || cpu_has_vint)
5726 ebase = (unsigned long) alloc_bootmem_low_pages (0x200 + VECTORSPACING*64);
5728 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/mips/mips-boards/generic/Makefile linux-2.6.18.kgdb/arch/mips/mips-boards/generic/Makefile
5729 --- linux-2.6.18/arch/mips/mips-boards/generic/Makefile 2006-09-20 07:42:06.000000000 +0400
5730 +++ linux-2.6.18.kgdb/arch/mips/mips-boards/generic/Makefile 2008-06-10 16:19:28.000000000 +0400
5732 obj-y := reset.o display.o init.o memory.o printf.o \
5734 obj-$(CONFIG_PCI) += pci.o
5735 -obj-$(CONFIG_KGDB) += gdb_hook.o
5737 EXTRA_AFLAGS := $(CFLAGS)
5738 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/mips/mips-boards/generic/init.c linux-2.6.18.kgdb/arch/mips/mips-boards/generic/init.c
5739 --- linux-2.6.18/arch/mips/mips-boards/generic/init.c 2006-09-20 07:42:06.000000000 +0400
5740 +++ linux-2.6.18.kgdb/arch/mips/mips-boards/generic/init.c 2008-06-10 16:19:28.000000000 +0400
5743 #include <asm/mips-boards/malta.h>
5746 -extern int rs_kgdb_hook(int, int);
5747 -extern int rs_putDebugChar(char);
5748 -extern char rs_getDebugChar(void);
5749 -extern int saa9730_kgdb_hook(int);
5750 -extern int saa9730_putDebugChar(char);
5751 -extern char saa9730_getDebugChar(void);
5755 int *_prom_argv, *_prom_envp;
5757 @@ -172,58 +163,6 @@ static void __init console_config(void)
5762 -void __init kgdb_config (void)
5764 - extern int (*generic_putDebugChar)(char);
5765 - extern char (*generic_getDebugChar)(void);
5769 - argptr = prom_getcmdline();
5770 - if ((argptr = strstr(argptr, "kgdb=ttyS")) != NULL) {
5771 - argptr += strlen("kgdb=ttyS");
5772 - if (*argptr != '0' && *argptr != '1')
5773 - printk("KGDB: Unknown serial line /dev/ttyS%c, "
5774 - "falling back to /dev/ttyS1\n", *argptr);
5775 - line = *argptr == '0' ? 0 : 1;
5776 - printk("KGDB: Using serial line /dev/ttyS%d for session\n", line);
5779 - if (*++argptr == ',')
5782 - while ((c = *++argptr) && ('0' <= c && c <= '9'))
5783 - speed = speed * 10 + c - '0';
5785 -#ifdef CONFIG_MIPS_ATLAS
5787 - speed = saa9730_kgdb_hook(speed);
5788 - generic_putDebugChar = saa9730_putDebugChar;
5789 - generic_getDebugChar = saa9730_getDebugChar;
5794 - speed = rs_kgdb_hook(line, speed);
5795 - generic_putDebugChar = rs_putDebugChar;
5796 - generic_getDebugChar = rs_getDebugChar;
5799 - prom_printf("KGDB: Using serial line /dev/ttyS%d at %d for session, "
5800 - "please connect your debugger\n", line ? 1 : 0, speed);
5804 - for (s = "Please connect GDB to this port\r\n"; *s; )
5805 - generic_putDebugChar (*s++);
5808 - /* Breakpoint is invoked after interrupts are initialised */
5813 void __init mips_nmi_setup (void)
5816 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/mips/mips-boards/malta/malta_setup.c linux-2.6.18.kgdb/arch/mips/mips-boards/malta/malta_setup.c
5817 --- linux-2.6.18/arch/mips/mips-boards/malta/malta_setup.c 2006-09-20 07:42:06.000000000 +0400
5818 +++ linux-2.6.18.kgdb/arch/mips/mips-boards/malta/malta_setup.c 2008-06-10 16:19:28.000000000 +0400
5819 @@ -46,10 +46,6 @@ extern void mips_reboot_setup(void);
5820 extern void mips_time_init(void);
5821 extern unsigned long mips_rtc_get_time(void);
5824 -extern void kgdb_config(void);
5827 struct resource standard_io_resources[] = {
5828 { .name = "dma1", .start = 0x00, .end = 0x1f, .flags = IORESOURCE_BUSY },
5829 { .name = "timer", .start = 0x40, .end = 0x5f, .flags = IORESOURCE_BUSY },
5830 @@ -124,10 +120,6 @@ void __init plat_mem_setup(void)
5838 if ((mips_revision_corid == MIPS_REVISION_CORID_BONITO64) ||
5839 (mips_revision_corid == MIPS_REVISION_CORID_CORE_20K) ||
5840 (mips_revision_corid == MIPS_REVISION_CORID_CORE_EMUL_BON)) {
5841 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/mips/mm/extable.c linux-2.6.18.kgdb/arch/mips/mm/extable.c
5842 --- linux-2.6.18/arch/mips/mm/extable.c 2006-09-20 07:42:06.000000000 +0400
5843 +++ linux-2.6.18.kgdb/arch/mips/mm/extable.c 2008-06-10 16:19:28.000000000 +0400
5846 #include <linux/module.h>
5847 #include <linux/spinlock.h>
5848 +#include <linux/kgdb.h>
5849 #include <asm/branch.h>
5850 #include <asm/uaccess.h>
5852 @@ -16,6 +17,12 @@ int fixup_exception(struct pt_regs *regs
5857 + if (atomic_read(&debugger_active) && kgdb_may_fault)
5858 + /* Restore our previous state. */
5859 + kgdb_fault_longjmp(kgdb_fault_jmp_regs);
5860 + /* Not reached. */
5865 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/mips/sibyte/cfe/setup.c linux-2.6.18.kgdb/arch/mips/sibyte/cfe/setup.c
5866 --- linux-2.6.18/arch/mips/sibyte/cfe/setup.c 2006-09-20 07:42:06.000000000 +0400
5867 +++ linux-2.6.18.kgdb/arch/mips/sibyte/cfe/setup.c 2008-06-10 16:19:28.000000000 +0400
5868 @@ -58,10 +58,6 @@ int cfe_cons_handle;
5869 extern unsigned long initrd_start, initrd_end;
5873 -extern int kgdb_port;
5876 static void ATTRIB_NORET cfe_linux_exit(void *arg)
5878 int warm = *(int *)arg;
5879 @@ -242,9 +238,6 @@ void __init prom_init(void)
5881 char **envp = (char **) fw_arg2;
5882 int *prom_vec = (int *) fw_arg3;
5887 _machine_restart = cfe_linux_restart;
5888 _machine_halt = cfe_linux_halt;
5889 @@ -308,13 +301,6 @@ void __init prom_init(void)
5894 - if ((arg = strstr(arcs_cmdline,"kgdb=duart")) != NULL)
5895 - kgdb_port = (arg[10] == '0') ? 0 : 1;
5900 #ifdef CONFIG_BLK_DEV_INITRD
5903 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/mips/sibyte/sb1250/Makefile linux-2.6.18.kgdb/arch/mips/sibyte/sb1250/Makefile
5904 --- linux-2.6.18/arch/mips/sibyte/sb1250/Makefile 2006-09-20 07:42:06.000000000 +0400
5905 +++ linux-2.6.18.kgdb/arch/mips/sibyte/sb1250/Makefile 2008-06-10 16:19:28.000000000 +0400
5906 @@ -4,5 +4,6 @@ obj-$(CONFIG_SMP) += smp.o
5907 obj-$(CONFIG_SIBYTE_TBPROF) += bcm1250_tbprof.o
5908 obj-$(CONFIG_SIBYTE_STANDALONE) += prom.o
5909 obj-$(CONFIG_SIBYTE_BUS_WATCHER) += bus_watcher.o
5910 +obj-$(CONFIG_KGDB_SIBYTE) += kgdb_sibyte.o
5912 EXTRA_AFLAGS := $(CFLAGS)
5913 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/mips/sibyte/sb1250/irq.c linux-2.6.18.kgdb/arch/mips/sibyte/sb1250/irq.c
5914 --- linux-2.6.18/arch/mips/sibyte/sb1250/irq.c 2006-09-20 07:42:06.000000000 +0400
5915 +++ linux-2.6.18.kgdb/arch/mips/sibyte/sb1250/irq.c 2008-06-10 16:19:28.000000000 +0400
5917 #include <asm/system.h>
5918 #include <asm/ptrace.h>
5920 +#include <asm/kgdb.h>
5922 #include <asm/sibyte/sb1250_regs.h>
5923 #include <asm/sibyte/sb1250_int.h>
5924 @@ -59,16 +60,6 @@ static void sb1250_set_affinity(unsigned
5925 extern unsigned long ldt_eoi_space;
5929 -static int kgdb_irq;
5931 -/* Default to UART1 */
5933 -#ifdef CONFIG_SIBYTE_SB1250_DUART
5934 -extern char sb1250_duart_present[];
5938 static struct irq_chip sb1250_irq_type = {
5939 .typename = "SB1250-IMR",
5940 .startup = startup_sb1250_irq,
5941 @@ -324,6 +315,11 @@ void __init arch_init_irq(void)
5942 unsigned int imask = STATUSF_IP4 | STATUSF_IP3 | STATUSF_IP2 |
5943 STATUSF_IP1 | STATUSF_IP0;
5946 + if (kgdb_early_setup)
5950 /* Default everything to IP2 */
5951 for (i = 0; i < SB1250_NR_IRQS; i++) { /* was I0 */
5952 __raw_writeq(IMR_IP2_VAL,
5953 @@ -375,50 +371,6 @@ void __init arch_init_irq(void)
5954 /* Enable necessary IPs, disable the rest */
5955 change_c0_status(ST0_IM, imask);
5959 - kgdb_irq = K_INT_UART_0 + kgdb_port;
5961 -#ifdef CONFIG_SIBYTE_SB1250_DUART
5962 - sb1250_duart_present[kgdb_port] = 0;
5964 - /* Setup uart 1 settings, mapper */
5965 - __raw_writeq(M_DUART_IMR_BRK,
5966 - IOADDR(A_DUART_IMRREG(kgdb_port)));
5968 - sb1250_steal_irq(kgdb_irq);
5969 - __raw_writeq(IMR_IP6_VAL,
5970 - IOADDR(A_IMR_REGISTER(0,
5971 - R_IMR_INTERRUPT_MAP_BASE) +
5972 - (kgdb_irq << 3)));
5973 - sb1250_unmask_irq(0, kgdb_irq);
5980 -#include <linux/delay.h>
5982 -#define duart_out(reg, val) csr_out32(val, IOADDR(A_DUART_CHANREG(kgdb_port,reg)))
5983 -#define duart_in(reg) csr_in32(IOADDR(A_DUART_CHANREG(kgdb_port,reg)))
5985 -static void sb1250_kgdb_interrupt(struct pt_regs *regs)
5988 - * Clear break-change status (allow some time for the remote
5989 - * host to stop the break, since we would see another
5990 - * interrupt on the end-of-break too)
5992 - kstat_this_cpu.irqs[kgdb_irq]++;
5994 - duart_out(R_DUART_CMD, V_DUART_MISC_CMD_RESET_BREAK_INT |
5995 - M_DUART_RX_EN | M_DUART_TX_EN);
5996 - set_async_breakpoint(®s->cp0_epc);
5999 -#endif /* CONFIG_KGDB */
6001 static inline int dclz(unsigned long long x)
6004 @@ -473,7 +425,7 @@ asmlinkage void plat_irq_dispatch(struct
6005 sb1250_mailbox_interrupt(regs);
6009 +#ifdef CONFIG_KGDB_SIBYTE
6010 else if (pending & CAUSEF_IP6) /* KGDB (uart 1) */
6011 sb1250_kgdb_interrupt(regs);
6013 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/mips/sibyte/sb1250/kgdb_sibyte.c linux-2.6.18.kgdb/arch/mips/sibyte/sb1250/kgdb_sibyte.c
6014 --- linux-2.6.18/arch/mips/sibyte/sb1250/kgdb_sibyte.c 1970-01-01 03:00:00.000000000 +0300
6015 +++ linux-2.6.18.kgdb/arch/mips/sibyte/sb1250/kgdb_sibyte.c 2008-06-10 16:19:28.000000000 +0400
6018 + * arch/mips/sibyte/sb1250/kgdb_sibyte.c
6020 + * Author: Manish Lachwani, mlachwani@mvista.com or manish@koffee-break.com
6022 + * 2004 (c) MontaVista Software, Inc. This file is licensed under
6023 + * the terms of the GNU General Public License version 2. This program
6024 + * is licensed "as is" without any warranty of any kind, whether express
6029 + * Support for KGDB on the Broadcom Sibyte. The SWARM board
6030 + * for example does not have a 8250/16550 compatible serial
6031 + * port. Hence, we need to have a driver for the serial
6032 + * ports to handle KGDB. This board needs nothing in addition
6033 + * to what is normally provided by the gdb portion of the stub.
6036 +#include <linux/delay.h>
6037 +#include <linux/kernel_stat.h>
6038 +#include <linux/init.h>
6039 +#include <linux/kgdb.h>
6041 +#include <asm/io.h>
6042 +#include <asm/sibyte/sb1250.h>
6043 +#include <asm/sibyte/sb1250_regs.h>
6044 +#include <asm/sibyte/sb1250_uart.h>
6045 +#include <asm/sibyte/sb1250_int.h>
6046 +#include <asm/addrspace.h>
6049 +static int kgdb_irq;
6051 +extern char sb1250_duart_present[];
6052 +extern int sb1250_steal_irq(int irq);
6054 +/* Forward declarations. */
6055 +static void kgdbsibyte_init_duart(void);
6056 +static int kgdb_init_io(void);
6058 +#define IMR_IP6_VAL K_INT_MAP_I4
6059 +#define duart_out(reg, val) csr_out32(val, IOADDR(A_DUART_CHANREG(kgdb_port,reg)))
6060 +#define duart_in(reg) csr_in32(IOADDR(A_DUART_CHANREG(kgdb_port,reg)))
6062 +static void kgdb_swarm_write_char(int c)
6064 + while ((duart_in(R_DUART_STATUS) & M_DUART_TX_RDY) == 0) ;
6065 + duart_out(R_DUART_TX_HOLD, c);
6068 +static int kgdb_swarm_read_char(void)
6071 + unsigned int status;
6073 + status = duart_in(R_DUART_STATUS);
6074 + while ((status & M_DUART_RX_RDY) == 0) {
6075 + status = duart_in(R_DUART_STATUS);
6079 + * Check for framing error
6081 + if (status & M_DUART_FRM_ERR) {
6082 + kgdbsibyte_init_duart();
6083 + kgdb_swarm_write_char('-');
6087 + ret_char = duart_in(R_DUART_RX_HOLD);
6092 +void sb1250_kgdb_interrupt(struct pt_regs *regs)
6094 + int kgdb_irq = K_INT_UART_0 + kgdb_port;
6096 + * Clear break-change status (allow some time for the remote
6097 + * host to stop the break, since we would see another
6098 + * interrupt on the end-of-break too)
6100 + kstat_this_cpu.irqs[kgdb_irq]++;
6102 + duart_out(R_DUART_CMD, V_DUART_MISC_CMD_RESET_BREAK_INT |
6103 + M_DUART_RX_EN | M_DUART_TX_EN);
6104 + if (kgdb_io_ops.init != kgdb_init_io) {
6105 + /* Throw away the data if another I/O routine is
6108 + unsigned int status;
6110 + status = duart_in(R_DUART_STATUS);
6111 + while ((status & M_DUART_RX_RDY) == 0) {
6112 + status = duart_in(R_DUART_STATUS);
6115 + * Check for framing error
6117 + if (status & M_DUART_FRM_ERR) {
6118 + kgdbsibyte_init_duart();
6120 + duart_in(R_DUART_RX_HOLD);
6127 + * We use port #1 and we set it for 115200 BAUD, 8n1.
6129 +static void kgdbsibyte_init_duart(void)
6132 + duart_out(R_DUART_MODE_REG_1,
6133 + V_DUART_BITS_PER_CHAR_8 | V_DUART_PARITY_MODE_NONE);
6134 + duart_out(R_DUART_MODE_REG_2, M_DUART_STOP_BIT_LEN_1);
6135 + /* Set baud rate of 115200. */
6136 + duart_out(R_DUART_CLK_SEL, V_DUART_BAUD_RATE(115200));
6137 + /* Enable rx and tx */
6138 + duart_out(R_DUART_CMD, M_DUART_RX_EN | M_DUART_TX_EN);
6141 +static int kgdb_init_io(void)
6143 +#ifdef CONFIG_SIBYTE_SB1250_DUART
6144 + sb1250_duart_present[kgdb_port] = 0;
6147 + kgdbsibyte_init_duart();
6153 + * Hookup our IRQ line. We will already have been initialized a
6156 +static void __init kgdbsibyte_hookup_irq(void)
6158 + /* Steal the IRQ. */
6159 + kgdb_irq = K_INT_UART_0 + kgdb_port;
6161 + /* Setup uart 1 settings, mapper */
6162 + __raw_writeq(M_DUART_IMR_BRK, IOADDR(A_DUART_IMRREG(kgdb_port)));
6164 + sb1250_steal_irq(kgdb_irq);
6166 + __raw_writeq(IMR_IP6_VAL,
6167 + IOADDR(A_IMR_REGISTER(0, R_IMR_INTERRUPT_MAP_BASE) +
6168 + (kgdb_irq << 3)));
6170 + sb1250_unmask_irq(0, kgdb_irq);
6173 +struct kgdb_io kgdb_io_ops = {
6174 + .read_char = kgdb_swarm_read_char,
6175 + .write_char = kgdb_swarm_write_char,
6176 + .init = kgdb_init_io,
6177 + .late_init = kgdbsibyte_hookup_irq,
6178 + .pre_exception = NULL,
6179 + .post_exception = NULL
6181 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/mips/sibyte/swarm/Makefile linux-2.6.18.kgdb/arch/mips/sibyte/swarm/Makefile
6182 --- linux-2.6.18/arch/mips/sibyte/swarm/Makefile 2006-09-20 07:42:06.000000000 +0400
6183 +++ linux-2.6.18.kgdb/arch/mips/sibyte/swarm/Makefile 2008-06-10 16:19:28.000000000 +0400
6185 lib-y = setup.o rtc_xicor1241.o rtc_m41t81.o
6187 -lib-$(CONFIG_KGDB) += dbg_io.o
6188 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/mips/sibyte/swarm/dbg_io.c linux-2.6.18.kgdb/arch/mips/sibyte/swarm/dbg_io.c
6189 --- linux-2.6.18/arch/mips/sibyte/swarm/dbg_io.c 2006-09-20 07:42:06.000000000 +0400
6190 +++ linux-2.6.18.kgdb/arch/mips/sibyte/swarm/dbg_io.c 1970-01-01 03:00:00.000000000 +0300
6193 - * kgdb debug routines for SiByte boards.
6195 - * Copyright (C) 2001 MontaVista Software Inc.
6196 - * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
6198 - * This program is free software; you can redistribute it and/or modify it
6199 - * under the terms of the GNU General Public License as published by the
6200 - * Free Software Foundation; either version 2 of the License, or (at your
6201 - * option) any later version.
6205 -/* -------------------- BEGINNING OF CONFIG --------------------- */
6207 -#include <linux/delay.h>
6208 -#include <asm/io.h>
6209 -#include <asm/sibyte/sb1250.h>
6210 -#include <asm/sibyte/sb1250_regs.h>
6211 -#include <asm/sibyte/sb1250_uart.h>
6212 -#include <asm/sibyte/sb1250_int.h>
6213 -#include <asm/addrspace.h>
6216 - * We use the second serial port for kgdb traffic.
6217 - * 115200, 8, N, 1.
6220 -#define BAUD_RATE 115200
6221 -#define CLK_DIVISOR V_DUART_BAUD_RATE(BAUD_RATE)
6222 -#define DATA_BITS V_DUART_BITS_PER_CHAR_8 /* or 7 */
6223 -#define PARITY V_DUART_PARITY_MODE_NONE /* or even */
6224 -#define STOP_BITS M_DUART_STOP_BIT_LEN_1 /* or 2 */
6226 -static int duart_initialized = 0; /* 0: need to be init'ed by kgdb */
6228 -/* -------------------- END OF CONFIG --------------------- */
6229 -extern int kgdb_port;
6231 -#define duart_out(reg, val) csr_out32(val, IOADDR(A_DUART_CHANREG(kgdb_port,reg)))
6232 -#define duart_in(reg) csr_in32(IOADDR(A_DUART_CHANREG(kgdb_port,reg)))
6234 -void putDebugChar(unsigned char c);
6235 -unsigned char getDebugChar(void);
6237 -duart_init(int clk_divisor, int data, int parity, int stop)
6239 - duart_out(R_DUART_MODE_REG_1, data | parity);
6240 - duart_out(R_DUART_MODE_REG_2, stop);
6241 - duart_out(R_DUART_CLK_SEL, clk_divisor);
6243 - duart_out(R_DUART_CMD, M_DUART_RX_EN | M_DUART_TX_EN); /* enable rx and tx */
6247 -putDebugChar(unsigned char c)
6249 - if (!duart_initialized) {
6250 - duart_initialized = 1;
6251 - duart_init(CLK_DIVISOR, DATA_BITS, PARITY, STOP_BITS);
6253 - while ((duart_in(R_DUART_STATUS) & M_DUART_TX_RDY) == 0);
6254 - duart_out(R_DUART_TX_HOLD, c);
6260 - if (!duart_initialized) {
6261 - duart_initialized = 1;
6262 - duart_init(CLK_DIVISOR, DATA_BITS, PARITY, STOP_BITS);
6264 - while ((duart_in(R_DUART_STATUS) & M_DUART_RX_RDY) == 0) ;
6265 - return duart_in(R_DUART_RX_HOLD);
6268 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/mips/tx4938/common/Makefile linux-2.6.18.kgdb/arch/mips/tx4938/common/Makefile
6269 --- linux-2.6.18/arch/mips/tx4938/common/Makefile 2006-09-20 07:42:06.000000000 +0400
6270 +++ linux-2.6.18.kgdb/arch/mips/tx4938/common/Makefile 2008-06-10 16:19:28.000000000 +0400
6274 obj-y += prom.o setup.o irq.o rtc_rx5c348.o
6275 -obj-$(CONFIG_KGDB) += dbgio.o
6276 +obj-$(CONFIG_KGDB_8250) += dbgio.o
6278 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/powerpc/Kconfig.debug linux-2.6.18.kgdb/arch/powerpc/Kconfig.debug
6279 --- linux-2.6.18/arch/powerpc/Kconfig.debug 2006-09-20 07:42:06.000000000 +0400
6280 +++ linux-2.6.18.kgdb/arch/powerpc/Kconfig.debug 2008-06-10 16:19:22.000000000 +0400
6281 @@ -18,52 +18,9 @@ config DEBUG_STACK_USAGE
6283 This option will slow down process creation somewhat.
6286 - bool "Enable debugger hooks"
6287 - depends on DEBUG_KERNEL
6289 - Include in-kernel hooks for kernel debuggers. Unless you are
6290 - intending to debug the kernel, say N here.
6293 - bool "Include kgdb kernel debugger"
6294 - depends on DEBUGGER && (BROKEN || PPC_GEN550 || 4xx)
6297 - Include in-kernel hooks for kgdb, the Linux kernel source level
6298 - debugger. See <http://kgdb.sourceforge.net/> for more information.
6299 - Unless you are intending to debug the kernel, say N here.
6302 - prompt "Serial Port"
6304 - default KGDB_TTYS1
6320 -config KGDB_CONSOLE
6321 - bool "Enable serial console thru kgdb port"
6322 - depends on KGDB && 8xx || CPM2
6324 - If you enable this, all serial console messages will be sent
6325 - over the gdb stub.
6329 bool "Include xmon kernel debugger"
6330 - depends on DEBUGGER && !PPC_ISERIES
6331 + depends on DEBUG_KERNEL && !PPC_ISERIES
6333 Include in-kernel hooks for the xmon kernel monitor/debugger.
6334 Unless you are intending to debug the kernel, say N here.
6335 @@ -82,6 +39,11 @@ config XMON_DEFAULT
6336 xmon is normally disabled unless booted with 'xmon=on'.
6337 Use 'xmon=off' to disable xmon init during runtime.
6341 + depends on KGDB || XMON
6345 bool "Use separate kernel stacks when processing interrupts"
6347 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/powerpc/kernel/Makefile linux-2.6.18.kgdb/arch/powerpc/kernel/Makefile
6348 --- linux-2.6.18/arch/powerpc/kernel/Makefile 2006-09-20 07:42:06.000000000 +0400
6349 +++ linux-2.6.18.kgdb/arch/powerpc/kernel/Makefile 2008-06-10 16:19:22.000000000 +0400
6350 @@ -60,6 +60,7 @@ obj-$(CONFIG_BOOTX_TEXT) += btext.o
6351 obj-$(CONFIG_SMP) += smp.o
6352 obj-$(CONFIG_KPROBES) += kprobes.o
6353 obj-$(CONFIG_PPC_UDBG_16550) += legacy_serial.o udbg_16550.o
6354 +obj-$(CONFIG_KGDB) += kgdb.o
6355 module-$(CONFIG_PPC64) += module_64.o
6356 obj-$(CONFIG_MODULES) += $(module-y)
6358 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/powerpc/kernel/kgdb.c linux-2.6.18.kgdb/arch/powerpc/kernel/kgdb.c
6359 --- linux-2.6.18/arch/powerpc/kernel/kgdb.c 1970-01-01 03:00:00.000000000 +0300
6360 +++ linux-2.6.18.kgdb/arch/powerpc/kernel/kgdb.c 2008-06-10 16:19:22.000000000 +0400
6363 + * arch/powerpc/kernel/kgdb.c
6365 + * PowerPC backend to the KGDB stub.
6367 + * Maintainer: Tom Rini <trini@kernel.crashing.org>
6369 + * Copied from arch/ppc/kernel/kgdb.c, updated for ppc64
6371 + * Copyright (C) 1996 Paul Mackerras (setjmp/longjmp)
6372 + * 1998 (c) Michael AK Tesch (tesch@cs.wisc.edu)
6373 + * Copyright (C) 2003 Timesys Corporation.
6374 + * Copyright (C) 2004-2006 MontaVista Software, Inc.
6375 + * PPC64 Mods (C) 2005 Frank Rowand (frowand@mvista.com)
6376 + * PPC32 support restored by Vitaly Wool <vwool@ru.mvista.com> and
6377 + * Sergei Shtylyov <sshtylyov@ru.mvista.com>
6379 + * This file is licensed under the terms of the GNU General Public License
6380 + * version 2. This program as licensed "as is" without any warranty of any
6381 + * kind, whether express or implied.
6384 +#include <linux/config.h>
6385 +#include <linux/kernel.h>
6386 +#include <linux/init.h>
6387 +#include <linux/kgdb.h>
6388 +#include <linux/smp.h>
6389 +#include <linux/signal.h>
6390 +#include <linux/ptrace.h>
6391 +#include <asm/current.h>
6392 +#include <asm/ptrace.h>
6393 +#include <asm/processor.h>
6394 +#include <asm/machdep.h>
6397 + * This table contains the mapping between PowerPC hardware trap types, and
6398 + * signals, which are primarily what GDB understands. GDB and the kernel
6399 + * don't always agree on values, so we use constants taken from gdb-6.2.
6401 +static struct hard_trap_info
6403 + unsigned int tt; /* Trap type code for powerpc */
6404 + unsigned char signo; /* Signal that we map this trap into */
6405 +} hard_trap_info[] = {
6406 + { 0x0100, 0x02 /* SIGINT */ }, /* system reset */
6407 + { 0x0200, 0x0b /* SIGSEGV */ }, /* machine check */
6408 + { 0x0300, 0x0b /* SIGSEGV */ }, /* data access */
6409 + { 0x0400, 0x0b /* SIGSEGV */ }, /* instruction access */
6410 + { 0x0500, 0x02 /* SIGINT */ }, /* external interrupt */
6411 + { 0x0600, 0x0a /* SIGBUS */ }, /* alignment */
6412 + { 0x0700, 0x05 /* SIGTRAP */ }, /* program check */
6413 + { 0x0800, 0x08 /* SIGFPE */ }, /* fp unavailable */
6414 + { 0x0900, 0x0e /* SIGALRM */ }, /* decrementer */
6415 + { 0x0c00, 0x14 /* SIGCHLD */ }, /* system call */
6416 +#if defined(CONFIG_40x) || defined(CONFIG_BOOKE)
6417 + { 0x2002, 0x05 /* SIGTRAP */ }, /* debug */
6418 +#if defined(CONFIG_FSL_BOOKE)
6419 + { 0x2010, 0x08 /* SIGFPE */ }, /* spe unavailable */
6420 + { 0x2020, 0x08 /* SIGFPE */ }, /* spe unavailable */
6421 + { 0x2030, 0x08 /* SIGFPE */ }, /* spe fp data */
6422 + { 0x2040, 0x08 /* SIGFPE */ }, /* spe fp data */
6423 + { 0x2050, 0x08 /* SIGFPE */ }, /* spe fp round */
6424 + { 0x2060, 0x0e /* SIGILL */ }, /* performace monitor */
6425 + { 0x2900, 0x08 /* SIGFPE */ }, /* apu unavailable */
6426 + { 0x3100, 0x0e /* SIGALRM */ }, /* fixed interval timer */
6427 + { 0x3200, 0x02 /* SIGINT */ }, /* watchdog */
6429 + { 0x1000, 0x0e /* SIGALRM */ }, /* programmable interval timer */
6430 + { 0x1010, 0x0e /* SIGALRM */ }, /* fixed interval timer */
6431 + { 0x1020, 0x02 /* SIGINT */ }, /* watchdog */
6432 + { 0x2010, 0x08 /* SIGFPE */ }, /* fp unavailable */
6433 + { 0x2020, 0x08 /* SIGFPE */ }, /* ap unavailable */
6436 + { 0x0d00, 0x05 /* SIGTRAP */ }, /* single-step */
6437 +#if defined(CONFIG_8xx)
6438 + { 0x1000, 0x04 /* SIGILL */ }, /* software emulation */
6440 + { 0x0f00, 0x04 /* SIGILL */ }, /* performance monitor */
6441 + { 0x0f20, 0x08 /* SIGFPE */ }, /* altivec unavailable */
6442 + { 0x1300, 0x05 /* SIGTRAP */ }, /* instruction address break */
6443 +#if defined(CONFIG_PPC64)
6444 + { 0x1200, 0x05 /* SIGILL */ }, /* system error */
6445 + { 0x1500, 0x04 /* SIGILL */ }, /* soft patch */
6446 + { 0x1600, 0x04 /* SIGILL */ }, /* maintenance */
6447 + { 0x1700, 0x08 /* SIGFPE */ }, /* altivec assist */
6448 + { 0x1800, 0x04 /* SIGILL */ }, /* thermal */
6450 + { 0x1400, 0x02 /* SIGINT */ }, /* SMI */
6451 + { 0x1600, 0x08 /* SIGFPE */ }, /* altivec assist */
6452 + { 0x1700, 0x04 /* SIGILL */ }, /* TAU */
6453 + { 0x2000, 0x05 /* SIGTRAP */ }, /* run mode */
6457 + { 0x0000, 0x00 } /* Must be last */
6460 +extern atomic_t cpu_doing_single_step;
6462 +static int computeSignal(unsigned int tt)
6464 + struct hard_trap_info *ht;
6466 + for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
6470 + return SIGHUP; /* default for things we don't know about */
6473 +static int kgdb_call_nmi_hook(struct pt_regs *regs)
6475 + kgdb_nmihook(smp_processor_id(), regs);
6480 +void kgdb_roundup_cpus(unsigned long flags)
6482 + smp_send_debugger_break(MSG_ALL_BUT_SELF);
6486 +/* KGDB functions to use existing PowerPC64 hooks. */
6487 +static int kgdb_debugger(struct pt_regs *regs)
6489 + return kgdb_handle_exception(0, computeSignal(TRAP(regs)), 0, regs);
6492 +static int kgdb_breakpoint(struct pt_regs *regs)
6494 + if (user_mode(regs))
6497 + kgdb_handle_exception(0, SIGTRAP, 0, regs);
6499 + if (*(u32 *) (regs->nip) == *(u32 *) (&arch_kgdb_ops.gdb_bpt_instr))
6505 +static int kgdb_singlestep(struct pt_regs *regs)
6507 + struct thread_info *thread_info, *exception_thread_info;
6508 + if (user_mode(regs))
6511 + * On Book E and perhaps other processsors, singlestep is handled on
6512 + * the critical exception stack. This causes current_thread_info()
6513 + * to fail, since it it locates the thread_info by masking off
6514 + * the low bits of the current stack pointer. We work around
6515 + * this issue by copying the thread_info from the kernel stack
6516 + * before calling kgdb_handle_exception, and copying it back
6517 + * afterwards. On most processors the copy is avoided since
6518 + * exception_thread_info == thread_info.
6520 + thread_info = (struct thread_info *)(regs->gpr[1] & ~(THREAD_SIZE-1));
6521 + exception_thread_info = current_thread_info();
6523 + if (thread_info != exception_thread_info)
6524 + memcpy(exception_thread_info, thread_info, sizeof *thread_info);
6526 + kgdb_handle_exception(0, SIGTRAP, 0, regs);
6528 + if (thread_info != exception_thread_info)
6529 + memcpy(thread_info, exception_thread_info, sizeof *thread_info);
6534 +int kgdb_iabr_match(struct pt_regs *regs)
6536 + if (user_mode(regs))
6539 + kgdb_handle_exception(0, computeSignal(TRAP(regs)), 0, regs);
6543 +int kgdb_dabr_match(struct pt_regs *regs)
6545 + if (user_mode(regs))
6548 + kgdb_handle_exception(0, computeSignal(TRAP(regs)), 0, regs);
6552 +#define PACK64(ptr,src) do { *(ptr++) = (src); } while(0)
6554 +#define PACK32(ptr,src) do { \
6556 + ptr32 = (u32 *)ptr; \
6557 + *(ptr32++) = (src); \
6558 + ptr = (unsigned long *)ptr32; \
6561 +void regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs)
6563 + unsigned long *ptr = gdb_regs;
6566 + memset(gdb_regs, 0, NUMREGBYTES);
6568 + for (reg = 0; reg < 32; reg++)
6569 + PACK64(ptr, regs->gpr[reg]);
6571 +#ifdef CONFIG_FSL_BOOKE
6573 + for (reg = 0; reg < 32; reg++)
6574 + PACK64(ptr, current->thread.evr[reg]);
6579 + /* fp registers not used by kernel, leave zero */
6580 + ptr += 32 * 8 / sizeof(long);
6583 + PACK64(ptr, regs->nip);
6584 + PACK64(ptr, regs->msr);
6585 + PACK32(ptr, regs->ccr);
6586 + PACK64(ptr, regs->link);
6587 + PACK64(ptr, regs->ctr);
6588 + PACK32(ptr, regs->xer);
6591 + Following are in struct thread_struct, not struct pt_regs,
6592 + ignoring for now since kernel does not use them. Would it
6593 + make sense to get them from the thread that kgdb is set to?
6595 + If this code is enabled, update the definition of NUMREGBYTES to
6596 + include the vector registers and vector state registers.
6598 + PACK32(ptr, current->thread->fpscr);
6600 + /* vr registers not used by kernel, leave zero */
6601 + ptr += 32 * 16 / sizeof(long);
6603 +#ifdef CONFIG_ALTIVEC
6604 + PACK32(ptr, current->thread->vscr);
6605 + PACK32(ptr, current->thread->vrsave);
6607 + ptr += 2 * 4 / sizeof(long);
6610 +#ifdef CONFIG_FSL_BOOKE
6613 + PACK32(ptr, current->thread.acc >> 32);
6614 + PACK32(ptr, current->thread.acc & 0xffffffff);
6615 + PACK64(ptr, current->thread.spefscr);
6620 + /* fpscr not used by kernel, leave zero */
6625 + BUG_ON((unsigned long)ptr >
6626 + (unsigned long)(((void *)gdb_regs) + NUMREGBYTES));
6629 +void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p)
6631 + struct pt_regs *regs = (struct pt_regs *)(p->thread.ksp +
6632 + STACK_FRAME_OVERHEAD);
6633 + unsigned long *ptr = gdb_regs;
6636 + memset(gdb_regs, 0, NUMREGBYTES);
6639 + for (reg = 0; reg < 3; reg++)
6640 + PACK64(ptr, regs->gpr[reg]);
6642 + /* Regs GPR3-13 are caller saved, not in regs->gpr[] */
6645 + /* Regs GPR14-31 */
6646 + for (reg = 14; reg < 32; reg++)
6647 + PACK64(ptr, regs->gpr[reg]);
6649 +#ifdef CONFIG_FSL_BOOKE
6651 + for (reg = 0; reg < 32; reg++)
6652 + PACK64(ptr, p->thread.evr[reg]);
6657 + /* fp registers not used by kernel, leave zero */
6658 + ptr += 32 * 8 / sizeof(long);
6660 + PACK64(ptr, regs->nip);
6661 + PACK64(ptr, regs->msr);
6662 + PACK32(ptr, regs->ccr);
6663 + PACK64(ptr, regs->link);
6664 + PACK64(ptr, regs->ctr);
6665 + PACK32(ptr, regs->xer);
6668 + Following are in struct thread_struct, not struct pt_regs,
6669 + ignoring for now since kernel does not use them. Would it
6670 + make sense to get them from the thread that kgdb is set to?
6672 + If this code is enabled, update the definition of NUMREGBYTES to
6673 + include the vector registers and vector state registers.
6675 + PACK32(ptr, p->thread->fpscr);
6677 + /* vr registers not used by kernel, leave zero */
6678 + ptr += 32 * 16 / sizeof(long);
6680 +#ifdef CONFIG_ALTIVEC
6681 + PACK32(ptr, p->thread->vscr);
6682 + PACK32(ptr, p->thread->vrsave);
6684 + ptr += 2 * 4 / sizeof(long);
6687 +#ifdef CONFIG_FSL_BOOKE
6690 + PACK32(ptr, p->thread.acc >> 32);
6691 + PACK32(ptr, p->thread.acc & 0xffffffff);
6692 + PACK64(ptr, p->thread.spefscr);
6697 + /* fpscr not used by kernel, leave zero */
6702 + BUG_ON((unsigned long)ptr >
6703 + (unsigned long)(((void *)gdb_regs) + NUMREGBYTES));
6706 +#define UNPACK64(dest,ptr) do { dest = *(ptr++); } while(0)
6708 +#define UNPACK32(dest,ptr) do { \
6710 + ptr32 = (u32 *)ptr; \
6711 + dest = *(ptr32++); \
6712 + ptr = (unsigned long *)ptr32; \
6715 +void gdb_regs_to_regs(unsigned long *gdb_regs, struct pt_regs *regs)
6717 + unsigned long *ptr = gdb_regs;
6726 + for (reg = 0; reg < 32; reg++)
6727 + UNPACK64(regs->gpr[reg], ptr);
6729 +#ifdef CONFIG_FSL_BOOKE
6731 + for (reg = 0; reg < 32; reg++)
6732 + UNPACK64(current->thread.evr[reg], ptr);
6737 + /* fp registers not used by kernel, leave zero */
6738 + ptr += 32 * 8 / sizeof(int);
6740 + UNPACK64(regs->nip, ptr);
6741 + UNPACK64(regs->msr, ptr);
6742 + UNPACK32(regs->ccr, ptr);
6743 + UNPACK64(regs->link, ptr);
6744 + UNPACK64(regs->ctr, ptr);
6745 + UNPACK32(regs->xer, ptr);
6748 + Following are in struct thread_struct, not struct pt_regs,
6749 + ignoring for now since kernel does not use them. Would it
6750 + make sense to get them from the thread that kgdb is set to?
6752 + If this code is enabled, update the definition of NUMREGBYTES to
6753 + include the vector registers and vector state registers.
6755 + /* fpscr, vscr, vrsave not used by kernel, leave unchanged */
6757 + UNPACK32(current->thread->fpscr, ptr);
6759 + /* vr registers not used by kernel, leave zero */
6760 + ptr += 32 * 16 / sizeof(long);
6762 + #ifdef CONFIG_ALTIVEC
6763 + UNPACK32(current->thread->vscr, ptr);
6764 + UNPACK32(current->thread->vrsave, ptr);
6766 + ptr += 2 * 4 / sizeof(long);
6769 +#ifdef CONFIG_FSL_BOOKE
6772 + UNPACK32(acc.v32[0], ptr);
6773 + UNPACK32(acc.v32[1], ptr);
6774 + current->thread.acc = acc.v64;
6775 + UNPACK64(current->thread.spefscr, ptr);
6782 + BUG_ON((unsigned long)ptr >
6783 + (unsigned long)(((void *)gdb_regs) + NUMREGBYTES));
6787 + * This function does PowerPC specific procesing for interfacing to gdb.
6789 +int kgdb_arch_handle_exception(int vector, int signo, int err_code,
6790 + char *remcom_in_buffer, char *remcom_out_buffer,
6791 + struct pt_regs *linux_regs)
6793 + char *ptr = &remcom_in_buffer[1];
6794 + unsigned long addr;
6796 + switch (remcom_in_buffer[0]) {
6798 + * sAA..AA Step one instruction from AA..AA
6799 + * This will return an error to gdb ..
6803 + /* handle the optional parameter */
6804 + if (kgdb_hex2long(&ptr, &addr))
6805 + linux_regs->nip = addr;
6807 + atomic_set(&cpu_doing_single_step, -1);
6808 + /* set the trace bit if we're stepping */
6809 + if (remcom_in_buffer[0] == 's') {
6810 +#if defined(CONFIG_40x) || defined(CONFIG_BOOKE)
6812 + mfspr(SPRN_DBCR0) | DBCR0_IC | DBCR0_IDM);
6813 + linux_regs->msr |= MSR_DE;
6815 + linux_regs->msr |= MSR_SE;
6817 + debugger_step = 1;
6818 + if (kgdb_contthread)
6819 + atomic_set(&cpu_doing_single_step,
6820 + smp_processor_id());
6828 +int kgdb_fault_setjmp(unsigned long *curr_context)
6830 +#ifdef CONFIG_PPC32
6831 + __asm__ __volatile__("mflr 0; stw 0,0(%0);\n\
6832 + stw 1,4(%0); stw 2,8(%0);\n\
6833 + mfcr 0; stw 0,12(%0);\n\
6834 + stmw 13,16(%0)\n" : : "r" (curr_context));
6836 + __asm__ __volatile__("mflr 0; std 0,0(%0)\n\
6839 + mfcr 0; std 0,24(%0)\n\
6858 + std 31,176(%0)\n" : : "r" (curr_context));
6863 +void kgdb_fault_longjmp(unsigned long *curr_context)
6865 +#ifdef CONFIG_PPC32
6866 + __asm__ __volatile__("lmw 13,16(%0);\n\
6867 + lwz 0,12(%0); mtcrf 0x38,0;\n\
6868 + lwz 0,0(%0); lwz 1,4(%0); lwz 2,8(%0);\n\
6869 + mtlr 0; mr 3,1\n" : : "r" (curr_context));
6871 + __asm__ __volatile__("ld 13,32(%0)\n\
6896 + mr 3,1\n" : : "r" (curr_context));
6903 +struct kgdb_arch arch_kgdb_ops = {
6904 + .gdb_bpt_instr = {0x7d, 0x82, 0x10, 0x08},
6907 +int kgdb_not_implemented(struct pt_regs *regs)
6912 +int kgdb_arch_init(void)
6915 +#error Both XMON and KGDB selected in .config. Unselect one of them.
6918 + __debugger_ipi = kgdb_call_nmi_hook;
6919 + __debugger = kgdb_debugger;
6920 + __debugger_bpt = kgdb_breakpoint;
6921 + __debugger_sstep = kgdb_singlestep;
6922 + __debugger_iabr_match = kgdb_iabr_match;
6923 + __debugger_dabr_match = kgdb_dabr_match;
6924 + __debugger_fault_handler = kgdb_not_implemented;
6929 +arch_initcall(kgdb_arch_init);
6930 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/powerpc/kernel/legacy_serial.c linux-2.6.18.kgdb/arch/powerpc/kernel/legacy_serial.c
6931 --- linux-2.6.18/arch/powerpc/kernel/legacy_serial.c 2006-09-20 07:42:06.000000000 +0400
6932 +++ linux-2.6.18.kgdb/arch/powerpc/kernel/legacy_serial.c 2008-06-10 16:19:22.000000000 +0400
6934 #include <asm/udbg.h>
6935 #include <asm/pci-bridge.h>
6936 #include <asm/ppc-pci.h>
6937 +#ifdef CONFIG_KGDB_8250
6938 +#include <linux/kgdb.h>
6943 @@ -470,6 +473,9 @@ static int __init serial_dev_init(void)
6944 fixup_port_pio(i, np, port);
6945 if ((port->iotype == UPIO_MEM) || (port->iotype == UPIO_TSI))
6946 fixup_port_mmio(i, np, port);
6947 +#ifdef CONFIG_KGDB_8250
6948 + kgdb8250_add_platform_port(i, port);
6952 DBG("Registering platform serial ports\n");
6953 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/powerpc/kernel/setup_32.c linux-2.6.18.kgdb/arch/powerpc/kernel/setup_32.c
6954 --- linux-2.6.18/arch/powerpc/kernel/setup_32.c 2006-09-20 07:42:06.000000000 +0400
6955 +++ linux-2.6.18.kgdb/arch/powerpc/kernel/setup_32.c 2008-06-10 16:19:22.000000000 +0400
6960 -#if defined CONFIG_KGDB
6961 -#include <asm/kgdb.h>
6964 extern void bootx_init(unsigned long r4, unsigned long phys);
6966 struct ide_machdep_calls ppc_ide_md;
6967 @@ -248,18 +244,6 @@ void __init setup_arch(char **cmdline_p)
6968 /* Register early console */
6969 register_early_udbg_console();
6971 -#if defined(CONFIG_KGDB)
6972 - if (ppc_md.kgdb_map_scc)
6973 - ppc_md.kgdb_map_scc();
6974 - set_debug_traps();
6975 - if (strstr(cmd_line, "gdb")) {
6976 - if (ppc_md.progress)
6977 - ppc_md.progress("setup_arch: kgdb breakpoint", 0x4000);
6978 - printk("kgdb breakpoint activated\n");
6984 * Set cache line size based on type of cpu as a default.
6985 * Systems with OF can look in the properties on the cpu node(s)
6986 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/powerpc/mm/fault.c linux-2.6.18.kgdb/arch/powerpc/mm/fault.c
6987 --- linux-2.6.18/arch/powerpc/mm/fault.c 2006-09-20 07:42:06.000000000 +0400
6988 +++ linux-2.6.18.kgdb/arch/powerpc/mm/fault.c 2008-06-10 16:19:22.000000000 +0400
6990 #include <linux/highmem.h>
6991 #include <linux/module.h>
6992 #include <linux/kprobes.h>
6993 +#include <linux/kgdb.h>
6995 #include <asm/page.h>
6996 #include <asm/pgtable.h>
6997 @@ -424,6 +425,13 @@ void bad_page_fault(struct pt_regs *regs
7002 + if (atomic_read(&debugger_active) && kgdb_may_fault)
7003 + /* Restore our previous state. */
7004 + kgdb_fault_longjmp(kgdb_fault_jmp_regs);
7005 + /* Not reached. */
7008 /* kernel has accessed a bad area */
7010 printk(KERN_ALERT "Unable to handle kernel paging request for ");
7011 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/powerpc/platforms/powermac/setup.c linux-2.6.18.kgdb/arch/powerpc/platforms/powermac/setup.c
7012 --- linux-2.6.18/arch/powerpc/platforms/powermac/setup.c 2006-09-20 07:42:06.000000000 +0400
7013 +++ linux-2.6.18.kgdb/arch/powerpc/platforms/powermac/setup.c 2008-06-10 16:19:22.000000000 +0400
7014 @@ -98,8 +98,6 @@ extern struct machdep_calls pmac_md;
7018 -extern void zs_kgdb_hook(int tty_num);
7020 sys_ctrler_t sys_ctrler = SYS_CTRLER_UNKNOWN;
7021 EXPORT_SYMBOL(sys_ctrler);
7023 @@ -319,10 +317,6 @@ static void __init pmac_setup_arch(void)
7025 #endif /* CONFIG_PPC32 */
7034 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ppc/Kconfig.debug linux-2.6.18.kgdb/arch/ppc/Kconfig.debug
7035 --- linux-2.6.18/arch/ppc/Kconfig.debug 2006-09-20 07:42:06.000000000 +0400
7036 +++ linux-2.6.18.kgdb/arch/ppc/Kconfig.debug 2008-06-10 16:19:22.000000000 +0400
7037 @@ -2,42 +2,6 @@ menu "Kernel hacking"
7039 source "lib/Kconfig.debug"
7042 - bool "Include kgdb kernel debugger"
7043 - depends on DEBUG_KERNEL && (BROKEN || PPC_GEN550 || 4xx)
7046 - Include in-kernel hooks for kgdb, the Linux kernel source level
7047 - debugger. See <http://kgdb.sourceforge.net/> for more information.
7048 - Unless you are intending to debug the kernel, say N here.
7051 - prompt "Serial Port"
7053 - default KGDB_TTYS1
7069 -config KGDB_CONSOLE
7070 - bool "Enable serial console thru kgdb port"
7071 - depends on KGDB && 8xx || CPM2
7073 - If you enable this, all serial console messages will be sent
7074 - over the gdb stub.
7078 bool "Include xmon kernel debugger"
7079 depends on DEBUG_KERNEL
7080 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ppc/kernel/kgdb.c linux-2.6.18.kgdb/arch/ppc/kernel/kgdb.c
7081 --- linux-2.6.18/arch/ppc/kernel/kgdb.c 1970-01-01 03:00:00.000000000 +0300
7082 +++ linux-2.6.18.kgdb/arch/ppc/kernel/kgdb.c 2008-06-10 16:20:19.000000000 +0400
7085 + * arch/ppc/kernel/kgdb.c
7087 + * PowerPC backend to the KGDB stub.
7089 + * Maintainer: Tom Rini <trini@kernel.crashing.org>
7091 + * 1998 (c) Michael AK Tesch (tesch@cs.wisc.edu)
7092 + * Copyright (C) 2003 Timesys Corporation.
7093 + * 2004 (c) MontaVista Software, Inc.
7095 + * This file is licensed under the terms of the GNU General Public License
7096 + * version 2. This program as licensed "as is" without any warranty of any
7097 + * kind, whether express or implied.
7100 +#include <linux/config.h>
7101 +#include <linux/kernel.h>
7102 +#include <linux/init.h>
7103 +#include <linux/kgdb.h>
7104 +#include <linux/smp.h>
7105 +#include <linux/signal.h>
7106 +#include <linux/ptrace.h>
7107 +#include <asm/current.h>
7108 +#include <asm/ptrace.h>
7109 +#include <asm/processor.h>
7110 +#include <asm/machdep.h>
7113 + * This table contains the mapping between PowerPC hardware trap types, and
7114 + * signals, which are primarily what GDB understands. GDB and the kernel
7115 + * don't always agree on values, so we use constants taken from gdb-6.2.
7117 +static struct hard_trap_info
7119 + unsigned int tt; /* Trap type code for powerpc */
7120 + unsigned char signo; /* Signal that we map this trap into */
7121 +} hard_trap_info[] = {
7122 +#if defined(CONFIG_40x) || defined(CONFIG_BOOKE)
7123 + { 0x0100, 0x02 /* SIGINT */ }, /* critical input interrupt */
7124 + { 0x0200, 0x0b /* SIGSEGV */ }, /* machine check */
7125 + { 0x0300, 0x0b /* SIGSEGV */ }, /* data storage */
7126 + { 0x0400, 0x0a /* SIGBUS */ }, /* instruction storage */
7127 + { 0x0500, 0x02 /* SIGINT */ }, /* interrupt */
7128 + { 0x0600, 0x0a /* SIGBUS */ }, /* alignment */
7129 + { 0x0700, 0x04 /* SIGILL */ }, /* program */
7130 + { 0x0800, 0x04 /* SIGILL */ }, /* reserved */
7131 + { 0x0900, 0x04 /* SIGILL */ }, /* reserved */
7132 + { 0x0a00, 0x04 /* SIGILL */ }, /* reserved */
7133 + { 0x0b00, 0x04 /* SIGILL */ }, /* reserved */
7134 + { 0x0c00, 0x14 /* SIGCHLD */ }, /* syscall */
7135 + { 0x0d00, 0x04 /* SIGILL */ }, /* reserved */
7136 + { 0x0e00, 0x04 /* SIGILL */ }, /* reserved */
7137 + { 0x0f00, 0x04 /* SIGILL */ }, /* reserved */
7138 + { 0x2002, 0x05 /* SIGTRAP */}, /* debug */
7140 + { 0x0200, 0x0b /* SIGSEGV */ }, /* machine check */
7141 + { 0x0300, 0x0b /* SIGSEGV */ }, /* address error (store) */
7142 + { 0x0400, 0x0a /* SIGBUS */ }, /* instruction bus error */
7143 + { 0x0500, 0x02 /* SIGINT */ }, /* interrupt */
7144 + { 0x0600, 0x0a /* SIGBUS */ }, /* alingment */
7145 + { 0x0700, 0x05 /* SIGTRAP */ }, /* breakpoint trap */
7146 + { 0x0800, 0x08 /* SIGFPE */}, /* fpu unavail */
7147 + { 0x0900, 0x0e /* SIGALRM */ }, /* decrementer */
7148 + { 0x0a00, 0x04 /* SIGILL */ }, /* reserved */
7149 + { 0x0b00, 0x04 /* SIGILL */ }, /* reserved */
7150 + { 0x0c00, 0x14 /* SIGCHLD */ }, /* syscall */
7151 + { 0x0d00, 0x05 /* SIGTRAP */ }, /* single-step/watch */
7152 + { 0x0e00, 0x08 /* SIGFPE */ }, /* fp assist */
7154 + { 0x0000, 0x000 } /* Must be last */
7157 +extern atomic_t cpu_doing_single_step;
7159 +static int computeSignal(unsigned int tt)
7161 + struct hard_trap_info *ht;
7163 + for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
7167 + return SIGHUP; /* default for things we don't know about */
7170 +/* KGDB functions to use existing PowerPC hooks. */
7171 +static void kgdb_debugger(struct pt_regs *regs)
7173 + kgdb_handle_exception(0, computeSignal(TRAP(regs)), 0, regs);
7176 +static int kgdb_breakpoint(struct pt_regs *regs)
7178 + if (user_mode(regs))
7181 + kgdb_handle_exception(0, SIGTRAP, 0, regs);
7183 + if (*(u32 *) (regs->nip) == *(u32 *) (&arch_kgdb_ops.gdb_bpt_instr))
7189 +static int kgdb_singlestep(struct pt_regs *regs)
7191 + struct thread_info *thread_info, *exception_thread_info;
7193 + if (user_mode(regs))
7196 + * On Book E and perhaps other processsors, singlestep is handled on
7197 + * the critical exception stack. This causes current_thread_info()
7198 + * to fail, since it it locates the thread_info by masking off
7199 + * the low bits of the current stack pointer. We work around
7200 + * this issue by copying the thread_info from the kernel stack
7201 + * before calling kgdb_handle_exception, and copying it back
7202 + * afterwards. On most processors the copy is avoided since
7203 + * exception_thread_info == thread_info.
7205 + thread_info = (struct thread_info *)(regs->gpr[1] & ~(THREAD_SIZE-1));
7206 + exception_thread_info = current_thread_info();
7208 + if (thread_info != exception_thread_info)
7209 + memcpy(exception_thread_info, thread_info, sizeof *thread_info);
7211 + kgdb_handle_exception(0, SIGTRAP, 0, regs);
7213 + if (thread_info != exception_thread_info)
7214 + memcpy(thread_info, exception_thread_info, sizeof *thread_info);
7219 +int kgdb_iabr_match(struct pt_regs *regs)
7221 + if (user_mode(regs))
7224 + kgdb_handle_exception(0, computeSignal(TRAP(regs)), 0, regs);
7228 +int kgdb_dabr_match(struct pt_regs *regs)
7230 + if (user_mode(regs))
7233 + kgdb_handle_exception(0, computeSignal(TRAP(regs)), 0, regs);
7237 +void regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs)
7240 + unsigned long *ptr = gdb_regs;
7242 + memset(gdb_regs, 0, MAXREG * 4);
7244 + for (reg = 0; reg < 32; reg++)
7245 + *(ptr++) = regs->gpr[reg];
7247 +#ifndef CONFIG_E500
7248 + for (reg = 0; reg < 64; reg++)
7251 + for (reg = 0; reg < 32; reg++)
7252 + *(ptr++) = current->thread.evr[reg];
7255 + *(ptr++) = regs->nip;
7256 + *(ptr++) = regs->msr;
7257 + *(ptr++) = regs->ccr;
7258 + *(ptr++) = regs->link;
7259 + *(ptr++) = regs->ctr;
7260 + *(ptr++) = regs->xer;
7264 + *(ptr++) = (current->thread.acc >> 32);
7265 + *(ptr++) = (current->thread.acc & 0xffffffff);
7266 + *(ptr++) = current->thread.spefscr;
7270 +void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p)
7272 + struct pt_regs *regs = (struct pt_regs *)(p->thread.ksp +
7273 + STACK_FRAME_OVERHEAD);
7275 + unsigned long *ptr = gdb_regs;
7277 + memset(gdb_regs, 0, MAXREG * 4);
7280 + for (reg = 0; reg < 3; reg++)
7281 + *(ptr++) = regs->gpr[reg];
7283 + /* Regs GPR3-13 are not saved */
7284 + for (reg = 3; reg < 14; reg++)
7287 + /* Regs GPR14-31 */
7288 + for (reg = 14; reg < 32; reg++)
7289 + *(ptr++) = regs->gpr[reg];
7291 +#ifndef CONFIG_E500
7292 + for (reg = 0; reg < 64; reg++)
7295 + for (reg = 0; reg < 32; reg++)
7296 + *(ptr++) = current->thread.evr[reg];
7299 + *(ptr++) = regs->nip;
7300 + *(ptr++) = regs->msr;
7301 + *(ptr++) = regs->ccr;
7302 + *(ptr++) = regs->link;
7303 + *(ptr++) = regs->ctr;
7304 + *(ptr++) = regs->xer;
7308 + *(ptr++) = (current->thread.acc >> 32);
7309 + *(ptr++) = (current->thread.acc & 0xffffffff);
7310 + *(ptr++) = current->thread.spefscr;
7314 +void gdb_regs_to_regs(unsigned long *gdb_regs, struct pt_regs *regs)
7317 + unsigned long *ptr = gdb_regs;
7325 + for (reg = 0; reg < 32; reg++)
7326 + regs->gpr[reg] = *(ptr++);
7328 +#ifndef CONFIG_E500
7329 + for (reg = 0; reg < 64; reg++)
7332 + for (reg = 0; reg < 32; reg++)
7333 + current->thread.evr[reg] = *(ptr++);
7336 + regs->nip = *(ptr++);
7337 + regs->msr = *(ptr++);
7338 + regs->ccr = *(ptr++);
7339 + regs->link = *(ptr++);
7340 + regs->ctr = *(ptr++);
7341 + regs->xer = *(ptr++);
7345 + u.v32[0] = *(ptr++);
7346 + u.v32[1] = *(ptr++);
7347 + current->thread.acc = u.v64;
7348 + current->thread.spefscr = *(ptr++);
7353 + * Save/restore state in case a memory access causes a fault.
7355 +int kgdb_fault_setjmp(unsigned long *curr_context)
7357 + __asm__ __volatile__("mflr 0; stw 0,0(%0);"
7358 + "stw 1,4(%0); stw 2,8(%0);"
7359 + "mfcr 0; stw 0,12(%0);"
7360 + "stmw 13,16(%0)"::"r"(curr_context));
7364 +void kgdb_fault_longjmp(unsigned long *curr_context)
7366 + __asm__ __volatile__("lmw 13,16(%0);"
7367 + "lwz 0,12(%0); mtcrf 0x38,0;"
7368 + "lwz 0,0(%0); lwz 1,4(%0); lwz 2,8(%0);"
7369 + "mtlr 0; mr 3,1"::"r"(curr_context));
7373 + * This function does PoerPC specific procesing for interfacing to gdb.
7375 +int kgdb_arch_handle_exception(int vector, int signo, int err_code,
7376 + char *remcom_in_buffer, char *remcom_out_buffer,
7377 + struct pt_regs *linux_regs)
7379 + char *ptr = &remcom_in_buffer[1];
7380 + unsigned long addr;
7382 + switch (remcom_in_buffer[0])
7385 + * sAA..AA Step one instruction from AA..AA
7386 + * This will return an error to gdb ..
7390 + /* handle the optional parameter */
7391 + if (kgdb_hex2long (&ptr, &addr))
7392 + linux_regs->nip = addr;
7394 + atomic_set(&cpu_doing_single_step, -1);
7395 + /* set the trace bit if we're stepping */
7396 + if (remcom_in_buffer[0] == 's') {
7397 +#if defined (CONFIG_40x) || defined(CONFIG_BOOKE)
7398 + mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) |
7399 + DBCR0_IC | DBCR0_IDM);
7400 + linux_regs->msr |= MSR_DE;
7402 + linux_regs->msr |= MSR_SE;
7404 + debugger_step = 1;
7405 + if (kgdb_contthread)
7406 + atomic_set(&cpu_doing_single_step,
7407 + smp_processor_id());
7418 +struct kgdb_arch arch_kgdb_ops = {
7419 + .gdb_bpt_instr = {0x7d, 0x82, 0x10, 0x08},
7422 +int kgdb_arch_init(void)
7424 + debugger = kgdb_debugger;
7425 + debugger_bpt = kgdb_breakpoint;
7426 + debugger_sstep = kgdb_singlestep;
7427 + debugger_iabr_match = kgdb_iabr_match;
7428 + debugger_dabr_match = kgdb_dabr_match;
7433 +arch_initcall(kgdb_arch_init);
7434 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ppc/kernel/ppc-stub.c linux-2.6.18.kgdb/arch/ppc/kernel/ppc-stub.c
7435 --- linux-2.6.18/arch/ppc/kernel/ppc-stub.c 2006-09-20 07:42:06.000000000 +0400
7436 +++ linux-2.6.18.kgdb/arch/ppc/kernel/ppc-stub.c 1970-01-01 03:00:00.000000000 +0300
7439 - * ppc-stub.c: KGDB support for the Linux kernel.
7441 - * adapted from arch/sparc/kernel/sparc-stub.c for the PowerPC
7442 - * some stuff borrowed from Paul Mackerras' xmon
7443 - * Copyright (C) 1998 Michael AK Tesch (tesch@cs.wisc.edu)
7445 - * Modifications to run under Linux
7446 - * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
7448 - * This file originally came from the gdb sources, and the
7449 - * copyright notices have been retained below.
7452 -/****************************************************************************
7454 - THIS SOFTWARE IS NOT COPYRIGHTED
7456 - HP offers the following for use in the public domain. HP makes no
7457 - warranty with regard to the software or its performance and the
7458 - user accepts the software "AS IS" with all faults.
7460 - HP DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD
7461 - TO THIS SOFTWARE INCLUDING BUT NOT LIMITED TO THE WARRANTIES
7462 - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
7464 -****************************************************************************/
7466 -/****************************************************************************
7467 - * Header: remcom.c,v 1.34 91/03/09 12:29:49 glenne Exp $
7469 - * Module name: remcom.c $
7470 - * Revision: 1.34 $
7471 - * Date: 91/03/09 12:29:49 $
7472 - * Contributor: Lake Stevens Instrument Division$
7474 - * Description: low level support for gdb debugger. $
7476 - * Considerations: only works on target hardware $
7478 - * Written by: Glenn Engel $
7479 - * ModuleState: Experimental $
7481 - * NOTES: See Below $
7483 - * Modified for SPARC by Stu Grossman, Cygnus Support.
7485 - * This code has been extensively tested on the Fujitsu SPARClite demo board.
7487 - * To enable debugger support, two things need to happen. One, a
7488 - * call to set_debug_traps() is necessary in order to allow any breakpoints
7489 - * or error conditions to be properly intercepted and reported to gdb.
7490 - * Two, a breakpoint needs to be generated to begin communication. This
7491 - * is most easily accomplished by a call to breakpoint(). Breakpoint()
7492 - * simulates a breakpoint by executing a trap #1.
7496 - * The following gdb commands are supported:
7498 - * command function Return value
7500 - * g return the value of the CPU registers hex data or ENN
7501 - * G set the value of the CPU registers OK or ENN
7502 - * qOffsets Get section offsets. Reply is Text=xxx;Data=yyy;Bss=zzz
7504 - * mAA..AA,LLLL Read LLLL bytes at address AA..AA hex data or ENN
7505 - * MAA..AA,LLLL: Write LLLL bytes at address AA.AA OK or ENN
7507 - * c Resume at current address SNN ( signal NN)
7508 - * cAA..AA Continue at address AA..AA SNN
7510 - * s Step one instruction SNN
7511 - * sAA..AA Step one instruction from AA..AA SNN
7515 - * ? What was the last sigval ? SNN (signal NN)
7517 - * bBB..BB Set baud rate to BB..BB OK or BNN, then sets
7520 - * All commands and responses are sent with a packet which includes a
7521 - * checksum. A packet consists of
7523 - * $<packet info>#<checksum>.
7526 - * <packet info> :: <characters representing the command or response>
7527 - * <checksum> :: <two hex digits computed as modulo 256 sum of <packetinfo>>
7529 - * When a packet is received, it is first acknowledged with either '+' or '-'.
7530 - * '+' indicates a successful transfer. '-' indicates a failed transfer.
7535 - * $m0,10#2a +$00010203040506070809101112131415#42
7537 - ****************************************************************************/
7539 -#include <linux/kernel.h>
7540 -#include <linux/string.h>
7541 -#include <linux/mm.h>
7542 -#include <linux/smp.h>
7543 -#include <linux/smp_lock.h>
7544 -#include <linux/init.h>
7545 -#include <linux/sysrq.h>
7547 -#include <asm/cacheflush.h>
7548 -#include <asm/system.h>
7549 -#include <asm/signal.h>
7550 -#include <asm/kgdb.h>
7551 -#include <asm/pgtable.h>
7552 -#include <asm/ptrace.h>
7554 -void breakinst(void);
7557 - * BUFMAX defines the maximum number of characters in inbound/outbound buffers
7558 - * at least NUMREGBYTES*2 are needed for register packets
7560 -#define BUFMAX 2048
7561 -static char remcomInBuffer[BUFMAX];
7562 -static char remcomOutBuffer[BUFMAX];
7564 -static int initialized;
7565 -static int kgdb_active;
7566 -static int kgdb_started;
7567 -static u_int fault_jmp_buf[100];
7571 -static const char hexchars[]="0123456789abcdef";
7573 -/* Place where we save old trap entries for restoration - sparc*/
7574 -/* struct tt_entry kgdb_savettable[256]; */
7575 -/* typedef void (*trapfunc_t)(void); */
7577 -static void kgdb_fault_handler(struct pt_regs *regs);
7578 -static int handle_exception (struct pt_regs *regs);
7581 -/* Install an exception handler for kgdb */
7582 -static void exceptionHandler(int tnum, unsigned int *tfunc)
7584 - /* We are dorking with a live trap table, all irqs off */
7589 -kgdb_setjmp(long *buf)
7591 - asm ("mflr 0; stw 0,0(%0);"
7592 - "stw 1,4(%0); stw 2,8(%0);"
7593 - "mfcr 0; stw 0,12(%0);"
7596 - /* XXX should save fp regs as well */
7600 -kgdb_longjmp(long *buf, int val)
7604 - asm ("lmw 13,16(%0);"
7605 - "lwz 0,12(%0); mtcrf 0x38,0;"
7606 - "lwz 0,0(%0); lwz 1,4(%0); lwz 2,8(%0);"
7608 - : : "r" (buf), "r" (val));
7610 -/* Convert ch from a hex digit to an int */
7612 -hex(unsigned char ch)
7614 - if (ch >= 'a' && ch <= 'f')
7616 - if (ch >= '0' && ch <= '9')
7618 - if (ch >= 'A' && ch <= 'F')
7623 -/* Convert the memory pointed to by mem into hex, placing result in buf.
7624 - * Return a pointer to the last char put in buf (null), in case of mem fault,
7627 -static unsigned char *
7628 -mem2hex(const char *mem, char *buf, int count)
7631 - unsigned short tmp_s;
7632 - unsigned long tmp_l;
7634 - if (kgdb_setjmp((long*)fault_jmp_buf) == 0) {
7635 - debugger_fault_handler = kgdb_fault_handler;
7637 - /* Accessing 16 bit and 32 bit objects in a single
7638 - ** load instruction is required to avoid bad side
7639 - ** effects for some IO registers.
7642 - if ((count == 2) && (((long)mem & 1) == 0)) {
7643 - tmp_s = *(unsigned short *)mem;
7645 - *buf++ = hexchars[(tmp_s >> 12) & 0xf];
7646 - *buf++ = hexchars[(tmp_s >> 8) & 0xf];
7647 - *buf++ = hexchars[(tmp_s >> 4) & 0xf];
7648 - *buf++ = hexchars[tmp_s & 0xf];
7650 - } else if ((count == 4) && (((long)mem & 3) == 0)) {
7651 - tmp_l = *(unsigned int *)mem;
7653 - *buf++ = hexchars[(tmp_l >> 28) & 0xf];
7654 - *buf++ = hexchars[(tmp_l >> 24) & 0xf];
7655 - *buf++ = hexchars[(tmp_l >> 20) & 0xf];
7656 - *buf++ = hexchars[(tmp_l >> 16) & 0xf];
7657 - *buf++ = hexchars[(tmp_l >> 12) & 0xf];
7658 - *buf++ = hexchars[(tmp_l >> 8) & 0xf];
7659 - *buf++ = hexchars[(tmp_l >> 4) & 0xf];
7660 - *buf++ = hexchars[tmp_l & 0xf];
7663 - while (count-- > 0) {
7665 - *buf++ = hexchars[ch >> 4];
7666 - *buf++ = hexchars[ch & 0xf];
7671 - /* error condition */
7673 - debugger_fault_handler = NULL;
7678 -/* convert the hex array pointed to by buf into binary to be placed in mem
7679 - * return a pointer to the character AFTER the last byte written.
7682 -hex2mem(char *buf, char *mem, int count)
7687 - unsigned short tmp_s;
7688 - unsigned long tmp_l;
7692 - if (kgdb_setjmp((long*)fault_jmp_buf) == 0) {
7693 - debugger_fault_handler = kgdb_fault_handler;
7695 - /* Accessing 16 bit and 32 bit objects in a single
7696 - ** store instruction is required to avoid bad side
7697 - ** effects for some IO registers.
7700 - if ((count == 2) && (((long)mem & 1) == 0)) {
7701 - tmp_s = hex(*buf++) << 12;
7702 - tmp_s |= hex(*buf++) << 8;
7703 - tmp_s |= hex(*buf++) << 4;
7704 - tmp_s |= hex(*buf++);
7706 - *(unsigned short *)mem = tmp_s;
7709 - } else if ((count == 4) && (((long)mem & 3) == 0)) {
7710 - tmp_l = hex(*buf++) << 28;
7711 - tmp_l |= hex(*buf++) << 24;
7712 - tmp_l |= hex(*buf++) << 20;
7713 - tmp_l |= hex(*buf++) << 16;
7714 - tmp_l |= hex(*buf++) << 12;
7715 - tmp_l |= hex(*buf++) << 8;
7716 - tmp_l |= hex(*buf++) << 4;
7717 - tmp_l |= hex(*buf++);
7719 - *(unsigned long *)mem = tmp_l;
7723 - for (i=0; i<count; i++) {
7724 - ch = hex(*buf++) << 4;
7725 - ch |= hex(*buf++);
7732 - ** Flush the data cache, invalidate the instruction cache.
7734 - flush_icache_range((int)orig_mem, (int)orig_mem + count - 1);
7737 - /* error condition */
7739 - debugger_fault_handler = NULL;
7744 - * While we find nice hex chars, build an int.
7745 - * Return number of chars processed.
7748 -hexToInt(char **ptr, int *intValue)
7755 - if (kgdb_setjmp((long*)fault_jmp_buf) == 0) {
7756 - debugger_fault_handler = kgdb_fault_handler;
7758 - hexValue = hex(**ptr);
7762 - *intValue = (*intValue << 4) | hexValue;
7768 - /* error condition */
7770 - debugger_fault_handler = NULL;
7772 - return (numChars);
7775 -/* scan for the sequence $<data>#<checksum> */
7777 -getpacket(char *buffer)
7779 - unsigned char checksum;
7780 - unsigned char xmitcsum;
7786 - /* wait around for the start character, ignore all other
7788 - while ((ch = (getDebugChar() & 0x7f)) != '$') ;
7795 - /* now, read until a # or end of buffer is found */
7796 - while (count < BUFMAX) {
7797 - ch = getDebugChar() & 0x7f;
7800 - checksum = checksum + ch;
7801 - buffer[count] = ch;
7802 - count = count + 1;
7805 - if (count >= BUFMAX)
7808 - buffer[count] = 0;
7811 - xmitcsum = hex(getDebugChar() & 0x7f) << 4;
7812 - xmitcsum |= hex(getDebugChar() & 0x7f);
7813 - if (checksum != xmitcsum)
7814 - putDebugChar('-'); /* failed checksum */
7816 - putDebugChar('+'); /* successful transfer */
7817 - /* if a sequence char is present, reply the ID */
7818 - if (buffer[2] == ':') {
7819 - putDebugChar(buffer[0]);
7820 - putDebugChar(buffer[1]);
7821 - /* remove sequence chars from buffer */
7822 - count = strlen(buffer);
7823 - for (i=3; i <= count; i++)
7824 - buffer[i-3] = buffer[i];
7828 - } while (checksum != xmitcsum);
7831 -/* send the packet in buffer. */
7832 -static void putpacket(unsigned char *buffer)
7834 - unsigned char checksum;
7836 - unsigned char ch, recv;
7838 - /* $<packet info>#<checksum>. */
7840 - putDebugChar('$');
7844 - while ((ch = buffer[count])) {
7850 - putDebugChar('#');
7851 - putDebugChar(hexchars[checksum >> 4]);
7852 - putDebugChar(hexchars[checksum & 0xf]);
7853 - recv = getDebugChar();
7854 - } while ((recv & 0x7f) != '+');
7857 -static void kgdb_flush_cache_all(void)
7859 - flush_instruction_cache();
7862 -/* Set up exception handlers for tracing and breakpoints
7863 - * [could be called kgdb_init()]
7865 -void set_debug_traps(void)
7870 - save_and_cli(flags);
7872 - /* In case GDB is started before us, ack any packets (presumably
7873 - * "$?#xx") sitting there.
7875 - * I've found this code causes more problems than it solves,
7876 - * so that's why it's commented out. GDB seems to work fine
7877 - * now starting either before or after the kernel -bwb
7880 - while((c = getDebugChar()) != '$');
7881 - while((c = getDebugChar()) != '#');
7882 - c = getDebugChar(); /* eat first csum byte */
7883 - c = getDebugChar(); /* eat second csum byte */
7884 - putDebugChar('+'); /* ack it */
7887 - debugger_bpt = kgdb_bpt;
7888 - debugger_sstep = kgdb_sstep;
7889 - debugger_iabr_match = kgdb_iabr_match;
7890 - debugger_dabr_match = kgdb_dabr_match;
7895 -static void kgdb_fault_handler(struct pt_regs *regs)
7897 - kgdb_longjmp((long*)fault_jmp_buf, 1);
7900 -int kgdb_bpt(struct pt_regs *regs)
7902 - return handle_exception(regs);
7905 -int kgdb_sstep(struct pt_regs *regs)
7907 - return handle_exception(regs);
7910 -void kgdb(struct pt_regs *regs)
7912 - handle_exception(regs);
7915 -int kgdb_iabr_match(struct pt_regs *regs)
7917 - printk(KERN_ERR "kgdb doesn't support iabr, what?!?\n");
7918 - return handle_exception(regs);
7921 -int kgdb_dabr_match(struct pt_regs *regs)
7923 - printk(KERN_ERR "kgdb doesn't support dabr, what?!?\n");
7924 - return handle_exception(regs);
7927 -/* Convert the hardware trap type code to a unix signal number. */
7929 - * This table contains the mapping between PowerPC hardware trap types, and
7930 - * signals, which are primarily what GDB understands.
7932 -static struct hard_trap_info
7934 - unsigned int tt; /* Trap type code for powerpc */
7935 - unsigned char signo; /* Signal that we map this trap into */
7936 -} hard_trap_info[] = {
7937 -#if defined(CONFIG_40x) || defined(CONFIG_BOOKE)
7938 - { 0x100, SIGINT }, /* critical input interrupt */
7939 - { 0x200, SIGSEGV }, /* machine check */
7940 - { 0x300, SIGSEGV }, /* data storage */
7941 - { 0x400, SIGBUS }, /* instruction storage */
7942 - { 0x500, SIGINT }, /* interrupt */
7943 - { 0x600, SIGBUS }, /* alignment */
7944 - { 0x700, SIGILL }, /* program */
7945 - { 0x800, SIGILL }, /* reserved */
7946 - { 0x900, SIGILL }, /* reserved */
7947 - { 0xa00, SIGILL }, /* reserved */
7948 - { 0xb00, SIGILL }, /* reserved */
7949 - { 0xc00, SIGCHLD }, /* syscall */
7950 - { 0xd00, SIGILL }, /* reserved */
7951 - { 0xe00, SIGILL }, /* reserved */
7952 - { 0xf00, SIGILL }, /* reserved */
7956 - ** 0x1020 watchdog
7957 - ** 0x1100 data TLB miss
7958 - ** 0x1200 instruction TLB miss
7960 - { 0x2002, SIGTRAP}, /* debug */
7962 - { 0x200, SIGSEGV }, /* machine check */
7963 - { 0x300, SIGSEGV }, /* address error (store) */
7964 - { 0x400, SIGBUS }, /* instruction bus error */
7965 - { 0x500, SIGINT }, /* interrupt */
7966 - { 0x600, SIGBUS }, /* alingment */
7967 - { 0x700, SIGTRAP }, /* breakpoint trap */
7968 - { 0x800, SIGFPE }, /* fpu unavail */
7969 - { 0x900, SIGALRM }, /* decrementer */
7970 - { 0xa00, SIGILL }, /* reserved */
7971 - { 0xb00, SIGILL }, /* reserved */
7972 - { 0xc00, SIGCHLD }, /* syscall */
7973 - { 0xd00, SIGTRAP }, /* single-step/watch */
7974 - { 0xe00, SIGFPE }, /* fp assist */
7976 - { 0, 0} /* Must be last */
7980 -static int computeSignal(unsigned int tt)
7982 - struct hard_trap_info *ht;
7984 - for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
7988 - return SIGHUP; /* default for things we don't know about */
7991 -#define PC_REGNUM 64
7992 -#define SP_REGNUM 1
7995 - * This function does all command processing for interfacing to gdb.
7998 -handle_exception (struct pt_regs *regs)
8006 - /* We don't handle user-mode breakpoints. */
8007 - if (user_mode(regs))
8010 - if (debugger_fault_handler) {
8011 - debugger_fault_handler(regs);
8012 - panic("kgdb longjump failed!\n");
8014 - if (kgdb_active) {
8015 - printk(KERN_ERR "interrupt while in kgdb, returning\n");
8023 - printk("kgdb: entering handle_exception; trap [0x%x]\n",
8024 - (unsigned int)regs->trap);
8027 - kgdb_interruptible(0);
8030 - mtmsr(msr & ~MSR_EE); /* disable interrupts */
8032 - if (regs->nip == (unsigned long)breakinst) {
8033 - /* Skip over breakpoint trap insn */
8037 - /* reply to host that an exception has occurred */
8038 - sigval = computeSignal(regs->trap);
8039 - ptr = remcomOutBuffer;
8042 - *ptr++ = hexchars[sigval >> 4];
8043 - *ptr++ = hexchars[sigval & 0xf];
8044 - *ptr++ = hexchars[PC_REGNUM >> 4];
8045 - *ptr++ = hexchars[PC_REGNUM & 0xf];
8047 - ptr = mem2hex((char *)®s->nip, ptr, 4);
8049 - *ptr++ = hexchars[SP_REGNUM >> 4];
8050 - *ptr++ = hexchars[SP_REGNUM & 0xf];
8052 - ptr = mem2hex(((char *)regs) + SP_REGNUM*4, ptr, 4);
8056 - putpacket(remcomOutBuffer);
8058 - printk("remcomOutBuffer: %s\n", remcomOutBuffer);
8060 - /* XXX We may want to add some features dealing with poking the
8061 - * XXX page tables, ... (look at sparc-stub.c for more info)
8062 - * XXX also required hacking to the gdb sources directly...
8066 - remcomOutBuffer[0] = 0;
8068 - getpacket(remcomInBuffer);
8069 - switch (remcomInBuffer[0]) {
8070 - case '?': /* report most recent signal */
8071 - remcomOutBuffer[0] = 'S';
8072 - remcomOutBuffer[1] = hexchars[sigval >> 4];
8073 - remcomOutBuffer[2] = hexchars[sigval & 0xf];
8074 - remcomOutBuffer[3] = 0;
8077 - case 'q': /* this screws up gdb for some reason...*/
8079 - extern long _start, sdata, __bss_start;
8081 - ptr = &remcomInBuffer[1];
8082 - if (strncmp(ptr, "Offsets", 7) != 0)
8085 - ptr = remcomOutBuffer;
8086 - sprintf(ptr, "Text=%8.8x;Data=%8.8x;Bss=%8.8x",
8087 - &_start, &sdata, &__bss_start);
8092 - /* toggle debug flag */
8096 - case 'g': /* return the value of the CPU registers.
8097 - * some of them are non-PowerPC names :(
8098 - * they are stored in gdb like:
8102 - * u32 pc, ps, cnd, lr; (ps=msr)
8103 - * u32 cnt, xer, mq;
8108 - ptr = remcomOutBuffer;
8109 - /* General Purpose Regs */
8110 - ptr = mem2hex((char *)regs, ptr, 32 * 4);
8111 - /* Floating Point Regs - FIXME */
8112 - /*ptr = mem2hex((char *), ptr, 32 * 8);*/
8113 - for(i=0; i<(32*8*2); i++) { /* 2chars/byte */
8117 - /* pc, msr, cr, lr, ctr, xer, (mq is unused) */
8118 - ptr = mem2hex((char *)®s->nip, ptr, 4);
8119 - ptr = mem2hex((char *)®s->msr, ptr, 4);
8120 - ptr = mem2hex((char *)®s->ccr, ptr, 4);
8121 - ptr = mem2hex((char *)®s->link, ptr, 4);
8122 - ptr = mem2hex((char *)®s->ctr, ptr, 4);
8123 - ptr = mem2hex((char *)®s->xer, ptr, 4);
8127 - case 'G': /* set the value of the CPU registers */
8129 - ptr = &remcomInBuffer[1];
8132 - * If the stack pointer has moved, you should pray.
8133 - * (cause only god can help you).
8136 - /* General Purpose Regs */
8137 - hex2mem(ptr, (char *)regs, 32 * 4);
8139 - /* Floating Point Regs - FIXME?? */
8140 - /*ptr = hex2mem(ptr, ??, 32 * 8);*/
8143 - /* pc, msr, cr, lr, ctr, xer, (mq is unused) */
8144 - ptr = hex2mem(ptr, (char *)®s->nip, 4);
8145 - ptr = hex2mem(ptr, (char *)®s->msr, 4);
8146 - ptr = hex2mem(ptr, (char *)®s->ccr, 4);
8147 - ptr = hex2mem(ptr, (char *)®s->link, 4);
8148 - ptr = hex2mem(ptr, (char *)®s->ctr, 4);
8149 - ptr = hex2mem(ptr, (char *)®s->xer, 4);
8151 - strcpy(remcomOutBuffer,"OK");
8155 - /* don't do anything, yet, just acknowledge */
8156 - hexToInt(&ptr, &addr);
8157 - strcpy(remcomOutBuffer,"OK");
8160 - case 'm': /* mAA..AA,LLLL Read LLLL bytes at address AA..AA */
8161 - /* Try to read %x,%x. */
8163 - ptr = &remcomInBuffer[1];
8165 - if (hexToInt(&ptr, &addr) && *ptr++ == ','
8166 - && hexToInt(&ptr, &length)) {
8167 - if (mem2hex((char *)addr, remcomOutBuffer,
8170 - strcpy(remcomOutBuffer, "E03");
8172 - strcpy(remcomOutBuffer, "E01");
8175 - case 'M': /* MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK */
8176 - /* Try to read '%x,%x:'. */
8178 - ptr = &remcomInBuffer[1];
8180 - if (hexToInt(&ptr, &addr) && *ptr++ == ','
8181 - && hexToInt(&ptr, &length)
8182 - && *ptr++ == ':') {
8183 - if (hex2mem(ptr, (char *)addr, length))
8184 - strcpy(remcomOutBuffer, "OK");
8186 - strcpy(remcomOutBuffer, "E03");
8187 - flush_icache_range(addr, addr+length);
8189 - strcpy(remcomOutBuffer, "E02");
8193 - case 'k': /* kill the program, actually just continue */
8194 - case 'c': /* cAA..AA Continue; address AA..AA optional */
8195 - /* try to read optional parameter, pc unchanged if no parm */
8197 - ptr = &remcomInBuffer[1];
8198 - if (hexToInt(&ptr, &addr))
8201 -/* Need to flush the instruction cache here, as we may have deposited a
8202 - * breakpoint, and the icache probably has no way of knowing that a data ref to
8203 - * some location may have changed something that is in the instruction cache.
8205 - kgdb_flush_cache_all();
8208 - kgdb_interruptible(1);
8212 - printk("remcomInBuffer: %s\n", remcomInBuffer);
8213 - printk("remcomOutBuffer: %s\n", remcomOutBuffer);
8218 - kgdb_flush_cache_all();
8219 -#if defined(CONFIG_40x) || defined(CONFIG_BOOKE)
8220 - mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) | DBCR0_IC);
8221 - regs->msr |= MSR_DE;
8223 - regs->msr |= MSR_SE;
8228 - printk("remcomInBuffer: %s\n", remcomInBuffer);
8229 - printk("remcomOutBuffer: %s\n", remcomOutBuffer);
8233 - case 'r': /* Reset (if user process..exit ???)*/
8234 - panic("kgdb reset.");
8237 - if (remcomOutBuffer[0] && kdebug) {
8238 - printk("remcomInBuffer: %s\n", remcomInBuffer);
8239 - printk("remcomOutBuffer: %s\n", remcomOutBuffer);
8241 - /* reply to the request */
8242 - putpacket(remcomOutBuffer);
8246 -/* This function will generate a breakpoint exception. It is used at the
8247 - beginning of a program to sync up with a debugger and can be used
8248 - otherwise as a quick means to stop program execution and "break" into
8254 - if (!initialized) {
8255 - printk("breakpoint() called b4 kgdb init\n");
8259 - asm(" .globl breakinst \n\
8260 - breakinst: .long 0x7d821008");
8263 -#ifdef CONFIG_KGDB_CONSOLE
8264 -/* Output string in GDB O-packet format if GDB has connected. If nothing
8265 - output, returns 0 (caller must then handle output). */
8267 -kgdb_output_string (const char* s, unsigned int count)
8271 - if (!kgdb_started)
8274 - count = (count <= (sizeof(buffer) / 2 - 2))
8275 - ? count : (sizeof(buffer) / 2 - 2);
8278 - mem2hex (s, &buffer[1], count);
8279 - putpacket(buffer);
8285 -static void sysrq_handle_gdb(int key, struct pt_regs *pt_regs,
8286 - struct tty_struct *tty)
8288 - printk("Entering GDB stub\n");
8291 -static struct sysrq_key_op sysrq_gdb_op = {
8292 - .handler = sysrq_handle_gdb,
8293 - .help_msg = "Gdb",
8294 - .action_msg = "GDB",
8297 -static int gdb_register_sysrq(void)
8299 - printk("Registering GDB sysrq handler\n");
8300 - register_sysrq_key('g', &sysrq_gdb_op);
8303 -module_init(gdb_register_sysrq);
8304 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ppc/kernel/setup.c linux-2.6.18.kgdb/arch/ppc/kernel/setup.c
8305 --- linux-2.6.18/arch/ppc/kernel/setup.c 2006-09-20 07:42:06.000000000 +0400
8306 +++ linux-2.6.18.kgdb/arch/ppc/kernel/setup.c 2008-06-10 16:19:22.000000000 +0400
8308 #include <asm/ppc_sys.h>
8311 -#if defined CONFIG_KGDB
8312 -#include <asm/kgdb.h>
8315 extern void platform_init(unsigned long r3, unsigned long r4,
8316 unsigned long r5, unsigned long r6, unsigned long r7);
8317 extern void identify_cpu(unsigned long offset, unsigned long cpu);
8318 @@ -504,18 +500,6 @@ void __init setup_arch(char **cmdline_p)
8319 #endif /* CONFIG_XMON */
8320 if ( ppc_md.progress ) ppc_md.progress("setup_arch: enter", 0x3eab);
8322 -#if defined(CONFIG_KGDB)
8323 - if (ppc_md.kgdb_map_scc)
8324 - ppc_md.kgdb_map_scc();
8325 - set_debug_traps();
8326 - if (strstr(cmd_line, "gdb")) {
8327 - if (ppc_md.progress)
8328 - ppc_md.progress("setup_arch: kgdb breakpoint", 0x4000);
8329 - printk("kgdb breakpoint activated\n");
8335 * Set cache line size based on type of cpu as a default.
8336 * Systems with OF can look in the properties on the cpu node(s)
8337 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ppc/mm/fault.c linux-2.6.18.kgdb/arch/ppc/mm/fault.c
8338 --- linux-2.6.18/arch/ppc/mm/fault.c 2006-09-20 07:42:06.000000000 +0400
8339 +++ linux-2.6.18.kgdb/arch/ppc/mm/fault.c 2008-06-10 16:19:22.000000000 +0400
8341 #include <linux/interrupt.h>
8342 #include <linux/highmem.h>
8343 #include <linux/module.h>
8344 +#include <linux/kgdb.h>
8346 #include <asm/page.h>
8347 #include <asm/pgtable.h>
8348 @@ -329,6 +330,14 @@ bad_page_fault(struct pt_regs *regs, uns
8353 + if (atomic_read(&debugger_active) && kgdb_may_fault) {
8354 + /* Restore our previous state. */
8355 + kgdb_fault_longjmp(kgdb_fault_jmp_regs);
8356 + /* Not reached. */
8360 /* kernel has accessed a bad area */
8361 #if defined(CONFIG_XMON) || defined(CONFIG_KGDB)
8362 if (debugger_kernel_faults)
8363 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ppc/platforms/4xx/bubinga.c linux-2.6.18.kgdb/arch/ppc/platforms/4xx/bubinga.c
8364 --- linux-2.6.18/arch/ppc/platforms/4xx/bubinga.c 2006-09-20 07:42:06.000000000 +0400
8365 +++ linux-2.6.18.kgdb/arch/ppc/platforms/4xx/bubinga.c 2008-06-10 16:19:22.000000000 +0400
8367 * Author: SAW (IBM), derived from walnut.c.
8368 * Maintained by MontaVista Software <source@mvista.com>
8370 - * 2003 (c) MontaVista Softare Inc. This file is licensed under the
8371 + * 2003-2004 (c) MontaVista Softare Inc. This file is licensed under the
8372 * terms of the GNU General Public License version 2. This program is
8373 * licensed "as is" without any warranty of any kind, whether express
8375 @@ -100,17 +100,26 @@ bubinga_early_serial_map(void)
8376 port.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST;
8379 - if (early_serial_setup(&port) != 0) {
8380 +#ifdef CONFIG_SERIAL_8250
8381 + if (early_serial_setup(&port) != 0)
8382 printk("Early serial init of port 0 failed\n");
8386 +#ifdef CONFIG_KGDB_8250
8387 + kgdb8250_add_port(0, &port);
8390 port.membase = (void*)ACTING_UART1_IO_BASE;
8391 port.irq = ACTING_UART1_INT;
8394 - if (early_serial_setup(&port) != 0) {
8395 +#ifdef CONFIG_SERIAL_8250
8396 + if (early_serial_setup(&port) != 0)
8397 printk("Early serial init of port 1 failed\n");
8400 +#ifdef CONFIG_KGDB_8250
8401 + kgdb8250_add_port(1, &port);
8406 @@ -255,8 +264,4 @@ platform_init(unsigned long r3, unsigned
8407 ppc_md.nvram_read_val = todc_direct_read_val;
8408 ppc_md.nvram_write_val = todc_direct_write_val;
8411 - ppc_md.early_serial_map = bubinga_early_serial_map;
8415 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ppc/platforms/4xx/ebony.c linux-2.6.18.kgdb/arch/ppc/platforms/4xx/ebony.c
8416 --- linux-2.6.18/arch/ppc/platforms/4xx/ebony.c 2006-09-20 07:42:06.000000000 +0400
8417 +++ linux-2.6.18.kgdb/arch/ppc/platforms/4xx/ebony.c 2008-06-10 16:19:22.000000000 +0400
8419 #include <linux/tty.h>
8420 #include <linux/serial.h>
8421 #include <linux/serial_core.h>
8422 +#include <linux/kgdb.h>
8424 #include <asm/system.h>
8425 #include <asm/pgtable.h>
8426 @@ -226,14 +227,20 @@ ebony_early_serial_map(void)
8427 port.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST;
8430 - if (early_serial_setup(&port) != 0) {
8431 +#ifdef CONFIG_SERIAL_8250
8432 + if (early_serial_setup(&port) != 0)
8433 printk("Early serial init of port 0 failed\n");
8437 -#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
8438 +#ifdef CONFIG_SERIAL_TEXT_DEBUG
8439 /* Configure debug serial access */
8440 gen550_init(0, &port);
8442 +#ifdef CONFIG_KGDB_8250
8443 + kgdb8250_add_port(0, &port);
8446 +#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB_8250)
8447 /* Purge TLB entry added in head_44x.S for early serial access */
8448 _tlbie(UART0_IO_BASE);
8450 @@ -243,14 +250,18 @@ ebony_early_serial_map(void)
8451 port.uartclk = clocks.uart1;
8454 - if (early_serial_setup(&port) != 0) {
8455 +#ifdef CONFIG_SERIAL_8250
8456 + if (early_serial_setup(&port) != 1)
8457 printk("Early serial init of port 1 failed\n");
8461 -#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
8462 +#ifdef CONFIG_SERIAL_TEXT_DEBUG
8463 /* Configure debug serial access */
8464 gen550_init(1, &port);
8466 +#ifdef CONFIG_KGDB_8250
8467 + kgdb8250_add_port(1, &port);
8472 @@ -327,8 +338,4 @@ void __init platform_init(unsigned long
8474 ppc_md.nvram_read_val = todc_direct_read_val;
8475 ppc_md.nvram_write_val = todc_direct_write_val;
8477 - ppc_md.early_serial_map = ebony_early_serial_map;
8481 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ppc/platforms/4xx/ocotea.c linux-2.6.18.kgdb/arch/ppc/platforms/4xx/ocotea.c
8482 --- linux-2.6.18/arch/ppc/platforms/4xx/ocotea.c 2006-09-20 07:42:06.000000000 +0400
8483 +++ linux-2.6.18.kgdb/arch/ppc/platforms/4xx/ocotea.c 2008-06-10 16:19:22.000000000 +0400
8485 #include <linux/tty.h>
8486 #include <linux/serial.h>
8487 #include <linux/serial_core.h>
8488 +#include <linux/kgdb.h>
8490 #include <asm/system.h>
8491 #include <asm/pgtable.h>
8492 @@ -249,14 +250,20 @@ ocotea_early_serial_map(void)
8493 port.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST;
8496 - if (early_serial_setup(&port) != 0) {
8497 +#ifdef CONFIG_SERIAL_8250
8498 + if (early_serial_setup(&port) != 0)
8499 printk("Early serial init of port 0 failed\n");
8503 -#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
8504 +#ifdef CONFIG_SERIAL_TEXT_DEBUG
8505 /* Configure debug serial access */
8506 gen550_init(0, &port);
8508 +#ifdef CONFIG_KGDB_8250
8509 + kgdb8250_add_port(0, &port);
8512 +#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB_8250)
8513 /* Purge TLB entry added in head_44x.S for early serial access */
8514 _tlbie(UART0_IO_BASE);
8516 @@ -266,14 +273,18 @@ ocotea_early_serial_map(void)
8517 port.uartclk = clocks.uart1;
8520 - if (early_serial_setup(&port) != 0) {
8521 +#ifdef CONFIG_SERIAL_8250
8522 + if (early_serial_setup(&port) != 1)
8523 printk("Early serial init of port 1 failed\n");
8527 -#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
8528 +#ifdef CONFIG_SERIAL_TEXT_DEBUG
8529 /* Configure debug serial access */
8530 gen550_init(1, &port);
8532 +#ifdef CONFIG_KGDB_8250
8533 + kgdb8250_add_port(1, &port);
8538 @@ -343,8 +354,5 @@ void __init platform_init(unsigned long
8540 ppc_md.nvram_read_val = todc_direct_read_val;
8541 ppc_md.nvram_write_val = todc_direct_write_val;
8543 - ppc_md.early_serial_map = ocotea_early_serial_map;
8545 ppc_md.init = ocotea_init;
8547 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ppc/platforms/4xx/xilinx_ml300.c linux-2.6.18.kgdb/arch/ppc/platforms/4xx/xilinx_ml300.c
8548 --- linux-2.6.18/arch/ppc/platforms/4xx/xilinx_ml300.c 2006-09-20 07:42:06.000000000 +0400
8549 +++ linux-2.6.18.kgdb/arch/ppc/platforms/4xx/xilinx_ml300.c 2008-06-10 16:19:22.000000000 +0400
8551 * ppc4xx_map_io arch/ppc/syslib/ppc4xx_setup.c
8552 * start_kernel init/main.c
8553 * setup_arch arch/ppc/kernel/setup.c
8554 - * #if defined(CONFIG_KGDB)
8555 - * *ppc_md.kgdb_map_scc() == gen550_kgdb_map_scc
8557 * *ppc_md.setup_arch == ml300_setup_arch this file
8558 * ppc4xx_setup_arch arch/ppc/syslib/ppc4xx_setup.c
8559 * ppc4xx_find_bridges arch/ppc/syslib/ppc405_pci.c
8560 @@ -117,7 +114,6 @@ ml300_early_serial_init(int num, struct
8562 ml300_early_serial_map(void)
8564 -#ifdef CONFIG_SERIAL_8250
8565 struct plat_serial8250_port *pdata;
8568 @@ -129,7 +125,14 @@ ml300_early_serial_map(void)
8572 -#endif /* CONFIG_SERIAL_8250 */
8573 +#ifdef CONFIG_SERIAL_8250
8574 + if (early_serial_setup(&port) != 0)
8575 + printk("Early serial init of port %d failed\n", i);
8578 +#ifdef CONFIG_KGDB_8250
8579 + kgdb8250_add_port(i, &port)
8584 @@ -165,9 +168,4 @@ platform_init(unsigned long r3, unsigned
8585 #if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
8586 ppc_md.power_off = xilinx_power_off;
8590 - ppc_md.early_serial_map = ml300_early_serial_map;
8594 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ppc/platforms/85xx/sbc8560.c linux-2.6.18.kgdb/arch/ppc/platforms/85xx/sbc8560.c
8595 --- linux-2.6.18/arch/ppc/platforms/85xx/sbc8560.c 2006-09-20 07:42:06.000000000 +0400
8596 +++ linux-2.6.18.kgdb/arch/ppc/platforms/85xx/sbc8560.c 2008-06-10 16:19:22.000000000 +0400
8598 #include <syslib/ppc85xx_common.h>
8599 #include <syslib/ppc85xx_setup.h>
8601 -#ifdef CONFIG_SERIAL_8250
8603 sbc8560_early_serial_map(void)
8605 @@ -66,12 +65,16 @@ sbc8560_early_serial_map(void)
8606 uart_req.membase = ioremap(uart_req.mapbase, MPC85xx_UART0_SIZE);
8607 uart_req.type = PORT_16650;
8609 -#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
8610 - gen550_init(0, &uart_req);
8611 +#ifdef CONFIG_SERIAL_8250
8612 + if (early_serial_setup(&uart_req) != 0)
8613 + printk("Early serial init of port 0 failed\n");
8615 +#ifdef CONFIG_SERIAL_TEXT_DEBUG
8616 + gen550_init(0, &uart_req);
8618 +#ifdef CONFIG_KGDB_8250
8619 + kgdb8250_add_port(0, &uart_req);
8622 - if (early_serial_setup(&uart_req) != 0)
8623 - printk("Early serial init of port 0 failed\n");
8625 /* Assume early_serial_setup() doesn't modify uart_req */
8627 @@ -79,14 +82,17 @@ sbc8560_early_serial_map(void)
8628 uart_req.membase = ioremap(uart_req.mapbase, MPC85xx_UART1_SIZE);
8629 uart_req.irq = MPC85xx_IRQ_EXT10;
8631 -#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
8632 - gen550_init(1, &uart_req);
8633 +#ifdef CONFIG_SERIAL_8250
8634 + if (early_serial_setup(&uart_req) != 0)
8635 + printk("Early serial init of port 0 failed\n");
8638 - if (early_serial_setup(&uart_req) != 0)
8639 - printk("Early serial init of port 1 failed\n");
8641 +#ifdef CONFIG_SERIAL_TEXT_DEBUG
8642 + gen550_init(0, &uart_req);
8644 +#ifdef CONFIG_KGDB_8250
8645 + kgdb8250_add_port(0, &uart_req);
8649 /* ************************************************************************
8651 @@ -115,9 +121,7 @@ sbc8560_setup_arch(void)
8652 /* setup PCI host bridges */
8653 mpc85xx_setup_hose();
8655 -#ifdef CONFIG_SERIAL_8250
8656 sbc8560_early_serial_map();
8658 #ifdef CONFIG_SERIAL_TEXT_DEBUG
8659 /* Invalidate the entry we stole earlier the serial ports
8660 * should be properly mapped */
8661 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ppc/platforms/chestnut.c linux-2.6.18.kgdb/arch/ppc/platforms/chestnut.c
8662 --- linux-2.6.18/arch/ppc/platforms/chestnut.c 2006-09-20 07:42:06.000000000 +0400
8663 +++ linux-2.6.18.kgdb/arch/ppc/platforms/chestnut.c 2008-06-10 16:19:22.000000000 +0400
8664 @@ -492,7 +492,7 @@ chestnut_power_off(void)
8666 chestnut_map_io(void)
8668 -#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
8669 +#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB_8250)
8670 io_block_mapping(CHESTNUT_UART_BASE, CHESTNUT_UART_BASE, 0x100000,
8673 @@ -566,9 +566,6 @@ platform_init(unsigned long r3, unsigned
8674 #if defined(CONFIG_SERIAL_TEXT_DEBUG)
8675 ppc_md.progress = gen550_progress;
8677 -#if defined(CONFIG_KGDB)
8678 - ppc_md.kgdb_map_scc = gen550_kgdb_map_scc;
8681 if (ppc_md.progress)
8682 ppc_md.progress("chestnut_init(): exit", 0);
8683 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ppc/platforms/pplus.c linux-2.6.18.kgdb/arch/ppc/platforms/pplus.c
8684 --- linux-2.6.18/arch/ppc/platforms/pplus.c 2006-09-20 07:42:06.000000000 +0400
8685 +++ linux-2.6.18.kgdb/arch/ppc/platforms/pplus.c 2008-06-10 16:19:22.000000000 +0400
8686 @@ -893,9 +893,6 @@ platform_init(unsigned long r3, unsigned
8687 #ifdef CONFIG_SERIAL_TEXT_DEBUG
8688 ppc_md.progress = gen550_progress;
8689 #endif /* CONFIG_SERIAL_TEXT_DEBUG */
8691 - ppc_md.kgdb_map_scc = gen550_kgdb_map_scc;
8694 smp_ops = &pplus_smp_ops;
8695 #endif /* CONFIG_SMP */
8696 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ppc/platforms/sandpoint.c linux-2.6.18.kgdb/arch/ppc/platforms/sandpoint.c
8697 --- linux-2.6.18/arch/ppc/platforms/sandpoint.c 2006-09-20 07:42:06.000000000 +0400
8698 +++ linux-2.6.18.kgdb/arch/ppc/platforms/sandpoint.c 2008-06-10 16:19:22.000000000 +0400
8699 @@ -730,9 +730,6 @@ platform_init(unsigned long r3, unsigned
8700 ppc_md.nvram_read_val = todc_mc146818_read_val;
8701 ppc_md.nvram_write_val = todc_mc146818_write_val;
8704 - ppc_md.kgdb_map_scc = gen550_kgdb_map_scc;
8706 #ifdef CONFIG_SERIAL_TEXT_DEBUG
8707 ppc_md.progress = gen550_progress;
8709 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ppc/platforms/spruce.c linux-2.6.18.kgdb/arch/ppc/platforms/spruce.c
8710 --- linux-2.6.18/arch/ppc/platforms/spruce.c 2006-09-20 07:42:06.000000000 +0400
8711 +++ linux-2.6.18.kgdb/arch/ppc/platforms/spruce.c 2008-06-10 16:19:22.000000000 +0400
8712 @@ -178,26 +178,32 @@ spruce_early_serial_map(void)
8713 serial_req.membase = (u_char *)UART0_IO_BASE;
8714 serial_req.regshift = 0;
8716 -#if defined(CONFIG_KGDB) || defined(CONFIG_SERIAL_TEXT_DEBUG)
8717 - gen550_init(0, &serial_req);
8719 #ifdef CONFIG_SERIAL_8250
8720 if (early_serial_setup(&serial_req) != 0)
8721 printk("Early serial init of port 0 failed\n");
8723 +#ifdef CONFIG_SERIAL_TEXT_DEBUG
8724 + gen550_init(0, &serial_req);
8726 +#ifdef CONFIG_KGDB_8250
8727 + kgdb8250_add_port(0, &port);
8730 /* Assume early_serial_setup() doesn't modify serial_req */
8731 serial_req.line = 1;
8732 serial_req.irq = UART1_INT;
8733 serial_req.membase = (u_char *)UART1_IO_BASE;
8735 -#if defined(CONFIG_KGDB) || defined(CONFIG_SERIAL_TEXT_DEBUG)
8736 - gen550_init(1, &serial_req);
8738 #ifdef CONFIG_SERIAL_8250
8739 if (early_serial_setup(&serial_req) != 0)
8740 printk("Early serial init of port 1 failed\n");
8742 +#ifdef CONFIG_SERIAL_TEXT_DEBUG
8743 + gen550_init(1, &serial_req);
8745 +#ifdef CONFIG_KGDB_8250
8746 + kgdb8250_add_port(1, &serial_req);
8751 @@ -316,7 +322,4 @@ platform_init(unsigned long r3, unsigned
8752 #ifdef CONFIG_SERIAL_TEXT_DEBUG
8753 ppc_md.progress = gen550_progress;
8754 #endif /* CONFIG_SERIAL_TEXT_DEBUG */
8756 - ppc_md.kgdb_map_scc = gen550_kgdb_map_scc;
8759 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ppc/syslib/Makefile linux-2.6.18.kgdb/arch/ppc/syslib/Makefile
8760 --- linux-2.6.18/arch/ppc/syslib/Makefile 2006-09-20 07:42:06.000000000 +0400
8761 +++ linux-2.6.18.kgdb/arch/ppc/syslib/Makefile 2008-06-10 16:19:22.000000000 +0400
8762 @@ -76,7 +76,6 @@ obj-$(CONFIG_PCI_8260) += m82xx_pci.o p
8763 obj-$(CONFIG_8260_PCI9) += m8260_pci_erratum9.o
8764 obj-$(CONFIG_CPM2) += cpm2_common.o cpm2_pic.o
8765 ifeq ($(CONFIG_PPC_GEN550),y)
8766 -obj-$(CONFIG_KGDB) += gen550_kgdb.o gen550_dbg.o
8767 obj-$(CONFIG_SERIAL_TEXT_DEBUG) += gen550_dbg.o
8769 ifeq ($(CONFIG_SERIAL_MPSC_CONSOLE),y)
8770 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ppc/syslib/gen550.h linux-2.6.18.kgdb/arch/ppc/syslib/gen550.h
8771 --- linux-2.6.18/arch/ppc/syslib/gen550.h 2006-09-20 07:42:06.000000000 +0400
8772 +++ linux-2.6.18.kgdb/arch/ppc/syslib/gen550.h 2008-06-10 16:19:22.000000000 +0400
8775 extern void gen550_progress(char *, unsigned short);
8776 extern void gen550_init(int, struct uart_port *);
8777 -extern void gen550_kgdb_map_scc(void);
8778 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ppc/syslib/ibm44x_common.c linux-2.6.18.kgdb/arch/ppc/syslib/ibm44x_common.c
8779 --- linux-2.6.18/arch/ppc/syslib/ibm44x_common.c 2006-09-20 07:42:06.000000000 +0400
8780 +++ linux-2.6.18.kgdb/arch/ppc/syslib/ibm44x_common.c 2008-06-10 16:19:22.000000000 +0400
8781 @@ -192,9 +192,6 @@ void __init ibm44x_platform_init(unsigne
8782 #ifdef CONFIG_SERIAL_TEXT_DEBUG
8783 ppc_md.progress = gen550_progress;
8784 #endif /* CONFIG_SERIAL_TEXT_DEBUG */
8786 - ppc_md.kgdb_map_scc = gen550_kgdb_map_scc;
8790 * The Abatron BDI JTAG debugger does not tolerate others
8791 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ppc/syslib/mv64x60.c linux-2.6.18.kgdb/arch/ppc/syslib/mv64x60.c
8792 --- linux-2.6.18/arch/ppc/syslib/mv64x60.c 2006-09-20 07:42:06.000000000 +0400
8793 +++ linux-2.6.18.kgdb/arch/ppc/syslib/mv64x60.c 2008-06-10 16:19:22.000000000 +0400
8794 @@ -241,6 +241,12 @@ static struct resource mv64x60_mpsc0_res
8795 .end = MV64x60_IRQ_SDMA_0,
8796 .flags = IORESOURCE_IRQ,
8799 + .name = "mpsc 0 irq",
8800 + .start = MV64x60_IRQ_MPSC_0,
8801 + .end = MV64x60_IRQ_MPSC_0,
8802 + .flags = IORESOURCE_IRQ,
8806 static struct platform_device mpsc0_device = {
8807 @@ -298,6 +304,12 @@ static struct resource mv64x60_mpsc1_res
8808 .end = MV64360_IRQ_SDMA_1,
8809 .flags = IORESOURCE_IRQ,
8812 + .name = "mpsc 1 irq",
8813 + .start = MV64360_IRQ_MPSC_1,
8814 + .end = MV64360_IRQ_MPSC_1,
8815 + .flags = IORESOURCE_IRQ,
8819 static struct platform_device mpsc1_device = {
8820 @@ -1426,12 +1438,46 @@ mv64x60_pd_fixup(struct mv64x60_handle *
8822 mv64x60_add_pds(void)
8824 - return platform_add_devices(mv64x60_pd_devs,
8825 - ARRAY_SIZE(mv64x60_pd_devs));
8828 + for (i = 0; i < ARRAY_SIZE(mv64x60_pd_devs); i++) {
8829 + if (mv64x60_pd_devs[i]) {
8830 + ret = platform_device_register(mv64x60_pd_devs[i]);
8834 + platform_device_unregister(mv64x60_pd_devs[i]);
8840 arch_initcall(mv64x60_add_pds);
8843 + * mv64x60_early_get_pdev_data()
8845 + * Get the data associated with a platform device by name and number.
8847 +struct platform_device * __init
8848 +mv64x60_early_get_pdev_data(const char *name, int id, int remove)
8851 + struct platform_device *pdev;
8853 + for (i = 0; i <ARRAY_SIZE(mv64x60_pd_devs); i++) {
8854 + if ((pdev = mv64x60_pd_devs[i]) &&
8856 + !strcmp(pdev->name, name)) {
8858 + mv64x60_pd_devs[i] = NULL;
8866 *****************************************************************************
8868 * GT64260-Specific Routines
8869 @@ -1764,6 +1810,11 @@ gt64260a_chip_specific_init(struct mv64x
8870 r->start = MV64x60_IRQ_SDMA_0;
8871 r->end = MV64x60_IRQ_SDMA_0;
8873 + if ((r = platform_get_resource(&mpsc1_device, IORESOURCE_IRQ, 1))
8875 + r->start = GT64260_IRQ_MPSC_1;
8876 + r->end = GT64260_IRQ_MPSC_1;
8881 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ppc/syslib/mv64x60_dbg.c linux-2.6.18.kgdb/arch/ppc/syslib/mv64x60_dbg.c
8882 --- linux-2.6.18/arch/ppc/syslib/mv64x60_dbg.c 2006-09-20 07:42:06.000000000 +0400
8883 +++ linux-2.6.18.kgdb/arch/ppc/syslib/mv64x60_dbg.c 2008-06-10 16:19:22.000000000 +0400
8884 @@ -34,7 +34,7 @@ static struct mv64x60_handle mv64x60_dbg
8886 mv64x60_progress_init(u32 base)
8888 - mv64x60_dbg_bh.v_base = base;
8889 + mv64x60_dbg_bh.v_base = (void*)base;
8893 @@ -69,53 +69,3 @@ mv64x60_mpsc_progress(char *s, unsigned
8896 #endif /* CONFIG_SERIAL_TEXT_DEBUG */
8899 -#if defined(CONFIG_KGDB)
8901 -#if defined(CONFIG_KGDB_TTYS0)
8902 -#define KGDB_PORT 0
8903 -#elif defined(CONFIG_KGDB_TTYS1)
8904 -#define KGDB_PORT 1
8906 -#error "Invalid kgdb_tty port"
8910 -putDebugChar(unsigned char c)
8912 - mv64x60_polled_putc(KGDB_PORT, (char)c);
8920 - while (!mv64x60_polled_getc(KGDB_PORT, &c));
8925 -putDebugString(char* str)
8927 - while (*str != '\0') {
8928 - putDebugChar(*str);
8931 - putDebugChar('\r');
8936 -kgdb_interruptible(int enable)
8943 - if (ppc_md.early_serial_map)
8944 - ppc_md.early_serial_map();
8946 -#endif /* CONFIG_KGDB */
8947 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/ppc/syslib/ppc85xx_setup.c linux-2.6.18.kgdb/arch/ppc/syslib/ppc85xx_setup.c
8948 --- linux-2.6.18/arch/ppc/syslib/ppc85xx_setup.c 2006-09-20 07:42:06.000000000 +0400
8949 +++ linux-2.6.18.kgdb/arch/ppc/syslib/ppc85xx_setup.c 2008-06-10 16:19:22.000000000 +0400
8950 @@ -69,7 +69,6 @@ mpc85xx_calibrate_decr(void)
8951 mtspr(SPRN_TCR, TCR_DIE);
8954 -#ifdef CONFIG_SERIAL_8250
8956 mpc85xx_early_serial_map(void)
8958 @@ -85,7 +84,7 @@ mpc85xx_early_serial_map(void)
8959 pdata[0].mapbase += binfo->bi_immr_base;
8960 pdata[0].membase = ioremap(pdata[0].mapbase, MPC85xx_UART0_SIZE);
8962 -#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
8963 +#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB_8250)
8964 memset(&serial_req, 0, sizeof (serial_req));
8965 serial_req.iotype = UPIO_MEM;
8966 serial_req.mapbase = pdata[0].mapbase;
8967 @@ -93,18 +92,24 @@ mpc85xx_early_serial_map(void)
8968 serial_req.regshift = 0;
8970 gen550_init(0, &serial_req);
8971 +#ifdef CONFIG_KGDB_8250
8972 + kgdb8250_add_port(0, &serial_req);
8976 pdata[1].uartclk = binfo->bi_busfreq;
8977 pdata[1].mapbase += binfo->bi_immr_base;
8978 pdata[1].membase = ioremap(pdata[1].mapbase, MPC85xx_UART0_SIZE);
8980 -#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
8981 +#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB_8250)
8982 /* Assume gen550_init() doesn't modify serial_req */
8983 serial_req.mapbase = pdata[1].mapbase;
8984 serial_req.membase = pdata[1].membase;
8986 gen550_init(1, &serial_req);
8987 +#ifdef CONFIG_KGDB_8250
8988 + kgdb8250_add_port(1, &serial_req);
8993 @@ -363,5 +368,3 @@ mpc85xx_setup_hose(void)
8996 #endif /* CONFIG_PCI */
8999 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/sh/Kconfig.debug linux-2.6.18.kgdb/arch/sh/Kconfig.debug
9000 --- linux-2.6.18/arch/sh/Kconfig.debug 2006-09-20 07:42:06.000000000 +0400
9001 +++ linux-2.6.18.kgdb/arch/sh/Kconfig.debug 2008-06-10 16:19:47.000000000 +0400
9002 @@ -29,96 +29,4 @@ config EARLY_PRINTK
9003 This option is only useful porting the kernel to a new machine,
9004 when the kernel may crash or hang before the serial console is
9005 initialised. If unsure, say N.
9008 - bool "Include KGDB kernel debugger"
9010 - Include in-kernel hooks for kgdb, the Linux kernel source level
9011 - debugger. See <http://kgdb.sourceforge.net/> for more information.
9012 - Unless you are intending to debug the kernel, say N here.
9014 -menu "KGDB configuration options"
9017 -config MORE_COMPILE_OPTIONS
9018 - bool "Add any additional compile options"
9020 - If you want to add additional CFLAGS to the kernel build, enable this
9021 - option and then enter what you would like to add in the next question.
9022 - Note however that -g is already appended with the selection of KGDB.
9024 -config COMPILE_OPTIONS
9025 - string "Additional compile arguments"
9026 - depends on MORE_COMPILE_OPTIONS
9029 - bool "Enter KGDB on NMI"
9033 - bool "Include KGDB thread support"
9036 -config SH_KGDB_CONSOLE
9037 - bool "Console messages through GDB"
9041 - bool "Allow SysRq 'G' to enter KGDB"
9044 -config KGDB_KERNEL_ASSERTS
9045 - bool "Include KGDB kernel assertions"
9048 -comment "Serial port setup"
9050 -config KGDB_DEFPORT
9051 - int "Port number (ttySCn)"
9054 -config KGDB_DEFBAUD
9061 - default KGDB_DEFPARITY_N
9063 -config KGDB_DEFPARITY_N
9066 -config KGDB_DEFPARITY_E
9069 -config KGDB_DEFPARITY_O
9075 - prompt "Data bits"
9077 - default KGDB_DEFBITS_8
9079 -config KGDB_DEFBITS_8
9082 -config KGDB_DEFBITS_7
9089 -config FRAME_POINTER
9090 - bool "Compile the kernel with frame pointers"
9093 - If you say Y here the resulting kernel image will be slightly larger
9094 - and slower, but it will give very useful debugging information.
9095 - If you don't debug the kernel, you can say N, but we may not be able
9096 - to solve problems without frame pointers.
9099 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/sh/Makefile linux-2.6.18.kgdb/arch/sh/Makefile
9100 --- linux-2.6.18/arch/sh/Makefile 2006-09-20 07:42:06.000000000 +0400
9101 +++ linux-2.6.18.kgdb/arch/sh/Makefile 2008-06-10 16:19:47.000000000 +0400
9102 @@ -43,7 +43,6 @@ cflags-$(CONFIG_CPU_SH4) += -m4 \
9103 cflags-$(CONFIG_CPU_SH4A) += $(call cc-option,-m4a-nofpu,)
9105 cflags-$(CONFIG_SH_DSP) += -Wa,-dsp
9106 -cflags-$(CONFIG_SH_KGDB) += -g
9108 cflags-$(CONFIG_MORE_COMPILE_OPTIONS) += \
9109 $(shell echo $(CONFIG_COMPILE_OPTIONS) | sed -e 's/"//g')
9110 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/sh/boards/se/7751/setup.c linux-2.6.18.kgdb/arch/sh/boards/se/7751/setup.c
9111 --- linux-2.6.18/arch/sh/boards/se/7751/setup.c 2006-09-20 07:42:06.000000000 +0400
9112 +++ linux-2.6.18.kgdb/arch/sh/boards/se/7751/setup.c 2008-06-10 16:19:47.000000000 +0400
9115 #include <asm/se7751/se7751.h>
9117 -#ifdef CONFIG_SH_KGDB
9118 -#include <asm/kgdb.h>
9122 * Configure the Super I/O chip
9124 @@ -82,12 +78,6 @@ const char *get_system_type(void)
9125 return "7751 SolutionEngine";
9128 -#ifdef CONFIG_SH_KGDB
9129 -static int kgdb_uart_setup(void);
9130 -static struct kgdb_sermap kgdb_uart_sermap =
9131 -{ "ttyS", 0, kgdb_uart_setup, NULL };
9135 * Initialize the board
9137 @@ -95,133 +85,4 @@ void __init platform_setup(void)
9139 /* Call init_smsc() replacement to set up SuperIO. */
9140 /* XXX: RTC setting comes here */
9141 -#ifdef CONFIG_SH_KGDB
9142 - kgdb_register_sermap(&kgdb_uart_sermap);
9146 -/*********************************************************************
9147 - * Currently a hack (e.g. does not interact well w/serial.c, lots of *
9148 - * hardcoded stuff) but may be useful if SCI/F needs debugging. *
9149 - * Mostly copied from x86 code (see files asm-i386/kgdb_local.h and *
9150 - * arch/i386/lib/kgdb_serial.c). *
9151 - *********************************************************************/
9153 -#ifdef CONFIG_SH_KGDB
9154 -#include <linux/types.h>
9155 -#include <linux/serial.h>
9156 -#include <linux/serialP.h>
9157 -#include <linux/serial_reg.h>
9159 -#define COM1_PORT 0x3f8 /* Base I/O address */
9160 -#define COM1_IRQ 4 /* IRQ not used yet */
9161 -#define COM2_PORT 0x2f8 /* Base I/O address */
9162 -#define COM2_IRQ 3 /* IRQ not used yet */
9164 -#define SB_CLOCK 1843200 /* Serial baud clock */
9165 -#define SB_BASE (SB_CLOCK/16)
9166 -#define SB_MCR UART_MCR_OUT2 | UART_MCR_DTR | UART_MCR_RTS
9171 -#define UART_NPORTS 2
9172 -struct uart_port uart_ports[] = {
9176 -struct uart_port *kgdb_uart_port;
9178 -#define UART_IN(reg) inb_p(kgdb_uart_port->base + reg)
9179 -#define UART_OUT(reg,v) outb_p((v), kgdb_uart_port->base + reg)
9181 -/* Basic read/write functions for the UART */
9182 -#define UART_LSR_RXCERR (UART_LSR_BI | UART_LSR_FE | UART_LSR_PE)
9183 -static int kgdb_uart_getchar(void)
9189 - lsr = UART_IN(UART_LSR);
9190 - if (lsr & UART_LSR_DR)
9191 - c = UART_IN(UART_RX);
9192 - if ((lsr & UART_LSR_RXCERR))
9198 -static void kgdb_uart_putchar(int c)
9200 - while ((UART_IN(UART_LSR) & UART_LSR_THRE) == 0)
9202 - UART_OUT(UART_TX, c);
9206 - * Initialize UART to configured/requested values.
9207 - * (But we don't interrupts yet, or interact w/serial.c)
9209 -static int kgdb_uart_setup(void)
9215 - if (kgdb_portnum >= UART_NPORTS) {
9216 - KGDB_PRINTK("uart port %d invalid.\n", kgdb_portnum);
9220 - kgdb_uart_port = &uart_ports[kgdb_portnum];
9222 - /* Init sequence from gdb_hook_interrupt */
9224 - UART_OUT(UART_IER, 0);
9226 - UART_IN(UART_RX); /* Serial driver comments say */
9227 - UART_IN(UART_IIR); /* this clears interrupt regs */
9228 - UART_IN(UART_MSR);
9230 - /* Figure basic LCR values */
9231 - switch (kgdb_bits) {
9233 - lcr |= UART_LCR_WLEN7;
9235 - default: case '8':
9236 - lcr |= UART_LCR_WLEN8;
9239 - switch (kgdb_parity) {
9241 - lcr |= UART_LCR_PARITY;
9244 - lcr |= (UART_LCR_PARITY | UART_LCR_EPAR);
9249 - /* Figure the baud rate divisor */
9250 - bdiv = (SB_BASE/kgdb_baud);
9252 - /* Set the baud rate and LCR values */
9253 - UART_OUT(UART_LCR, (lcr | UART_LCR_DLAB));
9254 - UART_OUT(UART_DLL, (bdiv & 0xff));
9255 - UART_OUT(UART_DLM, ((bdiv >> 8) & 0xff));
9256 - UART_OUT(UART_LCR, lcr);
9259 - UART_OUT(UART_MCR, SB_MCR);
9261 - /* Turn off FIFOs for now */
9262 - UART_OUT(UART_FCR, 0);
9264 - /* Setup complete: initialize function pointers */
9265 - kgdb_getchar = kgdb_uart_getchar;
9266 - kgdb_putchar = kgdb_uart_putchar;
9270 -#endif /* CONFIG_SH_KGDB */
9271 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/sh/kernel/Makefile linux-2.6.18.kgdb/arch/sh/kernel/Makefile
9272 --- linux-2.6.18/arch/sh/kernel/Makefile 2006-09-20 07:42:06.000000000 +0400
9273 +++ linux-2.6.18.kgdb/arch/sh/kernel/Makefile 2008-06-10 16:19:47.000000000 +0400
9274 @@ -13,7 +13,7 @@ obj-y += cpu/ timers/
9275 obj-$(CONFIG_SMP) += smp.o
9276 obj-$(CONFIG_CF_ENABLER) += cf-enabler.o
9277 obj-$(CONFIG_SH_STANDARD_BIOS) += sh_bios.o
9278 -obj-$(CONFIG_SH_KGDB) += kgdb_stub.o kgdb_jmp.o
9279 +obj-$(CONFIG_KGDB) += kgdb.o kgdb-jmp.o
9280 obj-$(CONFIG_SH_CPU_FREQ) += cpufreq.o
9281 obj-$(CONFIG_MODULES) += module.o
9282 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
9283 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/sh/kernel/cpu/sh3/ex.S linux-2.6.18.kgdb/arch/sh/kernel/cpu/sh3/ex.S
9284 --- linux-2.6.18/arch/sh/kernel/cpu/sh3/ex.S 2006-09-20 07:42:06.000000000 +0400
9285 +++ linux-2.6.18.kgdb/arch/sh/kernel/cpu/sh3/ex.S 2008-06-10 16:19:47.000000000 +0400
9286 @@ -42,7 +42,7 @@ ENTRY(exception_handling_table)
9287 .long exception_error ! reserved_instruction (filled by trap_init) /* 180 */
9288 .long exception_error ! illegal_slot_instruction (filled by trap_init) /*1A0*/
9290 -#if defined (CONFIG_KGDB_NMI)
9291 +#if defined (CONFIG_KGDB)
9292 .long debug_enter /* 1C0 */ ! Allow trap to debugger
9294 .long exception_none /* 1C0 */ ! Not implemented yet
9295 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/sh/kernel/cpu/sh4/ex.S linux-2.6.18.kgdb/arch/sh/kernel/cpu/sh4/ex.S
9296 --- linux-2.6.18/arch/sh/kernel/cpu/sh4/ex.S 2006-09-20 07:42:06.000000000 +0400
9297 +++ linux-2.6.18.kgdb/arch/sh/kernel/cpu/sh4/ex.S 2008-06-10 16:19:47.000000000 +0400
9298 @@ -46,7 +46,7 @@ ENTRY(exception_handling_table)
9299 .long exception_error ! reserved_instruction (filled by trap_init) /* 180 */
9300 .long exception_error ! illegal_slot_instruction (filled by trap_init) /*1A0*/
9302 -#if defined (CONFIG_KGDB_NMI)
9303 +#if defined (CONFIG_KGDB)
9304 .long debug_enter /* 1C0 */ ! Allow trap to debugger
9306 .long exception_none /* 1C0 */ ! Not implemented yet
9307 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/sh/kernel/entry.S linux-2.6.18.kgdb/arch/sh/kernel/entry.S
9308 --- linux-2.6.18/arch/sh/kernel/entry.S 2006-09-20 07:42:06.000000000 +0400
9309 +++ linux-2.6.18.kgdb/arch/sh/kernel/entry.S 2008-06-10 16:19:47.000000000 +0400
9314 -#if defined(CONFIG_KGDB_NMI)
9315 +#if defined(CONFIG_KGDB)
9316 NMI_VEC = 0x1c0 ! Must catch early for debounce
9319 @@ -227,31 +227,33 @@ call_dae:
9320 2: .long do_address_error
9321 #endif /* CONFIG_MMU */
9323 -#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
9324 +#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_KGDB)
9325 ! Handle kernel debug if either kgdb (SW) or gdb-stub (FW) is present.
9326 ! If both are configured, handle the debug traps (breakpoints) in SW,
9327 ! but still allow BIOS traps to FW.
9331 -#if defined(CONFIG_SH_STANDARD_BIOS) && defined(CONFIG_SH_KGDB)
9332 +#if defined(CONFIG_SH_STANDARD_BIOS) && defined(CONFIG_KGDB)
9333 /* Force BIOS call to FW (debug_trap put TRA in r8) */
9338 -#endif /* CONFIG_SH_STANDARD_BIOS && CONFIG_SH_KGDB */
9339 +#endif /* CONFIG_SH_STANDARD_BIOS && CONFIG_KGDB */
9342 -#if defined(CONFIG_SH_KGDB)
9344 + .globl debug_enter
9346 +#if defined(CONFIG_KGDB)
9347 /* Jump to kgdb, pass stacked regs as arg */
9353 -3: .long kgdb_handle_exception
9354 -#endif /* CONFIG_SH_KGDB */
9355 +3: .long kgdb_exception_handler
9356 +#endif /* CONFIG_KGDB */
9358 #if defined(CONFIG_SH_STANDARD_BIOS)
9359 /* Unwind the stack and jmp to the debug entry */
9360 @@ -293,12 +295,12 @@ debug_kernel_fw:
9361 2: .long gdb_vbr_vector
9362 #endif /* CONFIG_SH_STANDARD_BIOS */
9364 -#endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_SH_KGDB */
9365 +#endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_KGDB */
9370 -#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
9372 +#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_KGDB)
9374 mov.l @(r0,r15), r0 ! get status register
9376 @@ -642,7 +644,7 @@ skip_restore:
9377 6: or k0, k2 ! Set the IMASK-bits
9380 -#if defined(CONFIG_KGDB_NMI)
9381 +#if defined(CONFIG_KGDB)
9385 @@ -694,7 +696,7 @@ tlb_miss:
9389 -#if defined(CONFIG_KGDB_NMI)
9390 +#if defined(CONFIG_KGDB)
9391 ! Debounce (filter nested NMI)
9394 @@ -709,7 +711,7 @@ interrupt:
9398 -#endif /* defined(CONFIG_KGDB_NMI) */
9399 +#endif /* defined(CONFIG_KGDB) */
9400 bra handle_exception
9403 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/sh/kernel/kgdb-jmp.S linux-2.6.18.kgdb/arch/sh/kernel/kgdb-jmp.S
9404 --- linux-2.6.18/arch/sh/kernel/kgdb-jmp.S 1970-01-01 03:00:00.000000000 +0300
9405 +++ linux-2.6.18.kgdb/arch/sh/kernel/kgdb-jmp.S 2008-06-10 16:19:47.000000000 +0400
9407 +#include <linux/linkage.h>
9409 +ENTRY(kgdb_fault_setjmp)
9423 +ENTRY(kgdb_fault_longjmp)
9439 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/sh/kernel/kgdb.c linux-2.6.18.kgdb/arch/sh/kernel/kgdb.c
9440 --- linux-2.6.18/arch/sh/kernel/kgdb.c 1970-01-01 03:00:00.000000000 +0300
9441 +++ linux-2.6.18.kgdb/arch/sh/kernel/kgdb.c 2008-06-10 16:19:47.000000000 +0400
9444 + * arch/sh/kernel/kgdb.c
9446 + * Contains SH-specific low-level support for KGDB.
9448 + * Containes extracts from code by Glenn Engel, Jim Kingdon,
9449 + * David Grothe <dave@gcom.com>, Tigran Aivazian <tigran@sco.com>,
9450 + * Amit S. Kale <akale@veritas.com>, William Gatliff <bgat@open-widgets.com>,
9451 + * Ben Lee, Steve Chamberlain and Benoit Miller <fulg@iname.com>,
9452 + * Henry Bell <henry.bell@st.com> and Jeremy Siegel <jsiegel@mvista.com>
9454 + * Maintainer: Tom Rini <trini@kernel.crashing.org>
9456 + * 2004 (c) MontaVista Software, Inc. This file is licensed under
9457 + * the terms of the GNU General Public License version 2. This program
9458 + * is licensed "as is" without any warranty of any kind, whether express
9462 +#include <linux/string.h>
9463 +#include <linux/kernel.h>
9464 +#include <linux/sched.h>
9465 +#include <linux/smp.h>
9466 +#include <linux/spinlock.h>
9467 +#include <linux/delay.h>
9468 +#include <linux/linkage.h>
9469 +#include <linux/init.h>
9470 +#include <linux/kgdb.h>
9472 +#include <asm/system.h>
9473 +#include <asm/current.h>
9474 +#include <asm/signal.h>
9475 +#include <asm/pgtable.h>
9476 +#include <asm/ptrace.h>
9478 +extern void per_cpu_trap_init(void);
9479 +extern atomic_t cpu_doing_single_step;
9481 +/* Function pointers for linkage */
9482 +static struct kgdb_regs trap_registers;
9485 +char in_nmi; /* Set during NMI to prevent reentry */
9487 +/* TRA differs sh3/4 */
9488 +#if defined(CONFIG_CPU_SH3)
9489 +#define TRA 0xffffffd0
9490 +#elif defined(CONFIG_CPU_SH4)
9491 +#define TRA 0xff000020
9494 +/* Macros for single step instruction identification */
9495 +#define OPCODE_BT(op) (((op) & 0xff00) == 0x8900)
9496 +#define OPCODE_BF(op) (((op) & 0xff00) == 0x8b00)
9497 +#define OPCODE_BTF_DISP(op) (((op) & 0x80) ? (((op) | 0xffffff80) << 1) : \
9498 + (((op) & 0x7f ) << 1))
9499 +#define OPCODE_BFS(op) (((op) & 0xff00) == 0x8f00)
9500 +#define OPCODE_BTS(op) (((op) & 0xff00) == 0x8d00)
9501 +#define OPCODE_BRA(op) (((op) & 0xf000) == 0xa000)
9502 +#define OPCODE_BRA_DISP(op) (((op) & 0x800) ? (((op) | 0xfffff800) << 1) : \
9503 + (((op) & 0x7ff) << 1))
9504 +#define OPCODE_BRAF(op) (((op) & 0xf0ff) == 0x0023)
9505 +#define OPCODE_BRAF_REG(op) (((op) & 0x0f00) >> 8)
9506 +#define OPCODE_BSR(op) (((op) & 0xf000) == 0xb000)
9507 +#define OPCODE_BSR_DISP(op) (((op) & 0x800) ? (((op) | 0xfffff800) << 1) : \
9508 + (((op) & 0x7ff) << 1))
9509 +#define OPCODE_BSRF(op) (((op) & 0xf0ff) == 0x0003)
9510 +#define OPCODE_BSRF_REG(op) (((op) >> 8) & 0xf)
9511 +#define OPCODE_JMP(op) (((op) & 0xf0ff) == 0x402b)
9512 +#define OPCODE_JMP_REG(op) (((op) >> 8) & 0xf)
9513 +#define OPCODE_JSR(op) (((op) & 0xf0ff) == 0x400b)
9514 +#define OPCODE_JSR_REG(op) (((op) >> 8) & 0xf)
9515 +#define OPCODE_RTS(op) ((op) == 0xb)
9516 +#define OPCODE_RTE(op) ((op) == 0x2b)
9518 +#define SR_T_BIT_MASK 0x1
9519 +#define STEP_OPCODE 0xc320
9520 +#define BIOS_CALL_TRAP 0x3f
9522 +/* Exception codes as per SH-4 core manual */
9523 +#define ADDRESS_ERROR_LOAD_VEC 7
9524 +#define ADDRESS_ERROR_STORE_VEC 8
9525 +#define TRAP_VEC 11
9526 +#define INVALID_INSN_VEC 12
9527 +#define INVALID_SLOT_VEC 13
9529 +#define SERIAL_BREAK_VEC 58
9532 +static int stepped_address;
9533 +static short stepped_opcode;
9535 +/* Translate SH-3/4 exception numbers to unix-like signal values */
9536 +static int compute_signal(const int excep_code)
9538 + switch (excep_code) {
9539 + case INVALID_INSN_VEC:
9540 + case INVALID_SLOT_VEC:
9542 + case ADDRESS_ERROR_LOAD_VEC:
9543 + case ADDRESS_ERROR_STORE_VEC:
9545 + case SERIAL_BREAK_VEC:
9549 + /* Act like it was a break/trap. */
9555 + * Translate the registers of the system into the format that GDB wants. Since
9556 + * we use a local structure to store things, instead of getting them out
9557 + * of pt_regs, we can just do a memcpy.
9559 +void regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *ign)
9561 + memcpy(gdb_regs, &trap_registers, sizeof(trap_registers));
9565 + * On SH we save: r1 (prev->thread.sp) r2 (prev->thread.pc) r4 (prev) r5 (next)
9566 + * r6 (next->thread.sp) r7 (next->thread.pc)
9568 +void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p)
9572 + for (count = 0; count < 16; count++)
9573 + *(gdb_regs++) = 0;
9574 + *(gdb_regs++) = p->thread.pc;
9575 + *(gdb_regs++) = 0;
9576 + *(gdb_regs++) = 0;
9577 + *(gdb_regs++) = 0;
9578 + *(gdb_regs++) = 0;
9579 + *(gdb_regs++) = 0;
9580 + *(gdb_regs++) = 0;
9584 + * Translate the registers values that GDB has given us back into the
9585 + * format of the system. See the comment above about memcpy.
9587 +void gdb_regs_to_regs(unsigned long *gdb_regs, struct pt_regs *ign)
9589 + memcpy(&trap_registers, gdb_regs, sizeof(trap_registers));
9592 +/* Calculate the new address for after a step */
9593 +static short *get_step_address(void)
9595 + short op = *(short *)trap_registers.pc;
9599 + if (OPCODE_BT(op)) {
9600 + if (trap_registers.sr & SR_T_BIT_MASK)
9601 + addr = trap_registers.pc + 4 + OPCODE_BTF_DISP(op);
9603 + addr = trap_registers.pc + 2;
9607 + else if (OPCODE_BTS(op)) {
9608 + if (trap_registers.sr & SR_T_BIT_MASK)
9609 + addr = trap_registers.pc + 4 + OPCODE_BTF_DISP(op);
9611 + addr = trap_registers.pc + 4; /* Not in delay slot */
9615 + else if (OPCODE_BF(op)) {
9616 + if (!(trap_registers.sr & SR_T_BIT_MASK))
9617 + addr = trap_registers.pc + 4 + OPCODE_BTF_DISP(op);
9619 + addr = trap_registers.pc + 2;
9623 + else if (OPCODE_BFS(op)) {
9624 + if (!(trap_registers.sr & SR_T_BIT_MASK))
9625 + addr = trap_registers.pc + 4 + OPCODE_BTF_DISP(op);
9627 + addr = trap_registers.pc + 4; /* Not in delay slot */
9631 + else if (OPCODE_BRA(op))
9632 + addr = trap_registers.pc + 4 + OPCODE_BRA_DISP(op);
9635 + else if (OPCODE_BRAF(op))
9636 + addr = trap_registers.pc + 4
9637 + + trap_registers.regs[OPCODE_BRAF_REG(op)];
9640 + else if (OPCODE_BSR(op))
9641 + addr = trap_registers.pc + 4 + OPCODE_BSR_DISP(op);
9644 + else if (OPCODE_BSRF(op))
9645 + addr = trap_registers.pc + 4
9646 + + trap_registers.regs[OPCODE_BSRF_REG(op)];
9649 + else if (OPCODE_JMP(op))
9650 + addr = trap_registers.regs[OPCODE_JMP_REG(op)];
9653 + else if (OPCODE_JSR(op))
9654 + addr = trap_registers.regs[OPCODE_JSR_REG(op)];
9657 + else if (OPCODE_RTS(op))
9658 + addr = trap_registers.pr;
9661 + else if (OPCODE_RTE(op))
9662 + addr = trap_registers.regs[15];
9666 + addr = trap_registers.pc + 2;
9668 + kgdb_flush_icache_range(addr, addr + 2);
9669 + return (short *)addr;
9672 +/* The command loop, read and act on requests */
9673 +int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
9674 + char *remcom_in_buffer, char *remcom_out_buffer,
9675 + struct pt_regs *ign)
9677 + unsigned long addr;
9678 + char *ptr = &remcom_in_buffer[1];
9680 + /* Examine first char of buffer to see what we need to do */
9681 + switch (remcom_in_buffer[0]) {
9682 + case 'c': /* Continue at address AA..AA (optional) */
9683 + case 's': /* Step one instruction from AA..AA */
9684 + /* Try to read optional parameter, PC unchanged if none */
9685 + if (kgdb_hex2long(&ptr, &addr))
9686 + trap_registers.pc = addr;
9688 + atomic_set(&cpu_doing_single_step, -1);
9689 + if (remcom_in_buffer[0] == 's') {
9690 + /* Replace the instruction immediately after the
9691 + * current instruction (i.e. next in the expected
9692 + * flow of control) with a trap instruction, so that
9693 + * returning will cause only a single instruction to
9694 + * be executed. Note that this model is slightly
9695 + * broken for instructions with delay slots
9696 + * (e.g. B[TF]S, BSR, BRA etc), where both the branch
9697 + * and the instruction in the delay slot will be
9700 + /* Determine where the target instruction will send
9702 + unsigned short *next_addr = get_step_address();
9703 + stepped_address = (int)next_addr;
9706 + stepped_opcode = *(short *)next_addr;
9707 + *next_addr = STEP_OPCODE;
9709 + /* Flush and return */
9710 + kgdb_flush_icache_range((long)next_addr,
9711 + (long)next_addr + 2);
9712 + if (kgdb_contthread)
9713 + atomic_set(&cpu_doing_single_step,
9714 + smp_processor_id());
9722 + * When an exception has occured, we are called. We need to set things
9723 + * up so that we can call kgdb_handle_exception to handle requests from
9726 +void kgdb_exception_handler(struct pt_regs *regs)
9728 + int excep_code, vbr_val;
9731 + /* Copy kernel regs (from stack) */
9732 + for (count = 0; count < 16; count++)
9733 + trap_registers.regs[count] = regs->regs[count];
9734 + trap_registers.pc = regs->pc;
9735 + trap_registers.pr = regs->pr;
9736 + trap_registers.sr = regs->sr;
9737 + trap_registers.gbr = regs->gbr;
9738 + trap_registers.mach = regs->mach;
9739 + trap_registers.macl = regs->macl;
9741 + __asm__ __volatile__("stc vbr, %0":"=r"(vbr_val));
9742 + trap_registers.vbr = vbr_val;
9744 + /* Get the execption code. */
9745 + __asm__ __volatile__("stc r2_bank, %0":"=r"(excep_code));
9749 + /* If we got an NMI, and KGDB is not yet initialized, call
9750 + * breakpoint() to try and initialize everything for us. */
9751 + if (excep_code == NMI_VEC && !kgdb_initialized) {
9756 + /* TRAP_VEC exception indicates a software trap inserted in place of
9757 + * code by GDB so back up PC by one instruction, as this instruction
9758 + * will later be replaced by its original one. Do NOT do this for
9759 + * trap 0xff, since that indicates a compiled-in breakpoint which
9760 + * will not be replaced (and we would retake the trap forever) */
9761 + if (excep_code == TRAP_VEC &&
9762 + (*(volatile unsigned long *)TRA != (0xff << 2)))
9763 + trap_registers.pc -= 2;
9765 + /* If we have been single-stepping, put back the old instruction.
9766 + * We use stepped_address in case we have stopped more than one
9767 + * instruction away. */
9768 + if (stepped_opcode != 0) {
9769 + *(short *)stepped_address = stepped_opcode;
9770 + kgdb_flush_icache_range(stepped_address, stepped_address + 2);
9772 + stepped_opcode = 0;
9774 + /* Call the stub to do the processing. Note that not everything we
9775 + * need to send back and forth lives in pt_regs. */
9776 + kgdb_handle_exception(excep_code, compute_signal(excep_code), 0, regs);
9778 + /* Copy back the (maybe modified) registers */
9779 + for (count = 0; count < 16; count++)
9780 + regs->regs[count] = trap_registers.regs[count];
9781 + regs->pc = trap_registers.pc;
9782 + regs->pr = trap_registers.pr;
9783 + regs->sr = trap_registers.sr;
9784 + regs->gbr = trap_registers.gbr;
9785 + regs->mach = trap_registers.mach;
9786 + regs->macl = trap_registers.macl;
9788 + vbr_val = trap_registers.vbr;
9789 + __asm__ __volatile__("ldc %0, vbr": :"r"(vbr_val));
9792 +int __init kgdb_arch_init(void)
9794 + per_cpu_trap_init();
9799 +struct kgdb_arch arch_kgdb_ops = {
9800 +#ifdef CONFIG_CPU_LITTLE_ENDIAN
9801 + .gdb_bpt_instr = {0xff, 0xc3},
9803 + .gdb_bpt_instr = {0xc3, 0xff},
9806 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/sh/kernel/kgdb_jmp.S linux-2.6.18.kgdb/arch/sh/kernel/kgdb_jmp.S
9807 --- linux-2.6.18/arch/sh/kernel/kgdb_jmp.S 2006-09-20 07:42:06.000000000 +0400
9808 +++ linux-2.6.18.kgdb/arch/sh/kernel/kgdb_jmp.S 1970-01-01 03:00:00.000000000 +0300
9810 -#include <linux/linkage.h>
9839 - mov #1, r0 ! in case val==0
9843 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/sh/kernel/kgdb_stub.c linux-2.6.18.kgdb/arch/sh/kernel/kgdb_stub.c
9844 --- linux-2.6.18/arch/sh/kernel/kgdb_stub.c 2006-09-20 07:42:06.000000000 +0400
9845 +++ linux-2.6.18.kgdb/arch/sh/kernel/kgdb_stub.c 1970-01-01 03:00:00.000000000 +0300
9848 - * May be copied or modified under the terms of the GNU General Public
9849 - * License. See linux/COPYING for more information.
9851 - * Containes extracts from code by Glenn Engel, Jim Kingdon,
9852 - * David Grothe <dave@gcom.com>, Tigran Aivazian <tigran@sco.com>,
9853 - * Amit S. Kale <akale@veritas.com>, William Gatliff <bgat@open-widgets.com>,
9854 - * Ben Lee, Steve Chamberlain and Benoit Miller <fulg@iname.com>.
9856 - * This version by Henry Bell <henry.bell@st.com>
9857 - * Minor modifications by Jeremy Siegel <jsiegel@mvista.com>
9859 - * Contains low-level support for remote debug using GDB.
9861 - * To enable debugger support, two things need to happen. A call to
9862 - * set_debug_traps() is necessary in order to allow any breakpoints
9863 - * or error conditions to be properly intercepted and reported to gdb.
9864 - * A breakpoint also needs to be generated to begin communication. This
9865 - * is most easily accomplished by a call to breakpoint() which does
9866 - * a trapa if the initialisation phase has been successfully completed.
9868 - * In this case, set_debug_traps() is not used to "take over" exceptions;
9869 - * other kernel code is modified instead to enter the kgdb functions here
9870 - * when appropriate (see entry.S for breakpoint traps and NMI interrupts,
9871 - * see traps.c for kernel error exceptions).
9873 - * The following gdb commands are supported:
9875 - * Command Function Return value
9877 - * g return the value of the CPU registers hex data or ENN
9878 - * G set the value of the CPU registers OK or ENN
9880 - * mAA..AA,LLLL Read LLLL bytes at address AA..AA hex data or ENN
9881 - * MAA..AA,LLLL: Write LLLL bytes at address AA.AA OK or ENN
9882 - * XAA..AA,LLLL: Same, but data is binary (not hex) OK or ENN
9884 - * c Resume at current address SNN ( signal NN)
9885 - * cAA..AA Continue at address AA..AA SNN
9886 - * CNN; Resume at current address with signal SNN
9887 - * CNN;AA..AA Resume at address AA..AA with signal SNN
9889 - * s Step one instruction SNN
9890 - * sAA..AA Step one instruction from AA..AA SNN
9891 - * SNN; Step one instruction with signal SNN
9892 - * SNNAA..AA Step one instruction from AA..AA w/NN SNN
9894 - * k kill (Detach GDB)
9896 - * d Toggle debug flag
9899 - * Hct Set thread t for operations, OK or ENN
9900 - * c = 'c' (step, cont), c = 'g' (other
9903 - * qC Query current thread ID QCpid
9904 - * qfThreadInfo Get list of current threads (first) m<id>
9905 - * qsThreadInfo " " " " " (subsequent)
9906 - * qOffsets Get section offsets Text=x;Data=y;Bss=z
9908 - * TXX Find if thread XX is alive OK or ENN
9909 - * ? What was the last sigval ? SNN (signal NN)
9910 - * O Output to GDB console
9912 - * Remote communication protocol.
9914 - * A debug packet whose contents are <data> is encapsulated for
9915 - * transmission in the form:
9917 - * $ <data> # CSUM1 CSUM2
9919 - * <data> must be ASCII alphanumeric and cannot include characters
9920 - * '$' or '#'. If <data> starts with two characters followed by
9921 - * ':', then the existing stubs interpret this as a sequence number.
9923 - * CSUM1 and CSUM2 are ascii hex representation of an 8-bit
9924 - * checksum of <data>, the most significant nibble is sent first.
9925 - * the hex digits 0-9,a-f are used.
9927 - * Receiver responds with:
9929 - * + - if CSUM is correct and ready for next packet
9930 - * - - if CSUM is incorrect
9932 - * Responses can be run-length encoded to save space. A '*' means that
9933 - * the next character is an ASCII encoding giving a repeat count which
9934 - * stands for that many repititions of the character preceding the '*'.
9935 - * The encoding is n+29, yielding a printable character where n >=3
9936 - * (which is where RLE starts to win). Don't use an n > 126.
9938 - * So "0* " means the same as "0000".
9941 -#include <linux/string.h>
9942 -#include <linux/kernel.h>
9943 -#include <linux/sched.h>
9944 -#include <linux/smp.h>
9945 -#include <linux/spinlock.h>
9946 -#include <linux/delay.h>
9947 -#include <linux/linkage.h>
9948 -#include <linux/init.h>
9950 -#include <asm/system.h>
9951 -#include <asm/current.h>
9952 -#include <asm/signal.h>
9953 -#include <asm/pgtable.h>
9954 -#include <asm/ptrace.h>
9955 -#include <asm/kgdb.h>
9957 -#ifdef CONFIG_SH_KGDB_CONSOLE
9958 -#include <linux/console.h>
9961 -/* Function pointers for linkage */
9962 -kgdb_debug_hook_t *kgdb_debug_hook;
9963 -kgdb_bus_error_hook_t *kgdb_bus_err_hook;
9965 -int (*kgdb_getchar)(void);
9966 -void (*kgdb_putchar)(int);
9968 -static void put_debug_char(int c)
9970 - if (!kgdb_putchar)
9972 - (*kgdb_putchar)(c);
9974 -static int get_debug_char(void)
9976 - if (!kgdb_getchar)
9978 - return (*kgdb_getchar)();
9981 -/* Num chars in in/out bound buffers, register packets need NUMREGBYTES * 2 */
9982 -#define BUFMAX 1024
9983 -#define NUMREGBYTES (MAXREG*4)
9984 -#define OUTBUFMAX (NUMREGBYTES*2+512)
9987 - R0 = 0, R1, R2, R3, R4, R5, R6, R7,
9988 - R8, R9, R10, R11, R12, R13, R14, R15,
9989 - PC, PR, GBR, VBR, MACH, MACL, SR,
9994 -static unsigned int registers[MAXREG];
9995 -struct kgdb_regs trap_registers;
9997 -char kgdb_in_gdb_mode;
9998 -char in_nmi; /* Set during NMI to prevent reentry */
9999 -int kgdb_nofault; /* Boolean to ignore bus errs (i.e. in GDB) */
10000 -int kgdb_enabled = 1; /* Default to enabled, cmdline can disable */
10003 -/* Exposed for user access */
10004 -struct task_struct *kgdb_current;
10005 -unsigned int kgdb_g_imask;
10006 -int kgdb_trapa_val;
10009 -/* Default values for SCI (can override via kernel args in setup.c) */
10010 -#ifndef CONFIG_KGDB_DEFPORT
10011 -#define CONFIG_KGDB_DEFPORT 1
10014 -#ifndef CONFIG_KGDB_DEFBAUD
10015 -#define CONFIG_KGDB_DEFBAUD 115200
10018 -#if defined(CONFIG_KGDB_DEFPARITY_E)
10019 -#define CONFIG_KGDB_DEFPARITY 'E'
10020 -#elif defined(CONFIG_KGDB_DEFPARITY_O)
10021 -#define CONFIG_KGDB_DEFPARITY 'O'
10022 -#else /* CONFIG_KGDB_DEFPARITY_N */
10023 -#define CONFIG_KGDB_DEFPARITY 'N'
10026 -#ifdef CONFIG_KGDB_DEFBITS_7
10027 -#define CONFIG_KGDB_DEFBITS '7'
10028 -#else /* CONFIG_KGDB_DEFBITS_8 */
10029 -#define CONFIG_KGDB_DEFBITS '8'
10032 -/* SCI/UART settings, used in kgdb_console_setup() */
10033 -int kgdb_portnum = CONFIG_KGDB_DEFPORT;
10034 -int kgdb_baud = CONFIG_KGDB_DEFBAUD;
10035 -char kgdb_parity = CONFIG_KGDB_DEFPARITY;
10036 -char kgdb_bits = CONFIG_KGDB_DEFBITS;
10038 -/* Jump buffer for setjmp/longjmp */
10039 -static jmp_buf rem_com_env;
10041 -/* TRA differs sh3/4 */
10042 -#if defined(CONFIG_CPU_SH3)
10043 -#define TRA 0xffffffd0
10044 -#elif defined(CONFIG_CPU_SH4)
10045 -#define TRA 0xff000020
10048 -/* Macros for single step instruction identification */
10049 -#define OPCODE_BT(op) (((op) & 0xff00) == 0x8900)
10050 -#define OPCODE_BF(op) (((op) & 0xff00) == 0x8b00)
10051 -#define OPCODE_BTF_DISP(op) (((op) & 0x80) ? (((op) | 0xffffff80) << 1) : \
10052 - (((op) & 0x7f ) << 1))
10053 -#define OPCODE_BFS(op) (((op) & 0xff00) == 0x8f00)
10054 -#define OPCODE_BTS(op) (((op) & 0xff00) == 0x8d00)
10055 -#define OPCODE_BRA(op) (((op) & 0xf000) == 0xa000)
10056 -#define OPCODE_BRA_DISP(op) (((op) & 0x800) ? (((op) | 0xfffff800) << 1) : \
10057 - (((op) & 0x7ff) << 1))
10058 -#define OPCODE_BRAF(op) (((op) & 0xf0ff) == 0x0023)
10059 -#define OPCODE_BRAF_REG(op) (((op) & 0x0f00) >> 8)
10060 -#define OPCODE_BSR(op) (((op) & 0xf000) == 0xb000)
10061 -#define OPCODE_BSR_DISP(op) (((op) & 0x800) ? (((op) | 0xfffff800) << 1) : \
10062 - (((op) & 0x7ff) << 1))
10063 -#define OPCODE_BSRF(op) (((op) & 0xf0ff) == 0x0003)
10064 -#define OPCODE_BSRF_REG(op) (((op) >> 8) & 0xf)
10065 -#define OPCODE_JMP(op) (((op) & 0xf0ff) == 0x402b)
10066 -#define OPCODE_JMP_REG(op) (((op) >> 8) & 0xf)
10067 -#define OPCODE_JSR(op) (((op) & 0xf0ff) == 0x400b)
10068 -#define OPCODE_JSR_REG(op) (((op) >> 8) & 0xf)
10069 -#define OPCODE_RTS(op) ((op) == 0xb)
10070 -#define OPCODE_RTE(op) ((op) == 0x2b)
10072 -#define SR_T_BIT_MASK 0x1
10073 -#define STEP_OPCODE 0xc320
10074 -#define BIOS_CALL_TRAP 0x3f
10076 -/* Exception codes as per SH-4 core manual */
10077 -#define ADDRESS_ERROR_LOAD_VEC 7
10078 -#define ADDRESS_ERROR_STORE_VEC 8
10079 -#define TRAP_VEC 11
10080 -#define INVALID_INSN_VEC 12
10081 -#define INVALID_SLOT_VEC 13
10082 -#define NMI_VEC 14
10083 -#define USER_BREAK_VEC 15
10084 -#define SERIAL_BREAK_VEC 58
10087 -static int stepped_address;
10088 -static short stepped_opcode;
10089 -static const char hexchars[] = "0123456789abcdef";
10090 -static char in_buffer[BUFMAX];
10091 -static char out_buffer[OUTBUFMAX];
10093 -static void kgdb_to_gdb(const char *s);
10095 -#ifdef CONFIG_KGDB_THREAD
10096 -static struct task_struct *trapped_thread;
10097 -static struct task_struct *current_thread;
10098 -typedef unsigned char threadref[8];
10099 -#define BUF_THREAD_ID_SIZE 16
10102 -/* Return addr as a real volatile address */
10103 -static inline unsigned int ctrl_inl(const unsigned long addr)
10105 - return *(volatile unsigned long *) addr;
10108 -/* Correctly set *addr using volatile */
10109 -static inline void ctrl_outl(const unsigned int b, unsigned long addr)
10111 - *(volatile unsigned long *) addr = b;
10114 -/* Get high hex bits */
10115 -static char highhex(const int x)
10117 - return hexchars[(x >> 4) & 0xf];
10120 -/* Get low hex bits */
10121 -static char lowhex(const int x)
10123 - return hexchars[x & 0xf];
10126 -/* Convert ch to hex */
10127 -static int hex(const char ch)
10129 - if ((ch >= 'a') && (ch <= 'f'))
10130 - return (ch - 'a' + 10);
10131 - if ((ch >= '0') && (ch <= '9'))
10132 - return (ch - '0');
10133 - if ((ch >= 'A') && (ch <= 'F'))
10134 - return (ch - 'A' + 10);
10138 -/* Convert the memory pointed to by mem into hex, placing result in buf.
10139 - Returns a pointer to the last char put in buf (null) */
10140 -static char *mem_to_hex(const char *mem, char *buf, const int count)
10144 - unsigned short s_val;
10145 - unsigned long l_val;
10147 - /* Check for 16 or 32 */
10148 - if (count == 2 && ((long) mem & 1) == 0) {
10149 - s_val = *(unsigned short *) mem;
10150 - mem = (char *) &s_val;
10151 - } else if (count == 4 && ((long) mem & 3) == 0) {
10152 - l_val = *(unsigned long *) mem;
10153 - mem = (char *) &l_val;
10155 - for (i = 0; i < count; i++) {
10157 - *buf++ = highhex(ch);
10158 - *buf++ = lowhex(ch);
10164 -/* Convert the hex array pointed to by buf into binary, to be placed in mem.
10165 - Return a pointer to the character after the last byte written */
10166 -static char *hex_to_mem(const char *buf, char *mem, const int count)
10169 - unsigned char ch;
10171 - for (i = 0; i < count; i++) {
10172 - ch = hex(*buf++) << 4;
10173 - ch = ch + hex(*buf++);
10179 -/* While finding valid hex chars, convert to an integer, then return it */
10180 -static int hex_to_int(char **ptr, int *int_value)
10182 - int num_chars = 0;
10188 - hex_value = hex(**ptr);
10189 - if (hex_value >= 0) {
10190 - *int_value = (*int_value << 4) | hex_value;
10196 - return num_chars;
10199 -/* Copy the binary array pointed to by buf into mem. Fix $, #,
10200 - and 0x7d escaped with 0x7d. Return a pointer to the character
10201 - after the last byte written. */
10202 -static char *ebin_to_mem(const char *buf, char *mem, int count)
10204 - for (; count > 0; count--, buf++) {
10205 - if (*buf == 0x7d)
10206 - *mem++ = *(++buf) ^ 0x20;
10213 -/* Pack a hex byte */
10214 -static char *pack_hex_byte(char *pkt, int byte)
10216 - *pkt++ = hexchars[(byte >> 4) & 0xf];
10217 - *pkt++ = hexchars[(byte & 0xf)];
10221 -#ifdef CONFIG_KGDB_THREAD
10223 -/* Pack a thread ID */
10224 -static char *pack_threadid(char *pkt, threadref * id)
10227 - unsigned char *altid;
10229 - altid = (unsigned char *) id;
10231 - limit = pkt + BUF_THREAD_ID_SIZE;
10232 - while (pkt < limit)
10233 - pkt = pack_hex_byte(pkt, *altid++);
10237 -/* Convert an integer into our threadref */
10238 -static void int_to_threadref(threadref * id, const int value)
10240 - unsigned char *scan = (unsigned char *) id;
10246 - *scan++ = (value >> 24) & 0xff;
10247 - *scan++ = (value >> 16) & 0xff;
10248 - *scan++ = (value >> 8) & 0xff;
10249 - *scan++ = (value & 0xff);
10252 -/* Return a task structure ptr for a particular pid */
10253 -static struct task_struct *get_thread(int pid)
10255 - struct task_struct *thread;
10257 - /* Use PID_MAX w/gdb for pid 0 */
10258 - if (pid == PID_MAX) pid = 0;
10260 - /* First check via PID */
10261 - thread = find_task_by_pid(pid);
10266 - /* Start at the start */
10267 - thread = init_tasks[0];
10269 - /* Walk along the linked list of tasks */
10271 - if (thread->pid == pid)
10273 - thread = thread->next_task;
10274 - } while (thread != init_tasks[0]);
10279 -#endif /* CONFIG_KGDB_THREAD */
10281 -/* Scan for the start char '$', read the packet and check the checksum */
10282 -static void get_packet(char *buffer, int buflen)
10284 - unsigned char checksum;
10285 - unsigned char xmitcsum;
10291 - /* Ignore everything until the start character */
10292 - while ((ch = get_debug_char()) != '$');
10298 - /* Now, read until a # or end of buffer is found */
10299 - while (count < (buflen - 1)) {
10300 - ch = get_debug_char();
10305 - checksum = checksum + ch;
10306 - buffer[count] = ch;
10307 - count = count + 1;
10310 - buffer[count] = 0;
10312 - /* Continue to read checksum following # */
10314 - xmitcsum = hex(get_debug_char()) << 4;
10315 - xmitcsum += hex(get_debug_char());
10318 - if (checksum != xmitcsum)
10319 - put_debug_char('-'); /* Failed checksum */
10321 - /* Ack successful transfer */
10322 - put_debug_char('+');
10324 - /* If a sequence char is present, reply
10325 - the sequence ID */
10326 - if (buffer[2] == ':') {
10327 - put_debug_char(buffer[0]);
10328 - put_debug_char(buffer[1]);
10330 - /* Remove sequence chars from buffer */
10331 - count = strlen(buffer);
10332 - for (i = 3; i <= count; i++)
10333 - buffer[i - 3] = buffer[i];
10338 - while (checksum != xmitcsum); /* Keep trying while we fail */
10341 -/* Send the packet in the buffer with run-length encoding */
10342 -static void put_packet(char *buffer)
10351 - put_debug_char('$');
10354 - /* Continue while we still have chars left */
10356 - /* Check for runs up to 99 chars long */
10357 - for (runlen = 1; runlen < 99; runlen++) {
10358 - if (src[0] != src[runlen])
10362 - if (runlen > 3) {
10363 - /* Got a useful amount, send encoding */
10364 - encode = runlen + ' ' - 4;
10365 - put_debug_char(*src); checksum += *src;
10366 - put_debug_char('*'); checksum += '*';
10367 - put_debug_char(encode); checksum += encode;
10370 - /* Otherwise just send the current char */
10371 - put_debug_char(*src); checksum += *src;
10376 - /* '#' Separator, put high and low components of checksum */
10377 - put_debug_char('#');
10378 - put_debug_char(highhex(checksum));
10379 - put_debug_char(lowhex(checksum));
10381 - while ((get_debug_char()) != '+'); /* While no ack */
10384 -/* A bus error has occurred - perform a longjmp to return execution and
10385 - allow handling of the error */
10386 -static void kgdb_handle_bus_error(void)
10388 - longjmp(rem_com_env, 1);
10391 -/* Translate SH-3/4 exception numbers to unix-like signal values */
10392 -static int compute_signal(const int excep_code)
10396 - switch (excep_code) {
10398 - case INVALID_INSN_VEC:
10399 - case INVALID_SLOT_VEC:
10402 - case ADDRESS_ERROR_LOAD_VEC:
10403 - case ADDRESS_ERROR_STORE_VEC:
10404 - sigval = SIGSEGV;
10407 - case SERIAL_BREAK_VEC:
10412 - case USER_BREAK_VEC:
10414 - sigval = SIGTRAP;
10418 - sigval = SIGBUS; /* "software generated" */
10425 -/* Make a local copy of the registers passed into the handler (bletch) */
10426 -static void kgdb_regs_to_gdb_regs(const struct kgdb_regs *regs,
10429 - gdb_regs[R0] = regs->regs[R0];
10430 - gdb_regs[R1] = regs->regs[R1];
10431 - gdb_regs[R2] = regs->regs[R2];
10432 - gdb_regs[R3] = regs->regs[R3];
10433 - gdb_regs[R4] = regs->regs[R4];
10434 - gdb_regs[R5] = regs->regs[R5];
10435 - gdb_regs[R6] = regs->regs[R6];
10436 - gdb_regs[R7] = regs->regs[R7];
10437 - gdb_regs[R8] = regs->regs[R8];
10438 - gdb_regs[R9] = regs->regs[R9];
10439 - gdb_regs[R10] = regs->regs[R10];
10440 - gdb_regs[R11] = regs->regs[R11];
10441 - gdb_regs[R12] = regs->regs[R12];
10442 - gdb_regs[R13] = regs->regs[R13];
10443 - gdb_regs[R14] = regs->regs[R14];
10444 - gdb_regs[R15] = regs->regs[R15];
10445 - gdb_regs[PC] = regs->pc;
10446 - gdb_regs[PR] = regs->pr;
10447 - gdb_regs[GBR] = regs->gbr;
10448 - gdb_regs[MACH] = regs->mach;
10449 - gdb_regs[MACL] = regs->macl;
10450 - gdb_regs[SR] = regs->sr;
10451 - gdb_regs[VBR] = regs->vbr;
10454 -/* Copy local gdb registers back to kgdb regs, for later copy to kernel */
10455 -static void gdb_regs_to_kgdb_regs(const int *gdb_regs,
10456 - struct kgdb_regs *regs)
10458 - regs->regs[R0] = gdb_regs[R0];
10459 - regs->regs[R1] = gdb_regs[R1];
10460 - regs->regs[R2] = gdb_regs[R2];
10461 - regs->regs[R3] = gdb_regs[R3];
10462 - regs->regs[R4] = gdb_regs[R4];
10463 - regs->regs[R5] = gdb_regs[R5];
10464 - regs->regs[R6] = gdb_regs[R6];
10465 - regs->regs[R7] = gdb_regs[R7];
10466 - regs->regs[R8] = gdb_regs[R8];
10467 - regs->regs[R9] = gdb_regs[R9];
10468 - regs->regs[R10] = gdb_regs[R10];
10469 - regs->regs[R11] = gdb_regs[R11];
10470 - regs->regs[R12] = gdb_regs[R12];
10471 - regs->regs[R13] = gdb_regs[R13];
10472 - regs->regs[R14] = gdb_regs[R14];
10473 - regs->regs[R15] = gdb_regs[R15];
10474 - regs->pc = gdb_regs[PC];
10475 - regs->pr = gdb_regs[PR];
10476 - regs->gbr = gdb_regs[GBR];
10477 - regs->mach = gdb_regs[MACH];
10478 - regs->macl = gdb_regs[MACL];
10479 - regs->sr = gdb_regs[SR];
10480 - regs->vbr = gdb_regs[VBR];
10483 -#ifdef CONFIG_KGDB_THREAD
10484 -/* Make a local copy of registers from the specified thread */
10485 -asmlinkage void ret_from_fork(void);
10486 -static void thread_regs_to_gdb_regs(const struct task_struct *thread,
10492 - /* Initialize to zero */
10493 - for (regno = 0; regno < MAXREG; regno++)
10494 - gdb_regs[regno] = 0;
10496 - /* Just making sure... */
10497 - if (thread == NULL)
10500 - /* A new fork has pt_regs on the stack from a fork() call */
10501 - if (thread->thread.pc == (unsigned long)ret_from_fork) {
10504 - struct pt_regs *kregs;
10505 - kregs = (struct pt_regs*)thread->thread.sp;
10507 - gdb_regs[R0] = kregs->regs[R0];
10508 - gdb_regs[R1] = kregs->regs[R1];
10509 - gdb_regs[R2] = kregs->regs[R2];
10510 - gdb_regs[R3] = kregs->regs[R3];
10511 - gdb_regs[R4] = kregs->regs[R4];
10512 - gdb_regs[R5] = kregs->regs[R5];
10513 - gdb_regs[R6] = kregs->regs[R6];
10514 - gdb_regs[R7] = kregs->regs[R7];
10515 - gdb_regs[R8] = kregs->regs[R8];
10516 - gdb_regs[R9] = kregs->regs[R9];
10517 - gdb_regs[R10] = kregs->regs[R10];
10518 - gdb_regs[R11] = kregs->regs[R11];
10519 - gdb_regs[R12] = kregs->regs[R12];
10520 - gdb_regs[R13] = kregs->regs[R13];
10521 - gdb_regs[R14] = kregs->regs[R14];
10522 - gdb_regs[R15] = kregs->regs[R15];
10523 - gdb_regs[PC] = kregs->pc;
10524 - gdb_regs[PR] = kregs->pr;
10525 - gdb_regs[GBR] = kregs->gbr;
10526 - gdb_regs[MACH] = kregs->mach;
10527 - gdb_regs[MACL] = kregs->macl;
10528 - gdb_regs[SR] = kregs->sr;
10530 - asm("stc vbr, %0":"=r"(vbr_val));
10531 - gdb_regs[VBR] = vbr_val;
10535 - /* Otherwise, we have only some registers from switch_to() */
10536 - tregs = (int *)thread->thread.sp;
10537 - gdb_regs[R15] = (int)tregs;
10538 - gdb_regs[R14] = *tregs++;
10539 - gdb_regs[R13] = *tregs++;
10540 - gdb_regs[R12] = *tregs++;
10541 - gdb_regs[R11] = *tregs++;
10542 - gdb_regs[R10] = *tregs++;
10543 - gdb_regs[R9] = *tregs++;
10544 - gdb_regs[R8] = *tregs++;
10545 - gdb_regs[PR] = *tregs++;
10546 - gdb_regs[GBR] = *tregs++;
10547 - gdb_regs[PC] = thread->thread.pc;
10549 -#endif /* CONFIG_KGDB_THREAD */
10551 -/* Calculate the new address for after a step */
10552 -static short *get_step_address(void)
10554 - short op = *(short *) trap_registers.pc;
10558 - if (OPCODE_BT(op)) {
10559 - if (trap_registers.sr & SR_T_BIT_MASK)
10560 - addr = trap_registers.pc + 4 + OPCODE_BTF_DISP(op);
10562 - addr = trap_registers.pc + 2;
10566 - else if (OPCODE_BTS(op)) {
10567 - if (trap_registers.sr & SR_T_BIT_MASK)
10568 - addr = trap_registers.pc + 4 + OPCODE_BTF_DISP(op);
10570 - addr = trap_registers.pc + 4; /* Not in delay slot */
10574 - else if (OPCODE_BF(op)) {
10575 - if (!(trap_registers.sr & SR_T_BIT_MASK))
10576 - addr = trap_registers.pc + 4 + OPCODE_BTF_DISP(op);
10578 - addr = trap_registers.pc + 2;
10582 - else if (OPCODE_BFS(op)) {
10583 - if (!(trap_registers.sr & SR_T_BIT_MASK))
10584 - addr = trap_registers.pc + 4 + OPCODE_BTF_DISP(op);
10586 - addr = trap_registers.pc + 4; /* Not in delay slot */
10590 - else if (OPCODE_BRA(op))
10591 - addr = trap_registers.pc + 4 + OPCODE_BRA_DISP(op);
10594 - else if (OPCODE_BRAF(op))
10595 - addr = trap_registers.pc + 4
10596 - + trap_registers.regs[OPCODE_BRAF_REG(op)];
10599 - else if (OPCODE_BSR(op))
10600 - addr = trap_registers.pc + 4 + OPCODE_BSR_DISP(op);
10603 - else if (OPCODE_BSRF(op))
10604 - addr = trap_registers.pc + 4
10605 - + trap_registers.regs[OPCODE_BSRF_REG(op)];
10608 - else if (OPCODE_JMP(op))
10609 - addr = trap_registers.regs[OPCODE_JMP_REG(op)];
10612 - else if (OPCODE_JSR(op))
10613 - addr = trap_registers.regs[OPCODE_JSR_REG(op)];
10616 - else if (OPCODE_RTS(op))
10617 - addr = trap_registers.pr;
10620 - else if (OPCODE_RTE(op))
10621 - addr = trap_registers.regs[15];
10625 - addr = trap_registers.pc + 2;
10627 - kgdb_flush_icache_range(addr, addr + 2);
10628 - return (short *) addr;
10631 -/* Set up a single-step. Replace the instruction immediately after the
10632 - current instruction (i.e. next in the expected flow of control) with a
10633 - trap instruction, so that returning will cause only a single instruction
10634 - to be executed. Note that this model is slightly broken for instructions
10635 - with delay slots (e.g. B[TF]S, BSR, BRA etc), where both the branch
10636 - and the instruction in the delay slot will be executed. */
10637 -static void do_single_step(void)
10639 - unsigned short *addr = 0;
10641 - /* Determine where the target instruction will send us to */
10642 - addr = get_step_address();
10643 - stepped_address = (int)addr;
10646 - stepped_opcode = *(short *)addr;
10647 - *addr = STEP_OPCODE;
10649 - /* Flush and return */
10650 - kgdb_flush_icache_range((long) addr, (long) addr + 2);
10654 -/* Undo a single step */
10655 -static void undo_single_step(void)
10657 - /* If we have stepped, put back the old instruction */
10658 - /* Use stepped_address in case we stopped elsewhere */
10659 - if (stepped_opcode != 0) {
10660 - *(short*)stepped_address = stepped_opcode;
10661 - kgdb_flush_icache_range(stepped_address, stepped_address + 2);
10663 - stepped_opcode = 0;
10666 -/* Send a signal message */
10667 -static void send_signal_msg(const int signum)
10669 -#ifndef CONFIG_KGDB_THREAD
10670 - out_buffer[0] = 'S';
10671 - out_buffer[1] = highhex(signum);
10672 - out_buffer[2] = lowhex(signum);
10673 - out_buffer[3] = 0;
10674 - put_packet(out_buffer);
10675 -#else /* CONFIG_KGDB_THREAD */
10678 - char *out = out_buffer;
10679 - const char *tstring = "thread";
10682 - *out++ = highhex(signum);
10683 - *out++ = lowhex(signum);
10685 - while (*tstring) {
10686 - *out++ = *tstring++;
10690 - threadid = trapped_thread->pid;
10691 - if (threadid == 0) threadid = PID_MAX;
10692 - int_to_threadref(&thref, threadid);
10693 - pack_threadid(out, &thref);
10694 - out += BUF_THREAD_ID_SIZE;
10698 - put_packet(out_buffer);
10699 -#endif /* CONFIG_KGDB_THREAD */
10702 -/* Reply that all was well */
10703 -static void send_ok_msg(void)
10705 - strcpy(out_buffer, "OK");
10706 - put_packet(out_buffer);
10709 -/* Reply that an error occurred */
10710 -static void send_err_msg(void)
10712 - strcpy(out_buffer, "E01");
10713 - put_packet(out_buffer);
10716 -/* Empty message indicates unrecognised command */
10717 -static void send_empty_msg(void)
10722 -/* Read memory due to 'm' message */
10723 -static void read_mem_msg(void)
10729 - /* Jmp, disable bus error handler */
10730 - if (setjmp(rem_com_env) == 0) {
10732 - kgdb_nofault = 1;
10734 - /* Walk through, have m<addr>,<length> */
10735 - ptr = &in_buffer[1];
10736 - if (hex_to_int(&ptr, &addr) && (*ptr++ == ','))
10737 - if (hex_to_int(&ptr, &length)) {
10739 - if (length * 2 > OUTBUFMAX)
10740 - length = OUTBUFMAX / 2;
10741 - mem_to_hex((char *) addr, out_buffer, length);
10746 - put_packet(out_buffer);
10750 - /* Restore bus error handler */
10751 - kgdb_nofault = 0;
10754 -/* Write memory due to 'M' or 'X' message */
10755 -static void write_mem_msg(int binary)
10761 - if (setjmp(rem_com_env) == 0) {
10763 - kgdb_nofault = 1;
10765 - /* Walk through, have M<addr>,<length>:<data> */
10766 - ptr = &in_buffer[1];
10767 - if (hex_to_int(&ptr, &addr) && (*ptr++ == ','))
10768 - if (hex_to_int(&ptr, &length) && (*ptr++ == ':')) {
10770 - ebin_to_mem(ptr, (char*)addr, length);
10772 - hex_to_mem(ptr, (char*)addr, length);
10773 - kgdb_flush_icache_range(addr, addr + length);
10782 - /* Restore bus error handler */
10783 - kgdb_nofault = 0;
10786 -/* Continue message */
10787 -static void continue_msg(void)
10789 - /* Try to read optional parameter, PC unchanged if none */
10790 - char *ptr = &in_buffer[1];
10793 - if (hex_to_int(&ptr, &addr))
10794 - trap_registers.pc = addr;
10797 -/* Continue message with signal */
10798 -static void continue_with_sig_msg(void)
10801 - char *ptr = &in_buffer[1];
10804 - /* Report limitation */
10805 - kgdb_to_gdb("Cannot force signal in kgdb, continuing anyway.\n");
10808 - hex_to_int(&ptr, &signal);
10812 - /* Optional address */
10813 - if (hex_to_int(&ptr, &addr))
10814 - trap_registers.pc = addr;
10817 -/* Step message */
10818 -static void step_msg(void)
10821 - do_single_step();
10824 -/* Step message with signal */
10825 -static void step_with_sig_msg(void)
10827 - continue_with_sig_msg();
10828 - do_single_step();
10831 -/* Send register contents */
10832 -static void send_regs_msg(void)
10834 -#ifdef CONFIG_KGDB_THREAD
10835 - if (!current_thread)
10836 - kgdb_regs_to_gdb_regs(&trap_registers, registers);
10838 - thread_regs_to_gdb_regs(current_thread, registers);
10840 - kgdb_regs_to_gdb_regs(&trap_registers, registers);
10843 - mem_to_hex((char *) registers, out_buffer, NUMREGBYTES);
10844 - put_packet(out_buffer);
10847 -/* Set register contents - currently can't set other thread's registers */
10848 -static void set_regs_msg(void)
10850 -#ifdef CONFIG_KGDB_THREAD
10851 - if (!current_thread) {
10853 - kgdb_regs_to_gdb_regs(&trap_registers, registers);
10854 - hex_to_mem(&in_buffer[1], (char *) registers, NUMREGBYTES);
10855 - gdb_regs_to_kgdb_regs(registers, &trap_registers);
10857 -#ifdef CONFIG_KGDB_THREAD
10864 -#ifdef CONFIG_KGDB_THREAD
10866 -/* Set the status for a thread */
10867 -void set_thread_msg(void)
10870 - struct task_struct *thread = NULL;
10873 - switch (in_buffer[1]) {
10875 - /* To select which thread for gG etc messages, i.e. supported */
10878 - ptr = &in_buffer[2];
10879 - hex_to_int(&ptr, &threadid);
10880 - thread = get_thread(threadid);
10882 - /* If we haven't found it */
10888 - /* Set current_thread (or not) */
10889 - if (thread == trapped_thread)
10890 - current_thread = NULL;
10892 - current_thread = thread;
10896 - /* To select which thread for cCsS messages, i.e. unsupported */
10902 - send_empty_msg();
10907 -/* Is a thread alive? */
10908 -static void thread_status_msg(void)
10912 - struct task_struct *thread = NULL;
10914 - ptr = &in_buffer[1];
10915 - hex_to_int(&ptr, &threadid);
10916 - thread = get_thread(threadid);
10922 -/* Send the current thread ID */
10923 -static void thread_id_msg(void)
10928 - out_buffer[0] = 'Q';
10929 - out_buffer[1] = 'C';
10931 - if (current_thread)
10932 - threadid = current_thread->pid;
10933 - else if (trapped_thread)
10934 - threadid = trapped_thread->pid;
10935 - else /* Impossible, but just in case! */
10941 - /* Translate pid 0 to PID_MAX for gdb */
10942 - if (threadid == 0) threadid = PID_MAX;
10944 - int_to_threadref(&thref, threadid);
10945 - pack_threadid(out_buffer + 2, &thref);
10946 - out_buffer[2 + BUF_THREAD_ID_SIZE] = '\0';
10947 - put_packet(out_buffer);
10950 -/* Send thread info */
10951 -static void thread_info_msg(void)
10953 - struct task_struct *thread = NULL;
10958 - /* Start with 'm' */
10959 - out_buffer[0] = 'm';
10960 - pos = &out_buffer[1];
10962 - /* For all possible thread IDs - this will overrun if > 44 threads! */
10963 - /* Start at 1 and include PID_MAX (since GDB won't use pid 0...) */
10964 - for (threadid = 1; threadid <= PID_MAX; threadid++) {
10966 - read_lock(&tasklist_lock);
10967 - thread = get_thread(threadid);
10968 - read_unlock(&tasklist_lock);
10970 - /* If it's a valid thread */
10972 - int_to_threadref(&thref, threadid);
10973 - pack_threadid(pos, &thref);
10974 - pos += BUF_THREAD_ID_SIZE;
10978 - *--pos = 0; /* Lose final comma */
10979 - put_packet(out_buffer);
10983 -/* Return printable info for gdb's 'info threads' command */
10984 -static void thread_extra_info_msg(void)
10987 - struct task_struct *thread = NULL;
10988 - char buffer[20], *ptr;
10991 - /* Extract thread ID */
10992 - ptr = &in_buffer[17];
10993 - hex_to_int(&ptr, &threadid);
10994 - thread = get_thread(threadid);
10996 - /* If we don't recognise it, say so */
10997 - if (thread == NULL)
10998 - strcpy(buffer, "(unknown)");
11000 - strcpy(buffer, thread->comm);
11002 - /* Construct packet */
11003 - for (i = 0, ptr = out_buffer; buffer[i]; i++)
11004 - ptr = pack_hex_byte(ptr, buffer[i]);
11006 - if (thread->thread.pc == (unsigned long)ret_from_fork) {
11007 - strcpy(buffer, "<new fork>");
11008 - for (i = 0; buffer[i]; i++)
11009 - ptr = pack_hex_byte(ptr, buffer[i]);
11013 - put_packet(out_buffer);
11016 -/* Handle all qFooBarBaz messages - have to use an if statement as
11017 - opposed to a switch because q messages can have > 1 char id. */
11018 -static void query_msg(void)
11020 - const char *q_start = &in_buffer[1];
11022 - /* qC = return current thread ID */
11023 - if (strncmp(q_start, "C", 1) == 0)
11026 - /* qfThreadInfo = query all threads (first) */
11027 - else if (strncmp(q_start, "fThreadInfo", 11) == 0)
11028 - thread_info_msg();
11030 - /* qsThreadInfo = query all threads (subsequent). We know we have sent
11031 - them all after the qfThreadInfo message, so there are no to send */
11032 - else if (strncmp(q_start, "sThreadInfo", 11) == 0)
11033 - put_packet("l"); /* el = last */
11035 - /* qThreadExtraInfo = supply printable information per thread */
11036 - else if (strncmp(q_start, "ThreadExtraInfo", 15) == 0)
11037 - thread_extra_info_msg();
11039 - /* Unsupported - empty message as per spec */
11041 - send_empty_msg();
11043 -#endif /* CONFIG_KGDB_THREAD */
11046 - * Bring up the ports..
11048 -static int kgdb_serial_setup(void)
11050 - extern int kgdb_console_setup(struct console *co, char *options);
11051 - struct console dummy;
11053 - kgdb_console_setup(&dummy, 0);
11058 -/* The command loop, read and act on requests */
11059 -static void kgdb_command_loop(const int excep_code, const int trapa_value)
11063 - if (excep_code == NMI_VEC) {
11064 -#ifndef CONFIG_KGDB_NMI
11065 - KGDB_PRINTK("Ignoring unexpected NMI?\n");
11067 -#else /* CONFIG_KGDB_NMI */
11068 - if (!kgdb_enabled) {
11069 - kgdb_enabled = 1;
11072 -#endif /* CONFIG_KGDB_NMI */
11075 - /* Ignore if we're disabled */
11076 - if (!kgdb_enabled)
11079 -#ifdef CONFIG_KGDB_THREAD
11080 - /* Until GDB specifies a thread */
11081 - current_thread = NULL;
11082 - trapped_thread = current;
11085 - /* Enter GDB mode (e.g. after detach) */
11086 - if (!kgdb_in_gdb_mode) {
11087 - /* Do serial setup, notify user, issue preemptive ack */
11088 - kgdb_serial_setup();
11089 - KGDB_PRINTK("Waiting for GDB (on %s%d at %d baud)\n",
11090 - (kgdb_porttype ? kgdb_porttype->name : ""),
11091 - kgdb_portnum, kgdb_baud);
11092 - kgdb_in_gdb_mode = 1;
11093 - put_debug_char('+');
11096 - /* Reply to host that an exception has occurred */
11097 - sigval = compute_signal(excep_code);
11098 - send_signal_msg(sigval);
11100 - /* TRAP_VEC exception indicates a software trap inserted in place of
11101 - code by GDB so back up PC by one instruction, as this instruction
11102 - will later be replaced by its original one. Do NOT do this for
11103 - trap 0xff, since that indicates a compiled-in breakpoint which
11104 - will not be replaced (and we would retake the trap forever) */
11105 - if ((excep_code == TRAP_VEC) && (trapa_value != (0xff << 2))) {
11106 - trap_registers.pc -= 2;
11109 - /* Undo any stepping we may have done */
11110 - undo_single_step();
11114 - out_buffer[0] = 0;
11115 - get_packet(in_buffer, BUFMAX);
11117 - /* Examine first char of buffer to see what we need to do */
11118 - switch (in_buffer[0]) {
11120 - case '?': /* Send which signal we've received */
11121 - send_signal_msg(sigval);
11124 - case 'g': /* Return the values of the CPU registers */
11128 - case 'G': /* Set the value of the CPU registers */
11132 - case 'm': /* Read LLLL bytes address AA..AA */
11136 - case 'M': /* Write LLLL bytes address AA..AA, ret OK */
11137 - write_mem_msg(0); /* 0 = data in hex */
11140 - case 'X': /* Write LLLL bytes esc bin address AA..AA */
11141 - if (kgdb_bits == '8')
11142 - write_mem_msg(1); /* 1 = data in binary */
11144 - send_empty_msg();
11147 - case 'C': /* Continue, signum included, we ignore it */
11148 - continue_with_sig_msg();
11151 - case 'c': /* Continue at address AA..AA (optional) */
11155 - case 'S': /* Step, signum included, we ignore it */
11156 - step_with_sig_msg();
11159 - case 's': /* Step one instruction from AA..AA */
11163 -#ifdef CONFIG_KGDB_THREAD
11165 - case 'H': /* Task related */
11166 - set_thread_msg();
11169 - case 'T': /* Query thread status */
11170 - thread_status_msg();
11173 - case 'q': /* Handle query - currently thread-related */
11178 - case 'k': /* 'Kill the program' with a kernel ? */
11181 - case 'D': /* Detach from program, send reply OK */
11182 - kgdb_in_gdb_mode = 0;
11184 - get_debug_char();
11188 - send_empty_msg();
11194 -/* There has been an exception, most likely a breakpoint. */
11195 -void kgdb_handle_exception(struct pt_regs *regs)
11197 - int excep_code, vbr_val;
11199 - int trapa_value = ctrl_inl(TRA);
11201 - /* Copy kernel regs (from stack) */
11202 - for (count = 0; count < 16; count++)
11203 - trap_registers.regs[count] = regs->regs[count];
11204 - trap_registers.pc = regs->pc;
11205 - trap_registers.pr = regs->pr;
11206 - trap_registers.sr = regs->sr;
11207 - trap_registers.gbr = regs->gbr;
11208 - trap_registers.mach = regs->mach;
11209 - trap_registers.macl = regs->macl;
11211 - asm("stc vbr, %0":"=r"(vbr_val));
11212 - trap_registers.vbr = vbr_val;
11214 - /* Get excode for command loop call, user access */
11215 - asm("stc r2_bank, %0":"=r"(excep_code));
11216 - kgdb_excode = excep_code;
11218 - /* Other interesting environment items for reference */
11219 - asm("stc r6_bank, %0":"=r"(kgdb_g_imask));
11220 - kgdb_current = current;
11221 - kgdb_trapa_val = trapa_value;
11223 - /* Act on the exception */
11224 - kgdb_command_loop(excep_code >> 5, trapa_value);
11226 - kgdb_current = NULL;
11228 - /* Copy back the (maybe modified) registers */
11229 - for (count = 0; count < 16; count++)
11230 - regs->regs[count] = trap_registers.regs[count];
11231 - regs->pc = trap_registers.pc;
11232 - regs->pr = trap_registers.pr;
11233 - regs->sr = trap_registers.sr;
11234 - regs->gbr = trap_registers.gbr;
11235 - regs->mach = trap_registers.mach;
11236 - regs->macl = trap_registers.macl;
11238 - vbr_val = trap_registers.vbr;
11239 - asm("ldc %0, vbr": :"r"(vbr_val));
11244 -/* Trigger a breakpoint by function */
11245 -void breakpoint(void)
11247 - if (!kgdb_enabled) {
11248 - kgdb_enabled = 1;
11254 -/* Initialise the KGDB data structures and serial configuration */
11255 -int kgdb_init(void)
11257 - if (!kgdb_enabled)
11261 - kgdb_nofault = 0;
11262 - stepped_opcode = 0;
11263 - kgdb_in_gdb_mode = 0;
11265 - if (kgdb_serial_setup() != 0) {
11266 - KGDB_PRINTK("serial setup error\n");
11270 - /* Init ptr to exception handler */
11271 - kgdb_debug_hook = kgdb_handle_exception;
11272 - kgdb_bus_err_hook = kgdb_handle_bus_error;
11274 - /* Enter kgdb now if requested, or just report init done */
11276 - kgdb_in_gdb_mode = 1;
11277 - put_debug_char('+');
11282 - KGDB_PRINTK("stub is initialized.\n");
11288 -/* Make function available for "user messages"; console will use it too. */
11290 -char gdbmsgbuf[BUFMAX];
11291 -#define MAXOUT ((BUFMAX-2)/2)
11293 -static void kgdb_msg_write(const char *s, unsigned count)
11300 - gdbmsgbuf[0] = 'O';
11302 - /* Fill and send buffers... */
11303 - while (count > 0) {
11304 - bufptr = gdbmsgbuf + 1;
11306 - /* Calculate how many this time */
11307 - wcount = (count > MAXOUT) ? MAXOUT : count;
11309 - /* Pack in hex chars */
11310 - for (i = 0; i < wcount; i++)
11311 - bufptr = pack_hex_byte(bufptr, s[i]);
11318 - /* Write packet */
11319 - put_packet(gdbmsgbuf);
11323 -static void kgdb_to_gdb(const char *s)
11325 - kgdb_msg_write(s, strlen(s));
11328 -#ifdef CONFIG_SH_KGDB_CONSOLE
11329 -void kgdb_console_write(struct console *co, const char *s, unsigned count)
11331 - /* Bail if we're not talking to GDB */
11332 - if (!kgdb_in_gdb_mode)
11335 - kgdb_msg_write(s, count);
11338 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/sh/kernel/setup.c linux-2.6.18.kgdb/arch/sh/kernel/setup.c
11339 --- linux-2.6.18/arch/sh/kernel/setup.c 2006-09-20 07:42:06.000000000 +0400
11340 +++ linux-2.6.18.kgdb/arch/sh/kernel/setup.c 2008-06-10 16:19:47.000000000 +0400
11342 #include <asm/setup.h>
11343 #include <asm/clock.h>
11345 -#ifdef CONFIG_SH_KGDB
11346 -#include <asm/kgdb.h>
11347 -static int kgdb_parse_options(char *options);
11349 extern void * __rd_start, * __rd_end;
11352 @@ -528,93 +524,3 @@ struct seq_operations cpuinfo_op = {
11353 .show = show_cpuinfo,
11355 #endif /* CONFIG_PROC_FS */
11357 -#ifdef CONFIG_SH_KGDB
11359 - * Parse command-line kgdb options. By default KGDB is enabled,
11360 - * entered on error (or other action) using default serial info.
11361 - * The command-line option can include a serial port specification
11362 - * and an action to override default or configured behavior.
11364 -struct kgdb_sermap kgdb_sci_sermap =
11365 -{ "ttySC", 5, kgdb_sci_setup, NULL };
11367 -struct kgdb_sermap *kgdb_serlist = &kgdb_sci_sermap;
11368 -struct kgdb_sermap *kgdb_porttype = &kgdb_sci_sermap;
11370 -void kgdb_register_sermap(struct kgdb_sermap *map)
11372 - struct kgdb_sermap *last;
11374 - for (last = kgdb_serlist; last->next; last = last->next)
11376 - last->next = map;
11377 - if (!map->namelen) {
11378 - map->namelen = strlen(map->name);
11382 -static int __init kgdb_parse_options(char *options)
11387 - /* Check for port spec (or use default) */
11389 - /* Determine port type and instance */
11390 - if (!memcmp(options, "tty", 3)) {
11391 - struct kgdb_sermap *map = kgdb_serlist;
11393 - while (map && memcmp(options, map->name, map->namelen))
11397 - KGDB_PRINTK("unknown port spec in %s\n", options);
11401 - kgdb_porttype = map;
11402 - kgdb_serial_setup = map->setup_fn;
11403 - kgdb_portnum = options[map->namelen] - '0';
11404 - options += map->namelen + 1;
11406 - options = (*options == ',') ? options+1 : options;
11408 - /* Read optional parameters (baud/parity/bits) */
11409 - baud = simple_strtoul(options, &options, 10);
11411 - kgdb_baud = baud;
11413 - c = toupper(*options);
11414 - if (c == 'E' || c == 'O' || c == 'N') {
11420 - if (c == '7' || c == '8') {
11424 - options = (*options == ',') ? options+1 : options;
11428 - /* Check for action specification */
11429 - if (!memcmp(options, "halt", 4)) {
11432 - } else if (!memcmp(options, "disabled", 8)) {
11433 - kgdb_enabled = 0;
11438 - KGDB_PRINTK("ignored unknown options: %s\n", options);
11443 -__setup("kgdb=", kgdb_parse_options);
11444 -#endif /* CONFIG_SH_KGDB */
11446 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/sh/kernel/time.c linux-2.6.18.kgdb/arch/sh/kernel/time.c
11447 --- linux-2.6.18/arch/sh/kernel/time.c 2006-09-20 07:42:06.000000000 +0400
11448 +++ linux-2.6.18.kgdb/arch/sh/kernel/time.c 2008-06-10 16:19:47.000000000 +0400
11449 @@ -184,12 +184,4 @@ void __init time_init(void)
11451 sys_timer = get_sys_timer();
11452 printk(KERN_INFO "Using %s for system timer\n", sys_timer->name);
11454 -#if defined(CONFIG_SH_KGDB)
11456 - * Set up kgdb as requested. We do it here because the serial
11457 - * init uses the timer vars we just set up for figuring baud.
11462 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/sh/kernel/traps.c linux-2.6.18.kgdb/arch/sh/kernel/traps.c
11463 --- linux-2.6.18/arch/sh/kernel/traps.c 2006-09-20 07:42:06.000000000 +0400
11464 +++ linux-2.6.18.kgdb/arch/sh/kernel/traps.c 2008-06-10 16:19:47.000000000 +0400
11466 #include <linux/spinlock.h>
11467 #include <linux/module.h>
11468 #include <linux/kallsyms.h>
11469 +#include <linux/kgdb.h>
11471 #include <asm/system.h>
11472 #include <asm/uaccess.h>
11474 #include <asm/processor.h>
11475 #include <asm/sections.h>
11477 -#ifdef CONFIG_SH_KGDB
11478 -#include <asm/kgdb.h>
11479 -#define CHK_REMOTE_DEBUG(regs) \
11481 - if ((kgdb_debug_hook != (kgdb_debug_hook_t *) NULL) && (!user_mode(regs))) \
11483 - (*kgdb_debug_hook)(regs); \
11487 -#define CHK_REMOTE_DEBUG(regs)
11488 +#ifndef CONFIG_KGDB
11489 +#define kgdb_handle_exception(t, s, e, r)
11492 #define DO_ERROR(trapnr, signr, str, name, tsk) \
11493 @@ -65,7 +57,7 @@ asmlinkage void do_##name(unsigned long
11494 local_irq_enable(); \
11495 tsk->thread.error_code = error_code; \
11496 tsk->thread.trap_no = trapnr; \
11497 - CHK_REMOTE_DEBUG(®s); \
11498 + kgdb_handle_exception(trapnr, signr, error_code, ®s); \
11499 force_sig(signr, tsk); \
11500 die_if_no_fixup(str,®s,error_code); \
11502 @@ -92,10 +84,12 @@ void die(const char * str, struct pt_reg
11504 static int die_counter;
11506 +#ifdef CONFIG_KGDB
11507 + kgdb_handle_exception(1, SIGTRAP, err, regs);
11510 spin_lock_irq(&die_lock);
11511 printk("%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter);
11512 - CHK_REMOTE_DEBUG(regs);
11514 spin_unlock_irq(&die_lock);
11516 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/sh/mm/extable.c linux-2.6.18.kgdb/arch/sh/mm/extable.c
11517 --- linux-2.6.18/arch/sh/mm/extable.c 2006-09-20 07:42:06.000000000 +0400
11518 +++ linux-2.6.18.kgdb/arch/sh/mm/extable.c 2008-06-10 16:19:47.000000000 +0400
11522 #include <linux/module.h>
11523 +#include <linux/kgdb.h>
11524 #include <asm/uaccess.h>
11526 int fixup_exception(struct pt_regs *regs)
11527 @@ -16,6 +17,12 @@ int fixup_exception(struct pt_regs *regs
11528 regs->pc = fixup->fixup;
11531 +#ifdef CONFIG_KGDB
11532 + if (atomic_read(&debugger_active) && kgdb_may_fault)
11533 + /* Restore our previous state. */
11534 + kgdb_fault_longjmp(kgdb_fault_jmp_regs);
11535 + /* Never reached. */
11540 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/sh/mm/fault-nommu.c linux-2.6.18.kgdb/arch/sh/mm/fault-nommu.c
11541 --- linux-2.6.18/arch/sh/mm/fault-nommu.c 2006-09-20 07:42:06.000000000 +0400
11542 +++ linux-2.6.18.kgdb/arch/sh/mm/fault-nommu.c 2008-06-10 16:19:47.000000000 +0400
11544 #include <asm/mmu_context.h>
11545 #include <asm/cacheflush.h>
11547 -#if defined(CONFIG_SH_KGDB)
11548 -#include <asm/kgdb.h>
11551 extern void die(const char *,struct pt_regs *,long);
11554 @@ -43,11 +39,6 @@ extern void die(const char *,struct pt_r
11555 asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long writeaccess,
11556 unsigned long address)
11558 -#if defined(CONFIG_SH_KGDB)
11559 - if (kgdb_nofault && kgdb_bus_err_hook)
11560 - kgdb_bus_err_hook();
11564 * Oops. The kernel tried to access some bad page. We'll have to
11565 * terminate things with extreme prejudice.
11566 @@ -69,11 +60,6 @@ asmlinkage void do_page_fault(struct pt_
11567 asmlinkage int __do_page_fault(struct pt_regs *regs, unsigned long writeaccess,
11568 unsigned long address)
11570 -#if defined(CONFIG_SH_KGDB)
11571 - if (kgdb_nofault && kgdb_bus_err_hook)
11572 - kgdb_bus_err_hook();
11575 if (address >= TASK_SIZE)
11578 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/sh/mm/fault.c linux-2.6.18.kgdb/arch/sh/mm/fault.c
11579 --- linux-2.6.18/arch/sh/mm/fault.c 2006-09-20 07:42:06.000000000 +0400
11580 +++ linux-2.6.18.kgdb/arch/sh/mm/fault.c 2008-06-10 16:19:47.000000000 +0400
11582 #include <asm/pgalloc.h>
11583 #include <asm/mmu_context.h>
11584 #include <asm/cacheflush.h>
11585 -#include <asm/kgdb.h>
11587 extern void die(const char *,struct pt_regs *,long);
11589 @@ -45,11 +44,6 @@ asmlinkage void do_page_fault(struct pt_
11590 struct vm_area_struct * vma;
11591 unsigned long page;
11593 -#ifdef CONFIG_SH_KGDB
11594 - if (kgdb_nofault && kgdb_bus_err_hook)
11595 - kgdb_bus_err_hook();
11601 @@ -153,6 +147,7 @@ no_context:
11603 die("Oops", regs, writeaccess);
11608 * We ran out of memory, or some other thing happened to us that made
11609 @@ -202,11 +197,6 @@ asmlinkage int __do_page_fault(struct pt
11613 -#ifdef CONFIG_SH_KGDB
11614 - if (kgdb_nofault && kgdb_bus_err_hook)
11615 - kgdb_bus_err_hook();
11618 #ifdef CONFIG_SH_STORE_QUEUES
11619 addrmax = P4SEG_STORE_QUE + 0x04000000;
11621 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/x86_64/Kconfig.debug linux-2.6.18.kgdb/arch/x86_64/Kconfig.debug
11622 --- linux-2.6.18/arch/x86_64/Kconfig.debug 2006-09-20 07:42:06.000000000 +0400
11623 +++ linux-2.6.18.kgdb/arch/x86_64/Kconfig.debug 2008-06-10 16:19:41.000000000 +0400
11624 @@ -55,7 +55,4 @@ config DEBUG_STACK_USAGE
11626 This option will slow down process creation somewhat.
11628 -#config X86_REMOTE_DEBUG
11629 -# bool "kgdb debugging stub"
11632 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/x86_64/kernel/Makefile linux-2.6.18.kgdb/arch/x86_64/kernel/Makefile
11633 --- linux-2.6.18/arch/x86_64/kernel/Makefile 2006-09-20 07:42:06.000000000 +0400
11634 +++ linux-2.6.18.kgdb/arch/x86_64/kernel/Makefile 2008-06-10 16:19:41.000000000 +0400
11635 @@ -33,6 +33,7 @@ obj-$(CONFIG_IOMMU) += pci-gart.o apert
11636 obj-$(CONFIG_CALGARY_IOMMU) += pci-calgary.o tce.o
11637 obj-$(CONFIG_SWIOTLB) += pci-swiotlb.o
11638 obj-$(CONFIG_KPROBES) += kprobes.o
11639 +obj-$(CONFIG_KGDB) += kgdb.o kgdb-jmp.o
11640 obj-$(CONFIG_X86_PM_TIMER) += pmtimer.o
11641 obj-$(CONFIG_X86_VSMP) += vsmp.o
11642 obj-$(CONFIG_K8_NB) += k8.o
11643 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/x86_64/kernel/entry.S linux-2.6.18.kgdb/arch/x86_64/kernel/entry.S
11644 --- linux-2.6.18/arch/x86_64/kernel/entry.S 2006-09-20 07:42:06.000000000 +0400
11645 +++ linux-2.6.18.kgdb/arch/x86_64/kernel/entry.S 2008-06-10 16:19:58.000000000 +0400
11647 #include <asm/hw_irq.h>
11648 #include <asm/page.h>
11649 #include <asm/irqflags.h>
11650 +#include <asm/kgdb.h>
11654 @@ -881,6 +882,7 @@ error_exit:
11658 + CFI_END_FRAME(kernel_thread)
11662 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/x86_64/kernel/kgdb-jmp.S linux-2.6.18.kgdb/arch/x86_64/kernel/kgdb-jmp.S
11663 --- linux-2.6.18/arch/x86_64/kernel/kgdb-jmp.S 1970-01-01 03:00:00.000000000 +0300
11664 +++ linux-2.6.18.kgdb/arch/x86_64/kernel/kgdb-jmp.S 2008-06-10 16:19:41.000000000 +0400
11667 + * arch/x86_64/kernel/kgdb-jmp.S
11669 + * Save and restore system registers so that within a limited frame we
11670 + * may have a fault and "jump back" to a known safe location.
11672 + * Author: Tom Rini <trini@kernel.crashing.org>
11674 + * Cribbed from glibc, which carries the following:
11675 + * Copyright (C) 2001, 2003, 2004 Free Software Foundation, Inc.
11676 + * Copyright (C) 2005 by MontaVista Software.
11678 + * This file is licensed under the terms of the GNU General Public License
11679 + * version 2. This program as licensed "as is" without any warranty of
11680 + * any kind, whether express or implied.
11683 +#include <linux/linkage.h>
11696 +/* This must be called prior to kgdb_fault_longjmp and
11697 + * kgdb_fault_longjmp must not be called outside of the context of the
11698 + * last call to kgdb_fault_setjmp.
11700 +ENTRY(kgdb_fault_setjmp)
11701 + /* Save registers. */
11702 + movq %rbx, (JB_RBX*8)(%rdi)
11703 + movq %rbp, (JB_RBP*8)(%rdi)
11704 + movq %r12, (JB_R12*8)(%rdi)
11705 + movq %r13, (JB_R13*8)(%rdi)
11706 + movq %r14, (JB_R14*8)(%rdi)
11707 + movq %r15, (JB_R15*8)(%rdi)
11708 + leaq 8(%rsp), %rdx /* Save SP as it will be after we return. */
11709 + movq %rdx, (JB_RSP*8)(%rdi)
11710 + movq (%rsp), %rax /* Save PC we are returning to now. */
11711 + movq %rax, (JB_PC*8)(%rdi)
11712 + /* Set return value for setjmp. */
11714 + movq (JB_PC*8)(%rdi),%rdx
11715 + movq (JB_RSP*8)(%rdi),%rsp
11718 +ENTRY(kgdb_fault_longjmp)
11719 + /* Restore registers. */
11720 + movq (JB_RBX*8)(%rdi),%rbx
11721 + movq (JB_RBP*8)(%rdi),%rbp
11722 + movq (JB_R12*8)(%rdi),%r12
11723 + movq (JB_R13*8)(%rdi),%r13
11724 + movq (JB_R14*8)(%rdi),%r14
11725 + movq (JB_R15*8)(%rdi),%r15
11726 + /* Set return value for setjmp. */
11727 + movq (JB_PC*8)(%rdi),%rdx
11728 + movq (JB_RSP*8)(%rdi),%rsp
11731 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/x86_64/kernel/kgdb.c linux-2.6.18.kgdb/arch/x86_64/kernel/kgdb.c
11732 --- linux-2.6.18/arch/x86_64/kernel/kgdb.c 1970-01-01 03:00:00.000000000 +0300
11733 +++ linux-2.6.18.kgdb/arch/x86_64/kernel/kgdb.c 2008-06-10 16:19:41.000000000 +0400
11737 + * This program is free software; you can redistribute it and/or modify it
11738 + * under the terms of the GNU General Public License as published by the
11739 + * Free Software Foundation; either version 2, or (at your option) any
11742 + * This program is distributed in the hope that it will be useful, but
11743 + * WITHOUT ANY WARRANTY; without even the implied warranty of
11744 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11745 + * General Public License for more details.
11750 + * Copyright (C) 2004 Amit S. Kale <amitkale@linsyssoft.com>
11751 + * Copyright (C) 2000-2001 VERITAS Software Corporation.
11752 + * Copyright (C) 2002 Andi Kleen, SuSE Labs
11753 + * Copyright (C) 2004 LinSysSoft Technologies Pvt. Ltd.
11755 +/****************************************************************************
11756 + * Contributor: Lake Stevens Instrument Division$
11757 + * Written by: Glenn Engel $
11758 + * Updated by: Amit Kale<akale@veritas.com>
11759 + * Modified for 386 by Jim Kingdon, Cygnus Support.
11760 + * Origianl kgdb, compatibility with 2.1.xx kernel by
11761 + * David Grothe <dave@gcom.com>
11762 + * Integrated into 2.2.5 kernel by Tigran Aivazian <tigran@sco.com>
11763 + * X86_64 changes from Andi Kleen's patch merged by Jim Houston
11766 +#include <linux/string.h>
11767 +#include <linux/kernel.h>
11768 +#include <linux/sched.h>
11769 +#include <linux/smp.h>
11770 +#include <linux/spinlock.h>
11771 +#include <linux/delay.h>
11772 +#include <asm/system.h>
11773 +#include <asm/ptrace.h> /* for linux pt_regs struct */
11774 +#include <linux/kgdb.h>
11775 +#include <linux/init.h>
11776 +#include <asm/apicdef.h>
11777 +#include <asm/mach_apic.h>
11778 +#include <asm/kdebug.h>
11779 +#include <asm/debugreg.h>
11781 +/* Put the error code here just in case the user cares. */
11782 +int gdb_x86_64errcode;
11783 +/* Likewise, the vector number here (since GDB only gets the signal
11784 + number through the usual means, and that's not very specific). */
11785 +int gdb_x86_64vector = -1;
11787 +extern atomic_t cpu_doing_single_step;
11789 +void regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs)
11791 + gdb_regs[_RAX] = regs->rax;
11792 + gdb_regs[_RBX] = regs->rbx;
11793 + gdb_regs[_RCX] = regs->rcx;
11794 + gdb_regs[_RDX] = regs->rdx;
11795 + gdb_regs[_RSI] = regs->rsi;
11796 + gdb_regs[_RDI] = regs->rdi;
11797 + gdb_regs[_RBP] = regs->rbp;
11798 + gdb_regs[_PS] = regs->eflags;
11799 + gdb_regs[_PC] = regs->rip;
11800 + gdb_regs[_R8] = regs->r8;
11801 + gdb_regs[_R9] = regs->r9;
11802 + gdb_regs[_R10] = regs->r10;
11803 + gdb_regs[_R11] = regs->r11;
11804 + gdb_regs[_R12] = regs->r12;
11805 + gdb_regs[_R13] = regs->r13;
11806 + gdb_regs[_R14] = regs->r14;
11807 + gdb_regs[_R15] = regs->r15;
11808 + gdb_regs[_RSP] = regs->rsp;
11811 +extern void thread_return(void);
11812 +void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p)
11814 + gdb_regs[_RAX] = 0;
11815 + gdb_regs[_RBX] = 0;
11816 + gdb_regs[_RCX] = 0;
11817 + gdb_regs[_RDX] = 0;
11818 + gdb_regs[_RSI] = 0;
11819 + gdb_regs[_RDI] = 0;
11820 + gdb_regs[_RBP] = *(unsigned long *)p->thread.rsp;
11821 + gdb_regs[_PS] = *(unsigned long *)(p->thread.rsp + 8);
11822 + gdb_regs[_PC] = (unsigned long)&thread_return;
11823 + gdb_regs[_R8] = 0;
11824 + gdb_regs[_R9] = 0;
11825 + gdb_regs[_R10] = 0;
11826 + gdb_regs[_R11] = 0;
11827 + gdb_regs[_R12] = 0;
11828 + gdb_regs[_R13] = 0;
11829 + gdb_regs[_R14] = 0;
11830 + gdb_regs[_R15] = 0;
11831 + gdb_regs[_RSP] = p->thread.rsp;
11834 +void gdb_regs_to_regs(unsigned long *gdb_regs, struct pt_regs *regs)
11836 + regs->rax = gdb_regs[_RAX];
11837 + regs->rbx = gdb_regs[_RBX];
11838 + regs->rcx = gdb_regs[_RCX];
11839 + regs->rdx = gdb_regs[_RDX];
11840 + regs->rsi = gdb_regs[_RSI];
11841 + regs->rdi = gdb_regs[_RDI];
11842 + regs->rbp = gdb_regs[_RBP];
11843 + regs->eflags = gdb_regs[_PS];
11844 + regs->rip = gdb_regs[_PC];
11845 + regs->r8 = gdb_regs[_R8];
11846 + regs->r9 = gdb_regs[_R9];
11847 + regs->r10 = gdb_regs[_R10];
11848 + regs->r11 = gdb_regs[_R11];
11849 + regs->r12 = gdb_regs[_R12];
11850 + regs->r13 = gdb_regs[_R13];
11851 + regs->r14 = gdb_regs[_R14];
11852 + regs->r15 = gdb_regs[_R15];
11853 +#if 0 /* can't change these */
11854 + regs->rsp = gdb_regs[_RSP];
11855 + regs->ss = gdb_regs[_SS];
11856 + regs->fs = gdb_regs[_FS];
11857 + regs->gs = gdb_regs[_GS];
11860 +} /* gdb_regs_to_regs */
11862 +struct hw_breakpoint {
11863 + unsigned enabled;
11866 + unsigned long addr;
11867 +} breakinfo[4] = { {
11873 +void kgdb_correct_hw_break(void)
11878 + unsigned long dr7;
11880 + asm volatile ("movq %%db7, %0\n":"=r" (dr7):);
11882 + unsigned long addr0, addr1, addr2, addr3;
11883 + asm volatile ("movq %%db0, %0\n"
11884 + "movq %%db1, %1\n"
11885 + "movq %%db2, %2\n"
11886 + "movq %%db3, %3\n":"=r" (addr0), "=r"(addr1),
11887 + "=r"(addr2), "=r"(addr3):);
11890 + for (breakno = 0; breakno < 3; breakno++) {
11891 + breakbit = 2 << (breakno << 1);
11892 + if (!(dr7 & breakbit) && breakinfo[breakno].enabled) {
11895 + dr7 &= ~(0xf0000 << (breakno << 2));
11896 + dr7 |= (((breakinfo[breakno].len << 2) |
11897 + breakinfo[breakno].type) << 16) <<
11899 + switch (breakno) {
11901 + asm volatile ("movq %0, %%dr0\n"::"r"
11902 + (breakinfo[breakno].addr));
11906 + asm volatile ("movq %0, %%dr1\n"::"r"
11907 + (breakinfo[breakno].addr));
11911 + asm volatile ("movq %0, %%dr2\n"::"r"
11912 + (breakinfo[breakno].addr));
11916 + asm volatile ("movq %0, %%dr3\n"::"r"
11917 + (breakinfo[breakno].addr));
11920 + } else if ((dr7 & breakbit) && !breakinfo[breakno].enabled) {
11922 + dr7 &= ~breakbit;
11923 + dr7 &= ~(0xf0000 << (breakno << 2));
11927 + asm volatile ("movq %0, %%db7\n"::"r" (dr7));
11931 +int kgdb_remove_hw_break(unsigned long addr)
11934 + for (i = 0; i < 4; i++) {
11935 + if (breakinfo[i].addr == addr && breakinfo[i].enabled) {
11943 + breakinfo[idx].enabled = 0;
11947 +int kgdb_set_hw_break(unsigned long addr)
11950 + for (i = 0; i < 4; i++) {
11951 + if (!breakinfo[i].enabled) {
11959 + breakinfo[idx].enabled = 1;
11960 + breakinfo[idx].type = 1;
11961 + breakinfo[idx].len = 1;
11962 + breakinfo[idx].addr = addr;
11966 +int remove_hw_break(unsigned breakno)
11968 + if (!breakinfo[breakno].enabled) {
11971 + breakinfo[breakno].enabled = 0;
11975 +int set_hw_break(unsigned breakno, unsigned type, unsigned len, unsigned addr)
11977 + if (breakinfo[breakno].enabled) {
11980 + breakinfo[breakno].enabled = 1;
11981 + breakinfo[breakno].type = type;
11982 + breakinfo[breakno].len = len;
11983 + breakinfo[breakno].addr = addr;
11987 +void kgdb_disable_hw_debug(struct pt_regs *regs)
11989 + /* Disable hardware debugging while we are in kgdb */
11990 + asm volatile ("movq %0,%%db7": /* no output */ :"r" (0UL));
11993 +void kgdb_post_master_code(struct pt_regs *regs, int e_vector, int err_code)
11995 + /* Master processor is completely in the debugger */
11996 + gdb_x86_64vector = e_vector;
11997 + gdb_x86_64errcode = err_code;
12000 +void kgdb_roundup_cpus(unsigned long flags)
12002 + send_IPI_allbutself(APIC_DM_NMI);
12005 +int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
12006 + char *remcomInBuffer, char *remcomOutBuffer,
12007 + struct pt_regs *linux_regs)
12009 + unsigned long addr, length;
12010 + unsigned long breakno, breaktype;
12013 + unsigned long dr6;
12015 + switch (remcomInBuffer[0]) {
12018 + /* try to read optional parameter, pc unchanged if no parm */
12019 + ptr = &remcomInBuffer[1];
12020 + if (kgdb_hex2long(&ptr, &addr))
12021 + linux_regs->rip = addr;
12022 + newPC = linux_regs->rip;
12024 + /* clear the trace bit */
12025 + linux_regs->eflags &= ~TF_MASK;
12027 + atomic_set(&cpu_doing_single_step, -1);
12028 + /* set the trace bit if we're stepping */
12029 + if (remcomInBuffer[0] == 's') {
12030 + linux_regs->eflags |= TF_MASK;
12031 + debugger_step = 1;
12032 + if (kgdb_contthread)
12033 + atomic_set(&cpu_doing_single_step,
12034 + smp_processor_id());
12038 + asm volatile ("movq %%db6, %0\n":"=r" (dr6));
12039 + if (!(dr6 & 0x4000)) {
12040 + for (breakno = 0; breakno < 4; ++breakno) {
12041 + if (dr6 & (1 << breakno)) {
12042 + if (breakinfo[breakno].type == 0) {
12043 + /* Set restore flag */
12044 + linux_regs->eflags |=
12051 + kgdb_correct_hw_break();
12052 + asm volatile ("movq %0, %%db6\n"::"r" (0UL));
12057 + ptr = &remcomInBuffer[1];
12058 + kgdb_hex2long(&ptr, &breakno);
12060 + kgdb_hex2long(&ptr, &breaktype);
12062 + kgdb_hex2long(&ptr, &length);
12064 + kgdb_hex2long(&ptr, &addr);
12065 + if (set_hw_break(breakno & 0x3, breaktype & 0x3,
12066 + length & 0x3, addr) == 0)
12067 + strcpy(remcomOutBuffer, "OK");
12069 + strcpy(remcomOutBuffer, "ERROR");
12072 + /* Remove hardware breakpoint */
12074 + ptr = &remcomInBuffer[1];
12075 + kgdb_hex2long(&ptr, &breakno);
12076 + if (remove_hw_break(breakno & 0x3) == 0)
12077 + strcpy(remcomOutBuffer, "OK");
12079 + strcpy(remcomOutBuffer, "ERROR");
12086 +static struct pt_regs *in_interrupt_stack(unsigned long rsp, int cpu)
12088 + struct pt_regs *regs;
12089 + unsigned long end = (unsigned long)cpu_pda(cpu)->irqstackptr;
12090 + if (rsp <= end && rsp >= end - IRQSTACKSIZE + 8) {
12091 + regs = *(((struct pt_regs **)end) - 1);
12097 +static struct pt_regs *in_exception_stack(unsigned long rsp, int cpu)
12100 + struct tss_struct *init_tss = &__get_cpu_var(init_tss);
12101 + for (i = 0; i < N_EXCEPTION_STACKS; i++)
12102 + if (rsp >= init_tss[cpu].ist[i] &&
12103 + rsp <= init_tss[cpu].ist[i] + EXCEPTION_STKSZ) {
12104 + struct pt_regs *r =
12105 + (void *)init_tss[cpu].ist[i] + EXCEPTION_STKSZ;
12111 +void kgdb_shadowinfo(struct pt_regs *regs, char *buffer, unsigned threadid)
12113 + static char intr_desc[] = "Stack at interrupt entrypoint";
12114 + static char exc_desc[] = "Stack at exception entrypoint";
12115 + struct pt_regs *stregs;
12116 + int cpu = hard_smp_processor_id();
12118 + if ((stregs = in_interrupt_stack(regs->rsp, cpu)))
12119 + kgdb_mem2hex(intr_desc, buffer, strlen(intr_desc));
12120 + else if ((stregs = in_exception_stack(regs->rsp, cpu)))
12121 + kgdb_mem2hex(exc_desc, buffer, strlen(exc_desc));
12124 +struct task_struct *kgdb_get_shadow_thread(struct pt_regs *regs, int threadid)
12126 + struct pt_regs *stregs;
12127 + int cpu = hard_smp_processor_id();
12129 + if ((stregs = in_interrupt_stack(regs->rsp, cpu)))
12131 + else if ((stregs = in_exception_stack(regs->rsp, cpu)))
12137 +struct pt_regs *kgdb_shadow_regs(struct pt_regs *regs, int threadid)
12139 + struct pt_regs *stregs;
12140 + int cpu = hard_smp_processor_id();
12142 + if ((stregs = in_interrupt_stack(regs->rsp, cpu)))
12144 + else if ((stregs = in_exception_stack(regs->rsp, cpu)))
12150 +/* Register KGDB with the die_chain so that we hook into all of the right
12152 +static int kgdb_notify(struct notifier_block *self, unsigned long cmd,
12155 + struct die_args *args = ptr;
12156 + struct pt_regs *regs = args->regs;
12158 + if (cmd == DIE_PAGE_FAULT_NO_CONTEXT && atomic_read(&debugger_active)
12159 + && kgdb_may_fault) {
12160 + kgdb_fault_longjmp(kgdb_fault_jmp_regs);
12161 + return NOTIFY_STOP;
12162 + /* CPU roundup? */
12163 + } else if (atomic_read(&debugger_active) && cmd == DIE_NMI_IPI) {
12164 + kgdb_nmihook(smp_processor_id(), regs);
12165 + return NOTIFY_STOP;
12166 + /* See if KGDB is interested. */
12167 + } else if (cmd == DIE_PAGE_FAULT || user_mode(regs) ||
12168 + cmd == DIE_NMI_IPI || (cmd == DIE_DEBUG &&
12169 + atomic_read(&debugger_active)))
12170 + /* Userpace events, normal watchdog event, or spurious
12171 + * debug exception. Ignore. */
12172 + return NOTIFY_DONE;
12174 + kgdb_handle_exception(args->trapnr, args->signr, args->err, regs);
12176 + return NOTIFY_STOP;
12179 +static struct notifier_block kgdb_notifier = {
12180 + .notifier_call = kgdb_notify,
12181 + .priority = 0x7fffffff, /* we need to notified first */
12184 +int kgdb_arch_init(void)
12186 + atomic_notifier_chain_register(&die_chain, &kgdb_notifier);
12190 + * Skip an int3 exception when it occurs after a breakpoint has been
12191 + * removed. Backtrack eip by 1 since the int3 would have caused it to
12192 + * increment by 1.
12195 +int kgdb_skipexception(int exception, struct pt_regs *regs)
12197 + if (exception == 3 && kgdb_isremovedbreak(regs->rip - 1)) {
12204 +struct kgdb_arch arch_kgdb_ops = {
12205 + .gdb_bpt_instr = {0xcc},
12206 + .flags = KGDB_HW_BREAKPOINT,
12209 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/arch/x86_64/mm/fault.c linux-2.6.18.kgdb/arch/x86_64/mm/fault.c
12210 --- linux-2.6.18/arch/x86_64/mm/fault.c 2006-09-20 07:42:06.000000000 +0400
12211 +++ linux-2.6.18.kgdb/arch/x86_64/mm/fault.c 2008-06-10 16:19:36.000000000 +0400
12212 @@ -557,6 +557,10 @@ no_context:
12213 if (is_errata93(regs, address))
12216 + if (notify_die(DIE_PAGE_FAULT_NO_CONTEXT, "no context", regs,
12217 + error_code, 14, SIGSEGV) == NOTIFY_STOP)
12221 * Oops. The kernel tried to access some bad page. We'll have to
12222 * terminate things with extreme prejudice.
12223 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/drivers/char/keyboard.c linux-2.6.18.kgdb/drivers/char/keyboard.c
12224 --- linux-2.6.18/drivers/char/keyboard.c 2006-09-20 07:42:06.000000000 +0400
12225 +++ linux-2.6.18.kgdb/drivers/char/keyboard.c 2008-06-10 16:20:02.000000000 +0400
12226 @@ -1174,6 +1174,7 @@ static void kbd_keycode(unsigned int key
12228 if (sysrq_down && down && !rep) {
12229 handle_sysrq(kbd_sysrq_xlate[keycode], regs, tty);
12230 + sysrq_down = 0; /* In case we miss the 'up' event. */
12234 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/drivers/net/Makefile linux-2.6.18.kgdb/drivers/net/Makefile
12235 --- linux-2.6.18/drivers/net/Makefile 2006-09-20 07:42:06.000000000 +0400
12236 +++ linux-2.6.18.kgdb/drivers/net/Makefile 2008-06-10 16:19:13.000000000 +0400
12237 @@ -216,6 +216,7 @@ obj-$(CONFIG_ETRAX_ETHERNET) += cris/
12238 obj-$(CONFIG_ENP2611_MSF_NET) += ixp2000/
12240 obj-$(CONFIG_NETCONSOLE) += netconsole.o
12241 +obj-$(CONFIG_KGDBOE) += kgdboe.o
12243 obj-$(CONFIG_FS_ENET) += fs_enet/
12245 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/drivers/net/kgdboe.c linux-2.6.18.kgdb/drivers/net/kgdboe.c
12246 --- linux-2.6.18/drivers/net/kgdboe.c 1970-01-01 03:00:00.000000000 +0300
12247 +++ linux-2.6.18.kgdb/drivers/net/kgdboe.c 2008-06-10 16:19:13.000000000 +0400
12250 + * drivers/net/kgdboe.c
12252 + * A network interface for GDB.
12253 + * Based upon 'gdbserial' by David Grothe <dave@gcom.com>
12254 + * and Scott Foehner <sfoehner@engr.sgi.com>
12256 + * Maintainers: Amit S. Kale <amitkale@linsyssoft.com> and
12257 + * Tom Rini <trini@kernel.crashing.org>
12259 + * 2004 (c) Amit S. Kale <amitkale@linsyssoft.com>
12260 + * 2004-2005 (c) MontaVista Software, Inc.
12261 + * 2005 (c) Wind River Systems, Inc.
12263 + * Contributors at various stages not listed above:
12264 + * San Mehat <nettwerk@biodome.org>, Robert Walsh <rjwalsh@durables.org>,
12265 + * wangdi <wangdi@clusterfs.com>, Matt Mackall <mpm@selenic.com>,
12266 + * Pavel Machek <pavel@suse.cz>, Jason Wessel <jason.wessel@windriver.com>
12268 + * This file is licensed under the terms of the GNU General Public License
12269 + * version 2. This program is licensed "as is" without any warranty of any
12270 + * kind, whether express or implied.
12273 +#include <linux/kernel.h>
12274 +#include <linux/interrupt.h>
12275 +#include <linux/string.h>
12276 +#include <linux/kgdb.h>
12277 +#include <linux/netpoll.h>
12278 +#include <linux/init.h>
12280 +#include <asm/atomic.h>
12282 +#define IN_BUF_SIZE 512 /* power of 2, please */
12283 +#define NOT_CONFIGURED_STRING "not_configured"
12284 +#define OUT_BUF_SIZE 30 /* We don't want to send too big of a packet. */
12285 +#define MAX_KGDBOE_CONFIG_STR 256
12287 +static char in_buf[IN_BUF_SIZE], out_buf[OUT_BUF_SIZE];
12288 +static int in_head, in_tail, out_count;
12289 +static atomic_t in_count;
12290 +/* 0 = unconfigured, 1 = netpoll options parsed, 2 = fully configured. */
12291 +static int configured;
12292 +static struct kgdb_io local_kgdb_io_ops;
12293 +static int use_dynamic_mac;
12295 +MODULE_DESCRIPTION("KGDB driver for network interfaces");
12296 +MODULE_LICENSE("GPL");
12297 +static char config[MAX_KGDBOE_CONFIG_STR] = NOT_CONFIGURED_STRING;
12298 +static struct kparam_string kps = {
12299 + .string = config,
12300 + .maxlen = MAX_KGDBOE_CONFIG_STR,
12303 +static void rx_hook(struct netpoll *np, int port, char *msg, int len,
12304 + struct sk_buff *skb)
12308 + np->remote_port = port;
12310 + /* Copy the MAC address if we need to. */
12311 + if (use_dynamic_mac) {
12312 + memcpy(np->remote_mac, eth_hdr(skb)->h_source,
12313 + sizeof(np->remote_mac));
12314 + use_dynamic_mac = 0;
12318 + * This could be GDB trying to attach. But it could also be GDB
12319 + * finishing up a session, with kgdb_connected=0 but GDB sending
12320 + * an ACK for the final packet. To make sure we don't try and
12321 + * make a breakpoint when GDB is leaving, make sure that if
12322 + * !kgdb_connected the only len == 1 packet we allow is ^C.
12324 + if (!kgdb_connected && (len != 1 || msg[0] == 3) &&
12325 + !atomic_read(&kgdb_setting_breakpoint)) {
12326 + tasklet_schedule(&kgdb_tasklet_breakpoint);
12329 + for (i = 0; i < len; i++) {
12331 + tasklet_schedule(&kgdb_tasklet_breakpoint);
12333 + if (atomic_read(&in_count) >= IN_BUF_SIZE) {
12334 + /* buffer overflow, clear it */
12335 + in_head = in_tail = 0;
12336 + atomic_set(&in_count, 0);
12339 + in_buf[in_head++] = msg[i];
12340 + in_head &= (IN_BUF_SIZE - 1);
12341 + atomic_inc(&in_count);
12345 +static struct netpoll np = {
12346 + .dev_name = "eth0",
12347 + .name = "kgdboe",
12348 + .rx_hook = rx_hook,
12349 + .local_port = 6443,
12350 + .remote_port = 6442,
12351 + .remote_mac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
12354 +static void eth_pre_exception_handler(void)
12356 + /* Increment the module count when the debugger is active */
12357 + if (!kgdb_connected)
12358 + try_module_get(THIS_MODULE);
12359 + netpoll_set_trap(1);
12362 +static void eth_post_exception_handler(void)
12364 + /* decrement the module count when the debugger detaches */
12365 + if (!kgdb_connected)
12366 + module_put(THIS_MODULE);
12367 + netpoll_set_trap(0);
12370 +static int eth_get_char(void)
12374 + while (atomic_read(&in_count) == 0)
12375 + netpoll_poll(&np);
12377 + chr = in_buf[in_tail++];
12378 + in_tail &= (IN_BUF_SIZE - 1);
12379 + atomic_dec(&in_count);
12383 +static void eth_flush_buf(void)
12385 + if (out_count && np.dev) {
12386 + netpoll_send_udp(&np, out_buf, out_count);
12387 + memset(out_buf, 0, sizeof(out_buf));
12392 +static void eth_put_char(u8 chr)
12394 + out_buf[out_count++] = chr;
12395 + if (out_count == OUT_BUF_SIZE)
12399 +static int option_setup(char *opt)
12401 + char opt_scratch[MAX_KGDBOE_CONFIG_STR];
12403 + /* If we're being given a new configuration, copy it in. */
12404 + if (opt != config)
12405 + strcpy(config, opt);
12406 + /* But work on a copy as netpoll_parse_options will eat it. */
12407 + strcpy(opt_scratch, opt);
12408 + configured = !netpoll_parse_options(&np, opt_scratch);
12410 + use_dynamic_mac = 1;
12414 +__setup("kgdboe=", option_setup);
12416 +/* With our config string set by some means, configure kgdboe. */
12417 +static int configure_kgdboe(void)
12419 + /* Try out the string. */
12420 + option_setup(config);
12422 + if (!configured) {
12423 + printk(KERN_ERR "kgdboe: configuration incorrect - kgdboe not "
12425 + printk(KERN_ERR " Usage: kgdboe=[src-port]@[src-ip]/[dev],"
12426 + "[tgt-port]@<tgt-ip>/<tgt-macaddr>\n");
12430 + /* Bring it up. */
12431 + if (netpoll_setup(&np)) {
12432 + printk(KERN_ERR "kgdboe: netpoll_setup failed kgdboe failed\n");
12436 + if (kgdb_register_io_module(&local_kgdb_io_ops)) {
12437 + netpoll_cleanup(&np);
12446 +static int init_kgdboe(void)
12450 + /* Already done? */
12451 + if (configured == 2)
12454 + /* OK, go ahead and do it. */
12455 + ret = configure_kgdboe();
12457 + if (configured == 2)
12458 + printk(KERN_INFO "kgdboe: debugging over ethernet enabled\n");
12463 +static void cleanup_kgdboe(void)
12465 + netpoll_cleanup(&np);
12467 + kgdb_unregister_io_module(&local_kgdb_io_ops);
12470 +static int param_set_kgdboe_var(const char *kmessage, struct kernel_param *kp)
12472 + char kmessage_save[MAX_KGDBOE_CONFIG_STR];
12473 + int msg_len = strlen(kmessage);
12475 + if (msg_len + 1 > MAX_KGDBOE_CONFIG_STR) {
12476 + printk(KERN_ERR "%s: string doesn't fit in %u chars.\n",
12477 + kp->name, MAX_KGDBOE_CONFIG_STR - 1);
12481 + if (kgdb_connected) {
12482 + printk(KERN_ERR "kgdboe: Cannot reconfigure while KGDB is "
12487 + /* Start the reconfiguration process by saving the old string */
12488 + strncpy(kmessage_save, config, sizeof(kmessage_save));
12491 + /* Copy in the new param and strip out invalid characters so we
12492 + * can optionally specify the MAC.
12494 + strncpy(config, kmessage, sizeof(config));
12496 + while (msg_len > 0 &&
12497 + (config[msg_len] < ',' || config[msg_len] > 'f')) {
12498 + config[msg_len] = '\0';
12502 + /* Check to see if we are unconfiguring the io module and that it
12503 + * was in a fully configured state, as this is the only time that
12504 + * netpoll_cleanup should get called
12506 + if (configured == 2 && strcmp(config, NOT_CONFIGURED_STRING) == 0) {
12507 + printk(KERN_INFO "kgdboe: reverting to unconfigured state\n");
12508 + cleanup_kgdboe();
12511 + /* Go and configure with the new params. */
12512 + configure_kgdboe();
12514 + if (configured == 2)
12517 + /* If the new string was invalid, revert to the previous state, which
12518 + * is at a minimum not_configured. */
12519 + strncpy(config, kmessage_save, sizeof(config));
12520 + if (strcmp(kmessage_save, NOT_CONFIGURED_STRING) != 0) {
12521 + printk(KERN_INFO "kgdboe: reverting to prior configuration\n");
12522 + /* revert back to the original config */
12523 + strncpy(config, kmessage_save, sizeof(config));
12524 + configure_kgdboe();
12529 +static struct kgdb_io local_kgdb_io_ops = {
12530 + .read_char = eth_get_char,
12531 + .write_char = eth_put_char,
12532 + .init = init_kgdboe,
12533 + .flush = eth_flush_buf,
12534 + .pre_exception = eth_pre_exception_handler,
12535 + .post_exception = eth_post_exception_handler
12538 +module_init(init_kgdboe);
12539 +module_exit(cleanup_kgdboe);
12540 +module_param_call(kgdboe, param_set_kgdboe_var, param_get_string, &kps, 0644);
12541 +MODULE_PARM_DESC(kgdboe, " kgdboe=[src-port]@[src-ip]/[dev],"
12542 + "[tgt-port]@<tgt-ip>/<tgt-macaddr>\n");
12543 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/drivers/serial/8250.c linux-2.6.18.kgdb/drivers/serial/8250.c
12544 --- linux-2.6.18/drivers/serial/8250.c 2006-09-20 07:42:06.000000000 +0400
12545 +++ linux-2.6.18.kgdb/drivers/serial/8250.c 2008-06-10 16:19:03.000000000 +0400
12546 @@ -2628,6 +2628,25 @@ void serial8250_unregister_port(int line
12548 EXPORT_SYMBOL(serial8250_unregister_port);
12551 + * serial8250_unregister_by_port - remove a 16x50 serial port
12553 + * @port: A &struct uart_port that describes the port to remove.
12555 + * Remove one serial port. This may not be called from interrupt
12556 + * context. We hand the port back to the our control.
12558 +void serial8250_unregister_by_port(struct uart_port *port)
12560 + struct uart_8250_port *uart;
12562 + uart = serial8250_find_match_or_unused(port);
12565 + serial8250_unregister_port(uart->port.line);
12567 +EXPORT_SYMBOL(serial8250_unregister_by_port);
12569 static int __init serial8250_init(void)
12572 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/drivers/serial/8250_kgdb.c linux-2.6.18.kgdb/drivers/serial/8250_kgdb.c
12573 --- linux-2.6.18/drivers/serial/8250_kgdb.c 1970-01-01 03:00:00.000000000 +0300
12574 +++ linux-2.6.18.kgdb/drivers/serial/8250_kgdb.c 2008-06-10 16:19:03.000000000 +0400
12577 + * 8250 interface for kgdb.
12579 + * This is a merging of many different drivers, and all of the people have
12580 + * had an impact in some form or another:
12582 + * 2004-2005 (c) MontaVista Software, Inc.
12583 + * 2005-2006 (c) Wind River Systems, Inc.
12585 + * Amit Kale <amitkale@emsyssoft.com>, David Grothe <dave@gcom.com>,
12586 + * Scott Foehner <sfoehner@engr.sgi.com>, George Anzinger <george@mvista.com>,
12587 + * Robert Walsh <rjwalsh@durables.org>, wangdi <wangdi@clusterfs.com>,
12588 + * San Mehat, Tom Rini <trini@mvista.com>,
12589 + * Jason Wessel <jason.wessel@windriver.com>
12592 +#include <linux/config.h>
12593 +#include <linux/kernel.h>
12594 +#include <linux/init.h>
12595 +#include <linux/kgdb.h>
12596 +#include <linux/interrupt.h>
12597 +#include <linux/tty.h>
12598 +#include <linux/serial.h>
12599 +#include <linux/serial_reg.h>
12600 +#include <linux/serialP.h>
12601 +#include <linux/ioport.h>
12603 +#include <asm/io.h>
12604 +#include <asm/serial.h> /* For BASE_BAUD and SERIAL_PORT_DFNS */
12608 +#define GDB_BUF_SIZE 512 /* power of 2, please */
12610 +MODULE_DESCRIPTION("KGDB driver for the 8250");
12611 +MODULE_LICENSE("GPL");
12612 +/* These will conflict with early_param otherwise. */
12613 +#ifdef CONFIG_KGDB_8250_MODULE
12614 +static char config[256];
12615 +module_param_string(kgdb8250, config, 256, 0);
12616 +MODULE_PARM_DESC(kgdb8250,
12617 + " kgdb8250=<io or mmio>,<address>,<baud rate>,<irq>\n");
12618 +static struct kgdb_io local_kgdb_io_ops;
12619 +#endif /* CONFIG_KGDB_8250_MODULE */
12621 +/* Speed of the UART. */
12622 +static int kgdb8250_baud;
12624 +/* Flag for if we need to call request_mem_region */
12625 +static int kgdb8250_needs_request_mem_region;
12627 +static char kgdb8250_buf[GDB_BUF_SIZE];
12628 +static atomic_t kgdb8250_buf_in_cnt;
12629 +static int kgdb8250_buf_out_inx;
12631 +/* Old-style serial definitions, if existant, and a counter. */
12632 +#ifdef CONFIG_KGDB_SIMPLE_SERIAL
12633 +static int __initdata should_copy_rs_table = 1;
12634 +static struct serial_state old_rs_table[] __initdata = {
12635 +#ifdef SERIAL_PORT_DFNS
12641 +/* Our internal table of UARTS. */
12642 +#define UART_NR CONFIG_SERIAL_8250_NR_UARTS
12643 +static struct uart_port kgdb8250_ports[UART_NR];
12645 +static struct uart_port *current_port;
12647 +/* Base of the UART. */
12648 +static void *kgdb8250_addr;
12650 +/* Forward declarations. */
12651 +static int kgdb8250_uart_init(void);
12652 +static int __init kgdb_init_io(void);
12653 +static int __init kgdb8250_opt(char *str);
12655 +/* These are much shorter calls to ioread8/iowrite8 that take into
12656 + * account our shifts, etc. */
12657 +static inline unsigned int kgdb_ioread(u8 mask)
12659 + return ioread8(kgdb8250_addr + (mask << current_port->regshift));
12662 +static inline void kgdb_iowrite(u8 val, u8 mask)
12664 + iowrite8(val, kgdb8250_addr + (mask << current_port->regshift));
12668 + * Wait until the interface can accept a char, then write it.
12670 +static void kgdb_put_debug_char(u8 chr)
12672 + while (!(kgdb_ioread(UART_LSR) & UART_LSR_THRE)) ;
12674 + kgdb_iowrite(chr, UART_TX);
12678 + * Get a byte from the hardware data buffer and return it
12680 +static int read_data_bfr(void)
12682 + char it = kgdb_ioread(UART_LSR);
12684 + if (it & UART_LSR_DR)
12685 + return kgdb_ioread(UART_RX);
12688 + * If we have a framing error assume somebody messed with
12689 + * our uart. Reprogram it and send '-' both ways...
12692 + kgdb8250_uart_init();
12693 + kgdb_put_debug_char('-');
12701 + * Get a char if available, return -1 if nothing available.
12702 + * Empty the receive buffer first, then look at the interface hardware.
12704 +static int kgdb_get_debug_char(void)
12708 + /* intr routine has q'd chars */
12709 + if (atomic_read(&kgdb8250_buf_in_cnt) != 0) {
12710 + retchr = kgdb8250_buf[kgdb8250_buf_out_inx++];
12711 + kgdb8250_buf_out_inx &= (GDB_BUF_SIZE - 1);
12712 + atomic_dec(&kgdb8250_buf_in_cnt);
12717 + retchr = read_data_bfr();
12718 + } while (retchr < 0);
12724 + * This is the receiver interrupt routine for the GDB stub.
12725 + * All that we need to do is verify that the interrupt happened on the
12726 + * line we're in charge of. If this is true, schedule a breakpoint and
12729 +static irqreturn_t
12730 +kgdb8250_interrupt(int irq, void *dev_id, struct pt_regs *regs)
12732 + if (kgdb_ioread(UART_IIR) & UART_IIR_RDI) {
12733 + /* Throw away the data if another I/O routine is active. */
12734 + if (kgdb_io_ops.read_char != kgdb_get_debug_char &&
12735 + (kgdb_ioread(UART_LSR) & UART_LSR_DR))
12736 + kgdb_ioread(UART_RX);
12741 + return IRQ_HANDLED;
12745 + * Initializes the UART.
12747 + * 0 on success, 1 on failure.
12750 +kgdb8250_uart_init (void)
12752 + unsigned int ier, base_baud = current_port->uartclk ?
12753 + current_port->uartclk / 16 : BASE_BAUD;
12755 + /* test uart existance */
12756 + if(kgdb_ioread(UART_LSR) == 0xff)
12759 + /* disable interrupts */
12760 + kgdb_iowrite(0, UART_IER);
12762 +#if defined(CONFIG_ARCH_OMAP1510)
12763 + /* Workaround to enable 115200 baud on OMAP1510 internal ports */
12764 + if (cpu_is_omap1510() && is_omap_port((void *)kgdb8250_addr)) {
12765 + if (kgdb8250_baud == 115200) {
12767 + kgdb8250_baud = 1;
12768 + kgdb_iowrite(1, UART_OMAP_OSC_12M_SEL);
12770 + kgdb_iowrite(0, UART_OMAP_OSC_12M_SEL);
12774 + kgdb_iowrite(UART_LCR_DLAB, UART_LCR);
12777 + kgdb_iowrite((base_baud / kgdb8250_baud) & 0xff, UART_DLL);
12778 + kgdb_iowrite((base_baud / kgdb8250_baud) >> 8, UART_DLM);
12780 + /* reset DLAB, set LCR */
12781 + kgdb_iowrite(UART_LCR_WLEN8, UART_LCR);
12783 + /* set DTR and RTS */
12784 + kgdb_iowrite(UART_MCR_OUT2 | UART_MCR_DTR | UART_MCR_RTS, UART_MCR);
12787 + kgdb_iowrite(UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR
12788 + | UART_FCR_CLEAR_XMIT | UART_FCR_TRIGGER_8,
12791 + /* clear pending interrupts */
12792 + kgdb_ioread(UART_IIR);
12793 + kgdb_ioread(UART_RX);
12794 + kgdb_ioread(UART_LSR);
12795 + kgdb_ioread(UART_MSR);
12797 + /* turn on RX interrupt only */
12798 + kgdb_iowrite(UART_IER_RDI, UART_IER);
12801 + * Borrowed from the main 8250 driver.
12802 + * Try writing and reading the UART_IER_UUE bit (b6).
12803 + * If it works, this is probably one of the Xscale platform's
12804 + * internal UARTs.
12805 + * We're going to explicitly set the UUE bit to 0 before
12806 + * trying to write and read a 1 just to make sure it's not
12807 + * already a 1 and maybe locked there before we even start start.
12809 + ier = kgdb_ioread(UART_IER);
12810 + kgdb_iowrite(ier & ~UART_IER_UUE, UART_IER);
12811 + if (!(kgdb_ioread(UART_IER) & UART_IER_UUE)) {
12813 + * OK it's in a known zero state, try writing and reading
12814 + * without disturbing the current state of the other bits.
12816 + kgdb_iowrite(ier | UART_IER_UUE, UART_IER);
12817 + if (kgdb_ioread(UART_IER) & UART_IER_UUE)
12819 + * It's an Xscale.
12821 + ier |= UART_IER_UUE | UART_IER_RTOIE;
12823 + kgdb_iowrite(ier, UART_IER);
12828 + * Copy the old serial_state table to our uart_port table if we haven't
12829 + * had values specifically configured in. We need to make sure this only
12832 +static void __init kgdb8250_copy_rs_table(void)
12834 +#ifdef CONFIG_KGDB_SIMPLE_SERIAL
12837 + if (!should_copy_rs_table)
12840 + for (i = 0; i < ARRAY_SIZE(old_rs_table); i++) {
12841 + kgdb8250_ports[i].iobase = old_rs_table[i].port;
12842 + kgdb8250_ports[i].irq = irq_canonicalize(old_rs_table[i].irq);
12843 + kgdb8250_ports[i].uartclk = old_rs_table[i].baud_base * 16;
12844 + kgdb8250_ports[i].membase = old_rs_table[i].iomem_base;
12845 + kgdb8250_ports[i].iotype = old_rs_table[i].io_type;
12846 + kgdb8250_ports[i].regshift = old_rs_table[i].iomem_reg_shift;
12847 + kgdb8250_ports[i].line = i;
12850 + should_copy_rs_table = 0;
12855 + * Hookup our IRQ line now that it is safe to do so, after we grab any
12856 + * memory regions we might need to. If we haven't been initialized yet,
12857 + * go ahead and copy the old_rs_table in.
12859 +static void __init kgdb8250_late_init(void)
12861 + /* Try and copy the old_rs_table. */
12862 + kgdb8250_copy_rs_table();
12864 +#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
12865 + /* Take the port away from the main driver. */
12866 + serial8250_unregister_by_port(current_port);
12868 + /* Now reinit the port as the above has disabled things. */
12869 + kgdb8250_uart_init();
12871 + /* We may need to call request_mem_region() first. */
12872 + if (kgdb8250_needs_request_mem_region)
12873 + request_mem_region(current_port->mapbase,
12874 + 8 << current_port->regshift, "kgdb");
12875 + if (request_irq(current_port->irq, kgdb8250_interrupt, SA_SHIRQ,
12876 + "GDB-stub", current_port) < 0)
12877 + printk(KERN_ERR "KGDB failed to request the serial IRQ (%d)\n",
12878 + current_port->irq);
12881 +static __init int kgdb_init_io(void)
12883 + /* Give us the basic table of uarts. */
12884 + kgdb8250_copy_rs_table();
12886 + /* We're either a module and parse a config string, or we have a
12887 + * semi-static config. */
12888 +#ifdef CONFIG_KGDB_8250_MODULE
12889 + if (strlen(config)) {
12890 + if (kgdb8250_opt(config))
12893 + printk(KERN_ERR "kgdb8250: argument error, usage: "
12894 + "kgdb8250=<io or mmio>,<address>,<baud rate>,<irq>\n");
12897 +#elif defined(CONFIG_KGDB_SIMPLE_SERIAL)
12898 + kgdb8250_baud = CONFIG_KGDB_BAUDRATE;
12900 + /* Setup our pointer to the serial port now. */
12901 + current_port = &kgdb8250_ports[CONFIG_KGDB_PORT_NUM];
12903 + if (kgdb8250_opt(CONFIG_KGDB_8250_CONF_STRING))
12908 + /* Internal driver setup. */
12909 + switch (current_port->iotype) {
12911 + if (current_port->mapbase)
12912 + kgdb8250_needs_request_mem_region = 1;
12913 + if (current_port->flags & UPF_IOREMAP) {
12914 + current_port->membase = ioremap(current_port->mapbase,
12915 + 8 << current_port->regshift);
12916 + if (!current_port->membase)
12917 + return -EIO; /* Failed. */
12919 + kgdb8250_addr = current_port->membase;
12923 + kgdb8250_addr = ioport_map(current_port->iobase,
12924 + 8 << current_port->regshift);
12925 + if (!kgdb8250_addr)
12926 + return -EIO; /* Failed. */
12929 + if (kgdb8250_uart_init() == -1) {
12930 + printk(KERN_ERR "kgdb8250: init failed\n");
12933 +#ifdef CONFIG_KGDB_8250_MODULE
12934 + /* Attach the kgdb irq. When this is built into the kernel, it
12935 + * is called as a part of late_init sequence.
12937 + kgdb8250_late_init();
12938 + if (kgdb_register_io_module(&local_kgdb_io_ops))
12941 + printk(KERN_INFO "kgdb8250: debugging enabled\n");
12942 +#endif /* CONFIG_KGD_8250_MODULE */
12947 +#ifdef CONFIG_KGDB_8250_MODULE
12948 +/* If it is a module the kgdb_io_ops should be a static which
12949 + * is passed to the KGDB I/O initialization
12951 +static struct kgdb_io local_kgdb_io_ops = {
12952 +#else /* ! CONFIG_KGDB_8250_MODULE */
12953 +struct kgdb_io kgdb_io_ops = {
12954 +#endif /* ! CONFIG_KGD_8250_MODULE */
12955 + .read_char = kgdb_get_debug_char,
12956 + .write_char = kgdb_put_debug_char,
12957 + .init = kgdb_init_io,
12958 + .late_init = kgdb8250_late_init,
12962 + * kgdb8250_add_port - Define a serial port for use with KGDB
12963 + * @i: The index of the port being added
12964 + * @serial_req: The &struct uart_port describing the port
12966 + * On platforms where we must register the serial device
12967 + * dynamically, this is the best option if a platform also normally
12968 + * calls early_serial_setup().
12970 +void __init kgdb8250_add_port(int i, struct uart_port *serial_req)
12972 + /* Make sure we've got the built-in data before we override. */
12973 + kgdb8250_copy_rs_table();
12975 + /* Copy the whole thing over. */
12976 + if (current_port != &kgdb8250_ports[i])
12977 + memcpy(&kgdb8250_ports[i], serial_req, sizeof(struct uart_port));
12981 + * kgdb8250_add_platform_port - Define a serial port for use with KGDB
12982 + * @i: The index of the port being added
12983 + * @p: The &struct plat_serial8250_port describing the port
12985 + * On platforms where we must register the serial device
12986 + * dynamically, this is the best option if a platform normally
12987 + * handles uart setup with an array of &struct plat_serial8250_port.
12989 +void __init kgdb8250_add_platform_port(int i, struct plat_serial8250_port *p)
12991 + /* Make sure we've got the built-in data before we override. */
12992 + kgdb8250_copy_rs_table();
12994 + kgdb8250_ports[i].iobase = p->iobase;
12995 + kgdb8250_ports[i].membase = p->membase;
12996 + kgdb8250_ports[i].irq = p->irq;
12997 + kgdb8250_ports[i].uartclk = p->uartclk;
12998 + kgdb8250_ports[i].regshift = p->regshift;
12999 + kgdb8250_ports[i].iotype = p->iotype;
13000 + kgdb8250_ports[i].flags = p->flags;
13001 + kgdb8250_ports[i].mapbase = p->mapbase;
13005 + * Syntax for this cmdline option is:
13006 + * kgdb8250=<io or mmio>,<address>,<baud rate>,<irq>"
13008 +static int __init kgdb8250_opt(char *str)
13010 + /* We'll fill out and use the first slot. */
13011 + current_port = &kgdb8250_ports[0];
13013 + if (!strncmp(str, "io", 2)) {
13014 + current_port->iotype = UPIO_PORT;
13016 + } else if (!strncmp(str, "mmap", 4)) {
13017 + current_port->iotype = UPIO_MEM;
13018 + current_port->flags |= UPF_IOREMAP;
13020 + } else if (!strncmp(str, "mmio", 4)) {
13021 + current_port->iotype = UPIO_MEM;
13022 + current_port->flags &= ~UPF_IOREMAP;
13031 + if (current_port->iotype == UPIO_PORT)
13032 + current_port->iobase = simple_strtoul(str, &str, 16);
13034 + if (current_port->flags & UPF_IOREMAP)
13035 + current_port->mapbase =
13036 + (unsigned long) simple_strtoul(str, &str, 16);
13038 + current_port->membase =
13039 + (void *) simple_strtoul(str, &str, 16);
13046 + kgdb8250_baud = simple_strtoul(str, &str, 10);
13047 + if (!kgdb8250_baud)
13054 + current_port->irq = simple_strtoul(str, &str, 10);
13056 +#ifdef CONFIG_KGDB_SIMPLE_SERIAL
13057 + should_copy_rs_table = 0;
13063 + printk(KERN_ERR "Invalid syntax for option kgdb8250=\n");
13067 +#ifdef CONFIG_KGDB_8250_MODULE
13068 +static void cleanup_kgdb8250(void)
13070 + kgdb_unregister_io_module(&local_kgdb_io_ops);
13072 + /* Clean up the irq and memory */
13073 + free_irq(current_port->irq, current_port);
13075 + if (kgdb8250_needs_request_mem_region)
13076 + release_mem_region(current_port->mapbase,
13077 + 8 << current_port->regshift);
13078 + /* Hook up the serial port back to what it was previously
13081 +#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
13082 + /* Give the port back to the 8250 driver. */
13083 + serial8250_register_port(current_port);
13087 +module_init(kgdb_init_io);
13088 +module_exit(cleanup_kgdb8250);
13089 +#else /* ! CONFIG_KGDB_8250_MODULE */
13090 +early_param("kgdb8250", kgdb8250_opt);
13091 +#endif /* ! CONFIG_KGDB_8250_MODULE */
13092 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/drivers/serial/Kconfig linux-2.6.18.kgdb/drivers/serial/Kconfig
13093 --- linux-2.6.18/drivers/serial/Kconfig 2006-09-20 07:42:06.000000000 +0400
13094 +++ linux-2.6.18.kgdb/drivers/serial/Kconfig 2008-06-10 16:19:03.000000000 +0400
13095 @@ -106,7 +106,7 @@ config SERIAL_8250_CS
13097 config SERIAL_8250_NR_UARTS
13098 int "Maximum number of 8250/16550 serial ports"
13099 - depends on SERIAL_8250
13100 + depends on SERIAL_8250 || KGDB_8250
13103 Set this to the number of serial ports you want the driver
13104 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/drivers/serial/Makefile linux-2.6.18.kgdb/drivers/serial/Makefile
13105 --- linux-2.6.18/drivers/serial/Makefile 2006-09-20 07:42:06.000000000 +0400
13106 +++ linux-2.6.18.kgdb/drivers/serial/Makefile 2008-06-10 16:19:22.000000000 +0400
13107 @@ -47,6 +47,7 @@ obj-$(CONFIG_SERIAL_IMX) += imx.o
13108 obj-$(CONFIG_SERIAL_MPC52xx) += mpc52xx_uart.o
13109 obj-$(CONFIG_SERIAL_ICOM) += icom.o
13110 obj-$(CONFIG_SERIAL_M32R_SIO) += m32r_sio.o
13111 +obj-$(CONFIG_KGDB_MPSC) += mpsc_kgdb.o
13112 obj-$(CONFIG_SERIAL_MPSC) += mpsc.o
13113 obj-$(CONFIG_ETRAX_SERIAL) += crisv10.o
13114 obj-$(CONFIG_SERIAL_JSM) += jsm/
13115 @@ -56,3 +57,4 @@ obj-$(CONFIG_SERIAL_SGI_IOC4) += ioc4_se
13116 obj-$(CONFIG_SERIAL_SGI_IOC3) += ioc3_serial.o
13117 obj-$(CONFIG_SERIAL_AT91) += at91_serial.o
13118 obj-$(CONFIG_SERIAL_NETX) += netx-serial.o
13119 +obj-$(CONFIG_KGDB_8250) += 8250_kgdb.o
13120 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/drivers/serial/amba-pl011.c linux-2.6.18.kgdb/drivers/serial/amba-pl011.c
13121 --- linux-2.6.18/drivers/serial/amba-pl011.c 2006-09-20 07:42:06.000000000 +0400
13122 +++ linux-2.6.18.kgdb/drivers/serial/amba-pl011.c 2008-06-10 16:19:51.000000000 +0400
13123 @@ -340,7 +340,7 @@ static int pl011_startup(struct uart_por
13127 - retval = request_irq(uap->port.irq, pl011_int, 0, "uart-pl011", uap);
13128 + retval = request_irq(uap->port.irq, pl011_int, SA_SHIRQ, "uart-pl011", uap);
13132 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/drivers/serial/cpm_uart/Makefile linux-2.6.18.kgdb/drivers/serial/cpm_uart/Makefile
13133 --- linux-2.6.18/drivers/serial/cpm_uart/Makefile 2006-09-20 07:42:06.000000000 +0400
13134 +++ linux-2.6.18.kgdb/drivers/serial/cpm_uart/Makefile 2008-06-10 16:19:22.000000000 +0400
13135 @@ -7,5 +7,6 @@ obj-$(CONFIG_SERIAL_CPM) += cpm_uart.o
13136 # Select the correct platform objects.
13137 cpm_uart-objs-$(CONFIG_CPM2) += cpm_uart_cpm2.o
13138 cpm_uart-objs-$(CONFIG_8xx) += cpm_uart_cpm1.o
13139 +cpm_uart-objs-$(CONFIG_KGDB_CPM_UART) += cpm_uart_kgdb.o
13141 cpm_uart-objs := cpm_uart_core.o $(cpm_uart-objs-y)
13142 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/drivers/serial/cpm_uart/cpm_uart.h linux-2.6.18.kgdb/drivers/serial/cpm_uart/cpm_uart.h
13143 --- linux-2.6.18/drivers/serial/cpm_uart/cpm_uart.h 2006-09-20 07:42:06.000000000 +0400
13144 +++ linux-2.6.18.kgdb/drivers/serial/cpm_uart/cpm_uart.h 2008-06-10 16:19:22.000000000 +0400
13147 #define SCC_WAIT_CLOSING 100
13149 +#ifdef CONFIG_KGDB_CPM_UART
13151 +/* Speed of the debug UART. */
13152 +#if defined(CONFIG_KGDB_9600BAUD)
13153 +#define KGDB_BAUD B9600
13154 +#elif defined(CONFIG_KGDB_19200BAUD)
13155 +#define KGDB_BAUD B19200
13156 +#elif defined(CONFIG_KGDB_38400BAUD)
13157 +#define KGDB_BAUD B38400
13158 +#elif defined(CONFIG_KGDB_57600BAUD)
13159 +#define KGDB_BAUD B57600
13161 +#define KGDB_BAUD B115200 /* Start with this if not given */
13164 +#ifdef CONFIG_KGDB_CPM_UART_SCC1
13165 +#define KGDB_PINFO_INDEX UART_SCC1
13166 +#elif CONFIG_KGDB_CPM_UART_SCC2
13167 +#define KGDB_PINFO_INDEX UART_SCC2
13168 +#elif CONFIG_KGDB_CPM_UART_SCC3
13169 +#define KGDB_PINFO_INDEX UART_SCC3
13170 +#elif CONFIG_KGDB_CPM_UART_SCC4
13171 +#define KGDB_PINFO_INDEX UART_SCC4
13172 +#elif CONFIG_KGDB_CPM_UART_SMC1
13173 +#define KGDB_PINFO_INDEX UART_SMC1
13174 +#elif CONFIG_KGDB_CPM_UART_SMC2
13175 +#define KGDB_PINFO_INDEX UART_SMC2
13177 +#error The S(M)CC for kgdb console is undefined
13180 +#endif /* CONFIG_KGDB_CPM_UART */
13182 struct uart_cpm_port {
13183 struct uart_port port;
13185 @@ -87,6 +120,9 @@ extern int cpm_uart_port_map[UART_NR];
13186 extern int cpm_uart_nr;
13187 extern struct uart_cpm_port cpm_uart_ports[UART_NR];
13189 +void cpm_uart_early_write(int index, const char *s, u_int count);
13190 +int cpm_uart_early_setup(int index,int early);
13192 /* these are located in their respective files */
13193 void cpm_line_cr_cmd(int line, int cmd);
13194 int cpm_uart_init_portdesc(void);
13195 @@ -133,5 +169,4 @@ static inline void *cpm2cpu_addr(unsigne
13200 #endif /* CPM_UART_H */
13201 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/drivers/serial/cpm_uart/cpm_uart_core.c linux-2.6.18.kgdb/drivers/serial/cpm_uart/cpm_uart_core.c
13202 --- linux-2.6.18/drivers/serial/cpm_uart/cpm_uart_core.c 2006-09-20 07:42:06.000000000 +0400
13203 +++ linux-2.6.18.kgdb/drivers/serial/cpm_uart/cpm_uart_core.c 2008-06-10 16:19:22.000000000 +0400
13204 @@ -1070,22 +1070,17 @@ int cpm_uart_drv_get_platform_data(struc
13208 -#ifdef CONFIG_SERIAL_CPM_CONSOLE
13210 - * Print a string to the serial port trying not to disturb
13211 - * any possible real use of the port...
13213 - * Note that this is called with interrupts already disabled
13215 -static void cpm_uart_console_write(struct console *co, const char *s,
13216 +void cpm_uart_early_write(int index, const char *s,
13219 - struct uart_cpm_port *pinfo =
13220 - &cpm_uart_ports[cpm_uart_port_map[co->index]];
13221 + struct uart_cpm_port *pinfo;
13223 volatile cbd_t *bdp, *bdbase;
13224 volatile unsigned char *cp;
13226 + BUG_ON(index>UART_NR);
13227 + pinfo = &cpm_uart_ports[index];
13229 /* Get the address of the host memory buffer.
13231 bdp = pinfo->tx_cur;
13232 @@ -1149,16 +1144,11 @@ static void cpm_uart_console_write(struc
13233 pinfo->tx_cur = (volatile cbd_t *) bdp;
13237 -static int __init cpm_uart_console_setup(struct console *co, char *options)
13238 +int cpm_uart_early_setup(int index, int early)
13241 struct uart_port *port;
13242 struct uart_cpm_port *pinfo;
13243 - int baud = 38400;
13245 - int parity = 'n';
13249 struct fs_uart_platform_info *pdata;
13250 struct platform_device* pdev = early_uart_get_pdev(co->index);
13251 @@ -1169,8 +1159,9 @@ static int __init cpm_uart_console_setup
13252 cpm_uart_init_portdesc();
13255 + BUG_ON(index>UART_NR);
13257 - (struct uart_port *)&cpm_uart_ports[cpm_uart_port_map[co->index]];
13258 + (struct uart_port *)&cpm_uart_ports[index];
13259 pinfo = (struct uart_cpm_port *)port;
13261 if (pinfo->set_lineif)
13262 @@ -1184,19 +1175,6 @@ static int __init cpm_uart_console_setup
13263 cpm_uart_drv_get_platform_data(pdev, 1);
13266 - pinfo->flags |= FLAG_CONSOLE;
13269 - uart_parse_options(options, &baud, &parity, &bits, &flow);
13271 - bd_t *bd = (bd_t *) __res;
13273 - if (bd->bi_baudrate)
13274 - baud = bd->bi_baudrate;
13279 if (IS_SMC(pinfo)) {
13280 pinfo->smcp->smc_smcm &= ~(SMCM_RX | SMCM_TX);
13281 pinfo->smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN);
13282 @@ -1204,8 +1182,7 @@ static int __init cpm_uart_console_setup
13283 pinfo->sccp->scc_sccm &= ~(UART_SCCM_TX | UART_SCCM_RX);
13284 pinfo->sccp->scc_gsmrl &= ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
13287 - ret = cpm_uart_allocbuf(pinfo, 1);
13288 + ret = cpm_uart_allocbuf(pinfo, early);
13292 @@ -1217,6 +1194,56 @@ static int __init cpm_uart_console_setup
13294 cpm_uart_init_scc(pinfo);
13299 +#ifdef CONFIG_SERIAL_CPM_CONSOLE
13301 + * Print a string to the serial port trying not to disturb
13302 + * any possible real use of the port...
13304 + * Note that this is called with interrupts already disabled
13307 +static void cpm_uart_console_write(struct console *co, const char *s,
13310 + cpm_uart_early_write(cpm_uart_port_map[co->index],s,count);
13314 + * Setup console. Be careful is called early !
13316 +static int __init cpm_uart_console_setup(struct console *co, char *options)
13318 + struct uart_port *port;
13319 + struct uart_cpm_port *pinfo;
13320 + int baud = 115200;
13322 + int parity = 'n';
13327 + (struct uart_port *)&cpm_uart_ports[cpm_uart_port_map[co->index]];
13328 + pinfo = (struct uart_cpm_port *)port;
13330 + pinfo->flags |= FLAG_CONSOLE;
13333 + uart_parse_options(options, &baud, &parity, &bits, &flow);
13335 + bd_t *bd = (bd_t *) __res;
13337 + if (bd->bi_baudrate)
13338 + baud = bd->bi_baudrate;
13343 + ret = cpm_uart_early_setup(cpm_uart_port_map[co->index], 1);
13346 uart_set_options(port, co, baud, parity, bits, flow);
13349 @@ -1364,6 +1391,12 @@ static int cpm_uart_init(void) {
13351 for (i = 0; i < cpm_uart_nr; i++) {
13352 int con = cpm_uart_port_map[i];
13354 +#ifdef CONFIG_KGDB_CPM_UART
13355 + /* We are not interested in ports yet utilized by kgdb */
13356 + if(con == KGDB_PINFO_INDEX)
13359 cpm_uart_ports[con].port.line = i;
13360 cpm_uart_ports[con].port.flags = UPF_BOOT_AUTOCONF;
13361 uart_add_one_port(&cpm_reg, &cpm_uart_ports[con].port);
13362 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/drivers/serial/cpm_uart/cpm_uart_cpm1.c linux-2.6.18.kgdb/drivers/serial/cpm_uart/cpm_uart_cpm1.c
13363 --- linux-2.6.18/drivers/serial/cpm_uart/cpm_uart_cpm1.c 2006-09-20 07:42:06.000000000 +0400
13364 +++ linux-2.6.18.kgdb/drivers/serial/cpm_uart/cpm_uart_cpm1.c 2008-06-10 16:19:22.000000000 +0400
13365 @@ -52,6 +52,7 @@ void cpm_line_cr_cmd(int line, int cmd)
13368 volatile cpm8xx_t *cp = cpmp;
13369 + unsigned *bcsr_io;
13373 @@ -94,12 +95,35 @@ void scc1_lineif(struct uart_cpm_port *p
13375 /* XXX SCC1: insert port configuration here */
13378 +#if defined (CONFIG_MPC885ADS) || defined (CONFIG_MPC86XADS)
13379 + bcsr_io = ioremap(BCSR1, sizeof(unsigned long));
13381 + if (bcsr_io == NULL) {
13382 + printk(KERN_CRIT "Could not remap BCSR\n");
13385 + out_be32(bcsr_io, in_be32(bcsr_io) & ~BCSR1_RS232EN_1);
13386 + iounmap(bcsr_io);
13390 void scc2_lineif(struct uart_cpm_port *pinfo)
13392 /* XXX SCC2: insert port configuration here */
13394 + unsigned *bcsr_io;
13396 +#if defined (CONFIG_MPC885ADS) || defined (CONFIG_MPC86XADS)
13397 + bcsr_io = ioremap(BCSR1, sizeof(unsigned long));
13399 + if (bcsr_io == NULL) {
13400 + printk(KERN_CRIT "Could not remap BCSR\n");
13403 + out_be32(bcsr_io, in_be32(bcsr_io) & ~BCSR1_RS232EN_2);
13404 + iounmap(bcsr_io);
13408 void scc3_lineif(struct uart_cpm_port *pinfo)
13409 @@ -188,6 +212,10 @@ int cpm_uart_init_portdesc(void)
13411 pr_debug("CPM uart[-]:init portdesc\n");
13413 + /* Check if we have called this yet. This may happen if early kgdb
13414 + breakpoint is on */
13418 #ifdef CONFIG_SERIAL_CPM_SMC1
13419 cpm_uart_ports[UART_SMC1].smcp = &cpmp->cp_smc[0];
13420 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/drivers/serial/cpm_uart/cpm_uart_cpm2.c linux-2.6.18.kgdb/drivers/serial/cpm_uart/cpm_uart_cpm2.c
13421 --- linux-2.6.18/drivers/serial/cpm_uart/cpm_uart_cpm2.c 2006-09-20 07:42:06.000000000 +0400
13422 +++ linux-2.6.18.kgdb/drivers/serial/cpm_uart/cpm_uart_cpm2.c 2008-06-10 16:19:22.000000000 +0400
13423 @@ -256,6 +256,10 @@ int cpm_uart_init_portdesc(void)
13425 pr_debug("CPM uart[-]:init portdesc\n");
13427 + /* Check if we have called this yet. This may happen if early kgdb
13428 + breakpoint is on */
13432 #ifdef CONFIG_SERIAL_CPM_SMC1
13433 cpm_uart_ports[UART_SMC1].smcp = (smc_t *) & cpm2_immr->im_smc[0];
13434 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/drivers/serial/cpm_uart/cpm_uart_kgdb.c linux-2.6.18.kgdb/drivers/serial/cpm_uart/cpm_uart_kgdb.c
13435 --- linux-2.6.18/drivers/serial/cpm_uart/cpm_uart_kgdb.c 1970-01-01 03:00:00.000000000 +0300
13436 +++ linux-2.6.18.kgdb/drivers/serial/cpm_uart/cpm_uart_kgdb.c 2008-06-10 16:19:22.000000000 +0400
13439 + * drivers/serial/cpm_uart/cpm_uart_kgdb.c
13441 + * CPM UART interface for kgdb.
13443 + * Author: Vitaly Bordug <vbordug@ru.mvista.com>
13445 + * Used some bits from drivers/serial/kgdb_8250.c as a template
13447 + * 2005 (c) MontaVista Software, Inc. This file is licensed under
13448 + * the terms of the GNU General Public License version 2. This program
13449 + * is licensed "as is" without any warranty of any kind, whether express
13453 +#include <linux/kgdb.h>
13454 +#include <linux/config.h>
13455 +#include <linux/kernel.h>
13456 +#include <linux/init.h>
13457 +#include <linux/interrupt.h>
13458 +#include <linux/tty.h>
13459 +#include <linux/serial.h>
13460 +#include <linux/serial_core.h>
13461 +#include <linux/serial_reg.h>
13463 +#include <asm/io.h>
13464 +#include <asm/serial.h> /* For BASE_BAUD and SERIAL_PORT_DFNS */
13466 +#include "cpm_uart.h"
13468 +#define GDB_BUF_SIZE 512 /* power of 2, please */
13471 +static char kgdb_buf[GDB_BUF_SIZE], *kgdbp;
13472 +static int kgdb_chars;
13474 +/* Forward declarations. */
13477 + * Receive character from the serial port. This only works well
13478 + * before the port is initialize for real use.
13480 +static int kgdb_wait_key(char *obuf)
13482 + struct uart_cpm_port *pinfo;
13485 + volatile cbd_t *bdp;
13488 + pinfo = &cpm_uart_ports[KGDB_PINFO_INDEX];
13490 + /* Get the address of the host memory buffer.
13492 + bdp = pinfo->rx_cur;
13493 + while (bdp->cbd_sc & BD_SC_EMPTY);
13495 + /* If the buffer address is in the CPM DPRAM, don't
13498 + cp = cpm2cpu_addr(bdp->cbd_bufaddr);
13501 + i = c = bdp->cbd_datlen;
13509 + bdp->cbd_sc |= BD_SC_EMPTY;
13511 + if (bdp->cbd_sc & BD_SC_WRAP) {
13512 + bdp = pinfo->rx_bd_base;
13516 + pinfo->rx_cur = (cbd_t *)bdp;
13523 + * Wait until the interface can accept a char, then write it.
13526 +kgdb_put_debug_char(int chr)
13528 + static char ch[2];
13530 + cpm_uart_early_write(KGDB_PINFO_INDEX, ch, 1);
13535 + * Get a char if available, return -1 if nothing available.
13536 + * Empty the receive buffer first, then look at the interface hardware.
13539 +kgdb_get_debug_char(void)
13541 + if (kgdb_chars<=0) {
13542 + kgdb_chars = kgdb_wait_key(kgdb_buf);
13543 + kgdbp = kgdb_buf;
13547 + return (*kgdbp++);
13550 +static void termios_set_options(int index,
13551 + int baud, int parity, int bits, int flow)
13553 + struct termios termios;
13554 + struct uart_port *port;
13555 + struct uart_cpm_port *pinfo;
13557 + BUG_ON(index>UART_NR);
13560 + (struct uart_port *)&cpm_uart_ports[index];
13561 + pinfo = (struct uart_cpm_port *)port;
13564 + * Ensure that the serial console lock is initialised
13567 + spin_lock_init(&port->lock);
13569 + memset(&termios, 0, sizeof(struct termios));
13571 + termios.c_cflag = CREAD | HUPCL | CLOCAL;
13573 + termios.c_cflag |= baud;
13576 + termios.c_cflag |= CS7;
13578 + termios.c_cflag |= CS8;
13580 + switch (parity) {
13581 + case 'o': case 'O':
13582 + termios.c_cflag |= PARODD;
13584 + case 'e': case 'E':
13585 + termios.c_cflag |= PARENB;
13590 + termios.c_cflag |= CRTSCTS;
13592 + port->ops->set_termios(port, &termios, NULL);
13597 + * 0 on success, 1 on failure.
13599 +static int kgdb_init(void)
13601 + struct uart_port *port;
13602 + struct uart_cpm_port *pinfo;
13604 + int use_bootmem = 0; /* use dma by default */
13609 + cpm_uart_init_portdesc();
13611 + port = (struct uart_port *)&cpm_uart_ports[KGDB_PINFO_INDEX];
13612 + pinfo = (struct uart_cpm_port *)port;
13614 + if (cpm_uart_early_setup(KGDB_PINFO_INDEX, use_bootmem))
13617 + termios_set_options(KGDB_PINFO_INDEX, KGDB_BAUD,'n',8,'n');
13618 + if (IS_SMC(pinfo))
13619 + pinfo->smcp->smc_smcm |= SMCM_TX;
13621 + pinfo->sccp->scc_sccm |= UART_SCCM_TX;
13627 +struct kgdb_io kgdb_io_ops = {
13628 + .read_char = kgdb_get_debug_char,
13629 + .write_char = kgdb_put_debug_char,
13630 + .init = kgdb_init,
13633 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/drivers/serial/mpsc.c linux-2.6.18.kgdb/drivers/serial/mpsc.c
13634 --- linux-2.6.18/drivers/serial/mpsc.c 2006-09-20 07:42:06.000000000 +0400
13635 +++ linux-2.6.18.kgdb/drivers/serial/mpsc.c 2008-06-10 16:19:22.000000000 +0400
13636 @@ -242,6 +242,11 @@ struct mpsc_port_info *mpsc_device_remov
13637 #define MPSC_RCRR 0x0004
13638 #define MPSC_TCRR 0x0008
13640 +/* MPSC Interrupt registers (offset from MV64x60_SDMA_INTR_OFFSET) */
13641 +#define MPSC_INTR_CAUSE 0x0004
13642 +#define MPSC_INTR_MASK 0x0084
13643 +#define MPSC_INTR_CAUSE_RCC (1<<6)
13645 /* Serial DMA Controller Interface Registers */
13646 #define SDMA_SDC 0x0000
13647 #define SDMA_SDCM 0x0008
13648 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/drivers/serial/mpsc_kgdb.c linux-2.6.18.kgdb/drivers/serial/mpsc_kgdb.c
13649 --- linux-2.6.18/drivers/serial/mpsc_kgdb.c 1970-01-01 03:00:00.000000000 +0300
13650 +++ linux-2.6.18.kgdb/drivers/serial/mpsc_kgdb.c 2008-06-10 16:19:22.000000000 +0400
13653 + * drivers/serial/mpsc_kgdb.c
13655 + * KGDB driver for the Marvell MultiProtocol Serial Controller (MPCS)
13657 + * Based on the polled boot loader driver by Ajit Prem (ajit.prem@motorola.com)
13659 + * Author: Randy Vinson <rvinson@mvista.com>
13661 + * 2005 (c) MontaVista Software, Inc.
13662 + * This program is free software; you can redistribute it and/or modify it
13663 + * under the terms of the GNU General Public License as published by the
13664 + * Free Software Foundation; either version 2 of the License, or (at your
13665 + * option) any later version.
13668 +#include <linux/config.h>
13669 +#include <linux/kgdb.h>
13670 +#include <linux/mv643xx.h>
13671 +#include <linux/device.h>
13672 +#include <asm/mv64x60.h>
13673 +#include <asm/serial.h>
13674 +#include <asm/io.h>
13675 +#include <asm/delay.h>
13679 +/* Speed of the UART. */
13680 +static int kgdbmpsc_baud = CONFIG_KGDB_BAUDRATE;
13682 +/* Index of the UART, matches ttyMX naming. */
13683 +static int kgdbmpsc_ttyMM = CONFIG_KGDB_PORT_NUM;
13685 +#define MPSC_INTR_REG_SELECT(x) ((x) + (8 * kgdbmpsc_ttyMM))
13687 +static int kgdbmpsc_init(void);
13689 +static struct platform_device mpsc_dev, shared_dev;
13691 +static void __iomem *mpsc_base;
13692 +static void __iomem *brg_base;
13693 +static void __iomem *routing_base;
13694 +static void __iomem *sdma_base;
13696 +static unsigned int mpsc_irq;
13698 +static void kgdb_write_debug_char(int c)
13702 + data = readl(mpsc_base + MPSC_MPCR);
13703 + writeb(c, mpsc_base + MPSC_CHR_1);
13705 + data = readl(mpsc_base + MPSC_CHR_2);
13706 + data |= MPSC_CHR_2_TTCS;
13707 + writel(data, mpsc_base + MPSC_CHR_2);
13710 + while (readl(mpsc_base + MPSC_CHR_2) & MPSC_CHR_2_TTCS) ;
13713 +static int kgdb_get_debug_char(void)
13717 + while (!(readl(sdma_base + MPSC_INTR_REG_SELECT(MPSC_INTR_CAUSE)) &
13718 + MPSC_INTR_CAUSE_RCC)) ;
13720 + c = readb(mpsc_base + MPSC_CHR_10 + (1 << 1));
13722 + writeb(c, mpsc_base + MPSC_CHR_10 + (1 << 1));
13724 + writel(~MPSC_INTR_CAUSE_RCC, sdma_base +
13725 + MPSC_INTR_REG_SELECT(MPSC_INTR_CAUSE));
13730 + * This is the receiver interrupt routine for the GDB stub.
13731 + * All that we need to do is verify that the interrupt happened on the
13732 + * line we're in charge of. If this is true, schedule a breakpoint and
13735 +static irqreturn_t
13736 +kgdbmpsc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
13738 + if (irq != mpsc_irq)
13741 + * If there is some other CPU in KGDB then this is a
13742 + * spurious interrupt. so return without even checking a byte
13744 + if (atomic_read(&debugger_active))
13747 + if (readl(sdma_base + MPSC_INTR_REG_SELECT(MPSC_INTR_CAUSE)) &
13748 + MPSC_INTR_CAUSE_RCC)
13751 + return IRQ_HANDLED;
13754 +static int __init kgdbmpsc_init(void)
13756 + struct mpsc_pdata *pdata;
13759 + if (!brg_base || !mpsc_base || !routing_base || !sdma_base)
13762 + /* Set MPSC Routing to enable both ports */
13763 + writel(0x0, routing_base + MPSC_MRR);
13765 + /* MPSC 0/1 Rx & Tx get clocks BRG0/1 */
13766 + writel(0x00000100, routing_base + MPSC_RCRR);
13767 + writel(0x00000100, routing_base + MPSC_TCRR);
13769 + /* Disable all MPSC interrupts and clear any pending interrupts */
13770 + writel(0, sdma_base + MPSC_INTR_REG_SELECT(MPSC_INTR_MASK));
13771 + writel(0, sdma_base + MPSC_INTR_REG_SELECT(MPSC_INTR_CAUSE));
13773 + pdata = (struct mpsc_pdata *)mpsc_dev.dev.platform_data;
13775 + /* cdv = (clock/(2*16*baud rate)) for 16X mode. */
13776 + cdv = ((pdata->brg_clk_freq / (32 * kgdbmpsc_baud)) - 1);
13777 + writel((pdata->brg_clk_src << 18) | (1 << 16) | cdv,
13778 + brg_base + BRG_BCR);
13780 + /* Put MPSC into UART mode, no null modem, 16x clock mode */
13781 + writel(0x000004c4, mpsc_base + MPSC_MMCRL);
13782 + writel(0x04400400, mpsc_base + MPSC_MMCRH);
13784 + writel(0, mpsc_base + MPSC_CHR_1);
13785 + writel(0, mpsc_base + MPSC_CHR_9);
13786 + writel(0, mpsc_base + MPSC_CHR_10);
13787 + writel(4, mpsc_base + MPSC_CHR_3);
13788 + writel(0x20000000, mpsc_base + MPSC_CHR_4);
13789 + writel(0x9000, mpsc_base + MPSC_CHR_5);
13790 + writel(0, mpsc_base + MPSC_CHR_6);
13791 + writel(0, mpsc_base + MPSC_CHR_7);
13792 + writel(0, mpsc_base + MPSC_CHR_8);
13794 + /* 8 data bits, 1 stop bit */
13795 + writel((3 << 12), mpsc_base + MPSC_MPCR);
13797 + /* Enter "hunt" mode */
13798 + writel((1 << 31), mpsc_base + MPSC_CHR_2);
13804 +static void __iomem *__init
13805 +kgdbmpsc_map_resource(struct platform_device *pd, int type, int num)
13807 + void __iomem *base = NULL;
13808 + struct resource *r;
13810 + if ((r = platform_get_resource(pd, IORESOURCE_MEM, num)))
13811 + base = ioremap(r->start, r->end - r->start + 1);
13815 +static void __iomem *__init
13816 +kgdbmpsc_unmap_resource(struct platform_device *pd, int type, int num,
13817 + void __iomem * base)
13824 +static void __init
13825 +kgdbmpsc_reserve_resource(struct platform_device *pd, int type, int num)
13827 + struct resource *r;
13829 + if ((r = platform_get_resource(pd, IORESOURCE_MEM, num)))
13830 + request_mem_region(r->start, r->end - r->start + 1, "kgdb");
13833 +static int __init kgdbmpsc_local_init(void)
13835 + if (!mpsc_dev.num_resources || !shared_dev.num_resources)
13836 + return 1; /* failure */
13838 + mpsc_base = kgdbmpsc_map_resource(&mpsc_dev, IORESOURCE_MEM,
13839 + MPSC_BASE_ORDER);
13840 + brg_base = kgdbmpsc_map_resource(&mpsc_dev, IORESOURCE_MEM,
13841 + MPSC_BRG_BASE_ORDER);
13843 + /* get the platform data for the shared registers and get them mapped */
13844 + routing_base = kgdbmpsc_map_resource(&shared_dev,
13846 + MPSC_ROUTING_BASE_ORDER);
13848 + kgdbmpsc_map_resource(&shared_dev, IORESOURCE_MEM,
13849 + MPSC_SDMA_INTR_BASE_ORDER);
13851 + mpsc_irq = platform_get_irq(&mpsc_dev, 1);
13853 + if (mpsc_base && brg_base && routing_base && sdma_base)
13854 + return 0; /* success */
13856 + return 1; /* failure */
13859 +static void __init kgdbmpsc_local_exit(void)
13862 + sdma_base = kgdbmpsc_unmap_resource(&shared_dev, IORESOURCE_MEM,
13863 + MPSC_SDMA_INTR_BASE_ORDER,
13865 + if (routing_base)
13866 + routing_base = kgdbmpsc_unmap_resource(&shared_dev,
13868 + MPSC_ROUTING_BASE_ORDER,
13871 + brg_base = kgdbmpsc_unmap_resource(&mpsc_dev, IORESOURCE_MEM,
13872 + MPSC_BRG_BASE_ORDER,
13875 + mpsc_base = kgdbmpsc_unmap_resource(&mpsc_dev, IORESOURCE_MEM,
13876 + MPSC_BASE_ORDER, mpsc_base);
13879 +static void __init kgdbmpsc_update_pdata(struct platform_device *pdev)
13882 + snprintf(pdev->dev.bus_id, BUS_ID_SIZE, "%s%u", pdev->name, pdev->id);
13885 +static int __init kgdbmpsc_pdev_init(void)
13887 + struct platform_device *pdev;
13889 + /* get the platform data for the specified port. */
13890 + pdev = mv64x60_early_get_pdev_data(MPSC_CTLR_NAME, kgdbmpsc_ttyMM, 1);
13892 + memcpy(&mpsc_dev, pdev, sizeof(struct platform_device));
13893 + if (platform_notify) {
13894 + kgdbmpsc_update_pdata(&mpsc_dev);
13895 + platform_notify(&mpsc_dev.dev);
13898 + /* get the platform data for the shared registers. */
13899 + pdev = mv64x60_early_get_pdev_data(MPSC_SHARED_NAME, 0, 0);
13901 + memcpy(&shared_dev, pdev,
13902 + sizeof(struct platform_device));
13903 + if (platform_notify) {
13904 + kgdbmpsc_update_pdata(&shared_dev);
13905 + platform_notify(&shared_dev.dev);
13912 +postcore_initcall(kgdbmpsc_pdev_init);
13914 +static int __init kgdbmpsc_init_io(void)
13917 + kgdbmpsc_pdev_init();
13919 + if (kgdbmpsc_local_init()) {
13920 + kgdbmpsc_local_exit();
13924 + if (kgdbmpsc_init() == -1)
13929 +static void __init kgdbmpsc_hookup_irq(void)
13931 + unsigned int msk;
13932 + if (!request_irq(mpsc_irq, kgdbmpsc_interrupt, 0, "kgdb mpsc", NULL)) {
13933 + /* Enable interrupt */
13934 + msk = readl(sdma_base + MPSC_INTR_REG_SELECT(MPSC_INTR_MASK));
13935 + msk |= MPSC_INTR_CAUSE_RCC;
13936 + writel(msk, sdma_base + MPSC_INTR_REG_SELECT(MPSC_INTR_MASK));
13938 + kgdbmpsc_reserve_resource(&mpsc_dev, IORESOURCE_MEM,
13939 + MPSC_BASE_ORDER);
13940 + kgdbmpsc_reserve_resource(&mpsc_dev, IORESOURCE_MEM,
13941 + MPSC_BRG_BASE_ORDER);
13945 +struct kgdb_io kgdb_io_ops = {
13946 + .read_char = kgdb_get_debug_char,
13947 + .write_char = kgdb_write_debug_char,
13948 + .init = kgdbmpsc_init_io,
13949 + .late_init = kgdbmpsc_hookup_irq,
13951 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/drivers/serial/pxa.c linux-2.6.18.kgdb/drivers/serial/pxa.c
13952 --- linux-2.6.18/drivers/serial/pxa.c 2006-09-20 07:42:06.000000000 +0400
13953 +++ linux-2.6.18.kgdb/drivers/serial/pxa.c 2008-06-10 16:19:51.000000000 +0400
13955 #include <linux/tty.h>
13956 #include <linux/tty_flip.h>
13957 #include <linux/serial_core.h>
13958 +#ifdef CONFIG_KGDB_CONSOLE
13959 +#include <linux/kgdb.h>
13962 #include <asm/io.h>
13963 #include <asm/hardware.h>
13964 @@ -692,6 +695,8 @@ serial_pxa_console_init(void)
13965 console_initcall(serial_pxa_console_init);
13967 #define PXA_CONSOLE &serial_pxa_console
13968 +#elif defined(CONFIG_KGDB_CONSOLE)
13969 +#define PXA_CONSOLE &kgdbcons
13971 #define PXA_CONSOLE NULL
13973 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/drivers/serial/serial_core.c linux-2.6.18.kgdb/drivers/serial/serial_core.c
13974 --- linux-2.6.18/drivers/serial/serial_core.c 2006-09-20 07:42:06.000000000 +0400
13975 +++ linux-2.6.18.kgdb/drivers/serial/serial_core.c 2008-06-10 16:19:03.000000000 +0400
13977 #include <linux/serial.h> /* for serial_state and serial_icounter_struct */
13978 #include <linux/delay.h>
13979 #include <linux/mutex.h>
13980 +#include <linux/kgdb.h>
13982 #include <asm/irq.h>
13983 #include <asm/uaccess.h>
13984 @@ -65,6 +66,12 @@ static struct lock_class_key port_lock_k
13985 #define uart_console(port) (0)
13988 +#ifdef CONFIG_KGDB_CONSOLE
13989 +#define uart_kgdb(port) (port->cons && !strcmp(port->cons->name, "kgdb"))
13991 +#define uart_kgdb(port) (0)
13994 static void uart_change_speed(struct uart_state *state, struct termios *old_termios);
13995 static void uart_wait_until_sent(struct tty_struct *tty, int timeout);
13996 static void uart_change_pm(struct uart_state *state, int pm_state);
13997 @@ -1673,6 +1680,9 @@ static int uart_line_info(char *buf, str
13998 port->iotype == UPIO_MEM ? port->mapbase :
13999 (unsigned long) port->iobase,
14001 + if (port->iotype == UPIO_MEM)
14002 + ret += sprintf(buf+ret, " membase 0x%08lX",
14003 + (unsigned long) port->membase);
14005 if (port->type == PORT_UNKNOWN) {
14007 @@ -2038,7 +2048,8 @@ uart_report_port(struct uart_driver *drv
14010 snprintf(address, sizeof(address),
14011 - "MMIO 0x%lx", port->mapbase);
14012 + "MMIO map 0x%lx mem 0x%lx", port->mapbase,
14013 + (unsigned long) port->membase);
14016 strlcpy(address, "*unknown*", sizeof(address));
14017 @@ -2090,9 +2101,9 @@ uart_configure_port(struct uart_driver *
14020 * Power down all ports by default, except the
14021 - * console if we have one.
14022 + * console (real or kgdb) if we have one.
14024 - if (!uart_console(port))
14025 + if (!uart_console(port) && !uart_kgdb(port))
14026 uart_change_pm(state, 3);
14029 @@ -2284,6 +2295,12 @@ int uart_add_one_port(struct uart_driver
14031 port->flags &= ~UPF_DEAD;
14033 +#if defined(CONFIG_KGDB_8250)
14034 + /* Add any 8250-like ports we find later. */
14035 + if (port->type <= PORT_MAX_8250)
14036 + kgdb8250_add_port(port->line, port);
14040 mutex_unlock(&state->mutex);
14041 mutex_unlock(&port_mutex);
14042 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/drivers/serial/serial_txx9.c linux-2.6.18.kgdb/drivers/serial/serial_txx9.c
14043 --- linux-2.6.18/drivers/serial/serial_txx9.c 2006-09-20 07:42:06.000000000 +0400
14044 +++ linux-2.6.18.kgdb/drivers/serial/serial_txx9.c 2008-06-10 16:19:28.000000000 +0400
14045 @@ -1164,6 +1164,96 @@ static struct pci_driver serial_txx9_pci
14046 MODULE_DEVICE_TABLE(pci, serial_txx9_pci_tbl);
14047 #endif /* ENABLE_SERIAL_TXX9_PCI */
14049 +/******************************************************************************/
14050 +/* BEG: KDBG Routines */
14051 +/******************************************************************************/
14053 +#ifdef CONFIG_KGDB
14054 +int kgdb_init_count = 0;
14056 +void txx9_sio_kgdb_hook(unsigned int port, unsigned int baud_rate)
14058 + static struct resource kgdb_resource;
14060 + struct uart_txx9_port *up = &serial_txx9_ports[port];
14062 + /* prevent initialization by driver */
14063 + kgdb_resource.name = "serial_txx9(debug)";
14064 + kgdb_resource.start = (unsigned long)up->port.membase;
14065 + kgdb_resource.end = (unsigned long)(up->port.membase + 36 - 1);
14066 + kgdb_resource.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
14068 + ret = request_resource(&iomem_resource, &kgdb_resource);
14069 + if(ret == -EBUSY)
14070 + printk(" serial_txx9(debug): request_resource failed\n");
14075 +txx9_sio_kdbg_init( unsigned int port_number )
14077 + if (port_number == 1) {
14078 + txx9_sio_kgdb_hook(port_number, 38400);
14080 + printk("Bad Port Number [%u] != [1]\n",port_number);
14086 +txx9_sio_kdbg_rd( void )
14088 + unsigned int status,ch;
14089 + struct uart_txx9_port *up = &serial_txx9_ports[1];
14091 + if (kgdb_init_count == 0) {
14092 + txx9_sio_kdbg_init(1);
14093 + kgdb_init_count = 1;
14097 + status = sio_in(up, TXX9_SIDISR);
14098 + if ( status & 0x1f ) {
14099 + ch = sio_in(up, TXX9_SIRFIFO );
14108 +txx9_sio_kdbg_wr( u8 ch )
14110 + unsigned int status;
14111 + struct uart_txx9_port *up = &serial_txx9_ports[1];
14113 + if (kgdb_init_count == 0) {
14114 + txx9_sio_kdbg_init(1);
14115 + kgdb_init_count = 1;
14119 + status = sio_in(up, TXX9_SICISR);
14120 + if (status & TXX9_SICISR_TRDY) {
14121 + if ( ch == '\n' ) {
14122 + txx9_sio_kdbg_wr( '\r' );
14124 + sio_out(up, TXX9_SITFIFO, (u32)ch );
14132 +#endif /* CONFIG_KGDB */
14135 +/******************************************************************************/
14136 +/* END: KDBG Routines */
14137 +/******************************************************************************/
14139 static int __init serial_txx9_init(void)
14142 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/drivers/serial/sh-sci.c linux-2.6.18.kgdb/drivers/serial/sh-sci.c
14143 --- linux-2.6.18/drivers/serial/sh-sci.c 2006-09-20 07:42:06.000000000 +0400
14144 +++ linux-2.6.18.kgdb/drivers/serial/sh-sci.c 2008-06-10 16:19:47.000000000 +0400
14146 #include <linux/console.h>
14147 #include <linux/bitops.h>
14148 #include <linux/generic_serial.h>
14149 +#include <linux/kgdb.h>
14151 #ifdef CONFIG_CPU_FREQ
14152 #include <linux/notifier.h>
14153 @@ -67,14 +68,16 @@
14155 #include "sh-sci.h"
14157 -#ifdef CONFIG_SH_KGDB
14158 -#include <asm/kgdb.h>
14160 -static int kgdb_get_char(struct sci_port *port);
14161 -static void kgdb_put_char(struct sci_port *port, char c);
14162 -static void kgdb_handle_error(struct sci_port *port);
14163 -static struct sci_port *kgdb_sci_port;
14164 -#endif /* CONFIG_SH_KGDB */
14165 +#ifdef CONFIG_KGDB_SH_SCI
14166 +/* Speed of the UART. */
14167 +static int kgdbsci_baud = CONFIG_KGDB_BAUDRATE
14169 +/* Index of the UART, matches ttySCX naming. */
14170 +static int kgdbsci_ttySC = CONFIG_KGDB_PORT_NUM;
14172 +/* Make life easier on us. */
14173 +#define KGDBPORT sci_ports[kgdbsci_ttySC]
14174 +#endif /* CONFIG_KGDB_SH_SCI */
14176 #ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
14177 static struct sci_port *serial_console_port = 0;
14178 @@ -87,20 +90,17 @@ static void sci_start_rx(struct uart_por
14179 static void sci_stop_rx(struct uart_port *port);
14180 static int sci_request_irq(struct sci_port *port);
14181 static void sci_free_irq(struct sci_port *port);
14182 +static void sci_set_termios(struct uart_port *port, struct termios *termios,
14183 + struct termios *old);
14184 +static int kgdbsci_init(void);
14186 static struct sci_port sci_ports[];
14187 static struct uart_driver sci_uart_driver;
14189 #define SCI_NPORTS sci_uart_driver.nr
14191 -#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
14193 -static void handle_error(struct uart_port *port)
14194 -{ /* Clear error flags */
14195 - sci_out(port, SCxSR, SCxSR_ERROR_CLEAR(port));
14198 -static int get_char(struct uart_port *port)
14199 +#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_KGDB_SH_SCI)
14200 +static int get_char_for_gdb(struct uart_port *port)
14202 unsigned long flags;
14203 unsigned short status;
14204 @@ -110,7 +110,8 @@ static int get_char(struct uart_port *po
14206 status = sci_in(port, SCxSR);
14207 if (status & SCxSR_ERRORS(port)) {
14208 - handle_error(port);
14209 + /* Clear error flags. */
14210 + sci_out(port, SCxSR, SCxSR_ERROR_CLEAR(port));
14213 } while (!(status & SCxSR_RDxF(port)));
14214 @@ -121,21 +122,7 @@ static int get_char(struct uart_port *po
14219 -/* Taken from sh-stub.c of GDB 4.18 */
14220 -static const char hexchars[] = "0123456789abcdef";
14222 -static __inline__ char highhex(int x)
14224 - return hexchars[(x >> 4) & 0xf];
14227 -static __inline__ char lowhex(int x)
14229 - return hexchars[x & 0xf];
14232 -#endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_SH_KGDB */
14233 +#endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_KGDB_SH_SCI */
14236 * Send the packet in buffer. The host gets one chance to read it.
14237 @@ -167,21 +154,14 @@ static void put_string(struct sci_port *
14238 const unsigned char *p = buffer;
14241 -#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
14245 #ifdef CONFIG_SH_STANDARD_BIOS
14247 + const char hexchars[] = "0123456789abcdef";
14249 /* This call only does a trap the first time it is
14250 * called, and so is safe to do here unconditionally
14252 - usegdb |= sh_bios_in_gdb_mode();
14254 -#ifdef CONFIG_SH_KGDB
14255 - usegdb |= (kgdb_in_gdb_mode && (port == kgdb_sci_port));
14259 + if (sh_bios_in_gdb_mode()) {
14260 /* $<packet info>#<checksum>. */
14263 @@ -193,18 +173,18 @@ static void put_string(struct sci_port *
14269 + h = hexchars[c >> 4];
14270 + l = hexchars[c % 16];
14275 put_char(port, '#');
14276 - put_char(port, highhex(checksum));
14277 - put_char(port, lowhex(checksum));
14278 + put_char(port, hexchars[checksum >> 4]);
14279 + put_char(port, hexchars[checksum % 16]);
14280 } while (get_char(port) != '+');
14282 -#endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_SH_KGDB */
14283 +#endif /* CONFIG_SH_STANDARD_BIOS */
14284 for (i=0; i<count; i++) {
14286 put_char(port, '\r');
14287 @@ -214,90 +194,163 @@ static void put_string(struct sci_port *
14288 #endif /* CONFIG_SERIAL_SH_SCI_CONSOLE */
14291 -#ifdef CONFIG_SH_KGDB
14293 -/* Is the SCI ready, ie is there a char waiting? */
14294 -static int kgdb_is_char_ready(struct sci_port *port)
14295 +#ifdef CONFIG_KGDB_SH_SCI
14296 +static int kgdbsci_read_char(void)
14298 - unsigned short status = sci_in(port, SCxSR);
14300 - if (status & (SCxSR_ERRORS(port) | SCxSR_BRK(port)))
14301 - kgdb_handle_error(port);
14303 - return (status & SCxSR_RDxF(port));
14304 + return get_char_for_gdb(&KGDBPORT.port);
14307 -/* Write a char */
14308 -static void kgdb_put_char(struct sci_port *port, char c)
14309 +/* Called from kgdbstub.c to put a character, just a wrapper */
14310 +static void kgdbsci_write_char(int c)
14312 - unsigned short status;
14315 - status = sci_in(port, SCxSR);
14316 - while (!(status & SCxSR_TDxE(port)));
14317 + unsigned short status;
14319 - sci_out(port, SCxTDR, c);
14320 - sci_in(port, SCxSR); /* Dummy read */
14321 - sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port));
14323 + status = sci_in(&KGDBPORT.port, SCxSR);
14324 + while (!(status & SCxSR_TDxE(&KGDBPORT.port)));
14326 + sci_out(&KGDBPORT.port, SCxTDR, c);
14327 + sci_in(&KGDBPORT.port, SCxSR); /* Dummy read */
14328 + sci_out(&KGDBPORT.port, SCxSR, SCxSR_TDxE_CLEAR(&KGDBPORT.port));
14331 -/* Get a char if there is one, else ret -1 */
14332 -static int kgdb_get_char(struct sci_port *port)
14333 +#ifndef CONFIG_SERIAL_SH_SCI_CONSOLE
14334 +/* If we don't have console, we never hookup IRQs. But we need to
14335 + * hookup one so that we can interrupt the system.
14337 +static irqreturn_t kgdbsci_rx_interrupt(int irq, void *ptr,
14338 + struct pt_regs *regs)
14341 + struct uart_port *port = ptr;
14343 - if (kgdb_is_char_ready(port) == 0)
14346 - c = sci_in(port, SCxRDR);
14347 - sci_in(port, SCxSR); /* Dummy read */
14348 - sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port));
14350 + if (!(sci_in(port, SCxSR) & SCxSR_RDxF(port)))
14356 -/* Called from kgdbstub.c to get a character, i.e. is blocking */
14357 -static int kgdb_sci_getchar(void)
14360 + if (kgdb_io_ops.init != kgdbsci_init) {
14361 + /* Throw away the data if another I/O routine is active */
14362 + get_char_for_gdb(&KGDBPORT.port);
14364 + /* We've got an interrupt, so go ahead and call breakpoint() */
14367 - /* Keep trying to read a character, this could be neater */
14368 - while ((c = kgdb_get_char(kgdb_sci_port)) < 0);
14369 + sci_in(port, SCxSR); /* dummy read */
14370 + sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port));
14373 + return IRQ_HANDLED;
14376 -/* Called from kgdbstub.c to put a character, just a wrapper */
14377 -static void kgdb_sci_putchar(int c)
14378 +static irqreturn_t kgdbsci_mpxed_interrupt(int irq, void *ptr,
14379 + struct pt_regs *regs)
14381 + unsigned short ssr_status, scr_status;
14382 + struct uart_port *port = ptr;
14384 + ssr_status = sci_in(port,SCxSR);
14385 + scr_status = sci_in(port,SCSCR);
14387 + /* Rx Interrupt */
14388 + if ((ssr_status&0x0002) && (scr_status&0x0040))
14389 + kgdbsci_rx_interrupt(irq, ptr, regs);
14391 - kgdb_put_char(kgdb_sci_port, c);
14392 + return IRQ_HANDLED;
14395 -/* Clear any errors on the SCI */
14396 -static void kgdb_handle_error(struct sci_port *port)
14397 +static void __init kgdbsci_lateinit(void)
14399 - sci_out(port, SCxSR, SCxSR_ERROR_CLEAR(port)); /* Clear error flags */
14400 + if (KGDBPORT.irqs[0] == KGDBPORT.irqs[1]) {
14401 + if (!KGDBPORT.irqs[0]) {
14402 + printk(KERN_ERR "kgdbsci: Cannot allocate irq.\n");
14405 + if (request_irq(KGDBPORT.irqs[0], kgdbsci_mpxed_interrupt,
14406 + SA_INTERRUPT, "kgdbsci",
14407 + &KGDBPORT.port)) {
14408 + printk(KERN_ERR "kgdbsci: Cannot allocate irq.\n");
14412 + if (KGDBPORT.irqs[1])
14413 + request_irq(KGDBPORT.irqs[1],
14414 + kgdbsci_rx_interrupt, SA_INTERRUPT,
14415 + "kgdbsci", &KGDBPORT.port);
14420 -/* Breakpoint if there's a break sent on the serial port */
14421 -static void kgdb_break_interrupt(int irq, void *ptr, struct pt_regs *regs)
14423 + * We use the normal init routine to setup the port, so we can't be
14424 + * in here too early.
14426 +static int kgdbsci_init(void)
14428 - struct sci_port *port = ptr;
14429 - unsigned short status = sci_in(port, SCxSR);
14430 + struct termios termios;
14432 - if (status & SCxSR_BRK(port)) {
14433 + memset(&termios, 0, sizeof(struct termios));
14435 - /* Break into the debugger if a break is detected */
14437 + termios.c_cflag = CREAD | HUPCL | CLOCAL | CS8;
14438 + switch (kgdbsci_baud) {
14440 + termios.c_cflag |= B9600;
14443 + termios.c_cflag |= B19200;
14446 + termios.c_cflag |= B38400;
14449 + termios.c_cflag |= B57600;
14452 + termios.c_cflag |= B115200;
14455 + sci_set_termios(&KGDBPORT.port, &termios, NULL);
14458 - sci_out(port, SCxSR, SCxSR_BREAK_CLEAR(port));
14463 -#endif /* CONFIG_SH_KGDB */
14464 +struct kgdb_io kgdb_io_ops = {
14465 + .read_char = kgdbsci_read_char,
14466 + .write_char = kgdbsci_write_char,
14467 + .init = kgdbsci_init,
14468 +#ifndef CONFIG_SERIAL_SH_SCI_CONSOLE
14469 + .late_init = kgdbsci_lateinit,
14470 +#else /* ! CONFIG_SERIAL_SH_SCI_CONSOLE */
14471 + .late_init = NULL,
14472 +#endif /* ! CONFIG_SERIAL_SH_SCI_CONSOLE */
14473 + .pre_exception = NULL,
14474 + .post_exception = NULL
14478 + * Syntax for this cmdline option is "kgdbsci=ttyno,baudrate".
14481 +kgdbsci_opt(char *str)
14483 + /* We might have anywhere from 1 to 3 ports. */
14484 + if (*str < '0' || *str > SCI_NPORTS + '0')
14486 + kgdbsci_ttySC = *str - '0';
14491 + kgdbsci_baud = simple_strtoul(str, &str, 10);
14492 + if (kgdbsci_baud != 9600 && kgdbsci_baud != 19200 &&
14493 + kgdbsci_baud != 38400 && kgdbsci_baud != 57600 &&
14494 + kgdbsci_baud != 115200)
14500 + printk(KERN_ERR "Invalid syntax for option kgdbsci=\n");
14503 +__setup("kgdbsci", kgdbsci_opt);
14504 +#endif /* CONFIG_KGDB_SH_SCI */
14506 #if defined(__H8300S__)
14507 enum { sci_disable, sci_enable };
14508 @@ -555,6 +608,16 @@ static inline void sci_receive_chars(str
14512 +#ifdef CONFIG_KGDB_SH_SCI
14513 + /* We assume that a ^C on the port KGDB
14514 + * is using means that KGDB wants to
14515 + * interrupt the running system.
14517 + if (port->line == KGDBPORT.port.line &&
14522 /* Store data and status */
14523 if (status&SCxSR_FER(port)) {
14525 @@ -1618,6 +1681,7 @@ static int __init sci_console_init(void)
14526 console_initcall(sci_console_init);
14527 #endif /* CONFIG_SERIAL_SH_SCI_CONSOLE */
14530 #ifdef CONFIG_SH_KGDB
14532 * FIXME: Most of this can go away.. at the moment, we rely on
14533 @@ -1663,30 +1727,9 @@ int __init kgdb_console_setup(struct con
14534 return uart_set_options(port, co, baud, parity, bits, flow);
14536 #endif /* CONFIG_SH_KGDB */
14539 -#ifdef CONFIG_SH_KGDB_CONSOLE
14540 -static struct console kgdb_console = {
14542 - .write = kgdb_console_write,
14543 - .setup = kgdb_console_setup,
14544 - .flags = CON_PRINTBUFFER | CON_ENABLED,
14546 - .data = &sci_uart_driver,
14549 -/* Register the KGDB console so we get messages (d'oh!) */
14550 -static int __init kgdb_console_init(void)
14552 - register_console(&kgdb_console);
14556 -console_initcall(kgdb_console_init);
14557 -#endif /* CONFIG_SH_KGDB_CONSOLE */
14559 -#if defined(CONFIG_SH_KGDB_CONSOLE)
14560 -#define SCI_CONSOLE &kgdb_console
14561 -#elif defined(CONFIG_SERIAL_SH_SCI_CONSOLE)
14562 +#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
14563 #define SCI_CONSOLE &serial_console
14565 #define SCI_CONSOLE 0
14566 @@ -1757,4 +1800,3 @@ static void __exit sci_exit(void)
14568 module_init(sci_init);
14569 module_exit(sci_exit);
14571 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/include/asm-arm/kgdb.h linux-2.6.18.kgdb/include/asm-arm/kgdb.h
14572 --- linux-2.6.18/include/asm-arm/kgdb.h 1970-01-01 03:00:00.000000000 +0300
14573 +++ linux-2.6.18.kgdb/include/asm-arm/kgdb.h 2008-06-10 16:19:58.000000000 +0400
14576 + * include/asm-arm/kgdb.h
14578 + * ARM KGDB support
14580 + * Author: Deepak Saxena <dsaxena@mvista.com>
14582 + * Copyright (C) 2002 MontaVista Software Inc.
14586 +#ifndef __ASM_KGDB_H__
14587 +#define __ASM_KGDB_H__
14589 +#include <linux/config.h>
14590 +#include <asm/ptrace.h>
14591 +#include <asm-generic/kgdb.h>
14595 + * GDB assumes that we're a user process being debugged, so
14596 + * it will send us an SWI command to write into memory as the
14597 + * debug trap. When an SWI occurs, the next instruction addr is
14598 + * placed into R14_svc before jumping to the vector trap.
14599 + * This doesn't work for kernel debugging as we are already in SVC
14600 + * we would loose the kernel's LR, which is a bad thing. This
14603 + * By doing this as an undefined instruction trap, we force a mode
14604 + * switch from SVC to UND mode, allowing us to save full kernel state.
14606 + * We also define a KGDB_COMPILED_BREAK which can be used to compile
14607 + * in breakpoints. This is important for things like sysrq-G and for
14608 + * the initial breakpoint from trap_init().
14610 + * Note to ARM HW designers: Add real trap support like SH && PPC to
14611 + * make our lives much much simpler. :)
14613 +#define BREAK_INSTR_SIZE 4
14614 +#define GDB_BREAKINST 0xef9f0001
14615 +#define KGDB_BREAKINST 0xe7ffdefe
14616 +#define KGDB_COMPILED_BREAK 0xe7ffdeff
14617 +#define CACHE_FLUSH_IS_SAFE 1
14619 +#ifndef __ASSEMBLY__
14621 +#define BREAKPOINT() asm(".word 0xe7ffdeff")
14624 +extern void kgdb_handle_bus_error(void);
14625 +extern int kgdb_fault_expected;
14626 +#endif /* !__ASSEMBLY__ */
14629 + * From Amit S. Kale:
14631 + * In the register packet, words 0-15 are R0 to R10, FP, IP, SP, LR, PC. But
14632 + * Register 16 isn't cpsr. GDB passes CPSR in word 25. There are 9 words in
14633 + * between which are unused. Passing only 26 words to gdb is sufficient.
14634 + * GDB can figure out that floating point registers are not passed.
14635 + * GDB_MAX_REGS should be 26.
14637 +#define GDB_MAX_REGS (26)
14639 +#define KGDB_MAX_NO_CPUS 1
14640 +#define BUFMAX 400
14641 +#define NUMREGBYTES (GDB_MAX_REGS << 2)
14642 +#define NUMCRITREGBYTES (32 << 2)
14660 +#define _CPSR (GDB_MAX_REGS - 1)
14662 +/* So that we can denote the end of a frame for tracing, in the simple
14664 +#define CFI_END_FRAME(func) __CFI_END_FRAME(_PC,_SP,func)
14666 +#endif /* __ASM_KGDB_H__ */
14667 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/include/asm-arm/system.h linux-2.6.18.kgdb/include/asm-arm/system.h
14668 --- linux-2.6.18/include/asm-arm/system.h 2006-09-20 07:42:06.000000000 +0400
14669 +++ linux-2.6.18.kgdb/include/asm-arm/system.h 2008-06-10 16:19:51.000000000 +0400
14670 @@ -444,6 +444,47 @@ static inline unsigned long __xchg(unsig
14671 extern void disable_hlt(void);
14672 extern void enable_hlt(void);
14674 +#define __HAVE_ARCH_CMPXCHG 1
14676 +#include <asm/types.h>
14678 +static inline unsigned long __cmpxchg_u32(volatile int *m, unsigned long old,
14679 + unsigned long new)
14682 + unsigned long flags;
14684 + local_irq_save(flags);
14686 + if (retval == old)
14688 + local_irq_restore(flags); /* implies memory barrier */
14693 +/* This function doesn't exist, so you'll get a linker error
14694 + if something tries to do an invalid cmpxchg(). */
14695 +extern void __cmpxchg_called_with_bad_pointer(void);
14697 +static inline unsigned long __cmpxchg(volatile void * ptr, unsigned long old,
14698 + unsigned long new, int size)
14702 + return __cmpxchg_u32(ptr, old, new);
14704 + __cmpxchg_called_with_bad_pointer();
14708 +#define cmpxchg(ptr,o,n) \
14710 + __typeof__(*(ptr)) _o_ = (o); \
14711 + __typeof__(*(ptr)) _n_ = (n); \
14712 + (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \
14713 + (unsigned long)_n_, sizeof(*(ptr))); \
14715 #endif /* __ASSEMBLY__ */
14717 #define arch_align_stack(x) (x)
14718 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/include/asm-generic/kgdb.h linux-2.6.18.kgdb/include/asm-generic/kgdb.h
14719 --- linux-2.6.18/include/asm-generic/kgdb.h 1970-01-01 03:00:00.000000000 +0300
14720 +++ linux-2.6.18.kgdb/include/asm-generic/kgdb.h 2008-06-10 16:19:58.000000000 +0400
14723 + * include/asm-generic/kgdb.h
14725 + * This provides the assembly level information so that KGDB can provide
14726 + * a GDB that has been patched with enough information to know to stop
14727 + * trying to unwind the function.
14729 + * Author: Tom Rini <trini@kernel.crashing.org>
14731 + * 2005 (c) MontaVista Software, Inc. This file is licensed under the terms
14732 + * of the GNU General Public License version 2. This program is licensed
14733 + * "as is" without any warranty of any kind, whether express or implied.
14736 +#ifndef __ASM_GENERIC_KGDB_H__
14737 +#define __ASM_GENERIC_KGDB_H__
14739 +#include <linux/dwarf2-lang.h>
14740 +#ifdef __ASSEMBLY__
14741 +#ifdef CONFIG_KGDB
14742 +/* This MUST be put at the end of a given assembly function */
14743 +#define __CFI_END_FRAME(pc,sp,func) \
14744 +CAT3(.Lend_,func,:) \
14745 + CFI_preamble(func,pc,0x1,-DATA_ALIGN_FACTOR) \
14746 + CFA_define_reference(sp, 0) \
14747 + CFA_undefine_reg(pc) \
14748 + CFI_postamble() \
14749 + FDE_preamble(func,func,CAT3(.Lend,_,func)) \
14752 +#define __CFI_END_FRAME(pc,sp,fn)
14753 +#endif /* CONFIG_KGDB */
14754 +#endif /* __ASSEMBLY__ */
14755 +#endif /* __ASM_GENERIC_KGDB_H__ */
14756 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/include/asm-i386/kdebug.h linux-2.6.18.kgdb/include/asm-i386/kdebug.h
14757 --- linux-2.6.18/include/asm-i386/kdebug.h 2006-09-20 07:42:06.000000000 +0400
14758 +++ linux-2.6.18.kgdb/include/asm-i386/kdebug.h 2008-06-10 16:19:17.000000000 +0400
14759 @@ -39,6 +39,7 @@ enum die_val {
14763 + DIE_PAGE_FAULT_NO_CONTEXT,
14766 static inline int notify_die(enum die_val val, const char *str,
14767 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/include/asm-i386/kgdb.h linux-2.6.18.kgdb/include/asm-i386/kgdb.h
14768 --- linux-2.6.18/include/asm-i386/kgdb.h 1970-01-01 03:00:00.000000000 +0300
14769 +++ linux-2.6.18.kgdb/include/asm-i386/kgdb.h 2008-06-10 16:19:58.000000000 +0400
14772 +#ifndef _ASM_KGDB_H_
14773 +#define _ASM_KGDB_H_
14776 + * Copyright (C) 2001-2004 Amit S. Kale
14779 +#include <asm-generic/kgdb.h>
14782 + * Note that this register image is in a different order than
14783 + * the register image that Linux produces at interrupt time.
14785 + * Linux's register image is defined by struct pt_regs in ptrace.h.
14786 + * Just why GDB uses a different order is a historical mystery.
14807 +/* So that we can denote the end of a frame for tracing, in the simple
14809 +#define CFI_END_FRAME(func) __CFI_END_FRAME(_EIP,_ESP,func)
14811 +#ifndef __ASSEMBLY__
14812 +/************************************************************************/
14813 +/* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/
14814 +/* at least NUMREGBYTES*2 are needed for register packets */
14815 +/* Longer buffer is needed to list all threads */
14816 +#define BUFMAX 1024
14818 +/* Number of bytes of registers. */
14819 +#define NUMREGBYTES 64
14820 +/* Number of bytes of registers we need to save for a setjmp/longjmp. */
14821 +#define NUMCRITREGBYTES 24
14823 +#define BREAKPOINT() asm(" int $3");
14824 +#define BREAK_INSTR_SIZE 1
14825 +#define CACHE_FLUSH_IS_SAFE 1
14826 +#endif /* !__ASSEMBLY__ */
14827 +#endif /* _ASM_KGDB_H_ */
14828 +#endif /* __KERNEL__ */
14829 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/include/asm-ia64/kdebug.h linux-2.6.18.kgdb/include/asm-ia64/kdebug.h
14830 --- linux-2.6.18/include/asm-ia64/kdebug.h 2006-09-20 07:42:06.000000000 +0400
14831 +++ linux-2.6.18.kgdb/include/asm-ia64/kdebug.h 2008-06-10 16:19:32.000000000 +0400
14832 @@ -72,6 +72,7 @@ enum die_val {
14836 + DIE_PAGE_FAULT_NO_CONTEXT,
14839 static inline int notify_die(enum die_val val, char *str, struct pt_regs *regs,
14840 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/include/asm-ia64/kgdb.h linux-2.6.18.kgdb/include/asm-ia64/kgdb.h
14841 --- linux-2.6.18/include/asm-ia64/kgdb.h 1970-01-01 03:00:00.000000000 +0300
14842 +++ linux-2.6.18.kgdb/include/asm-ia64/kgdb.h 2008-06-10 16:19:32.000000000 +0400
14845 +#ifndef _ASM_KGDB_H_
14846 +#define _ASM_KGDB_H_
14849 + * Copyright (C) 2001-2004 Amit S. Kale
14852 +#include <linux/threads.h>
14854 +/************************************************************************/
14855 +/* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/
14856 +/* at least NUMREGBYTES*2 are needed for register packets */
14857 +/* Longer buffer is needed to list all threads */
14858 +#define BUFMAX 1024
14860 +/* Number of bytes of registers. We set this to 0 so that certain GDB
14861 + * packets will fail, forcing the use of others, which are more friendly
14863 +#define NUMREGBYTES 0
14865 +#define NUMCRITREGBYTES (70*8)
14866 +#define JMP_REGS_ALIGNMENT __attribute__ ((aligned (16)))
14868 +#define BREAKNUM 0x00003333300LL
14869 +#define KGDBBREAKNUM 0x6665UL
14870 +#define BREAKPOINT() asm volatile ("break.m 0x6665")
14871 +#define BREAK_INSTR_SIZE 16
14872 +#define CACHE_FLUSH_IS_SAFE 1
14875 +extern volatile int kgdb_hwbreak_sstep[NR_CPUS];
14876 +extern void smp_send_nmi_allbutself(void);
14877 +extern void kgdb_wait_ipi(struct pt_regs *);
14878 +#endif /* _ASM_KGDB_H_ */
14879 +#endif /* __KERNEL__ */
14880 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/include/asm-mips/kdebug.h linux-2.6.18.kgdb/include/asm-mips/kdebug.h
14881 --- linux-2.6.18/include/asm-mips/kdebug.h 1970-01-01 03:00:00.000000000 +0300
14882 +++ linux-2.6.18.kgdb/include/asm-mips/kdebug.h 2008-06-10 16:19:28.000000000 +0400
14886 + * Copyright (C) 2004 MontaVista Software Inc.
14887 + * Author: Manish Lachwani, mlachwani@mvista.com or manish@koffee-break.com
14889 + * This program is free software; you can redistribute it and/or modify it
14890 + * under the terms of the GNU General Public License as published by the
14891 + * Free Software Foundation; either version 2 of the License, or (at your
14892 + * option) any later version.
14895 +#ifndef _MIPS_KDEBUG_H
14896 +#define _MIPS_KDEBUG_H
14898 +#include <linux/notifier.h>
14903 + struct pt_regs *regs;
14908 +int register_die_notifier(struct notifier_block *nb);
14909 +extern struct notifier_block *mips_die_chain;
14921 + * trap number can be computed from regs and signr can be computed using
14922 + * compute_signal()
14924 +static inline int notify_die(enum die_val val,char *str,struct pt_regs *regs,long err)
14926 + struct die_args args = { .regs=regs, .str=str, .err=err };
14927 + return notifier_call_chain(&mips_die_chain, val, &args);
14930 +#endif /* _MIPS_KDEBUG_H */
14931 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/include/asm-mips/kgdb.h linux-2.6.18.kgdb/include/asm-mips/kgdb.h
14932 --- linux-2.6.18/include/asm-mips/kgdb.h 1970-01-01 03:00:00.000000000 +0300
14933 +++ linux-2.6.18.kgdb/include/asm-mips/kgdb.h 2008-06-10 16:19:58.000000000 +0400
14936 +#ifndef _ASM_KGDB_H_
14937 +#define _ASM_KGDB_H_
14939 +#ifndef __ASSEMBLY__
14940 +#if (_MIPS_ISA == _MIPS_ISA_MIPS1) || (_MIPS_ISA == _MIPS_ISA_MIPS2)
14941 +typedef u32 gdb_reg_t;
14942 +#elif (_MIPS_ISA == _MIPS_ISA_MIPS3) || (_MIPS_ISA == _MIPS_ISA_MIPS4)
14943 +typedef u64 gdb_reg_t;
14946 +#endif /* _MIPS_ISA */
14948 +#include <asm-generic/kgdb.h>
14950 +#ifndef __ASSEMBLY__
14951 +#define BUFMAX 2048
14952 +#define NUMREGBYTES (90*sizeof(gdb_reg_t))
14953 +#define NUMCRITREGBYTES (12*sizeof(gdb_reg_t))
14954 +#define BREAK_INSTR_SIZE 4
14955 +#define BREAKPOINT() __asm__ __volatile__( \
14956 + ".globl breakinst\n\t" \
14957 + ".set\tnoreorder\n\t" \
14959 + "breakinst:\tbreak\n\t" \
14962 +#define CACHE_FLUSH_IS_SAFE 0
14964 +extern int kgdb_early_setup;
14966 +#endif /* !__ASSEMBLY__ */
14967 +#endif /* _ASM_KGDB_H_ */
14968 +#endif /* __KERNEL__ */
14969 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/include/asm-powerpc/kgdb.h linux-2.6.18.kgdb/include/asm-powerpc/kgdb.h
14970 --- linux-2.6.18/include/asm-powerpc/kgdb.h 1970-01-01 03:00:00.000000000 +0300
14971 +++ linux-2.6.18.kgdb/include/asm-powerpc/kgdb.h 2008-06-10 16:19:58.000000000 +0400
14974 + * include/asm-powerpc/kgdb.h
14976 + * The PowerPC (32/64) specific defines / externs for KGDB. Based on
14977 + * the previous 32bit and 64bit specific files, which had the following
14980 + * PPC64 Mods (C) 2005 Frank Rowand (frowand@mvista.com)
14981 + * PPC Mods (C) 2004 Tom Rini (trini@mvista.com)
14982 + * PPC Mods (C) 2003 John Whitney (john.whitney@timesys.com)
14983 + * PPC Mods (C) 1998 Michael Tesch (tesch@cs.wisc.edu)
14986 + * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
14987 + * Author: Tom Rini <trini@kernel.crashing.org>
14989 + * 2006 (c) MontaVista Software, Inc. This file is licensed under
14990 + * the terms of the GNU General Public License version 2. This program
14991 + * is licensed "as is" without any warranty of any kind, whether express
14995 +#ifndef __POWERPC_KGDB_H__
14996 +#define __POWERPC_KGDB_H__
14998 +#include <asm-generic/kgdb.h>
14999 +#ifndef __ASSEMBLY__
15001 +#define BREAK_INSTR_SIZE 4
15002 +#define BUFMAX ((NUMREGBYTES * 2) + 512)
15003 +#define OUTBUFMAX ((NUMREGBYTES * 2) + 512)
15004 +#define BREAKPOINT() asm(".long 0x7d821008"); /* twge r2, r2 */
15005 +#define CACHE_FLUSH_IS_SAFE 1
15007 +/* The number bytes of registers we have to save depends on a few
15008 + * things. For 64bit we default to not including vector registers and
15009 + * vector state registers. */
15010 +#ifdef CONFIG_PPC64
15012 + * 64 bit (8 byte) registers:
15013 + * 32 gpr, 32 fpr, nip, msr, link, ctr
15014 + * 32 bit (4 byte) registers:
15015 + * ccr, xer, fpscr
15017 +#define NUMREGBYTES ((68 * 8) + (3 * 4))
15019 +/* The following adds in vector registers and vector state registers. */
15020 +/* 128 bit (16 byte) registers:
15022 + * 64 bit (8 byte) registers:
15023 + * 32 gpr, 32 fpr, nip, msr, link, ctr
15024 + * 32 bit (4 byte) registers:
15025 + * ccr, xer, fpscr, vscr, vrsave
15027 +#define NUMREGBYTES ((128 * 16) + (68 * 8) + (5 * 4))
15029 +#define NUMCRITREGBYTES 184
15030 +#else /* CONFIG_PPC32 */
15031 +/* On non-E500 family PPC32 we determine the size by picking the last
15032 + * register we need, but on E500 we skip sections so we list what we
15033 + * need to store, and add it up. */
15034 +#ifndef CONFIG_E500
15035 +#define MAXREG (PT_FPSCR+1)
15037 +/* 32 GPRs (8 bytes), nip, msr, ccr, link, ctr, xer, acc (8 bytes), spefscr*/
15038 +#define MAXREG ((32*2)+6+2+1)
15040 +#define NUMREGBYTES (MAXREG * sizeof(int))
15041 +/* CR/LR, R1, R2, R13-R31 inclusive. */
15042 +#define NUMCRITREGBYTES (23 * sizeof(int))
15043 +#endif /* 32/64 */
15044 +#endif /* !(__ASSEMBLY__) */
15045 +#endif /* !__POWERPC_KGDB_H__ */
15046 +#endif /* __KERNEL__ */
15047 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/include/asm-ppc/kgdb.h linux-2.6.18.kgdb/include/asm-ppc/kgdb.h
15048 --- linux-2.6.18/include/asm-ppc/kgdb.h 2006-09-20 07:42:06.000000000 +0400
15049 +++ linux-2.6.18.kgdb/include/asm-ppc/kgdb.h 2008-06-10 16:19:22.000000000 +0400
15052 - * kgdb.h: Defines and declarations for serial line source level
15053 - * remote debugging of the Linux kernel using gdb.
15055 - * PPC Mods (C) 1998 Michael Tesch (tesch@cs.wisc.edu)
15057 - * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
15060 -#ifndef _PPC_KGDB_H
15061 -#define _PPC_KGDB_H
15063 +#ifndef __PPC_KGDB_H__
15064 +#define __PPC_KGDB_H__
15065 +#include <asm-powerpc/kgdb.h>
15066 #ifndef __ASSEMBLY__
15068 -/* Things specific to the gen550 backend. */
15071 -extern void gen550_progress(char *, unsigned short);
15072 -extern void gen550_kgdb_map_scc(void);
15073 -extern void gen550_init(int, struct uart_port *);
15075 -/* Things specific to the pmac backend. */
15076 -extern void zs_kgdb_hook(int tty_num);
15078 -/* To init the kgdb engine. (called by serial hook)*/
15079 -extern void set_debug_traps(void);
15081 -/* To enter the debugger explicitly. */
15082 -extern void breakpoint(void);
15084 -/* For taking exceptions
15085 - * these are defined in traps.c
15087 -extern int (*debugger)(struct pt_regs *regs);
15088 + /* For taking exceptions
15089 + * these are defined in traps.c
15092 +extern void (*debugger)(struct pt_regs *regs);
15093 extern int (*debugger_bpt)(struct pt_regs *regs);
15094 extern int (*debugger_sstep)(struct pt_regs *regs);
15095 extern int (*debugger_iabr_match)(struct pt_regs *regs);
15096 extern int (*debugger_dabr_match)(struct pt_regs *regs);
15097 extern void (*debugger_fault_handler)(struct pt_regs *regs);
15099 -/* What we bring to the party */
15100 -int kgdb_bpt(struct pt_regs *regs);
15101 -int kgdb_sstep(struct pt_regs *regs);
15102 -void kgdb(struct pt_regs *regs);
15103 -int kgdb_iabr_match(struct pt_regs *regs);
15104 -int kgdb_dabr_match(struct pt_regs *regs);
15107 - * external low-level support routines (ie macserial.c)
15109 -extern void kgdb_interruptible(int); /* control interrupts from serial */
15110 -extern void putDebugChar(char); /* write a single character */
15111 -extern char getDebugChar(void); /* read and return a single char */
15113 -#endif /* !(__ASSEMBLY__) */
15114 -#endif /* !(_PPC_KGDB_H) */
15115 +#endif /* !__ASSEMBLY__ */
15116 +#endif /* __PPC_KGDB_H__ */
15117 #endif /* __KERNEL__ */
15118 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/include/asm-ppc/machdep.h linux-2.6.18.kgdb/include/asm-ppc/machdep.h
15119 --- linux-2.6.18/include/asm-ppc/machdep.h 2006-09-20 07:42:06.000000000 +0400
15120 +++ linux-2.6.18.kgdb/include/asm-ppc/machdep.h 2008-06-10 16:19:22.000000000 +0400
15121 @@ -72,9 +72,7 @@ struct machdep_calls {
15122 unsigned long (*find_end_of_memory)(void);
15123 void (*setup_io_mappings)(void);
15125 - void (*early_serial_map)(void);
15126 void (*progress)(char *, unsigned short);
15127 - void (*kgdb_map_scc)(void);
15129 unsigned char (*nvram_read_val)(int addr);
15130 void (*nvram_write_val)(int addr, unsigned char val);
15131 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/include/asm-ppc/mv64x60.h linux-2.6.18.kgdb/include/asm-ppc/mv64x60.h
15132 --- linux-2.6.18/include/asm-ppc/mv64x60.h 2006-09-20 07:42:06.000000000 +0400
15133 +++ linux-2.6.18.kgdb/include/asm-ppc/mv64x60.h 2008-06-10 16:19:22.000000000 +0400
15134 @@ -348,6 +348,8 @@ u32 mv64x60_calc_mem_size(struct mv64x60
15136 void mv64x60_progress_init(u32 base);
15137 void mv64x60_mpsc_progress(char *s, unsigned short hex);
15138 +struct platform_device * mv64x60_early_get_pdev_data(const char *name,
15139 + int id, int remove);
15141 extern struct mv64x60_32bit_window
15142 gt64260_32bit_windows[MV64x60_32BIT_WIN_COUNT];
15143 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/include/asm-ppc/mv64x60_defs.h linux-2.6.18.kgdb/include/asm-ppc/mv64x60_defs.h
15144 --- linux-2.6.18/include/asm-ppc/mv64x60_defs.h 2006-09-20 07:42:06.000000000 +0400
15145 +++ linux-2.6.18.kgdb/include/asm-ppc/mv64x60_defs.h 2008-06-10 16:19:22.000000000 +0400
15147 #define MV64x60_IRQ_I2C 37
15148 #define MV64x60_IRQ_BRG 39
15149 #define MV64x60_IRQ_MPSC_0 40
15150 -#define MV64x60_IRQ_MPSC_1 42
15151 +#define MV64360_IRQ_MPSC_1 41
15152 +#define GT64260_IRQ_MPSC_1 42
15153 #define MV64x60_IRQ_COMM 43
15154 #define MV64x60_IRQ_P0_GPP_0_7 56
15155 #define MV64x60_IRQ_P0_GPP_8_15 57
15156 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/include/asm-sh/kgdb.h linux-2.6.18.kgdb/include/asm-sh/kgdb.h
15157 --- linux-2.6.18/include/asm-sh/kgdb.h 2006-09-20 07:42:06.000000000 +0400
15158 +++ linux-2.6.18.kgdb/include/asm-sh/kgdb.h 2008-06-10 16:19:58.000000000 +0400
15160 * May be copied or modified under the terms of the GNU General Public
15161 * License. See linux/COPYING for more information.
15163 - * Based on original code by Glenn Engel, Jim Kingdon,
15164 - * David Grothe <dave@gcom.com>, Tigran Aivazian, <tigran@sco.com> and
15165 - * Amit S. Kale <akale@veritas.com>
15167 - * Super-H port based on sh-stub.c (Ben Lee and Steve Chamberlain) by
15168 - * Henry Bell <henry.bell@st.com>
15170 - * Header file for low-level support for remote debug using GDB.
15171 + * Based on a file that was modified or based on files by: Glenn Engel,
15172 + * Jim Kingdon, David Grothe <dave@gcom.com>, Tigran Aivazian <tigran@sco.com>,
15173 + * Amit S. Kale <akale@veritas.com>, sh-stub.c from Ben Lee and
15174 + * Steve Chamberlain, Henry Bell <henry.bell@st.com>
15176 + * Maintainer: Tom Rini <trini@kernel.crashing.org>
15183 -#include <asm/ptrace.h>
15186 +#include <asm-generic/kgdb.h>
15187 +/* Based on sh-gdb.c from gdb-6.1, Glenn
15188 + Engel at HP Ben Lee and Steve Chamberlain */
15189 +#define NUMREGBYTES 112 /* 92 */
15190 +#define NUMCRITREGBYTES (9 << 2)
15191 +#define BUFMAX 400
15193 -/* Same as pt_regs but has vbr in place of syscall_nr */
15194 +#ifndef __ASSEMBLY__
15196 unsigned long regs[16];
15199 - unsigned long sr;
15201 + unsigned long vbr;
15202 unsigned long mach;
15203 unsigned long macl;
15204 - unsigned long vbr;
15208 -extern char kgdb_in_gdb_mode;
15209 -extern int kgdb_done_init;
15210 -extern int kgdb_enabled;
15211 -extern int kgdb_nofault; /* Ignore bus errors (in gdb mem access) */
15212 -extern int kgdb_halt; /* Execute initial breakpoint at startup */
15213 -extern char in_nmi; /* Debounce flag to prevent NMI reentry*/
15216 -extern int kgdb_portnum;
15217 -extern int kgdb_baud;
15218 -extern char kgdb_parity;
15219 -extern char kgdb_bits;
15220 -extern int kgdb_console_setup(struct console *, char *);
15222 -/* Init and interface stuff */
15223 -extern int kgdb_init(void);
15224 -extern int (*kgdb_serial_setup)(void);
15225 -extern int (*kgdb_getchar)(void);
15226 -extern void (*kgdb_putchar)(int);
15228 -struct kgdb_sermap {
15231 - int (*setup_fn)(struct console *, char *);
15232 - struct kgdb_sermap *next;
15233 + unsigned long sr;
15235 -extern void kgdb_register_sermap(struct kgdb_sermap *map);
15236 -extern struct kgdb_sermap *kgdb_porttype;
15238 -/* Trap functions */
15239 -typedef void (kgdb_debug_hook_t)(struct pt_regs *regs);
15240 -typedef void (kgdb_bus_error_hook_t)(void);
15241 -extern kgdb_debug_hook_t *kgdb_debug_hook;
15242 -extern kgdb_bus_error_hook_t *kgdb_bus_err_hook;
15244 -extern void breakpoint(void);
15248 -void kgdb_console_write(struct console *co, const char *s, unsigned count);
15249 -void kgdb_console_init(void);
15251 -/* Prototypes for jmp fns */
15253 -typedef int jmp_buf[_JBLEN];
15254 -extern void longjmp(jmp_buf __jmpb, int __retval);
15255 -extern int setjmp(jmp_buf __jmpb);
15257 -/* Variadic macro to print our own message to the console */
15258 -#define KGDB_PRINTK(...) printk("KGDB: " __VA_ARGS__)
15260 -/* Forced breakpoint */
15261 -#define BREAKPOINT() do { \
15262 - if (kgdb_enabled) { \
15263 - asm volatile("trapa #0xff"); \
15266 +#define BREAKPOINT() asm("trapa #0xff");
15267 +#define BREAK_INSTR_SIZE 2
15268 +#define CACHE_FLUSH_IS_SAFE 1
15270 /* KGDB should be able to flush all kernel text space */
15271 #if defined(CONFIG_CPU_SH4)
15272 @@ -102,30 +48,5 @@ extern int setjmp(jmp_buf __jmpb);
15274 #define kgdb_flush_icache_range(start, end) do { } while (0)
15277 -/* Kernel assert macros */
15278 -#ifdef CONFIG_KGDB_KERNEL_ASSERTS
15280 -/* Predefined conditions */
15281 -#define KA_VALID_ERRNO(errno) ((errno) > 0 && (errno) <= EMEDIUMTYPE)
15282 -#define KA_VALID_PTR_ERR(ptr) KA_VALID_ERRNO(-PTR_ERR(ptr))
15283 -#define KA_VALID_KPTR(ptr) (!(ptr) || \
15284 - ((void *)(ptr) >= (void *)PAGE_OFFSET && \
15285 - (void *)(ptr) < ERR_PTR(-EMEDIUMTYPE)))
15286 -#define KA_VALID_PTRORERR(errptr) \
15287 - (KA_VALID_KPTR(errptr) || KA_VALID_PTR_ERR(errptr))
15288 -#define KA_HELD_GKL() (current->lock_depth >= 0)
15290 -/* The actual assert */
15291 -#define KGDB_ASSERT(condition, message) do { \
15292 - if (!(condition) && (kgdb_enabled)) { \
15293 - KGDB_PRINTK("Assertion failed at %s:%d: %s\n", \
15294 - __FILE__, __LINE__, message);\
15299 -#define KGDB_ASSERT(condition, message)
15302 +#endif /* !__ASSEMBLY__ */
15304 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/include/asm-sh/system.h linux-2.6.18.kgdb/include/asm-sh/system.h
15305 --- linux-2.6.18/include/asm-sh/system.h 2006-09-20 07:42:06.000000000 +0400
15306 +++ linux-2.6.18.kgdb/include/asm-sh/system.h 2008-06-10 16:19:47.000000000 +0400
15308 * Copyright (C) 2002 Paul Mundt
15311 +#include <asm/types.h>
15314 * switch_to() should switch tasks to task nr n, first
15315 @@ -260,6 +261,45 @@ static __inline__ unsigned long __xchg(u
15319 +static inline unsigned long __cmpxchg_u32(volatile int * m, unsigned long old,
15320 + unsigned long new)
15323 + unsigned long flags;
15325 + local_irq_save(flags);
15327 + if (retval == old)
15329 + local_irq_restore(flags); /* implies memory barrier */
15333 +/* This function doesn't exist, so you'll get a linker error
15334 + * if something tries to do an invalid cmpxchg(). */
15335 +extern void __cmpxchg_called_with_bad_pointer(void);
15337 +#define __HAVE_ARCH_CMPXCHG 1
15339 +static inline unsigned long __cmpxchg(volatile void * ptr, unsigned long old,
15340 + unsigned long new, int size)
15344 + return __cmpxchg_u32(ptr, old, new);
15346 + __cmpxchg_called_with_bad_pointer();
15350 +#define cmpxchg(ptr,o,n) \
15352 + __typeof__(*(ptr)) _o_ = (o); \
15353 + __typeof__(*(ptr)) _n_ = (n); \
15354 + (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \
15355 + (unsigned long)_n_, sizeof(*(ptr))); \
15359 * disable hlt during certain critical i/o operations
15361 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/include/asm-x86_64/kdebug.h linux-2.6.18.kgdb/include/asm-x86_64/kdebug.h
15362 --- linux-2.6.18/include/asm-x86_64/kdebug.h 2006-09-20 07:42:06.000000000 +0400
15363 +++ linux-2.6.18.kgdb/include/asm-x86_64/kdebug.h 2008-06-10 16:19:36.000000000 +0400
15364 @@ -34,6 +34,7 @@ enum die_val {
15368 + DIE_PAGE_FAULT_NO_CONTEXT,
15371 static inline int notify_die(enum die_val val, const char *str,
15372 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/include/asm-x86_64/kgdb.h linux-2.6.18.kgdb/include/asm-x86_64/kgdb.h
15373 --- linux-2.6.18/include/asm-x86_64/kgdb.h 1970-01-01 03:00:00.000000000 +0300
15374 +++ linux-2.6.18.kgdb/include/asm-x86_64/kgdb.h 2008-06-10 16:19:58.000000000 +0400
15377 +#ifndef _ASM_KGDB_H_
15378 +#define _ASM_KGDB_H_
15381 + * Copyright (C) 2001-2004 Amit S. Kale
15384 +#include <asm-generic/kgdb.h>
15387 + * Note that this register image is in a different order than
15388 + * the register image that Linux produces at interrupt time.
15390 + * Linux's register image is defined by struct pt_regs in ptrace.h.
15391 + * Just why GDB uses a different order is a historical mystery.
15412 +/* Number of bytes of registers. */
15413 +#define NUMREGBYTES ((_PS+1)*8)
15414 +#define NUMCRITREGBYTES (8 * 8) /* 8 registers. */
15416 +/* Help GDB to know when to stop backtracing. */
15417 +#define CFI_END_FRAME(func) __CFI_END_FRAME(_PC,_RSP,func)
15418 +#ifndef __ASSEMBLY__
15419 +/* BUFMAX defines the maximum number of characters in inbound/outbound
15420 + * buffers at least NUMREGBYTES*2 are needed for register packets, and
15421 + * a longer buffer is needed to list all threads. */
15422 +#define BUFMAX 1024
15423 +#define BREAKPOINT() asm(" int $3");
15424 +#define CHECK_EXCEPTION_STACK() ((&__get_cpu_var(init_tss))[0].ist[0])
15425 +#define BREAK_INSTR_SIZE 1
15426 +#define CACHE_FLUSH_IS_SAFE 1
15427 +#endif /* !__ASSEMBLY__ */
15428 +#endif /* _ASM_KGDB_H_ */
15429 +#endif /* __KERNEL__ */
15430 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/include/asm-x86_64/system.h linux-2.6.18.kgdb/include/asm-x86_64/system.h
15431 --- linux-2.6.18/include/asm-x86_64/system.h 2006-09-20 07:42:06.000000000 +0400
15432 +++ linux-2.6.18.kgdb/include/asm-x86_64/system.h 2008-06-10 16:19:42.000000000 +0400
15434 ,"rcx","rbx","rdx","r8","r9","r10","r11","r12","r13","r14","r15"
15436 #define switch_to(prev,next,last) \
15437 - asm volatile(SAVE_CONTEXT \
15438 + asm volatile(".globl __switch_to_begin\n\t" \
15439 + "__switch_to_begin:\n\t" \
15441 "movq %%rsp,%P[threadrsp](%[prev])\n\t" /* save RSP */ \
15442 "movq %P[threadrsp](%[next]),%%rsp\n\t" /* restore RSP */ \
15443 "call __switch_to\n\t" \
15445 "movq %%rax,%%rdi\n\t" \
15446 "jc ret_from_fork\n\t" \
15448 + ".globl __switch_to_end\n\t" \
15449 + "__switch_to_end:\n\t" \
15451 : [next] "S" (next), [prev] "D" (prev), \
15452 [threadrsp] "i" (offsetof(struct task_struct, thread.rsp)), \
15453 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/include/linux/dwarf2-defs.h linux-2.6.18.kgdb/include/linux/dwarf2-defs.h
15454 --- linux-2.6.18/include/linux/dwarf2-defs.h 1970-01-01 03:00:00.000000000 +0300
15455 +++ linux-2.6.18.kgdb/include/linux/dwarf2-defs.h 2008-06-10 16:22:59.000000000 +0400
15457 +#ifndef _ELF_DWARF_H
15458 +/* Machine generated from dwarf2.h by scripts/dwarfh.awk */
15459 +#define _ELF_DWARF2_H
15460 +#define DW_TAG_padding 0x00
15461 +#define DW_TAG_array_type 0x01
15462 +#define DW_TAG_class_type 0x02
15463 +#define DW_TAG_entry_point 0x03
15464 +#define DW_TAG_enumeration_type 0x04
15465 +#define DW_TAG_formal_parameter 0x05
15466 +#define DW_TAG_imported_declaration 0x08
15467 +#define DW_TAG_label 0x0a
15468 +#define DW_TAG_lexical_block 0x0b
15469 +#define DW_TAG_member 0x0d
15470 +#define DW_TAG_pointer_type 0x0f
15471 +#define DW_TAG_reference_type 0x10
15472 +#define DW_TAG_compile_unit 0x11
15473 +#define DW_TAG_string_type 0x12
15474 +#define DW_TAG_structure_type 0x13
15475 +#define DW_TAG_subroutine_type 0x15
15476 +#define DW_TAG_typedef 0x16
15477 +#define DW_TAG_union_type 0x17
15478 +#define DW_TAG_unspecified_parameters 0x18
15479 +#define DW_TAG_variant 0x19
15480 +#define DW_TAG_common_block 0x1a
15481 +#define DW_TAG_common_inclusion 0x1b
15482 +#define DW_TAG_inheritance 0x1c
15483 +#define DW_TAG_inlined_subroutine 0x1d
15484 +#define DW_TAG_module 0x1e
15485 +#define DW_TAG_ptr_to_member_type 0x1f
15486 +#define DW_TAG_set_type 0x20
15487 +#define DW_TAG_subrange_type 0x21
15488 +#define DW_TAG_with_stmt 0x22
15489 +#define DW_TAG_access_declaration 0x23
15490 +#define DW_TAG_base_type 0x24
15491 +#define DW_TAG_catch_block 0x25
15492 +#define DW_TAG_const_type 0x26
15493 +#define DW_TAG_constant 0x27
15494 +#define DW_TAG_enumerator 0x28
15495 +#define DW_TAG_file_type 0x29
15496 +#define DW_TAG_friend 0x2a
15497 +#define DW_TAG_namelist 0x2b
15498 +#define DW_TAG_namelist_item 0x2c
15499 +#define DW_TAG_packed_type 0x2d
15500 +#define DW_TAG_subprogram 0x2e
15501 +#define DW_TAG_template_type_param 0x2f
15502 +#define DW_TAG_template_value_param 0x30
15503 +#define DW_TAG_thrown_type 0x31
15504 +#define DW_TAG_try_block 0x32
15505 +#define DW_TAG_variant_part 0x33
15506 +#define DW_TAG_variable 0x34
15507 +#define DW_TAG_volatile_type 0x35
15508 +#define DW_TAG_dwarf_procedure 0x36
15509 +#define DW_TAG_restrict_type 0x37
15510 +#define DW_TAG_interface_type 0x38
15511 +#define DW_TAG_namespace 0x39
15512 +#define DW_TAG_imported_module 0x3a
15513 +#define DW_TAG_unspecified_type 0x3b
15514 +#define DW_TAG_partial_unit 0x3c
15515 +#define DW_TAG_imported_unit 0x3d
15516 +#define DW_TAG_MIPS_loop 0x4081
15517 +#define DW_TAG_HP_array_descriptor 0x4090
15518 +#define DW_TAG_format_label 0x4101
15519 +#define DW_TAG_function_template 0x4102
15520 +#define DW_TAG_class_template 0x4103
15521 +#define DW_TAG_GNU_BINCL 0x4104
15522 +#define DW_TAG_GNU_EINCL 0x4105
15523 +#define DW_TAG_upc_shared_type 0x8765
15524 +#define DW_TAG_upc_strict_type 0x8766
15525 +#define DW_TAG_upc_relaxed_type 0x8767
15526 +#define DW_TAG_PGI_kanji_type 0xA000
15527 +#define DW_TAG_PGI_interface_block 0xA020
15528 +#define DW_TAG_lo_user 0x4080
15529 +#define DW_TAG_hi_user 0xffff
15530 +#define DW_children_no 0
15531 +#define DW_children_yes 1
15532 +#define DW_FORM_addr 0x01
15533 +#define DW_FORM_block2 0x03
15534 +#define DW_FORM_block4 0x04
15535 +#define DW_FORM_data2 0x05
15536 +#define DW_FORM_data4 0x06
15537 +#define DW_FORM_data8 0x07
15538 +#define DW_FORM_string 0x08
15539 +#define DW_FORM_block 0x09
15540 +#define DW_FORM_block1 0x0a
15541 +#define DW_FORM_data1 0x0b
15542 +#define DW_FORM_flag 0x0c
15543 +#define DW_FORM_sdata 0x0d
15544 +#define DW_FORM_strp 0x0e
15545 +#define DW_FORM_udata 0x0f
15546 +#define DW_FORM_ref_addr 0x10
15547 +#define DW_FORM_ref1 0x11
15548 +#define DW_FORM_ref2 0x12
15549 +#define DW_FORM_ref4 0x13
15550 +#define DW_FORM_ref8 0x14
15551 +#define DW_FORM_ref_udata 0x15
15552 +#define DW_FORM_indirect 0x16
15553 +#define DW_AT_sibling 0x01
15554 +#define DW_AT_location 0x02
15555 +#define DW_AT_name 0x03
15556 +#define DW_AT_ordering 0x09
15557 +#define DW_AT_subscr_data 0x0a
15558 +#define DW_AT_byte_size 0x0b
15559 +#define DW_AT_bit_offset 0x0c
15560 +#define DW_AT_bit_size 0x0d
15561 +#define DW_AT_element_list 0x0f
15562 +#define DW_AT_stmt_list 0x10
15563 +#define DW_AT_low_pc 0x11
15564 +#define DW_AT_high_pc 0x12
15565 +#define DW_AT_language 0x13
15566 +#define DW_AT_member 0x14
15567 +#define DW_AT_discr 0x15
15568 +#define DW_AT_discr_value 0x16
15569 +#define DW_AT_visibility 0x17
15570 +#define DW_AT_import 0x18
15571 +#define DW_AT_string_length 0x19
15572 +#define DW_AT_common_reference 0x1a
15573 +#define DW_AT_comp_dir 0x1b
15574 +#define DW_AT_const_value 0x1c
15575 +#define DW_AT_containing_type 0x1d
15576 +#define DW_AT_default_value 0x1e
15577 +#define DW_AT_inline 0x20
15578 +#define DW_AT_is_optional 0x21
15579 +#define DW_AT_lower_bound 0x22
15580 +#define DW_AT_producer 0x25
15581 +#define DW_AT_prototyped 0x27
15582 +#define DW_AT_return_addr 0x2a
15583 +#define DW_AT_start_scope 0x2c
15584 +#define DW_AT_stride_size 0x2e
15585 +#define DW_AT_upper_bound 0x2f
15586 +#define DW_AT_abstract_origin 0x31
15587 +#define DW_AT_accessibility 0x32
15588 +#define DW_AT_address_class 0x33
15589 +#define DW_AT_artificial 0x34
15590 +#define DW_AT_base_types 0x35
15591 +#define DW_AT_calling_convention 0x36
15592 +#define DW_AT_count 0x37
15593 +#define DW_AT_data_member_location 0x38
15594 +#define DW_AT_decl_column 0x39
15595 +#define DW_AT_decl_file 0x3a
15596 +#define DW_AT_decl_line 0x3b
15597 +#define DW_AT_declaration 0x3c
15598 +#define DW_AT_discr_list 0x3d
15599 +#define DW_AT_encoding 0x3e
15600 +#define DW_AT_external 0x3f
15601 +#define DW_AT_frame_base 0x40
15602 +#define DW_AT_friend 0x41
15603 +#define DW_AT_identifier_case 0x42
15604 +#define DW_AT_macro_info 0x43
15605 +#define DW_AT_namelist_items 0x44
15606 +#define DW_AT_priority 0x45
15607 +#define DW_AT_segment 0x46
15608 +#define DW_AT_specification 0x47
15609 +#define DW_AT_static_link 0x48
15610 +#define DW_AT_type 0x49
15611 +#define DW_AT_use_location 0x4a
15612 +#define DW_AT_variable_parameter 0x4b
15613 +#define DW_AT_virtuality 0x4c
15614 +#define DW_AT_vtable_elem_location 0x4d
15615 +#define DW_AT_allocated 0x4e
15616 +#define DW_AT_associated 0x4f
15617 +#define DW_AT_data_location 0x50
15618 +#define DW_AT_stride 0x51
15619 +#define DW_AT_entry_pc 0x52
15620 +#define DW_AT_use_UTF8 0x53
15621 +#define DW_AT_extension 0x54
15622 +#define DW_AT_ranges 0x55
15623 +#define DW_AT_trampoline 0x56
15624 +#define DW_AT_call_column 0x57
15625 +#define DW_AT_call_file 0x58
15626 +#define DW_AT_call_line 0x59
15627 +#define DW_AT_MIPS_fde 0x2001
15628 +#define DW_AT_MIPS_loop_begin 0x2002
15629 +#define DW_AT_MIPS_tail_loop_begin 0x2003
15630 +#define DW_AT_MIPS_epilog_begin 0x2004
15631 +#define DW_AT_MIPS_loop_unroll_factor 0x2005
15632 +#define DW_AT_MIPS_software_pipeline_depth 0x2006
15633 +#define DW_AT_MIPS_linkage_name 0x2007
15634 +#define DW_AT_MIPS_stride 0x2008
15635 +#define DW_AT_MIPS_abstract_name 0x2009
15636 +#define DW_AT_MIPS_clone_origin 0x200a
15637 +#define DW_AT_MIPS_has_inlines 0x200b
15638 +#define DW_AT_HP_block_index 0x2000
15639 +#define DW_AT_HP_unmodifiable 0x2001
15640 +#define DW_AT_HP_actuals_stmt_list 0x2010
15641 +#define DW_AT_HP_proc_per_section 0x2011
15642 +#define DW_AT_HP_raw_data_ptr 0x2012
15643 +#define DW_AT_HP_pass_by_reference 0x2013
15644 +#define DW_AT_HP_opt_level 0x2014
15645 +#define DW_AT_HP_prof_version_id 0x2015
15646 +#define DW_AT_HP_opt_flags 0x2016
15647 +#define DW_AT_HP_cold_region_low_pc 0x2017
15648 +#define DW_AT_HP_cold_region_high_pc 0x2018
15649 +#define DW_AT_HP_all_variables_modifiable 0x2019
15650 +#define DW_AT_HP_linkage_name 0x201a
15651 +#define DW_AT_HP_prof_flags 0x201b
15652 +#define DW_AT_sf_names 0x2101
15653 +#define DW_AT_src_info 0x2102
15654 +#define DW_AT_mac_info 0x2103
15655 +#define DW_AT_src_coords 0x2104
15656 +#define DW_AT_body_begin 0x2105
15657 +#define DW_AT_body_end 0x2106
15658 +#define DW_AT_GNU_vector 0x2107
15659 +#define DW_AT_VMS_rtnbeg_pd_address 0x2201
15660 +#define DW_AT_upc_threads_scaled 0x3210
15661 +#define DW_AT_PGI_lbase 0x3a00
15662 +#define DW_AT_PGI_soffset 0x3a01
15663 +#define DW_AT_PGI_lstride 0x3a02
15664 +#define DW_AT_lo_user 0x2000 /* Implementation-defined range start. */
15665 +#define DW_AT_hi_user 0x3ff0 /* Implementation-defined range end. */
15666 +#define DW_OP_addr 0x03
15667 +#define DW_OP_deref 0x06
15668 +#define DW_OP_const1u 0x08
15669 +#define DW_OP_const1s 0x09
15670 +#define DW_OP_const2u 0x0a
15671 +#define DW_OP_const2s 0x0b
15672 +#define DW_OP_const4u 0x0c
15673 +#define DW_OP_const4s 0x0d
15674 +#define DW_OP_const8u 0x0e
15675 +#define DW_OP_const8s 0x0f
15676 +#define DW_OP_constu 0x10
15677 +#define DW_OP_consts 0x11
15678 +#define DW_OP_dup 0x12
15679 +#define DW_OP_drop 0x13
15680 +#define DW_OP_over 0x14
15681 +#define DW_OP_pick 0x15
15682 +#define DW_OP_swap 0x16
15683 +#define DW_OP_rot 0x17
15684 +#define DW_OP_xderef 0x18
15685 +#define DW_OP_abs 0x19
15686 +#define DW_OP_and 0x1a
15687 +#define DW_OP_div 0x1b
15688 +#define DW_OP_minus 0x1c
15689 +#define DW_OP_mod 0x1d
15690 +#define DW_OP_mul 0x1e
15691 +#define DW_OP_neg 0x1f
15692 +#define DW_OP_not 0x20
15693 +#define DW_OP_or 0x21
15694 +#define DW_OP_plus 0x22
15695 +#define DW_OP_plus_uconst 0x23
15696 +#define DW_OP_shl 0x24
15697 +#define DW_OP_shr 0x25
15698 +#define DW_OP_shra 0x26
15699 +#define DW_OP_xor 0x27
15700 +#define DW_OP_bra 0x28
15701 +#define DW_OP_eq 0x29
15702 +#define DW_OP_ge 0x2a
15703 +#define DW_OP_gt 0x2b
15704 +#define DW_OP_le 0x2c
15705 +#define DW_OP_lt 0x2d
15706 +#define DW_OP_ne 0x2e
15707 +#define DW_OP_skip 0x2f
15708 +#define DW_OP_lit0 0x30
15709 +#define DW_OP_lit1 0x31
15710 +#define DW_OP_lit2 0x32
15711 +#define DW_OP_lit3 0x33
15712 +#define DW_OP_lit4 0x34
15713 +#define DW_OP_lit5 0x35
15714 +#define DW_OP_lit6 0x36
15715 +#define DW_OP_lit7 0x37
15716 +#define DW_OP_lit8 0x38
15717 +#define DW_OP_lit9 0x39
15718 +#define DW_OP_lit10 0x3a
15719 +#define DW_OP_lit11 0x3b
15720 +#define DW_OP_lit12 0x3c
15721 +#define DW_OP_lit13 0x3d
15722 +#define DW_OP_lit14 0x3e
15723 +#define DW_OP_lit15 0x3f
15724 +#define DW_OP_lit16 0x40
15725 +#define DW_OP_lit17 0x41
15726 +#define DW_OP_lit18 0x42
15727 +#define DW_OP_lit19 0x43
15728 +#define DW_OP_lit20 0x44
15729 +#define DW_OP_lit21 0x45
15730 +#define DW_OP_lit22 0x46
15731 +#define DW_OP_lit23 0x47
15732 +#define DW_OP_lit24 0x48
15733 +#define DW_OP_lit25 0x49
15734 +#define DW_OP_lit26 0x4a
15735 +#define DW_OP_lit27 0x4b
15736 +#define DW_OP_lit28 0x4c
15737 +#define DW_OP_lit29 0x4d
15738 +#define DW_OP_lit30 0x4e
15739 +#define DW_OP_lit31 0x4f
15740 +#define DW_OP_reg0 0x50
15741 +#define DW_OP_reg1 0x51
15742 +#define DW_OP_reg2 0x52
15743 +#define DW_OP_reg3 0x53
15744 +#define DW_OP_reg4 0x54
15745 +#define DW_OP_reg5 0x55
15746 +#define DW_OP_reg6 0x56
15747 +#define DW_OP_reg7 0x57
15748 +#define DW_OP_reg8 0x58
15749 +#define DW_OP_reg9 0x59
15750 +#define DW_OP_reg10 0x5a
15751 +#define DW_OP_reg11 0x5b
15752 +#define DW_OP_reg12 0x5c
15753 +#define DW_OP_reg13 0x5d
15754 +#define DW_OP_reg14 0x5e
15755 +#define DW_OP_reg15 0x5f
15756 +#define DW_OP_reg16 0x60
15757 +#define DW_OP_reg17 0x61
15758 +#define DW_OP_reg18 0x62
15759 +#define DW_OP_reg19 0x63
15760 +#define DW_OP_reg20 0x64
15761 +#define DW_OP_reg21 0x65
15762 +#define DW_OP_reg22 0x66
15763 +#define DW_OP_reg23 0x67
15764 +#define DW_OP_reg24 0x68
15765 +#define DW_OP_reg25 0x69
15766 +#define DW_OP_reg26 0x6a
15767 +#define DW_OP_reg27 0x6b
15768 +#define DW_OP_reg28 0x6c
15769 +#define DW_OP_reg29 0x6d
15770 +#define DW_OP_reg30 0x6e
15771 +#define DW_OP_reg31 0x6f
15772 +#define DW_OP_breg0 0x70
15773 +#define DW_OP_breg1 0x71
15774 +#define DW_OP_breg2 0x72
15775 +#define DW_OP_breg3 0x73
15776 +#define DW_OP_breg4 0x74
15777 +#define DW_OP_breg5 0x75
15778 +#define DW_OP_breg6 0x76
15779 +#define DW_OP_breg7 0x77
15780 +#define DW_OP_breg8 0x78
15781 +#define DW_OP_breg9 0x79
15782 +#define DW_OP_breg10 0x7a
15783 +#define DW_OP_breg11 0x7b
15784 +#define DW_OP_breg12 0x7c
15785 +#define DW_OP_breg13 0x7d
15786 +#define DW_OP_breg14 0x7e
15787 +#define DW_OP_breg15 0x7f
15788 +#define DW_OP_breg16 0x80
15789 +#define DW_OP_breg17 0x81
15790 +#define DW_OP_breg18 0x82
15791 +#define DW_OP_breg19 0x83
15792 +#define DW_OP_breg20 0x84
15793 +#define DW_OP_breg21 0x85
15794 +#define DW_OP_breg22 0x86
15795 +#define DW_OP_breg23 0x87
15796 +#define DW_OP_breg24 0x88
15797 +#define DW_OP_breg25 0x89
15798 +#define DW_OP_breg26 0x8a
15799 +#define DW_OP_breg27 0x8b
15800 +#define DW_OP_breg28 0x8c
15801 +#define DW_OP_breg29 0x8d
15802 +#define DW_OP_breg30 0x8e
15803 +#define DW_OP_breg31 0x8f
15804 +#define DW_OP_regx 0x90
15805 +#define DW_OP_fbreg 0x91
15806 +#define DW_OP_bregx 0x92
15807 +#define DW_OP_piece 0x93
15808 +#define DW_OP_deref_size 0x94
15809 +#define DW_OP_xderef_size 0x95
15810 +#define DW_OP_nop 0x96
15811 +#define DW_OP_push_object_address 0x97
15812 +#define DW_OP_call2 0x98
15813 +#define DW_OP_call4 0x99
15814 +#define DW_OP_call_ref 0x9a
15815 +#define DW_OP_GNU_push_tls_address 0xe0
15816 +#define DW_OP_HP_unknown 0xe0
15817 +#define DW_OP_HP_is_value 0xe1
15818 +#define DW_OP_HP_fltconst4 0xe2
15819 +#define DW_OP_HP_fltconst8 0xe3
15820 +#define DW_OP_HP_mod_range 0xe4
15821 +#define DW_OP_HP_unmod_range 0xe5
15822 +#define DW_OP_HP_tls 0xe6
15823 +#define DW_OP_lo_user 0xe0 /* Implementation-defined range start. */
15824 +#define DW_OP_hi_user 0xff /* Implementation-defined range end. */
15825 +#define DW_ATE_void 0x0
15826 +#define DW_ATE_address 0x1
15827 +#define DW_ATE_boolean 0x2
15828 +#define DW_ATE_complex_float 0x3
15829 +#define DW_ATE_float 0x4
15830 +#define DW_ATE_signed 0x5
15831 +#define DW_ATE_signed_char 0x6
15832 +#define DW_ATE_unsigned 0x7
15833 +#define DW_ATE_unsigned_char 0x8
15834 +#define DW_ATE_imaginary_float 0x9
15835 +#define DW_ATE_HP_float80 0x80
15836 +#define DW_ATE_HP_complex_float80 0x81
15837 +#define DW_ATE_HP_float128 0x82
15838 +#define DW_ATE_HP_complex_float128 0x83
15839 +#define DW_ATE_HP_floathpintel 0x84
15840 +#define DW_ATE_HP_imaginary_float80 0x85
15841 +#define DW_ATE_HP_imaginary_float128 0x86
15842 +#define DW_ATE_lo_user 0x80
15843 +#define DW_ATE_hi_user 0xff
15844 +#define DW_ORD_row_major 0
15845 +#define DW_ORD_col_major 1
15846 +#define DW_ACCESS_public 1
15847 +#define DW_ACCESS_protected 2
15848 +#define DW_ACCESS_private 3
15849 +#define DW_VIS_local 1
15850 +#define DW_VIS_exported 2
15851 +#define DW_VIS_qualified 3
15852 +#define DW_VIRTUALITY_none 0
15853 +#define DW_VIRTUALITY_virtual 1
15854 +#define DW_VIRTUALITY_pure_virtual 2
15855 +#define DW_ID_case_sensitive 0
15856 +#define DW_ID_up_case 1
15857 +#define DW_ID_down_case 2
15858 +#define DW_ID_case_insensitive 3
15859 +#define DW_CC_normal 0x1
15860 +#define DW_CC_program 0x2
15861 +#define DW_CC_nocall 0x3
15862 +#define DW_CC_lo_user 0x40
15863 +#define DW_CC_hi_user 0xff
15864 +#define DW_INL_not_inlined 0
15865 +#define DW_INL_inlined 1
15866 +#define DW_INL_declared_not_inlined 2
15867 +#define DW_INL_declared_inlined 3
15868 +#define DW_DSC_label 0
15869 +#define DW_DSC_range 1
15870 +#define DW_LNS_extended_op 0
15871 +#define DW_LNS_copy 1
15872 +#define DW_LNS_advance_pc 2
15873 +#define DW_LNS_advance_line 3
15874 +#define DW_LNS_set_file 4
15875 +#define DW_LNS_set_column 5
15876 +#define DW_LNS_negate_stmt 6
15877 +#define DW_LNS_set_basic_block 7
15878 +#define DW_LNS_const_add_pc 8
15879 +#define DW_LNS_fixed_advance_pc 9
15880 +#define DW_LNS_set_prologue_end 10
15881 +#define DW_LNS_set_epilogue_begin 11
15882 +#define DW_LNS_set_isa 12
15883 +#define DW_LNE_end_sequence 1
15884 +#define DW_LNE_set_address 2
15885 +#define DW_LNE_define_file 3
15886 +#define DW_LNE_HP_negate_is_UV_update 0x11
15887 +#define DW_LNE_HP_push_context 0x12
15888 +#define DW_LNE_HP_pop_context 0x13
15889 +#define DW_LNE_HP_set_file_line_column 0x14
15890 +#define DW_LNE_HP_set_routine_name 0x15
15891 +#define DW_LNE_HP_set_sequence 0x16
15892 +#define DW_LNE_HP_negate_post_semantics 0x17
15893 +#define DW_LNE_HP_negate_function_exit 0x18
15894 +#define DW_LNE_HP_negate_front_end_logical 0x19
15895 +#define DW_LNE_HP_define_proc 0x20
15896 +#define DW_CFA_advance_loc 0x40
15897 +#define DW_CFA_offset 0x80
15898 +#define DW_CFA_restore 0xc0
15899 +#define DW_CFA_nop 0x00
15900 +#define DW_CFA_set_loc 0x01
15901 +#define DW_CFA_advance_loc1 0x02
15902 +#define DW_CFA_advance_loc2 0x03
15903 +#define DW_CFA_advance_loc4 0x04
15904 +#define DW_CFA_offset_extended 0x05
15905 +#define DW_CFA_restore_extended 0x06
15906 +#define DW_CFA_undefined 0x07
15907 +#define DW_CFA_same_value 0x08
15908 +#define DW_CFA_register 0x09
15909 +#define DW_CFA_remember_state 0x0a
15910 +#define DW_CFA_restore_state 0x0b
15911 +#define DW_CFA_def_cfa 0x0c
15912 +#define DW_CFA_def_cfa_register 0x0d
15913 +#define DW_CFA_def_cfa_offset 0x0e
15914 +#define DW_CFA_def_cfa_expression 0x0f
15915 +#define DW_CFA_expression 0x10
15916 +#define DW_CFA_offset_extended_sf 0x11
15917 +#define DW_CFA_def_cfa_sf 0x12
15918 +#define DW_CFA_def_cfa_offset_sf 0x13
15919 +#define DW_CFA_MIPS_advance_loc8 0x1d
15920 +#define DW_CFA_GNU_window_save 0x2d
15921 +#define DW_CFA_GNU_args_size 0x2e
15922 +#define DW_CFA_GNU_negative_offset_extended 0x2f
15923 +#define DW_CIE_ID 0xffffffff
15924 +#define DW_CIE_VERSION 1
15925 +#define DW_CFA_extended 0
15926 +#define DW_CFA_lo_user 0x1c
15927 +#define DW_CFA_hi_user 0x3f
15928 +#define DW_CHILDREN_no 0x00
15929 +#define DW_CHILDREN_yes 0x01
15930 +#define DW_ADDR_none 0
15931 +#define DW_LANG_C89 0x0001
15932 +#define DW_LANG_C 0x0002
15933 +#define DW_LANG_Ada83 0x0003
15934 +#define DW_LANG_C_plus_plus 0x0004
15935 +#define DW_LANG_Cobol74 0x0005
15936 +#define DW_LANG_Cobol85 0x0006
15937 +#define DW_LANG_Fortran77 0x0007
15938 +#define DW_LANG_Fortran90 0x0008
15939 +#define DW_LANG_Pascal83 0x0009
15940 +#define DW_LANG_Modula2 0x000a
15941 +#define DW_LANG_Java 0x000b
15942 +#define DW_LANG_C99 0x000c
15943 +#define DW_LANG_Ada95 0x000d
15944 +#define DW_LANG_Fortran95 0x000e
15945 +#define DW_LANG_Mips_Assembler 0x8001
15946 +#define DW_LANG_Upc 0x8765
15947 +#define DW_LANG_lo_user 0x8000 /* Implementation-defined range start. */
15948 +#define DW_LANG_hi_user 0xffff /* Implementation-defined range start. */
15949 +#define DW_MACINFO_define 1
15950 +#define DW_MACINFO_undef 2
15951 +#define DW_MACINFO_start_file 3
15952 +#define DW_MACINFO_end_file 4
15953 +#define DW_MACINFO_vendor_ext 255
15954 +#define DW_EH_PE_absptr 0x00
15955 +#define DW_EH_PE_omit 0xff
15956 +#define DW_EH_PE_uleb128 0x01
15957 +#define DW_EH_PE_udata2 0x02
15958 +#define DW_EH_PE_udata4 0x03
15959 +#define DW_EH_PE_udata8 0x04
15960 +#define DW_EH_PE_sleb128 0x09
15961 +#define DW_EH_PE_sdata2 0x0A
15962 +#define DW_EH_PE_sdata4 0x0B
15963 +#define DW_EH_PE_sdata8 0x0C
15964 +#define DW_EH_PE_signed 0x08
15965 +#define DW_EH_PE_pcrel 0x10
15966 +#define DW_EH_PE_textrel 0x20
15967 +#define DW_EH_PE_datarel 0x30
15968 +#define DW_EH_PE_funcrel 0x40
15969 +#define DW_EH_PE_aligned 0x50
15970 +#define DW_EH_PE_indirect 0x80
15972 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/include/linux/dwarf2-lang.h linux-2.6.18.kgdb/include/linux/dwarf2-lang.h
15973 --- linux-2.6.18/include/linux/dwarf2-lang.h 1970-01-01 03:00:00.000000000 +0300
15974 +++ linux-2.6.18.kgdb/include/linux/dwarf2-lang.h 2008-06-10 16:19:58.000000000 +0400
15976 +#ifndef DWARF2_LANG
15977 +#define DWARF2_LANG
15980 + * This is free software; you can redistribute it and/or modify it under
15981 + * the terms of the GNU General Public License as published by the Free
15982 + * Software Foundation; either version 2, or (at your option) any later
15986 + * This file defines macros that allow generation of DWARF debug records
15987 + * for asm files. This file is platform independent. Register numbers
15988 + * (which are about the only thing that is platform dependent) are to be
15989 + * supplied by a platform defined file.
15992 + * We need this to work for both asm and C. In asm we are using the
15993 + * old comment trick to concatenate while C uses the new ANSI thing.
15994 + * Here we have concat macro... The multi level thing is to allow and
15995 + * macros used in the names to be resolved prior to the cat (at which
15996 + * time they are no longer the same string).
15998 +#define CAT3(a,b,c) _CAT3(a,b,c)
15999 +#define _CAT3(a,b,c) __CAT3(a,b,c)
16001 +#define __CAT3(a,b,c) a/**/b/**/c
16003 +#define __CAT3(a,b,c) a##b##c
16005 +#ifdef __ASSEMBLY__
16007 +#define IFN_C(a) a
16009 +#define QUOTE_THIS(a) a
16010 +#define DWARF_preamble .section .debug_frame,"",%progbits;
16015 +#define QUOTE_THIS(a) _QUOTE_THIS(a)
16016 +#define _QUOTE_THIS(a) #a
16017 +/* Don't let CPP see the " and , \042=" \054=, */
16018 +#define DWARF_preamble .section .debug_frame \054\042\042\054%progbits
16021 +#ifdef CONFIG_64BIT
16022 +#define DATA_ALIGN_FACTOR 8
16023 +#define ADDR_LOC .quad
16025 +#define DATA_ALIGN_FACTOR 4
16026 +#define ADDR_LOC .long
16029 +#include <linux/dwarf2-defs.h>
16031 + * This macro starts a debug frame section. The debug_frame describes
16032 + * where to find the registers that the enclosing function saved on
16035 + * ORD is use by the label generator and should be the same as what is
16036 + * passed to CFI_postamble.
16038 + * pc, pc register gdb ordinal.
16040 + * code_align this is the factor used to define locations or regions
16041 + * where the given definitions apply. If you use labels to define these
16042 + * this should be 1.
16044 + * data_align this is the factor used to define register offsets. If
16045 + * you use struct offset, this should be the size of the register in
16046 + * bytes or the negative of that. This is how it is used: you will
16047 + * define a register as the reference register, say the stack pointer,
16048 + * then you will say where a register is located relative to this
16049 + * reference registers value, say 40 for register 3 (the gdb register
16050 + * number). The <40> will be multiplied by <data_align> to define the
16051 + * byte offset of the given register (3, in this example). So if your
16052 + * <40> is the byte offset and the reference register points at the
16053 + * begining, you would want 1 for the data_offset. If <40> was the 40th
16054 + * 4-byte element in that structure you would want 4. And if your
16055 + * reference register points at the end of the structure you would want
16056 + * a negative data_align value(and you would have to do other math as
16060 +#define CFI_preamble(ORD, pc, code_align, data_align) \
16061 + DWARF_preamble NL \
16062 + .align DATA_ALIGN_FACTOR NL \
16063 + .globl CAT3(frame,_,ORD) NL \
16064 +CAT3(frame,_,ORD): NL \
16067 + .long DW_CIE_ID NL \
16068 + .byte DW_CIE_VERSION NL \
16070 + .uleb128 code_align NL \
16071 + .sleb128 data_align NL \
16075 + * After the above macro and prior to the CFI_postamble, you need to
16076 + * define the initial state. This starts with defining the reference
16077 + * register and, usually the pc. Here are some helper macros:
16080 +#define CFA_define_reference(reg, offset) \
16081 + .byte DW_CFA_def_cfa NL \
16082 + .uleb128 reg NL \
16083 + .uleb128 (offset) NL
16085 +#define CFA_define_offset(reg, offset) \
16086 + .byte (DW_CFA_offset + reg) NL \
16087 + .uleb128 (offset) NL
16089 +#define CFA_restore(reg) \
16090 + .byte (DW_CFA_restore + reg) NL
16092 +#define CFI_postamble() \
16093 + .align DATA_ALIGN_FACTOR NL \
16098 + * So now your code pushs stuff on the stack, you need a new location
16099 + * and the rules for what to do. This starts a running description of
16100 + * the call frame. You need to describe what changes with respect to
16101 + * the call registers as the location of the pc moves through the code.
16102 + * The following builds an FDE (fram descriptor entry?). Like the
16103 + * above, it has a preamble and a postamble. It also is tied to the CFI
16105 + * The preamble macro is tied to the CFI thru the first parameter. The
16106 + * second is the code start address and then the code end address+1.
16108 +#define FDE_preamble(ORD, initial_address, end_address) \
16109 + DWARF_preamble NL \
16110 + .align DATA_ALIGN_FACTOR NL \
16113 + .long CAT3(frame,_,ORD) NL \
16114 + ADDR_LOC initial_address NL \
16115 + ADDR_LOC (end_address - initial_address) NL
16117 +#define FDE_postamble() \
16118 + .align DATA_ALIGN_FACTOR NL \
16123 + * That done, you can now add registers, subtract registers, move the
16124 + * reference and even change the reference. You can also define a new
16125 + * area of code the info applies to. For discontinuous bits you should
16126 + * start a new FDE. You may have as many as you like.
16130 + * To advance the stack address by <bytes> (0x3f max)
16133 +#define CFA_advance_loc(bytes) \
16134 + .byte DW_CFA_advance_loc+bytes NL
16137 + * This one is good for 0xff or 255
16139 +#define CFA_advance_loc1(bytes) \
16140 + .byte DW_CFA_advance_loc1 NL \
16143 +#define CFA_undefine_reg(reg) \
16144 + .byte DW_CFA_undefined NL \
16147 + * With the above you can define all the register locations. But
16148 + * suppose the reference register moves... Takes the new offset NOT an
16149 + * increment. This is how esp is tracked if it is not saved.
16152 +#define CFA_define_cfa_offset(offset) \
16153 + .byte DW_CFA_def_cfa_offset NL \
16154 + .uleb128 (offset) NL
16156 + * Or suppose you want to use a different reference register...
16158 +#define CFA_define_cfa_register(reg) \
16159 + .byte DW_CFA_def_cfa_register NL \
16163 + * If you want to mess with the stack pointer, here is the expression.
16164 + * The stack starts empty.
16166 +#define CFA_def_cfa_expression \
16167 + .byte DW_CFA_def_cfa_expression NL \
16168 + .uleb128 20f-10f NL \
16171 + * This expression is to be used for other regs. The stack starts with the
16175 +#define CFA_expression(reg) \
16176 + .byte DW_CFA_expression NL \
16177 + .uleb128 reg NL \
16178 + .uleb128 20f-10f NL \
16181 + * Here we do the expression stuff. You should code the above followed
16182 + * by expression OPs followed by CFA_expression_end.
16186 +#define CFA_expression_end \
16189 +#define CFA_exp_OP_const4s(a) \
16190 + .byte DW_OP_const4s NL \
16193 +#define CFA_exp_OP_swap .byte DW_OP_swap NL
16194 +#define CFA_exp_OP_dup .byte DW_OP_dup NL
16195 +#define CFA_exp_OP_drop .byte DW_OP_drop NL
16197 + * All these work on the top two elements on the stack, replacing them
16198 + * with the result. Top comes first where it matters. True is 1, false 0.
16200 +#define CFA_exp_OP_deref .byte DW_OP_deref NL
16201 +#define CFA_exp_OP_and .byte DW_OP_and NL
16202 +#define CFA_exp_OP_div .byte DW_OP_div NL
16203 +#define CFA_exp_OP_minus .byte DW_OP_minus NL
16204 +#define CFA_exp_OP_mod .byte DW_OP_mod NL
16205 +#define CFA_exp_OP_neg .byte DW_OP_neg NL
16206 +#define CFA_exp_OP_plus .byte DW_OP_plus NL
16207 +#define CFA_exp_OP_not .byte DW_OP_not NL
16208 +#define CFA_exp_OP_or .byte DW_OP_or NL
16209 +#define CFA_exp_OP_xor .byte DW_OP_xor NL
16210 +#define CFA_exp_OP_le .byte DW_OP_le NL
16211 +#define CFA_exp_OP_ge .byte DW_OP_ge NL
16212 +#define CFA_exp_OP_eq .byte DW_OP_eq NL
16213 +#define CFA_exp_OP_lt .byte DW_OP_lt NL
16214 +#define CFA_exp_OP_gt .byte DW_OP_gt NL
16215 +#define CFA_exp_OP_ne .byte DW_OP_ne NL
16217 + * These take a parameter as noted
16220 + * Unconditional skip to loc. loc is a label (loc:)
16222 +#define CFA_exp_OP_skip(loc) \
16223 + .byte DW_OP_skip NL \
16224 + .hword loc-.-2 NL
16226 + * Conditional skip to loc (TOS != 0, TOS--) (loc is a label)
16228 +#define CFA_exp_OP_bra(loc) \
16229 + .byte DW_OP_bra NL \
16230 + .hword loc-.-2 NL
16233 + * TOS += no (an unsigned number)
16235 +#define CFA_exp_OP_plus_uconst(no) \
16236 + .byte DW_OP_plus_uconst NL \
16240 + * ++TOS = no (a unsigned number)
16242 +#define CFA_exp_OP_constu(no) \
16243 + .byte DW_OP_constu NL \
16246 + * ++TOS = no (a signed number)
16248 +#define CFA_exp_OP_consts(no) \
16249 + .byte DW_OP_consts NL \
16252 + * ++TOS = no (an unsigned byte)
16254 +#define CFA_exp_OP_const1u(no) \
16255 + .byte DW_OP_const1u NL \
16260 + * ++TOS = no (a address)
16262 +#define CFA_exp_OP_addr(no) \
16263 + .byte DW_OP_addr NL \
16267 + * Push current frames value for "reg" + offset
16268 + * We take advantage of the opcode assignments to make this a litteral reg
16269 + * rather than use the DW_OP_bregx opcode.
16272 +#define CFA_exp_OP_breg(reg,offset) \
16273 + .byte DW_OP_breg0+reg NL \
16274 + .sleb128 offset NL
16276 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/include/linux/dwarf2.h linux-2.6.18.kgdb/include/linux/dwarf2.h
16277 --- linux-2.6.18/include/linux/dwarf2.h 1970-01-01 03:00:00.000000000 +0300
16278 +++ linux-2.6.18.kgdb/include/linux/dwarf2.h 2008-06-10 16:19:58.000000000 +0400
16280 +/* Declarations and definitions of codes relating to the DWARF2 symbolic
16281 + debugging information format.
16282 + Copyright (C) 1992, 1993, 1995, 1996, 1997, 1999, 2000, 2001, 2002,
16283 + 2003 Free Software Foundation, Inc.
16285 + Written by Gary Funck (gary@intrepid.com) The Ada Joint Program
16286 + Office (AJPO), Florida State Unviversity and Silicon Graphics Inc.
16287 + provided support for this effort -- June 21, 1995.
16289 + Derived from the DWARF 1 implementation written by Ron Guilmette
16290 + (rfg@netcom.com), November 1990.
16292 + This file is part of GCC.
16294 + GCC is free software; you can redistribute it and/or modify it under
16295 + the terms of the GNU General Public License as published by the Free
16296 + Software Foundation; either version 2, or (at your option) any later
16299 + GCC is distributed in the hope that it will be useful, but WITHOUT
16300 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16301 + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16302 + License for more details.
16304 + You should have received a copy of the GNU General Public License
16305 + along with GCC; see the file COPYING. If not, write to the Free
16306 + Software Foundation, 59 Temple Place - Suite 330, Boston, MA
16307 + 02111-1307, USA. */
16309 +/* This file is derived from the DWARF specification (a public document)
16310 + Revision 2.0.0 (July 27, 1993) developed by the UNIX International
16311 + Programming Languages Special Interest Group (UI/PLSIG) and distributed
16312 + by UNIX International. Copies of this specification are available from
16313 + UNIX International, 20 Waterview Boulevard, Parsippany, NJ, 07054.
16315 + This file also now contains definitions from the DWARF 3 specification. */
16317 +/* This file is shared between GCC and GDB, and should not contain
16320 +#ifndef _ELF_DWARF2_H
16321 +#define _ELF_DWARF2_H
16323 +/* Structure found in the .debug_line section. */
16326 + unsigned char li_length [4];
16327 + unsigned char li_version [2];
16328 + unsigned char li_prologue_length [4];
16329 + unsigned char li_min_insn_length [1];
16330 + unsigned char li_default_is_stmt [1];
16331 + unsigned char li_line_base [1];
16332 + unsigned char li_line_range [1];
16333 + unsigned char li_opcode_base [1];
16335 +DWARF2_External_LineInfo;
16339 + unsigned long li_length;
16340 + unsigned short li_version;
16341 + unsigned int li_prologue_length;
16342 + unsigned char li_min_insn_length;
16343 + unsigned char li_default_is_stmt;
16344 + int li_line_base;
16345 + unsigned char li_line_range;
16346 + unsigned char li_opcode_base;
16348 +DWARF2_Internal_LineInfo;
16350 +/* Structure found in .debug_pubnames section. */
16353 + unsigned char pn_length [4];
16354 + unsigned char pn_version [2];
16355 + unsigned char pn_offset [4];
16356 + unsigned char pn_size [4];
16358 +DWARF2_External_PubNames;
16362 + unsigned long pn_length;
16363 + unsigned short pn_version;
16364 + unsigned long pn_offset;
16365 + unsigned long pn_size;
16367 +DWARF2_Internal_PubNames;
16369 +/* Structure found in .debug_info section. */
16372 + unsigned char cu_length [4];
16373 + unsigned char cu_version [2];
16374 + unsigned char cu_abbrev_offset [4];
16375 + unsigned char cu_pointer_size [1];
16377 +DWARF2_External_CompUnit;
16381 + unsigned long cu_length;
16382 + unsigned short cu_version;
16383 + unsigned long cu_abbrev_offset;
16384 + unsigned char cu_pointer_size;
16386 +DWARF2_Internal_CompUnit;
16390 + unsigned char ar_length [4];
16391 + unsigned char ar_version [2];
16392 + unsigned char ar_info_offset [4];
16393 + unsigned char ar_pointer_size [1];
16394 + unsigned char ar_segment_size [1];
16396 +DWARF2_External_ARange;
16400 + unsigned long ar_length;
16401 + unsigned short ar_version;
16402 + unsigned long ar_info_offset;
16403 + unsigned char ar_pointer_size;
16404 + unsigned char ar_segment_size;
16406 +DWARF2_Internal_ARange;
16409 +/* Tag names and codes. */
16412 + DW_TAG_padding = 0x00,
16413 + DW_TAG_array_type = 0x01,
16414 + DW_TAG_class_type = 0x02,
16415 + DW_TAG_entry_point = 0x03,
16416 + DW_TAG_enumeration_type = 0x04,
16417 + DW_TAG_formal_parameter = 0x05,
16418 + DW_TAG_imported_declaration = 0x08,
16419 + DW_TAG_label = 0x0a,
16420 + DW_TAG_lexical_block = 0x0b,
16421 + DW_TAG_member = 0x0d,
16422 + DW_TAG_pointer_type = 0x0f,
16423 + DW_TAG_reference_type = 0x10,
16424 + DW_TAG_compile_unit = 0x11,
16425 + DW_TAG_string_type = 0x12,
16426 + DW_TAG_structure_type = 0x13,
16427 + DW_TAG_subroutine_type = 0x15,
16428 + DW_TAG_typedef = 0x16,
16429 + DW_TAG_union_type = 0x17,
16430 + DW_TAG_unspecified_parameters = 0x18,
16431 + DW_TAG_variant = 0x19,
16432 + DW_TAG_common_block = 0x1a,
16433 + DW_TAG_common_inclusion = 0x1b,
16434 + DW_TAG_inheritance = 0x1c,
16435 + DW_TAG_inlined_subroutine = 0x1d,
16436 + DW_TAG_module = 0x1e,
16437 + DW_TAG_ptr_to_member_type = 0x1f,
16438 + DW_TAG_set_type = 0x20,
16439 + DW_TAG_subrange_type = 0x21,
16440 + DW_TAG_with_stmt = 0x22,
16441 + DW_TAG_access_declaration = 0x23,
16442 + DW_TAG_base_type = 0x24,
16443 + DW_TAG_catch_block = 0x25,
16444 + DW_TAG_const_type = 0x26,
16445 + DW_TAG_constant = 0x27,
16446 + DW_TAG_enumerator = 0x28,
16447 + DW_TAG_file_type = 0x29,
16448 + DW_TAG_friend = 0x2a,
16449 + DW_TAG_namelist = 0x2b,
16450 + DW_TAG_namelist_item = 0x2c,
16451 + DW_TAG_packed_type = 0x2d,
16452 + DW_TAG_subprogram = 0x2e,
16453 + DW_TAG_template_type_param = 0x2f,
16454 + DW_TAG_template_value_param = 0x30,
16455 + DW_TAG_thrown_type = 0x31,
16456 + DW_TAG_try_block = 0x32,
16457 + DW_TAG_variant_part = 0x33,
16458 + DW_TAG_variable = 0x34,
16459 + DW_TAG_volatile_type = 0x35,
16461 + DW_TAG_dwarf_procedure = 0x36,
16462 + DW_TAG_restrict_type = 0x37,
16463 + DW_TAG_interface_type = 0x38,
16464 + DW_TAG_namespace = 0x39,
16465 + DW_TAG_imported_module = 0x3a,
16466 + DW_TAG_unspecified_type = 0x3b,
16467 + DW_TAG_partial_unit = 0x3c,
16468 + DW_TAG_imported_unit = 0x3d,
16469 + /* SGI/MIPS Extensions. */
16470 + DW_TAG_MIPS_loop = 0x4081,
16471 + /* HP extensions. See: ftp://ftp.hp.com/pub/lang/tools/WDB/wdb-4.0.tar.gz . */
16472 + DW_TAG_HP_array_descriptor = 0x4090,
16473 + /* GNU extensions. */
16474 + DW_TAG_format_label = 0x4101, /* For FORTRAN 77 and Fortran 90. */
16475 + DW_TAG_function_template = 0x4102, /* For C++. */
16476 + DW_TAG_class_template = 0x4103, /* For C++. */
16477 + DW_TAG_GNU_BINCL = 0x4104,
16478 + DW_TAG_GNU_EINCL = 0x4105,
16479 + /* Extensions for UPC. See: http://upc.gwu.edu/~upc. */
16480 + DW_TAG_upc_shared_type = 0x8765,
16481 + DW_TAG_upc_strict_type = 0x8766,
16482 + DW_TAG_upc_relaxed_type = 0x8767,
16483 + /* PGI (STMicroelectronics) extensions. No documentation available. */
16484 + DW_TAG_PGI_kanji_type = 0xA000,
16485 + DW_TAG_PGI_interface_block = 0xA020
16488 +#define DW_TAG_lo_user 0x4080
16489 +#define DW_TAG_hi_user 0xffff
16491 +/* Flag that tells whether entry has a child or not. */
16492 +#define DW_children_no 0
16493 +#define DW_children_yes 1
16495 +/* Form names and codes. */
16498 + DW_FORM_addr = 0x01,
16499 + DW_FORM_block2 = 0x03,
16500 + DW_FORM_block4 = 0x04,
16501 + DW_FORM_data2 = 0x05,
16502 + DW_FORM_data4 = 0x06,
16503 + DW_FORM_data8 = 0x07,
16504 + DW_FORM_string = 0x08,
16505 + DW_FORM_block = 0x09,
16506 + DW_FORM_block1 = 0x0a,
16507 + DW_FORM_data1 = 0x0b,
16508 + DW_FORM_flag = 0x0c,
16509 + DW_FORM_sdata = 0x0d,
16510 + DW_FORM_strp = 0x0e,
16511 + DW_FORM_udata = 0x0f,
16512 + DW_FORM_ref_addr = 0x10,
16513 + DW_FORM_ref1 = 0x11,
16514 + DW_FORM_ref2 = 0x12,
16515 + DW_FORM_ref4 = 0x13,
16516 + DW_FORM_ref8 = 0x14,
16517 + DW_FORM_ref_udata = 0x15,
16518 + DW_FORM_indirect = 0x16
16521 +/* Attribute names and codes. */
16522 +enum dwarf_attribute
16524 + DW_AT_sibling = 0x01,
16525 + DW_AT_location = 0x02,
16526 + DW_AT_name = 0x03,
16527 + DW_AT_ordering = 0x09,
16528 + DW_AT_subscr_data = 0x0a,
16529 + DW_AT_byte_size = 0x0b,
16530 + DW_AT_bit_offset = 0x0c,
16531 + DW_AT_bit_size = 0x0d,
16532 + DW_AT_element_list = 0x0f,
16533 + DW_AT_stmt_list = 0x10,
16534 + DW_AT_low_pc = 0x11,
16535 + DW_AT_high_pc = 0x12,
16536 + DW_AT_language = 0x13,
16537 + DW_AT_member = 0x14,
16538 + DW_AT_discr = 0x15,
16539 + DW_AT_discr_value = 0x16,
16540 + DW_AT_visibility = 0x17,
16541 + DW_AT_import = 0x18,
16542 + DW_AT_string_length = 0x19,
16543 + DW_AT_common_reference = 0x1a,
16544 + DW_AT_comp_dir = 0x1b,
16545 + DW_AT_const_value = 0x1c,
16546 + DW_AT_containing_type = 0x1d,
16547 + DW_AT_default_value = 0x1e,
16548 + DW_AT_inline = 0x20,
16549 + DW_AT_is_optional = 0x21,
16550 + DW_AT_lower_bound = 0x22,
16551 + DW_AT_producer = 0x25,
16552 + DW_AT_prototyped = 0x27,
16553 + DW_AT_return_addr = 0x2a,
16554 + DW_AT_start_scope = 0x2c,
16555 + DW_AT_stride_size = 0x2e,
16556 + DW_AT_upper_bound = 0x2f,
16557 + DW_AT_abstract_origin = 0x31,
16558 + DW_AT_accessibility = 0x32,
16559 + DW_AT_address_class = 0x33,
16560 + DW_AT_artificial = 0x34,
16561 + DW_AT_base_types = 0x35,
16562 + DW_AT_calling_convention = 0x36,
16563 + DW_AT_count = 0x37,
16564 + DW_AT_data_member_location = 0x38,
16565 + DW_AT_decl_column = 0x39,
16566 + DW_AT_decl_file = 0x3a,
16567 + DW_AT_decl_line = 0x3b,
16568 + DW_AT_declaration = 0x3c,
16569 + DW_AT_discr_list = 0x3d,
16570 + DW_AT_encoding = 0x3e,
16571 + DW_AT_external = 0x3f,
16572 + DW_AT_frame_base = 0x40,
16573 + DW_AT_friend = 0x41,
16574 + DW_AT_identifier_case = 0x42,
16575 + DW_AT_macro_info = 0x43,
16576 + DW_AT_namelist_items = 0x44,
16577 + DW_AT_priority = 0x45,
16578 + DW_AT_segment = 0x46,
16579 + DW_AT_specification = 0x47,
16580 + DW_AT_static_link = 0x48,
16581 + DW_AT_type = 0x49,
16582 + DW_AT_use_location = 0x4a,
16583 + DW_AT_variable_parameter = 0x4b,
16584 + DW_AT_virtuality = 0x4c,
16585 + DW_AT_vtable_elem_location = 0x4d,
16586 + /* DWARF 3 values. */
16587 + DW_AT_allocated = 0x4e,
16588 + DW_AT_associated = 0x4f,
16589 + DW_AT_data_location = 0x50,
16590 + DW_AT_stride = 0x51,
16591 + DW_AT_entry_pc = 0x52,
16592 + DW_AT_use_UTF8 = 0x53,
16593 + DW_AT_extension = 0x54,
16594 + DW_AT_ranges = 0x55,
16595 + DW_AT_trampoline = 0x56,
16596 + DW_AT_call_column = 0x57,
16597 + DW_AT_call_file = 0x58,
16598 + DW_AT_call_line = 0x59,
16599 + /* SGI/MIPS extensions. */
16600 + DW_AT_MIPS_fde = 0x2001,
16601 + DW_AT_MIPS_loop_begin = 0x2002,
16602 + DW_AT_MIPS_tail_loop_begin = 0x2003,
16603 + DW_AT_MIPS_epilog_begin = 0x2004,
16604 + DW_AT_MIPS_loop_unroll_factor = 0x2005,
16605 + DW_AT_MIPS_software_pipeline_depth = 0x2006,
16606 + DW_AT_MIPS_linkage_name = 0x2007,
16607 + DW_AT_MIPS_stride = 0x2008,
16608 + DW_AT_MIPS_abstract_name = 0x2009,
16609 + DW_AT_MIPS_clone_origin = 0x200a,
16610 + DW_AT_MIPS_has_inlines = 0x200b,
16611 + /* HP extensions. */
16612 + DW_AT_HP_block_index = 0x2000,
16613 + DW_AT_HP_unmodifiable = 0x2001, /* Same as DW_AT_MIPS_fde. */
16614 + DW_AT_HP_actuals_stmt_list = 0x2010,
16615 + DW_AT_HP_proc_per_section = 0x2011,
16616 + DW_AT_HP_raw_data_ptr = 0x2012,
16617 + DW_AT_HP_pass_by_reference = 0x2013,
16618 + DW_AT_HP_opt_level = 0x2014,
16619 + DW_AT_HP_prof_version_id = 0x2015,
16620 + DW_AT_HP_opt_flags = 0x2016,
16621 + DW_AT_HP_cold_region_low_pc = 0x2017,
16622 + DW_AT_HP_cold_region_high_pc = 0x2018,
16623 + DW_AT_HP_all_variables_modifiable = 0x2019,
16624 + DW_AT_HP_linkage_name = 0x201a,
16625 + DW_AT_HP_prof_flags = 0x201b, /* In comp unit of procs_info for -g. */
16626 + /* GNU extensions. */
16627 + DW_AT_sf_names = 0x2101,
16628 + DW_AT_src_info = 0x2102,
16629 + DW_AT_mac_info = 0x2103,
16630 + DW_AT_src_coords = 0x2104,
16631 + DW_AT_body_begin = 0x2105,
16632 + DW_AT_body_end = 0x2106,
16633 + DW_AT_GNU_vector = 0x2107,
16634 + /* VMS extensions. */
16635 + DW_AT_VMS_rtnbeg_pd_address = 0x2201,
16636 + /* UPC extension. */
16637 + DW_AT_upc_threads_scaled = 0x3210,
16638 + /* PGI (STMicroelectronics) extensions. */
16639 + DW_AT_PGI_lbase = 0x3a00,
16640 + DW_AT_PGI_soffset = 0x3a01,
16641 + DW_AT_PGI_lstride = 0x3a02
16644 +#define DW_AT_lo_user 0x2000 /* Implementation-defined range start. */
16645 +#define DW_AT_hi_user 0x3ff0 /* Implementation-defined range end. */
16647 +/* Location atom names and codes. */
16648 +enum dwarf_location_atom
16650 + DW_OP_addr = 0x03,
16651 + DW_OP_deref = 0x06,
16652 + DW_OP_const1u = 0x08,
16653 + DW_OP_const1s = 0x09,
16654 + DW_OP_const2u = 0x0a,
16655 + DW_OP_const2s = 0x0b,
16656 + DW_OP_const4u = 0x0c,
16657 + DW_OP_const4s = 0x0d,
16658 + DW_OP_const8u = 0x0e,
16659 + DW_OP_const8s = 0x0f,
16660 + DW_OP_constu = 0x10,
16661 + DW_OP_consts = 0x11,
16662 + DW_OP_dup = 0x12,
16663 + DW_OP_drop = 0x13,
16664 + DW_OP_over = 0x14,
16665 + DW_OP_pick = 0x15,
16666 + DW_OP_swap = 0x16,
16667 + DW_OP_rot = 0x17,
16668 + DW_OP_xderef = 0x18,
16669 + DW_OP_abs = 0x19,
16670 + DW_OP_and = 0x1a,
16671 + DW_OP_div = 0x1b,
16672 + DW_OP_minus = 0x1c,
16673 + DW_OP_mod = 0x1d,
16674 + DW_OP_mul = 0x1e,
16675 + DW_OP_neg = 0x1f,
16676 + DW_OP_not = 0x20,
16678 + DW_OP_plus = 0x22,
16679 + DW_OP_plus_uconst = 0x23,
16680 + DW_OP_shl = 0x24,
16681 + DW_OP_shr = 0x25,
16682 + DW_OP_shra = 0x26,
16683 + DW_OP_xor = 0x27,
16684 + DW_OP_bra = 0x28,
16691 + DW_OP_skip = 0x2f,
16692 + DW_OP_lit0 = 0x30,
16693 + DW_OP_lit1 = 0x31,
16694 + DW_OP_lit2 = 0x32,
16695 + DW_OP_lit3 = 0x33,
16696 + DW_OP_lit4 = 0x34,
16697 + DW_OP_lit5 = 0x35,
16698 + DW_OP_lit6 = 0x36,
16699 + DW_OP_lit7 = 0x37,
16700 + DW_OP_lit8 = 0x38,
16701 + DW_OP_lit9 = 0x39,
16702 + DW_OP_lit10 = 0x3a,
16703 + DW_OP_lit11 = 0x3b,
16704 + DW_OP_lit12 = 0x3c,
16705 + DW_OP_lit13 = 0x3d,
16706 + DW_OP_lit14 = 0x3e,
16707 + DW_OP_lit15 = 0x3f,
16708 + DW_OP_lit16 = 0x40,
16709 + DW_OP_lit17 = 0x41,
16710 + DW_OP_lit18 = 0x42,
16711 + DW_OP_lit19 = 0x43,
16712 + DW_OP_lit20 = 0x44,
16713 + DW_OP_lit21 = 0x45,
16714 + DW_OP_lit22 = 0x46,
16715 + DW_OP_lit23 = 0x47,
16716 + DW_OP_lit24 = 0x48,
16717 + DW_OP_lit25 = 0x49,
16718 + DW_OP_lit26 = 0x4a,
16719 + DW_OP_lit27 = 0x4b,
16720 + DW_OP_lit28 = 0x4c,
16721 + DW_OP_lit29 = 0x4d,
16722 + DW_OP_lit30 = 0x4e,
16723 + DW_OP_lit31 = 0x4f,
16724 + DW_OP_reg0 = 0x50,
16725 + DW_OP_reg1 = 0x51,
16726 + DW_OP_reg2 = 0x52,
16727 + DW_OP_reg3 = 0x53,
16728 + DW_OP_reg4 = 0x54,
16729 + DW_OP_reg5 = 0x55,
16730 + DW_OP_reg6 = 0x56,
16731 + DW_OP_reg7 = 0x57,
16732 + DW_OP_reg8 = 0x58,
16733 + DW_OP_reg9 = 0x59,
16734 + DW_OP_reg10 = 0x5a,
16735 + DW_OP_reg11 = 0x5b,
16736 + DW_OP_reg12 = 0x5c,
16737 + DW_OP_reg13 = 0x5d,
16738 + DW_OP_reg14 = 0x5e,
16739 + DW_OP_reg15 = 0x5f,
16740 + DW_OP_reg16 = 0x60,
16741 + DW_OP_reg17 = 0x61,
16742 + DW_OP_reg18 = 0x62,
16743 + DW_OP_reg19 = 0x63,
16744 + DW_OP_reg20 = 0x64,
16745 + DW_OP_reg21 = 0x65,
16746 + DW_OP_reg22 = 0x66,
16747 + DW_OP_reg23 = 0x67,
16748 + DW_OP_reg24 = 0x68,
16749 + DW_OP_reg25 = 0x69,
16750 + DW_OP_reg26 = 0x6a,
16751 + DW_OP_reg27 = 0x6b,
16752 + DW_OP_reg28 = 0x6c,
16753 + DW_OP_reg29 = 0x6d,
16754 + DW_OP_reg30 = 0x6e,
16755 + DW_OP_reg31 = 0x6f,
16756 + DW_OP_breg0 = 0x70,
16757 + DW_OP_breg1 = 0x71,
16758 + DW_OP_breg2 = 0x72,
16759 + DW_OP_breg3 = 0x73,
16760 + DW_OP_breg4 = 0x74,
16761 + DW_OP_breg5 = 0x75,
16762 + DW_OP_breg6 = 0x76,
16763 + DW_OP_breg7 = 0x77,
16764 + DW_OP_breg8 = 0x78,
16765 + DW_OP_breg9 = 0x79,
16766 + DW_OP_breg10 = 0x7a,
16767 + DW_OP_breg11 = 0x7b,
16768 + DW_OP_breg12 = 0x7c,
16769 + DW_OP_breg13 = 0x7d,
16770 + DW_OP_breg14 = 0x7e,
16771 + DW_OP_breg15 = 0x7f,
16772 + DW_OP_breg16 = 0x80,
16773 + DW_OP_breg17 = 0x81,
16774 + DW_OP_breg18 = 0x82,
16775 + DW_OP_breg19 = 0x83,
16776 + DW_OP_breg20 = 0x84,
16777 + DW_OP_breg21 = 0x85,
16778 + DW_OP_breg22 = 0x86,
16779 + DW_OP_breg23 = 0x87,
16780 + DW_OP_breg24 = 0x88,
16781 + DW_OP_breg25 = 0x89,
16782 + DW_OP_breg26 = 0x8a,
16783 + DW_OP_breg27 = 0x8b,
16784 + DW_OP_breg28 = 0x8c,
16785 + DW_OP_breg29 = 0x8d,
16786 + DW_OP_breg30 = 0x8e,
16787 + DW_OP_breg31 = 0x8f,
16788 + DW_OP_regx = 0x90,
16789 + DW_OP_fbreg = 0x91,
16790 + DW_OP_bregx = 0x92,
16791 + DW_OP_piece = 0x93,
16792 + DW_OP_deref_size = 0x94,
16793 + DW_OP_xderef_size = 0x95,
16794 + DW_OP_nop = 0x96,
16795 + /* DWARF 3 extensions. */
16796 + DW_OP_push_object_address = 0x97,
16797 + DW_OP_call2 = 0x98,
16798 + DW_OP_call4 = 0x99,
16799 + DW_OP_call_ref = 0x9a,
16800 + /* GNU extensions. */
16801 + DW_OP_GNU_push_tls_address = 0xe0,
16802 + /* HP extensions. */
16803 + DW_OP_HP_unknown = 0xe0, /* Ouch, the same as GNU_push_tls_address. */
16804 + DW_OP_HP_is_value = 0xe1,
16805 + DW_OP_HP_fltconst4 = 0xe2,
16806 + DW_OP_HP_fltconst8 = 0xe3,
16807 + DW_OP_HP_mod_range = 0xe4,
16808 + DW_OP_HP_unmod_range = 0xe5,
16809 + DW_OP_HP_tls = 0xe6
16812 +#define DW_OP_lo_user 0xe0 /* Implementation-defined range start. */
16813 +#define DW_OP_hi_user 0xff /* Implementation-defined range end. */
16815 +/* Type encodings. */
16818 + DW_ATE_void = 0x0,
16819 + DW_ATE_address = 0x1,
16820 + DW_ATE_boolean = 0x2,
16821 + DW_ATE_complex_float = 0x3,
16822 + DW_ATE_float = 0x4,
16823 + DW_ATE_signed = 0x5,
16824 + DW_ATE_signed_char = 0x6,
16825 + DW_ATE_unsigned = 0x7,
16826 + DW_ATE_unsigned_char = 0x8,
16828 + DW_ATE_imaginary_float = 0x9,
16829 + /* HP extensions. */
16830 + DW_ATE_HP_float80 = 0x80, /* Floating-point (80 bit). */
16831 + DW_ATE_HP_complex_float80 = 0x81, /* Complex floating-point (80 bit). */
16832 + DW_ATE_HP_float128 = 0x82, /* Floating-point (128 bit). */
16833 + DW_ATE_HP_complex_float128 = 0x83, /* Complex floating-point (128 bit). */
16834 + DW_ATE_HP_floathpintel = 0x84, /* Floating-point (82 bit IA64). */
16835 + DW_ATE_HP_imaginary_float80 = 0x85,
16836 + DW_ATE_HP_imaginary_float128 = 0x86
16839 +#define DW_ATE_lo_user 0x80
16840 +#define DW_ATE_hi_user 0xff
16842 +/* Array ordering names and codes. */
16843 +enum dwarf_array_dim_ordering
16845 + DW_ORD_row_major = 0,
16846 + DW_ORD_col_major = 1
16849 +/* Access attribute. */
16850 +enum dwarf_access_attribute
16852 + DW_ACCESS_public = 1,
16853 + DW_ACCESS_protected = 2,
16854 + DW_ACCESS_private = 3
16858 +enum dwarf_visibility_attribute
16860 + DW_VIS_local = 1,
16861 + DW_VIS_exported = 2,
16862 + DW_VIS_qualified = 3
16866 +enum dwarf_virtuality_attribute
16868 + DW_VIRTUALITY_none = 0,
16869 + DW_VIRTUALITY_virtual = 1,
16870 + DW_VIRTUALITY_pure_virtual = 2
16873 +/* Case sensitivity. */
16874 +enum dwarf_id_case
16876 + DW_ID_case_sensitive = 0,
16877 + DW_ID_up_case = 1,
16878 + DW_ID_down_case = 2,
16879 + DW_ID_case_insensitive = 3
16882 +/* Calling convention. */
16883 +enum dwarf_calling_convention
16885 + DW_CC_normal = 0x1,
16886 + DW_CC_program = 0x2,
16887 + DW_CC_nocall = 0x3
16890 +#define DW_CC_lo_user 0x40
16891 +#define DW_CC_hi_user 0xff
16893 +/* Inline attribute. */
16894 +enum dwarf_inline_attribute
16896 + DW_INL_not_inlined = 0,
16897 + DW_INL_inlined = 1,
16898 + DW_INL_declared_not_inlined = 2,
16899 + DW_INL_declared_inlined = 3
16902 +/* Discriminant lists. */
16903 +enum dwarf_discrim_list
16905 + DW_DSC_label = 0,
16909 +/* Line number opcodes. */
16910 +enum dwarf_line_number_ops
16912 + DW_LNS_extended_op = 0,
16914 + DW_LNS_advance_pc = 2,
16915 + DW_LNS_advance_line = 3,
16916 + DW_LNS_set_file = 4,
16917 + DW_LNS_set_column = 5,
16918 + DW_LNS_negate_stmt = 6,
16919 + DW_LNS_set_basic_block = 7,
16920 + DW_LNS_const_add_pc = 8,
16921 + DW_LNS_fixed_advance_pc = 9,
16923 + DW_LNS_set_prologue_end = 10,
16924 + DW_LNS_set_epilogue_begin = 11,
16925 + DW_LNS_set_isa = 12
16928 +/* Line number extended opcodes. */
16929 +enum dwarf_line_number_x_ops
16931 + DW_LNE_end_sequence = 1,
16932 + DW_LNE_set_address = 2,
16933 + DW_LNE_define_file = 3,
16934 + /* HP extensions. */
16935 + DW_LNE_HP_negate_is_UV_update = 0x11,
16936 + DW_LNE_HP_push_context = 0x12,
16937 + DW_LNE_HP_pop_context = 0x13,
16938 + DW_LNE_HP_set_file_line_column = 0x14,
16939 + DW_LNE_HP_set_routine_name = 0x15,
16940 + DW_LNE_HP_set_sequence = 0x16,
16941 + DW_LNE_HP_negate_post_semantics = 0x17,
16942 + DW_LNE_HP_negate_function_exit = 0x18,
16943 + DW_LNE_HP_negate_front_end_logical = 0x19,
16944 + DW_LNE_HP_define_proc = 0x20
16947 +/* Call frame information. */
16948 +enum dwarf_call_frame_info
16950 + DW_CFA_advance_loc = 0x40,
16951 + DW_CFA_offset = 0x80,
16952 + DW_CFA_restore = 0xc0,
16953 + DW_CFA_nop = 0x00,
16954 + DW_CFA_set_loc = 0x01,
16955 + DW_CFA_advance_loc1 = 0x02,
16956 + DW_CFA_advance_loc2 = 0x03,
16957 + DW_CFA_advance_loc4 = 0x04,
16958 + DW_CFA_offset_extended = 0x05,
16959 + DW_CFA_restore_extended = 0x06,
16960 + DW_CFA_undefined = 0x07,
16961 + DW_CFA_same_value = 0x08,
16962 + DW_CFA_register = 0x09,
16963 + DW_CFA_remember_state = 0x0a,
16964 + DW_CFA_restore_state = 0x0b,
16965 + DW_CFA_def_cfa = 0x0c,
16966 + DW_CFA_def_cfa_register = 0x0d,
16967 + DW_CFA_def_cfa_offset = 0x0e,
16969 + DW_CFA_def_cfa_expression = 0x0f,
16970 + DW_CFA_expression = 0x10,
16971 + DW_CFA_offset_extended_sf = 0x11,
16972 + DW_CFA_def_cfa_sf = 0x12,
16973 + DW_CFA_def_cfa_offset_sf = 0x13,
16974 + /* SGI/MIPS specific. */
16975 + DW_CFA_MIPS_advance_loc8 = 0x1d,
16976 + /* GNU extensions. */
16977 + DW_CFA_GNU_window_save = 0x2d,
16978 + DW_CFA_GNU_args_size = 0x2e,
16979 + DW_CFA_GNU_negative_offset_extended = 0x2f
16982 +#define DW_CIE_ID 0xffffffff
16983 +#define DW_CIE_VERSION 1
16985 +#define DW_CFA_extended 0
16986 +#define DW_CFA_lo_user 0x1c
16987 +#define DW_CFA_hi_user 0x3f
16989 +#define DW_CHILDREN_no 0x00
16990 +#define DW_CHILDREN_yes 0x01
16992 +#define DW_ADDR_none 0
16994 +/* Source language names and codes. */
16995 +enum dwarf_source_language
16997 + DW_LANG_C89 = 0x0001,
16998 + DW_LANG_C = 0x0002,
16999 + DW_LANG_Ada83 = 0x0003,
17000 + DW_LANG_C_plus_plus = 0x0004,
17001 + DW_LANG_Cobol74 = 0x0005,
17002 + DW_LANG_Cobol85 = 0x0006,
17003 + DW_LANG_Fortran77 = 0x0007,
17004 + DW_LANG_Fortran90 = 0x0008,
17005 + DW_LANG_Pascal83 = 0x0009,
17006 + DW_LANG_Modula2 = 0x000a,
17007 + DW_LANG_Java = 0x000b,
17009 + DW_LANG_C99 = 0x000c,
17010 + DW_LANG_Ada95 = 0x000d,
17011 + DW_LANG_Fortran95 = 0x000e,
17013 + DW_LANG_Mips_Assembler = 0x8001,
17015 + DW_LANG_Upc = 0x8765
17018 +#define DW_LANG_lo_user 0x8000 /* Implementation-defined range start. */
17019 +#define DW_LANG_hi_user 0xffff /* Implementation-defined range start. */
17021 +/* Names and codes for macro information. */
17022 +enum dwarf_macinfo_record_type
17024 + DW_MACINFO_define = 1,
17025 + DW_MACINFO_undef = 2,
17026 + DW_MACINFO_start_file = 3,
17027 + DW_MACINFO_end_file = 4,
17028 + DW_MACINFO_vendor_ext = 255
17031 +/* @@@ For use with GNU frame unwind information. */
17033 +#define DW_EH_PE_absptr 0x00
17034 +#define DW_EH_PE_omit 0xff
17036 +#define DW_EH_PE_uleb128 0x01
17037 +#define DW_EH_PE_udata2 0x02
17038 +#define DW_EH_PE_udata4 0x03
17039 +#define DW_EH_PE_udata8 0x04
17040 +#define DW_EH_PE_sleb128 0x09
17041 +#define DW_EH_PE_sdata2 0x0A
17042 +#define DW_EH_PE_sdata4 0x0B
17043 +#define DW_EH_PE_sdata8 0x0C
17044 +#define DW_EH_PE_signed 0x08
17046 +#define DW_EH_PE_pcrel 0x10
17047 +#define DW_EH_PE_textrel 0x20
17048 +#define DW_EH_PE_datarel 0x30
17049 +#define DW_EH_PE_funcrel 0x40
17050 +#define DW_EH_PE_aligned 0x50
17052 +#define DW_EH_PE_indirect 0x80
17054 +#endif /* _ELF_DWARF2_H */
17055 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/include/linux/kgdb.h linux-2.6.18.kgdb/include/linux/kgdb.h
17056 --- linux-2.6.18/include/linux/kgdb.h 1970-01-01 03:00:00.000000000 +0300
17057 +++ linux-2.6.18.kgdb/include/linux/kgdb.h 2008-06-10 16:20:11.000000000 +0400
17060 + * include/linux/kgdb.h
17062 + * This provides the hooks and functions that KGDB needs to share between
17063 + * the core, I/O and arch-specific portions.
17065 + * Author: Amit Kale <amitkale@linsyssoft.com> and
17066 + * Tom Rini <trini@kernel.crashing.org>
17068 + * 2001-2004 (c) Amit S. Kale and 2003-2005 (c) MontaVista Software, Inc.
17069 + * This file is licensed under the terms of the GNU General Public License
17070 + * version 2. This program is licensed "as is" without any warranty of any
17071 + * kind, whether express or implied.
17077 +#include <asm/atomic.h>
17079 +#ifdef CONFIG_KGDB
17080 +#include <asm/kgdb.h>
17081 +#include <linux/serial_8250.h>
17082 +#include <linux/linkage.h>
17083 +#include <linux/init.h>
17085 +#ifndef CHECK_EXCEPTION_STACK
17086 +#define CHECK_EXCEPTION_STACK() 1
17089 +struct tasklet_struct;
17091 +struct task_struct;
17094 +#ifdef CONFIG_KGDB_CONSOLE
17095 +extern struct console kgdbcons;
17098 +/* To enter the debugger explicitly. */
17099 +extern void breakpoint(void);
17100 +extern int kgdb_connected;
17101 +extern int kgdb_may_fault;
17102 +extern struct tasklet_struct kgdb_tasklet_breakpoint;
17104 +extern atomic_t kgdb_setting_breakpoint;
17105 +extern atomic_t cpu_doing_single_step;
17106 +extern atomic_t kgdb_sync_softlockup[NR_CPUS];
17108 +extern struct task_struct *kgdb_usethread, *kgdb_contthread;
17110 +enum kgdb_bptype {
17111 + bp_breakpoint = '0',
17112 + bp_hardware_breakpoint,
17113 + bp_write_watchpoint,
17114 + bp_read_watchpoint,
17115 + bp_access_watchpoint
17118 +enum kgdb_bpstate {
17125 +struct kgdb_bkpt {
17126 + unsigned long bpt_addr;
17127 + unsigned char saved_instr[BREAK_INSTR_SIZE];
17128 + enum kgdb_bptype type;
17129 + enum kgdb_bpstate state;
17132 +/* The maximum number of KGDB I/O modules that can be loaded */
17133 +#define MAX_KGDB_IO_HANDLERS 3
17135 +#ifndef MAX_BREAKPOINTS
17136 +#define MAX_BREAKPOINTS 1000
17139 +#define KGDB_HW_BREAKPOINT 1
17141 +/* Required functions. */
17143 + * regs_to_gdb_regs - Convert ptrace regs to GDB regs
17144 + * @gdb_regs: A pointer to hold the registers in the order GDB wants.
17145 + * @regs: The &struct pt_regs of the current process.
17147 + * Convert the pt_regs in @regs into the format for registers that
17148 + * GDB expects, stored in @gdb_regs.
17150 +extern void regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs);
17153 + * sleeping_regs_to_gdb_regs - Convert ptrace regs to GDB regs
17154 + * @gdb_regs: A pointer to hold the registers in the order GDB wants.
17155 + * @p: The &struct task_struct of the desired process.
17157 + * Convert the register values of the sleeping process in @p to
17158 + * the format that GDB expects.
17159 + * This function is called when kgdb does not have access to the
17160 + * &struct pt_regs and therefore it should fill the gdb registers
17161 + * @gdb_regs with what has been saved in &struct thread_struct
17162 + * thread field during switch_to.
17164 +extern void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs,
17165 + struct task_struct *p);
17168 + * gdb_regs_to_regs - Convert GDB regs to ptrace regs.
17169 + * @gdb_regs: A pointer to hold the registers we've recieved from GDB.
17170 + * @regs: A pointer to a &struct pt_regs to hold these values in.
17172 + * Convert the GDB regs in @gdb_regs into the pt_regs, and store them
17175 +extern void gdb_regs_to_regs(unsigned long *gdb_regs, struct pt_regs *regs);
17178 + * kgdb_arch_handle_exception - Handle architecture specific GDB packets.
17179 + * @vector: The error vector of the exception that happened.
17180 + * @signo: The signal number of the exception that happened.
17181 + * @err_code: The error code of the exception that happened.
17182 + * @remcom_in_buffer: The buffer of the packet we have read.
17183 + * @remcom_out_buffer: The buffer, of %BUFMAX to write a packet into.
17184 + * @regs: The &struct pt_regs of the current process.
17186 + * This function MUST handle the 'c' and 's' command packets,
17187 + * as well packets to set / remove a hardware breakpoint, if used.
17188 + * If there are additional packets which the hardware needs to handle,
17189 + * they are handled here. The code should return -1 if it wants to
17190 + * process more packets, and a %0 or %1 if it wants to exit from the
17193 +extern int kgdb_arch_handle_exception(int vector, int signo, int err_code,
17194 + char *remcom_in_buffer,
17195 + char *remcom_out_buffer,
17196 + struct pt_regs *regs);
17198 +#ifndef JMP_REGS_ALIGNMENT
17199 +#define JMP_REGS_ALIGNMENT
17202 +extern unsigned long kgdb_fault_jmp_regs[];
17205 + * kgdb_fault_setjmp - Store state in case we fault.
17206 + * @curr_context: An array to store state into.
17208 + * Certain functions may try and access memory, and in doing so may
17209 + * cause a fault. When this happens, we trap it, restore state to
17210 + * this call, and let ourself know that something bad has happened.
17212 +extern asmlinkage int kgdb_fault_setjmp(unsigned long *curr_context);
17215 + * kgdb_fault_longjmp - Restore state when we have faulted.
17216 + * @curr_context: The previously stored state.
17218 + * When something bad does happen, this function is called to
17219 + * restore the known good state, and set the return value to 1, so
17220 + * we know something bad happened.
17222 +extern asmlinkage void kgdb_fault_longjmp(unsigned long *curr_context);
17224 +/* Optional functions. */
17225 +extern int kgdb_arch_init(void);
17226 +extern void kgdb_disable_hw_debug(struct pt_regs *regs);
17227 +extern void kgdb_post_master_code(struct pt_regs *regs, int e_vector,
17229 +extern void kgdb_roundup_cpus(unsigned long flags);
17230 +extern int kgdb_set_hw_break(unsigned long addr);
17231 +extern int kgdb_remove_hw_break(unsigned long addr);
17232 +extern void kgdb_remove_all_hw_break(void);
17233 +extern void kgdb_correct_hw_break(void);
17234 +extern void kgdb_shadowinfo(struct pt_regs *regs, char *buffer,
17235 + unsigned threadid);
17236 +extern struct task_struct *kgdb_get_shadow_thread(struct pt_regs *regs,
17238 +extern struct pt_regs *kgdb_shadow_regs(struct pt_regs *regs, int threadid);
17239 +extern int kgdb_validate_break_address(unsigned long addr);
17240 +extern int kgdb_arch_set_breakpoint(unsigned long addr, char *saved_instr);
17241 +extern int kgdb_arch_remove_breakpoint(unsigned long addr, char *bundle);
17244 + * struct kgdb_arch - Desribe architecture specific values.
17245 + * @gdb_bpt_instr: The instruction to trigger a breakpoint.
17246 + * @flags: Flags for the breakpoint, currently just %KGDB_HW_BREAKPOINT.
17247 + * @shadowth: A value of %1 indicates we shadow information on processes.
17248 + * @set_breakpoint: Allow an architecture to specify how to set a software
17250 + * @remove_breakpoint: Allow an architecture to specify how to remove a
17251 + * software breakpoint.
17252 + * @set_hw_breakpoint: Allow an architecture to specify how to set a hardware
17254 + * @remove_hw_breakpoint: Allow an architecture to specify how to remove a
17255 + * hardware breakpoint.
17257 + * The @shadowth flag is an option to shadow information not retrievable by
17258 + * gdb otherwise. This is deprecated in favor of a binutils which supports
17261 +struct kgdb_arch {
17262 + unsigned char gdb_bpt_instr[BREAK_INSTR_SIZE];
17263 + unsigned long flags;
17264 + unsigned shadowth;
17265 + int (*set_breakpoint) (unsigned long, char *);
17266 + int (*remove_breakpoint)(unsigned long, char *);
17267 + int (*set_hw_breakpoint)(unsigned long, int, enum kgdb_bptype);
17268 + int (*remove_hw_breakpoint)(unsigned long, int, enum kgdb_bptype);
17271 +/* Thread reference */
17272 +typedef unsigned char threadref[8];
17275 + * struct kgdb_io - Desribe the interface for an I/O driver to talk with KGDB.
17276 + * @read_char: Pointer to a function that will return one char.
17277 + * @write_char: Pointer to a function that will write one char.
17278 + * @flush: Pointer to a function that will flush any pending writes.
17279 + * @init: Pointer to a function that will initialize the device.
17280 + * @late_init: Pointer to a function that will do any setup that has
17281 + * other dependencies.
17282 + * @pre_exception: Pointer to a function that will do any prep work for
17283 + * the I/O driver.
17284 + * @post_exception: Pointer to a function that will do any cleanup work
17285 + * for the I/O driver.
17287 + * The @init and @late_init function pointers allow for an I/O driver
17288 + * such as a serial driver to fully initialize the port with @init and
17289 + * be called very early, yet safely call request_irq() later in the boot
17292 + * @init is allowed to return a non-0 return value to indicate failure.
17293 + * If this is called early on, then KGDB will try again when it would call
17294 + * @late_init. If it has failed later in boot as well, the user will be
17298 + int (*read_char) (void);
17299 + void (*write_char) (u8);
17300 + void (*flush) (void);
17301 + int (*init) (void);
17302 + void (*late_init) (void);
17303 + void (*pre_exception) (void);
17304 + void (*post_exception) (void);
17307 +extern struct kgdb_io kgdb_io_ops;
17308 +extern struct kgdb_arch arch_kgdb_ops;
17309 +extern int kgdb_initialized;
17311 +extern int kgdb_register_io_module(struct kgdb_io *local_kgdb_io_ops);
17312 +extern void kgdb_unregister_io_module(struct kgdb_io *local_kgdb_io_ops);
17314 +extern void __init kgdb8250_add_port(int i, struct uart_port *serial_req);
17315 +extern void __init kgdb8250_add_platform_port(int i, struct plat_serial8250_port *serial_req);
17317 +extern int kgdb_hex2long(char **ptr, long *long_val);
17318 +extern char *kgdb_mem2hex(char *mem, char *buf, int count);
17319 +extern char *kgdb_hex2mem(char *buf, char *mem, int count);
17320 +extern int kgdb_get_mem(char *addr, unsigned char *buf, int count);
17321 +extern int kgdb_set_mem(char *addr, unsigned char *buf, int count);
17323 +int kgdb_isremovedbreak(unsigned long addr);
17324 +int kgdb_skipexception(int exception, struct pt_regs *regs);
17326 +extern int kgdb_handle_exception(int ex_vector, int signo, int err_code,
17327 + struct pt_regs *regs);
17328 +extern void kgdb_nmihook(int cpu, void *regs);
17329 +extern int debugger_step;
17330 +extern atomic_t debugger_active;
17331 +extern struct kgdb_arch *kgdb_ops;
17333 +/* Stubs for when KGDB is not set. */
17334 +static const atomic_t debugger_active = ATOMIC_INIT(0);
17335 +#endif /* CONFIG_KGDB */
17336 +#endif /* _KGDB_H_ */
17337 +#endif /* __KERNEL__ */
17338 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/include/linux/module.h linux-2.6.18.kgdb/include/linux/module.h
17339 --- linux-2.6.18/include/linux/module.h 2006-09-20 07:42:06.000000000 +0400
17340 +++ linux-2.6.18.kgdb/include/linux/module.h 2008-06-10 16:20:07.000000000 +0400
17341 @@ -224,8 +224,17 @@ enum module_state
17343 MODULE_STATE_COMING,
17344 MODULE_STATE_GOING,
17345 + MODULE_STATE_GONE,
17348 +#ifdef CONFIG_KGDB
17349 +#define MAX_SECTNAME 31
17350 +struct mod_section {
17352 + char name[MAX_SECTNAME + 1];
17356 /* Similar stuff for section attributes. */
17357 #define MODULE_SECT_NAME_LEN 32
17358 struct module_sect_attr
17359 @@ -253,6 +262,13 @@ struct module
17360 /* Unique handle for this module */
17361 char name[MODULE_NAME_LEN];
17363 +#ifdef CONFIG_KGDB
17364 + /* keep kgdb info at the begining so that gdb doesn't have a chance to
17365 + * miss out any fields */
17366 + unsigned long num_sections;
17367 + struct mod_section *mod_sections;
17371 struct module_kobject mkobj;
17372 struct module_param_attrs *param_attrs;
17373 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/include/linux/netpoll.h linux-2.6.18.kgdb/include/linux/netpoll.h
17374 --- linux-2.6.18/include/linux/netpoll.h 2006-09-20 07:42:06.000000000 +0400
17375 +++ linux-2.6.18.kgdb/include/linux/netpoll.h 2008-06-10 16:19:07.000000000 +0400
17376 @@ -17,7 +17,7 @@ struct netpoll;
17378 struct net_device *dev;
17379 char dev_name[16], *name;
17380 - void (*rx_hook)(struct netpoll *, int, char *, int);
17381 + void (*rx_hook)(struct netpoll *, int, char *, int, struct sk_buff *);
17382 void (*drop)(struct sk_buff *skb);
17383 u32 local_ip, remote_ip;
17384 u16 local_port, remote_port;
17385 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/include/linux/serial_8250.h linux-2.6.18.kgdb/include/linux/serial_8250.h
17386 --- linux-2.6.18/include/linux/serial_8250.h 2006-09-20 07:42:06.000000000 +0400
17387 +++ linux-2.6.18.kgdb/include/linux/serial_8250.h 2008-06-10 16:19:03.000000000 +0400
17388 @@ -56,6 +56,7 @@ struct uart_port;
17390 int serial8250_register_port(struct uart_port *);
17391 void serial8250_unregister_port(int line);
17392 +void serial8250_unregister_by_port(struct uart_port *port);
17393 void serial8250_suspend_port(int line);
17394 void serial8250_resume_port(int line);
17396 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/kernel/Makefile linux-2.6.18.kgdb/kernel/Makefile
17397 --- linux-2.6.18/kernel/Makefile 2006-09-20 07:42:06.000000000 +0400
17398 +++ linux-2.6.18.kgdb/kernel/Makefile 2008-06-10 16:18:58.000000000 +0400
17399 @@ -42,6 +42,7 @@ obj-$(CONFIG_STOP_MACHINE) += stop_machi
17400 obj-$(CONFIG_AUDIT) += audit.o auditfilter.o
17401 obj-$(CONFIG_AUDITSYSCALL) += auditsc.o
17402 obj-$(CONFIG_KPROBES) += kprobes.o
17403 +obj-$(CONFIG_KGDB) += kgdb.o kgdbarchlib.o
17404 obj-$(CONFIG_SYSFS) += ksysfs.o
17405 obj-$(CONFIG_DETECT_SOFTLOCKUP) += softlockup.o
17406 obj-$(CONFIG_GENERIC_HARDIRQS) += irq/
17407 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/kernel/kgdb.c linux-2.6.18.kgdb/kernel/kgdb.c
17408 --- linux-2.6.18/kernel/kgdb.c 1970-01-01 03:00:00.000000000 +0300
17409 +++ linux-2.6.18.kgdb/kernel/kgdb.c 2008-06-10 16:20:11.000000000 +0400
17414 + * Maintainer: Tom Rini <trini@kernel.crashing.org>
17416 + * Copyright (C) 2000-2001 VERITAS Software Corporation.
17417 + * Copyright (C) 2002-2004 Timesys Corporation
17418 + * Copyright (C) 2003-2004 Amit S. Kale <amitkale@linsyssoft.com>
17419 + * Copyright (C) 2004 Pavel Machek <pavel@suse.cz>
17420 + * Copyright (C) 2004-2005 Tom Rini <trini@kernel.crashing.org>
17421 + * Copyright (C) 2004-2006 LinSysSoft Technologies Pvt. Ltd.
17422 + * Copyright (C) 2005 Wind River Systems, Inc.
17424 + * Contributors at various stages not listed above:
17425 + * Jason Wessel ( jason.wessel@windriver.com )
17426 + * George Anzinger <george@mvista.com>
17427 + * Anurekh Saxena (anurekh.saxena@timesys.com)
17428 + * Lake Stevens Instrument Division (Glenn Engel)
17429 + * Jim Kingdon, Cygnus Support.
17431 + * Original KGDB stub: David Grothe <dave@gcom.com>,
17432 + * Tigran Aivazian <tigran@sco.com>
17434 + * This file is licensed under the terms of the GNU General Public License
17435 + * version 2. This program is licensed "as is" without any warranty of any
17436 + * kind, whether express or implied.
17439 +#include <linux/string.h>
17440 +#include <linux/kernel.h>
17441 +#include <linux/interrupt.h>
17442 +#include <linux/sched.h>
17443 +#include <linux/smp.h>
17444 +#include <linux/spinlock.h>
17445 +#include <linux/delay.h>
17446 +#include <linux/mm.h>
17447 +#include <linux/threads.h>
17448 +#include <linux/reboot.h>
17449 +#include <asm/system.h>
17450 +#include <asm/ptrace.h>
17451 +#include <asm/uaccess.h>
17452 +#include <linux/kgdb.h>
17453 +#include <asm/atomic.h>
17454 +#include <linux/notifier.h>
17455 +#include <linux/module.h>
17456 +#include <asm/cacheflush.h>
17457 +#include <linux/init.h>
17458 +#include <linux/sysrq.h>
17459 +#include <linux/console.h>
17460 +#include <linux/sched.h>
17461 +#include <asm/byteorder.h>
17463 +extern int pid_max;
17464 +/* How many times to count all of the waiting CPUs */
17465 +#define ROUNDUP_WAIT 640000 /* Arbitrary, increase if needed. */
17466 +#define BUF_THREAD_ID_SIZE 16
17469 + * kgdb_initialized with a value of 1 indicates that kgdb is setup and is
17470 + * all ready to serve breakpoints and other kernel exceptions. A value of
17471 + * -1 indicates that we have tried to initialize early, and need to try
17474 +int kgdb_initialized;
17475 +/* Is a host GDB connected to us? */
17476 +int kgdb_connected;
17477 +/* Could we be about to try and access a bad memory location? If so we
17478 + * also need to flag this has happend. */
17479 +int kgdb_may_fault;
17480 +/* All the KGDB handlers are installed */
17481 +int kgdb_from_module_registered = 0;
17483 +/* We provide a kgdb_io_ops structure that may be overriden. */
17484 +struct kgdb_io __attribute__ ((weak)) kgdb_io_ops;
17486 +static struct kgdb_io kgdb_io_ops_prev[MAX_KGDB_IO_HANDLERS];
17487 +static int kgdb_io_handler_cnt = 0;
17489 +/* Export the following symbols for use with kernel modules */
17490 +EXPORT_SYMBOL(kgdb_io_ops);
17491 +EXPORT_SYMBOL(kgdb_tasklet_breakpoint);
17492 +EXPORT_SYMBOL(kgdb_connected);
17493 +EXPORT_SYMBOL(kgdb_register_io_module);
17494 +EXPORT_SYMBOL(kgdb_unregister_io_module);
17495 +EXPORT_SYMBOL(debugger_active);
17498 + * Holds information about breakpoints in a kernel. These breakpoints are
17499 + * added and removed by gdb.
17501 +struct kgdb_bkpt kgdb_break[MAX_BREAKPOINTS];
17503 +static const char hexchars[] = "0123456789abcdef";
17505 +static spinlock_t slavecpulocks[NR_CPUS];
17506 +static atomic_t procindebug[NR_CPUS];
17507 +atomic_t kgdb_setting_breakpoint;
17508 +EXPORT_SYMBOL(kgdb_setting_breakpoint);
17509 +struct task_struct *kgdb_usethread, *kgdb_contthread;
17511 +int debugger_step;
17512 +atomic_t debugger_active;
17514 +/* Our I/O buffers. */
17515 +static char remcom_in_buffer[BUFMAX];
17516 +static char remcom_out_buffer[BUFMAX];
17517 +/* Storage for the registers, in GDB format. */
17518 +static unsigned long gdb_regs[(NUMREGBYTES + sizeof(unsigned long) - 1) /
17519 + sizeof(unsigned long)];
17520 +/* Storage of registers for handling a fault. */
17521 +unsigned long kgdb_fault_jmp_regs[NUMCRITREGBYTES / sizeof(unsigned long)]
17522 + JMP_REGS_ALIGNMENT;
17523 +static int kgdb_notify_reboot(struct notifier_block *this,
17524 + unsigned long code ,void *x);
17525 +struct debuggerinfo_struct {
17526 + void *debuggerinfo;
17527 + struct task_struct *task;
17528 +} kgdb_info[NR_CPUS];
17530 +/* to keep track of the CPU which is doing the single stepping*/
17531 +atomic_t cpu_doing_single_step = ATOMIC_INIT(-1);
17533 +atomic_t kgdb_sync_softlockup[NR_CPUS] = {ATOMIC_INIT(0)};
17535 +/* reboot notifier block */
17536 +static struct notifier_block kgdb_reboot_notifier = {
17537 + .notifier_call = kgdb_notify_reboot,
17539 + .priority = INT_MAX,
17542 +static int hex(char ch)
17544 + if ((ch >= 'a') && (ch <= 'f'))
17545 + return (ch - 'a' + 10);
17546 + if ((ch >= '0') && (ch <= '9'))
17547 + return (ch - '0');
17548 + if ((ch >= 'A') && (ch <= 'F'))
17549 + return (ch - 'A' + 10);
17553 +/* scan for the sequence $<data>#<checksum> */
17554 +static void get_packet(char *buffer)
17556 + unsigned char checksum;
17557 + unsigned char xmitcsum;
17560 + if (!kgdb_io_ops.read_char)
17563 + /* Spin and wait around for the start character, ignore all
17564 + * other characters */
17565 + while ((ch = (kgdb_io_ops.read_char())) != '$') ;
17566 + kgdb_connected = 1;
17572 + /* now, read until a # or end of buffer is found */
17573 + while (count < (BUFMAX - 1)) {
17574 + ch = kgdb_io_ops.read_char();
17577 + checksum = checksum + ch;
17578 + buffer[count] = ch;
17579 + count = count + 1;
17581 + buffer[count] = 0;
17584 + xmitcsum = hex(kgdb_io_ops.read_char()) << 4;
17585 + xmitcsum += hex(kgdb_io_ops.read_char());
17587 + if (checksum != xmitcsum)
17588 + /* failed checksum */
17589 + kgdb_io_ops.write_char('-');
17591 + /* successful transfer */
17592 + kgdb_io_ops.write_char('+');
17593 + if (kgdb_io_ops.flush)
17594 + kgdb_io_ops.flush();
17596 + } while (checksum != xmitcsum);
17600 + * Send the packet in buffer.
17601 + * Check for gdb connection if asked for.
17603 +static void put_packet(char *buffer)
17605 + unsigned char checksum;
17609 + if (!kgdb_io_ops.write_char)
17611 + /* $<packet info>#<checksum>. */
17613 + kgdb_io_ops.write_char('$');
17617 + while ((ch = buffer[count])) {
17618 + kgdb_io_ops.write_char(ch);
17623 + kgdb_io_ops.write_char('#');
17624 + kgdb_io_ops.write_char(hexchars[checksum >> 4]);
17625 + kgdb_io_ops.write_char(hexchars[checksum % 16]);
17626 + if (kgdb_io_ops.flush)
17627 + kgdb_io_ops.flush();
17629 + /* Now see what we get in reply. */
17630 + ch = kgdb_io_ops.read_char();
17633 + ch = kgdb_io_ops.read_char();
17635 + /* If we get an ACK, we are done. */
17639 + /* If we get the start of another packet, this means
17640 + * that GDB is attempting to reconnect. We will NAK
17641 + * the packet being sent, and stop trying to send this
17644 + kgdb_io_ops.write_char('-');
17645 + if (kgdb_io_ops.flush)
17646 + kgdb_io_ops.flush();
17653 + * convert the memory pointed to by mem into hex, placing result in buf
17654 + * return a pointer to the last char put in buf (null). May return an error.
17656 +char *kgdb_mem2hex(char *mem, char *buf, int count)
17658 + kgdb_may_fault = 1;
17659 + if ((kgdb_fault_setjmp(kgdb_fault_jmp_regs)) != 0) {
17660 + kgdb_may_fault = 0;
17661 + return ERR_PTR(-EINVAL);
17663 + /* Accessing some registers in a single load instruction is
17664 + * required to avoid bad side effects for some I/O registers.
17666 + if ((count == 2) && (((long)mem & 1) == 0)) {
17667 + unsigned short tmp_s = *(unsigned short *)mem;
17669 +#ifdef __BIG_ENDIAN
17670 + *buf++ = hexchars[(tmp_s >> 12) & 0xf];
17671 + *buf++ = hexchars[(tmp_s >> 8) & 0xf];
17672 + *buf++ = hexchars[(tmp_s >> 4) & 0xf];
17673 + *buf++ = hexchars[tmp_s & 0xf];
17675 + *buf++ = hexchars[(tmp_s >> 4) & 0xf];
17676 + *buf++ = hexchars[tmp_s & 0xf];
17677 + *buf++ = hexchars[(tmp_s >> 12) & 0xf];
17678 + *buf++ = hexchars[(tmp_s >> 8) & 0xf];
17680 + } else if ((count == 4) && (((long)mem & 3) == 0)) {
17681 + unsigned long tmp_l = *(unsigned int *)mem;
17683 +#ifdef __BIG_ENDIAN
17684 + *buf++ = hexchars[(tmp_l >> 28) & 0xf];
17685 + *buf++ = hexchars[(tmp_l >> 24) & 0xf];
17686 + *buf++ = hexchars[(tmp_l >> 20) & 0xf];
17687 + *buf++ = hexchars[(tmp_l >> 16) & 0xf];
17688 + *buf++ = hexchars[(tmp_l >> 12) & 0xf];
17689 + *buf++ = hexchars[(tmp_l >> 8) & 0xf];
17690 + *buf++ = hexchars[(tmp_l >> 4) & 0xf];
17691 + *buf++ = hexchars[tmp_l & 0xf];
17693 + *buf++ = hexchars[(tmp_l >> 4) & 0xf];
17694 + *buf++ = hexchars[tmp_l & 0xf];
17695 + *buf++ = hexchars[(tmp_l >> 12) & 0xf];
17696 + *buf++ = hexchars[(tmp_l >> 8) & 0xf];
17697 + *buf++ = hexchars[(tmp_l >> 20) & 0xf];
17698 + *buf++ = hexchars[(tmp_l >> 16) & 0xf];
17699 + *buf++ = hexchars[(tmp_l >> 28) & 0xf];
17700 + *buf++ = hexchars[(tmp_l >> 24) & 0xf];
17702 +#ifdef CONFIG_64BIT
17703 + } else if ((count == 8) && (((long)mem & 7) == 0)) {
17704 + unsigned long long tmp_ll = *(unsigned long long *)mem;
17706 +#ifdef __BIG_ENDIAN
17707 + *buf++ = hexchars[(tmp_ll >> 60) & 0xf];
17708 + *buf++ = hexchars[(tmp_ll >> 56) & 0xf];
17709 + *buf++ = hexchars[(tmp_ll >> 52) & 0xf];
17710 + *buf++ = hexchars[(tmp_ll >> 48) & 0xf];
17711 + *buf++ = hexchars[(tmp_ll >> 44) & 0xf];
17712 + *buf++ = hexchars[(tmp_ll >> 40) & 0xf];
17713 + *buf++ = hexchars[(tmp_ll >> 36) & 0xf];
17714 + *buf++ = hexchars[(tmp_ll >> 32) & 0xf];
17715 + *buf++ = hexchars[(tmp_ll >> 28) & 0xf];
17716 + *buf++ = hexchars[(tmp_ll >> 24) & 0xf];
17717 + *buf++ = hexchars[(tmp_ll >> 20) & 0xf];
17718 + *buf++ = hexchars[(tmp_ll >> 16) & 0xf];
17719 + *buf++ = hexchars[(tmp_ll >> 12) & 0xf];
17720 + *buf++ = hexchars[(tmp_ll >> 8) & 0xf];
17721 + *buf++ = hexchars[(tmp_ll >> 4) & 0xf];
17722 + *buf++ = hexchars[tmp_ll & 0xf];
17724 + *buf++ = hexchars[(tmp_ll >> 4) & 0xf];
17725 + *buf++ = hexchars[tmp_ll & 0xf];
17726 + *buf++ = hexchars[(tmp_ll >> 12) & 0xf];
17727 + *buf++ = hexchars[(tmp_ll >> 8) & 0xf];
17728 + *buf++ = hexchars[(tmp_ll >> 20) & 0xf];
17729 + *buf++ = hexchars[(tmp_ll >> 16) & 0xf];
17730 + *buf++ = hexchars[(tmp_ll >> 28) & 0xf];
17731 + *buf++ = hexchars[(tmp_ll >> 24) & 0xf];
17732 + *buf++ = hexchars[(tmp_ll >> 36) & 0xf];
17733 + *buf++ = hexchars[(tmp_ll >> 32) & 0xf];
17734 + *buf++ = hexchars[(tmp_ll >> 44) & 0xf];
17735 + *buf++ = hexchars[(tmp_ll >> 40) & 0xf];
17736 + *buf++ = hexchars[(tmp_ll >> 52) & 0xf];
17737 + *buf++ = hexchars[(tmp_ll >> 48) & 0xf];
17738 + *buf++ = hexchars[(tmp_ll >> 60) & 0xf];
17739 + *buf++ = hexchars[(tmp_ll >> 56) & 0xf];
17743 + while (count-- > 0) {
17744 + unsigned char ch = *mem++;
17745 + *buf++ = hexchars[ch >> 4];
17746 + *buf++ = hexchars[ch & 0xf];
17749 + kgdb_may_fault = 0;
17755 + * Copy the binary array pointed to by buf into mem. Fix $, #, and
17756 + * 0x7d escaped with 0x7d. Return a pointer to the character after
17757 + * the last byte written.
17759 +static char *kgdb_ebin2mem(char *buf, char *mem, int count)
17761 + kgdb_may_fault = 1;
17762 + if ((kgdb_fault_setjmp(kgdb_fault_jmp_regs)) != 0) {
17763 + kgdb_may_fault = 0;
17764 + return ERR_PTR(-EINVAL);
17766 + for (; count > 0; count--, buf++) {
17767 + if (*buf == 0x7d)
17768 + *mem++ = *(++buf) ^ 0x20;
17772 + kgdb_may_fault = 0;
17777 + * convert the hex array pointed to by buf into binary to be placed in mem
17778 + * return a pointer to the character AFTER the last byte written
17779 + * May return an error.
17781 +char *kgdb_hex2mem(char *buf, char *mem, int count)
17783 + kgdb_may_fault = 1;
17784 + if ((kgdb_fault_setjmp(kgdb_fault_jmp_regs)) != 0) {
17785 + kgdb_may_fault = 0;
17786 + return ERR_PTR(-EINVAL);
17788 + if ((count == 2) && (((long)mem & 1) == 0)) {
17789 + unsigned short tmp_s = 0;
17790 +#ifdef __BIG_ENDIAN
17791 + tmp_s |= hex(*buf++) << 12;
17792 + tmp_s |= hex(*buf++) << 8;
17793 + tmp_s |= hex(*buf++) << 4;
17794 + tmp_s |= hex(*buf++);
17796 + tmp_s |= hex(*buf++) << 4;
17797 + tmp_s |= hex(*buf++);
17798 + tmp_s |= hex(*buf++) << 12;
17799 + tmp_s |= hex(*buf++) << 8;
17801 + *(unsigned short *)mem = tmp_s;
17803 + } else if ((count == 4) && (((long)mem & 3) == 0)) {
17804 + unsigned long tmp_l = 0;
17805 +#ifdef __BIG_ENDIAN
17806 + tmp_l |= hex(*buf++) << 28;
17807 + tmp_l |= hex(*buf++) << 24;
17808 + tmp_l |= hex(*buf++) << 20;
17809 + tmp_l |= hex(*buf++) << 16;
17810 + tmp_l |= hex(*buf++) << 12;
17811 + tmp_l |= hex(*buf++) << 8;
17812 + tmp_l |= hex(*buf++) << 4;
17813 + tmp_l |= hex(*buf++);
17815 + tmp_l |= hex(*buf++) << 4;
17816 + tmp_l |= hex(*buf++);
17817 + tmp_l |= hex(*buf++) << 12;
17818 + tmp_l |= hex(*buf++) << 8;
17819 + tmp_l |= hex(*buf++) << 20;
17820 + tmp_l |= hex(*buf++) << 16;
17821 + tmp_l |= hex(*buf++) << 28;
17822 + tmp_l |= hex(*buf++) << 24;
17824 + *(unsigned long *)mem = tmp_l;
17828 + for (i = 0; i < count; i++) {
17829 + unsigned char ch = hex(*buf++) << 4;
17830 + ch |= hex(*buf++);
17834 + kgdb_may_fault = 0;
17839 + * While we find nice hex chars, build a long_val.
17840 + * Return number of chars processed.
17842 +int kgdb_hex2long(char **ptr, long *long_val)
17844 + int hex_val, num = 0;
17849 + hex_val = hex(**ptr);
17850 + if (hex_val >= 0) {
17851 + *long_val = (*long_val << 4) | hex_val;
17862 +/* Write memory due to an 'M' or 'X' packet. */
17863 +static char *write_mem_msg(int binary)
17865 + char *ptr = &remcom_in_buffer[1];
17866 + unsigned long addr, length;
17868 + if (kgdb_hex2long(&ptr, &addr) > 0 && *(ptr++) == ',' &&
17869 + kgdb_hex2long(&ptr, &length) > 0 && *(ptr++) == ':') {
17871 + ptr = kgdb_ebin2mem(ptr, (char *)addr, length);
17873 + ptr = kgdb_hex2mem(ptr, (char *)addr, length);
17874 + if (CACHE_FLUSH_IS_SAFE)
17875 + flush_icache_range(addr, addr + length + 1);
17881 + return ERR_PTR(-EINVAL);
17884 +static inline char *pack_hex_byte(char *pkt, int byte)
17886 + *pkt++ = hexchars[(byte >> 4) & 0xf];
17887 + *pkt++ = hexchars[(byte & 0xf)];
17891 +static inline void error_packet(char *pkt, int error)
17895 + pkt[1] = hexchars[(error / 10)];
17896 + pkt[2] = hexchars[(error % 10)];
17900 +static char *pack_threadid(char *pkt, threadref * id)
17903 + unsigned char *altid;
17905 + altid = (unsigned char *)id;
17906 + limit = pkt + BUF_THREAD_ID_SIZE;
17907 + while (pkt < limit)
17908 + pkt = pack_hex_byte(pkt, *altid++);
17913 +void int_to_threadref(threadref * id, int value)
17915 + unsigned char *scan;
17918 + scan = (unsigned char *)id;
17921 + *scan++ = (value >> 24) & 0xff;
17922 + *scan++ = (value >> 16) & 0xff;
17923 + *scan++ = (value >> 8) & 0xff;
17924 + *scan++ = (value & 0xff);
17927 +static struct task_struct *getthread(struct pt_regs *regs, int tid)
17929 + if (last_pid == 0)
17932 + if (num_online_cpus() &&
17933 + (tid >= pid_max + num_online_cpus() + kgdb_ops->shadowth))
17936 + if (kgdb_ops->shadowth && (tid >= pid_max + num_online_cpus()))
17937 + return kgdb_get_shadow_thread(regs, tid - pid_max -
17938 + num_online_cpus());
17940 + if (tid >= pid_max)
17941 + return idle_task(tid - pid_max);
17946 + return find_task_by_pid(tid);
17950 +static void kgdb_wait(struct pt_regs *regs)
17952 + unsigned long flags;
17955 + local_irq_save(flags);
17956 + processor = smp_processor_id();
17957 + kgdb_info[processor].debuggerinfo = regs;
17958 + kgdb_info[processor].task = current;
17959 + atomic_set(&procindebug[processor], 1);
17960 + atomic_set(&kgdb_sync_softlockup[smp_processor_id()], 1);
17962 + /* Wait till master processor goes completely into the debugger.
17963 + * FIXME: this looks racy */
17964 + while (!atomic_read(&procindebug[atomic_read(&debugger_active) - 1])) {
17965 + int i = 10; /* an arbitrary number */
17971 + /* Wait till master processor is done with debugging */
17972 + spin_lock_nested(&slavecpulocks[processor], processor);
17974 + /* This has been taken from x86 kgdb implementation and
17975 + * will be needed by architectures that have SMP support
17977 + kgdb_correct_hw_break();
17979 + kgdb_info[processor].debuggerinfo = NULL;
17980 + kgdb_info[processor].task = NULL;
17982 + /* Signal the master processor that we are done */
17983 + atomic_set(&procindebug[processor], 0);
17984 + spin_unlock(&slavecpulocks[processor]);
17985 + local_irq_restore(flags);
17989 +int kgdb_get_mem(char *addr, unsigned char *buf, int count)
17991 + kgdb_may_fault = 1;
17992 + if ((kgdb_fault_setjmp(kgdb_fault_jmp_regs)) != 0) {
17993 + kgdb_may_fault = 0;
17997 + if ((unsigned long)addr < TASK_SIZE)
17999 + *buf++ = *addr++;
18002 + kgdb_may_fault = 0;
18006 +int kgdb_set_mem(char *addr, unsigned char *buf, int count)
18008 + kgdb_may_fault = 1;
18009 + if ((kgdb_fault_setjmp(kgdb_fault_jmp_regs)) != 0) {
18010 + kgdb_may_fault = 0;
18014 + if ((unsigned long)addr < TASK_SIZE)
18016 + *addr++ = *buf++;
18019 + kgdb_may_fault = 0;
18022 +int kgdb_activate_sw_breakpoints(void)
18026 + unsigned long addr;
18027 + for (i = 0; i < MAX_BREAKPOINTS; i++) {
18028 + if (kgdb_break[i].state != bp_set)
18030 + addr = kgdb_break[i].bpt_addr;
18031 + if ((error = kgdb_arch_set_breakpoint(addr,
18032 + kgdb_break[i].saved_instr)))
18035 + if (CACHE_FLUSH_IS_SAFE) {
18036 + if (current->mm && addr < TASK_SIZE)
18037 + flush_cache_range(current->mm->mmap_cache,
18038 + addr, addr + BREAK_INSTR_SIZE);
18040 + flush_icache_range(addr, addr +
18041 + BREAK_INSTR_SIZE);
18044 + kgdb_break[i].state = bp_active;
18049 +static int kgdb_set_sw_break(unsigned long addr)
18051 + int i, breakno = -1;
18053 + if ((error = kgdb_validate_break_address(addr)) < 0)
18055 + for (i = 0; i < MAX_BREAKPOINTS; i++) {
18056 + if ((kgdb_break[i].state == bp_set) &&
18057 + (kgdb_break[i].bpt_addr == addr))
18060 + for (i = 0; i < MAX_BREAKPOINTS; i++) {
18061 + if (kgdb_break[i].state == bp_removed &&
18062 + kgdb_break[i].bpt_addr == addr) {
18068 + if (breakno == -1) {
18069 + for (i = 0; i < MAX_BREAKPOINTS; i++) {
18070 + if (kgdb_break[i].state == bp_none) {
18076 + if (breakno == -1)
18079 + kgdb_break[breakno].state = bp_set;
18080 + kgdb_break[breakno].type = bp_breakpoint;
18081 + kgdb_break[breakno].bpt_addr = addr;
18086 +int kgdb_deactivate_sw_breakpoints(void)
18090 + unsigned long addr;
18091 + for (i = 0; i < MAX_BREAKPOINTS; i++) {
18092 + if (kgdb_break[i].state != bp_active)
18094 + addr = kgdb_break[i].bpt_addr;
18095 + if ((error = kgdb_arch_remove_breakpoint(addr,
18096 + kgdb_break[i].saved_instr)))
18099 + if (CACHE_FLUSH_IS_SAFE && current->mm &&
18100 + addr < TASK_SIZE)
18101 + flush_cache_range(current->mm->mmap_cache,
18102 + addr, addr + BREAK_INSTR_SIZE);
18103 + else if (CACHE_FLUSH_IS_SAFE)
18104 + flush_icache_range(addr,
18105 + addr + BREAK_INSTR_SIZE);
18106 + kgdb_break[i].state = bp_set;
18111 +static int kgdb_remove_sw_break(unsigned long addr)
18115 + for (i = 0; i < MAX_BREAKPOINTS; i++) {
18116 + if ((kgdb_break[i].state == bp_set) &&
18117 + (kgdb_break[i].bpt_addr == addr)) {
18118 + kgdb_break[i].state = bp_removed;
18125 +int kgdb_isremovedbreak(unsigned long addr)
18128 + for (i = 0; i < MAX_BREAKPOINTS; i++) {
18129 + if ((kgdb_break[i].state == bp_removed) &&
18130 + (kgdb_break[i].bpt_addr == addr)) {
18137 +int remove_all_break(void)
18141 + unsigned long addr;
18143 + /* Clear memory breakpoints. */
18144 + for (i = 0; i < MAX_BREAKPOINTS; i++) {
18145 + if (kgdb_break[i].state != bp_set)
18147 + addr = kgdb_break[i].bpt_addr;
18148 + if ((error = kgdb_arch_remove_breakpoint(addr,
18149 + kgdb_break[i].saved_instr)))
18151 + kgdb_break[i].state = bp_removed;
18154 + /* Clear hardware breakpoints. */
18155 + kgdb_remove_all_hw_break();
18160 +static inline int shadow_pid(int realpid)
18165 + return pid_max + smp_processor_id();
18168 +static char gdbmsgbuf[BUFMAX + 1];
18169 +static void kgdb_msg_write(const char *s, int len)
18176 + gdbmsgbuf[0] = 'O';
18178 + /* Fill and send buffers... */
18179 + while (len > 0) {
18180 + bufptr = gdbmsgbuf + 1;
18182 + /* Calculate how many this time */
18183 + if ((len << 1) > (BUFMAX - 2))
18184 + wcount = (BUFMAX - 2) >> 1;
18188 + /* Pack in hex chars */
18189 + for (i = 0; i < wcount; i++)
18190 + bufptr = pack_hex_byte(bufptr, s[i]);
18197 + /* Write packet */
18198 + put_packet(gdbmsgbuf);
18203 + * This function does all command procesing for interfacing to gdb.
18205 + * Locking hierarchy:
18206 + * interface locks, if any (begin_session)
18207 + * kgdb lock (debugger_active)
18209 + * Note that since we can be in here prior to our cpumask being filled
18210 + * out, we err on the side of caution and loop over NR_CPUS instead
18211 + * of a for_each_online_cpu.
18214 +int kgdb_handle_exception(int ex_vector, int signo, int err_code,
18215 + struct pt_regs *linux_regs)
18217 + unsigned long length, addr;
18219 + unsigned long flags;
18223 + struct task_struct *thread = NULL;
18225 + int numshadowth = num_online_cpus() + kgdb_ops->shadowth;
18226 + long kgdb_usethreadid = 0;
18227 + int error = 0, all_cpus_synced = 0;
18228 + struct pt_regs *shadowregs;
18229 + int processor = smp_processor_id();
18230 + void *local_debuggerinfo;
18232 + /* Panic on recursive debugger calls. */
18233 + if (atomic_read(&debugger_active) == smp_processor_id() + 1)
18238 + /* Call the I/O drivers pre_exception routine if the I/O
18239 + * driver defined one
18241 + if (kgdb_io_ops.pre_exception)
18242 + kgdb_io_ops.pre_exception();
18245 + * Interrupts will be restored by the 'trap return' code, except when
18246 + * single stepping.
18248 + local_irq_save(flags);
18250 + /* Hold debugger_active */
18251 + procid = smp_processor_id();
18253 + while (cmpxchg(&atomic_read(&debugger_active), 0, (procid + 1)) != 0) {
18254 + int i = 25; /* an arbitrary number */
18259 + if (atomic_read(&cpu_doing_single_step) != -1 &&
18260 + atomic_read(&cpu_doing_single_step) != procid)
18264 + atomic_set(&kgdb_sync_softlockup[smp_processor_id()], 1);
18267 + * Don't enter if the last instance of the exception handler wanted to
18268 + * come into the debugger again.
18270 + if (atomic_read(&cpu_doing_single_step) != -1 &&
18271 + atomic_read(&cpu_doing_single_step) != procid) {
18272 + atomic_set(&debugger_active, 0);
18273 + local_irq_restore(flags);
18274 + goto acquirelock;
18278 + * Don't enter if we have hit a removed breakpoint.
18280 + if (kgdb_skipexception(ex_vector, linux_regs))
18281 + goto kgdb_restore;
18283 + kgdb_info[processor].debuggerinfo = linux_regs;
18284 + kgdb_info[processor].task = current;
18286 + kgdb_disable_hw_debug(linux_regs);
18288 + if (!debugger_step || !kgdb_contthread)
18289 + for (i = 0; i < NR_CPUS; i++)
18290 + spin_lock_nested(&slavecpulocks[i], i);
18292 + /* Make sure we get the other CPUs */
18293 + if (!debugger_step || !kgdb_contthread)
18294 + kgdb_roundup_cpus(flags);
18296 + /* spin_lock code is good enough as a barrier so we don't
18297 + * need one here */
18298 + atomic_set(&procindebug[processor], 1);
18300 + /* Wait a reasonable time for the other CPUs to be notified and
18301 + * be waiting for us. Very early on this could be imperfect
18302 + * as num_online_cpus() could be 0.*/
18303 + for (i = 0; i < ROUNDUP_WAIT; i++) {
18304 + int cpu, num = 0;
18305 + for (cpu = 0; cpu < NR_CPUS; cpu++) {
18306 + if (atomic_read(&procindebug[cpu]))
18309 + if (num >= num_online_cpus()) {
18310 + all_cpus_synced = 1;
18315 + /* Clear the out buffer. */
18316 + memset(remcom_out_buffer, 0, sizeof(remcom_out_buffer));
18318 + /* Master processor is completely in the debugger */
18319 + kgdb_post_master_code(linux_regs, ex_vector, err_code);
18320 + kgdb_deactivate_sw_breakpoints();
18321 + debugger_step = 0;
18322 + kgdb_contthread = NULL;
18324 + if (kgdb_connected) {
18325 + /* If we're still unable to roundup all of the CPUs,
18326 + * send an 'O' packet informing the user again. */
18327 + if (!all_cpus_synced)
18328 + kgdb_msg_write("Not all CPUs have been synced for "
18330 + /* Reply to host that an exception has occurred */
18331 + ptr = remcom_out_buffer;
18333 + *ptr++ = hexchars[(signo >> 4) % 16];
18334 + *ptr++ = hexchars[signo % 16];
18335 + ptr += strlen(strcpy(ptr, "thread:"));
18336 + int_to_threadref(&thref, shadow_pid(current->pid));
18337 + ptr = pack_threadid(ptr, &thref);
18340 + put_packet(remcom_out_buffer);
18343 + kgdb_usethread = kgdb_info[processor].task;
18344 + kgdb_usethreadid = shadow_pid(kgdb_info[processor].task->pid);
18346 + while (kgdb_io_ops.read_char) {
18350 + /* Clear the out buffer. */
18351 + memset(remcom_out_buffer, 0, sizeof(remcom_out_buffer));
18353 + get_packet(remcom_in_buffer);
18355 + switch (remcom_in_buffer[0]) {
18357 + /* We know that this packet is only sent
18358 + * during initial connect. So to be safe,
18359 + * we clear out our breakpoints now incase
18360 + * GDB is reconnecting. */
18361 + remove_all_break();
18362 + /* Also, if we haven't been able to roundup all
18363 + * CPUs, send an 'O' packet informing the user
18364 + * as much. Only need to do this once. */
18365 + if (!all_cpus_synced)
18366 + kgdb_msg_write("Not all CPUs have been "
18367 + "synced for KGDB\n", 39);
18368 + remcom_out_buffer[0] = 'S';
18369 + remcom_out_buffer[1] = hexchars[signo >> 4];
18370 + remcom_out_buffer[2] = hexchars[signo % 16];
18373 + case 'g': /* return the value of the CPU registers */
18374 + thread = kgdb_usethread;
18377 + thread = kgdb_info[processor].task;
18378 + local_debuggerinfo =
18379 + kgdb_info[processor].debuggerinfo;
18381 + local_debuggerinfo = NULL;
18382 + for (i = 0; i < NR_CPUS; i++) {
18383 + /* Try to find the task on some other
18384 + * or possibly this node if we do not
18385 + * find the matching task then we try
18386 + * to approximate the results.
18388 + if (thread == kgdb_info[i].task)
18389 + local_debuggerinfo =
18390 + kgdb_info[i].debuggerinfo;
18394 + /* All threads that don't have debuggerinfo should be
18395 + * in __schedule() sleeping, since all other CPUs
18396 + * are in kgdb_wait, and thus have debuggerinfo. */
18397 + if (kgdb_ops->shadowth &&
18398 + kgdb_usethreadid >= pid_max + num_online_cpus()) {
18399 + shadowregs = kgdb_shadow_regs(linux_regs,
18400 + kgdb_usethreadid -
18404 + if (!shadowregs) {
18405 + error_packet(remcom_out_buffer,
18409 + regs_to_gdb_regs(gdb_regs, shadowregs);
18410 + } else if (local_debuggerinfo)
18411 + regs_to_gdb_regs(gdb_regs, local_debuggerinfo);
18413 + /* Pull stuff saved during
18414 + * switch_to; nothing else is
18415 + * accessible (or even particularly relevant).
18416 + * This should be enough for a stack trace. */
18417 + sleeping_thread_to_gdb_regs(gdb_regs, thread);
18419 + kgdb_mem2hex((char *)gdb_regs, remcom_out_buffer,
18423 + /* set the value of the CPU registers - return OK */
18425 + kgdb_hex2mem(&remcom_in_buffer[1], (char *)gdb_regs,
18428 + if (kgdb_usethread && kgdb_usethread != current)
18429 + error_packet(remcom_out_buffer, -EINVAL);
18431 + gdb_regs_to_regs(gdb_regs, linux_regs);
18432 + strcpy(remcom_out_buffer, "OK");
18436 + /* mAA..AA,LLLL Read LLLL bytes at address AA..AA */
18438 + ptr = &remcom_in_buffer[1];
18439 + if (kgdb_hex2long(&ptr, &addr) > 0 && *ptr++ == ',' &&
18440 + kgdb_hex2long(&ptr, &length) > 0) {
18441 + if (IS_ERR(ptr = kgdb_mem2hex((char *)addr,
18442 + remcom_out_buffer,
18444 + error_packet(remcom_out_buffer,
18447 + error_packet(remcom_out_buffer, -EINVAL);
18450 + /* MAA..AA,LLLL: Write LLLL bytes at address AA..AA */
18452 + if (IS_ERR(ptr = write_mem_msg(0)))
18453 + error_packet(remcom_out_buffer, PTR_ERR(ptr));
18455 + strcpy(remcom_out_buffer, "OK");
18457 + /* XAA..AA,LLLL: Write LLLL bytes at address AA..AA */
18459 + if (IS_ERR(ptr = write_mem_msg(1)))
18460 + error_packet(remcom_out_buffer, PTR_ERR(ptr));
18462 + strcpy(remcom_out_buffer, "OK");
18465 + /* kill or detach. KGDB should treat this like a
18469 + if ((error = remove_all_break()) < 0) {
18470 + error_packet(remcom_out_buffer, error);
18472 + strcpy(remcom_out_buffer, "OK");
18473 + kgdb_connected = 0;
18475 + put_packet(remcom_out_buffer);
18476 + goto default_handle;
18479 + /* Don't care about error from remove_all_break */
18480 + remove_all_break();
18481 + kgdb_connected = 0;
18482 + goto default_handle;
18486 + /* For now, only honor R0 */
18487 + if (strcmp(remcom_in_buffer, "R0") == 0) {
18488 + printk(KERN_CRIT "Executing reboot\n");
18489 + strcpy(remcom_out_buffer, "OK");
18490 + put_packet(remcom_out_buffer);
18491 + emergency_sync();
18492 + /* Execution should not return from
18493 + * machine_restart()
18495 + machine_restart(NULL);
18496 + kgdb_connected = 0;
18497 + goto default_handle;
18502 + switch (remcom_in_buffer[1]) {
18505 + if (memcmp(remcom_in_buffer + 2, "ThreadInfo",
18507 + error_packet(remcom_out_buffer,
18513 + * If we have not yet completed in
18514 + * pidhash_init() there isn't much we
18517 + if (last_pid == 0) {
18518 + if (remcom_in_buffer[1] == 'f')
18519 + strcpy(remcom_out_buffer,
18520 + "m0000000000000001");
18524 + if (remcom_in_buffer[1] == 'f') {
18527 + remcom_out_buffer[0] = 'm';
18528 + ptr = remcom_out_buffer + 1;
18529 + for (i = 0; i < 17 && threadid < pid_max +
18530 + numshadowth; threadid++) {
18531 + thread = getthread(linux_regs,
18534 + int_to_threadref(&thref,
18536 + pack_threadid(ptr, &thref);
18546 + /* Current thread id */
18547 + strcpy(remcom_out_buffer, "QC");
18549 + threadid = shadow_pid(current->pid);
18551 + int_to_threadref(&thref, threadid);
18552 + pack_threadid(remcom_out_buffer + 2, &thref);
18555 + if (memcmp(remcom_in_buffer + 1,
18556 + "ThreadExtraInfo,", 16)) {
18557 + error_packet(remcom_out_buffer,
18562 + ptr = remcom_in_buffer + 17;
18563 + kgdb_hex2long(&ptr, &threadid);
18564 + if (!getthread(linux_regs, threadid)) {
18565 + error_packet(remcom_out_buffer,
18569 + if (threadid < pid_max) {
18570 + kgdb_mem2hex(getthread(linux_regs,
18572 + remcom_out_buffer, 16);
18573 + } else if (threadid >= pid_max +
18574 + num_online_cpus()) {
18575 + kgdb_shadowinfo(linux_regs,
18576 + remcom_out_buffer,
18577 + threadid - pid_max -
18578 + num_online_cpus());
18580 + static char tmpstr[23 +
18581 + BUF_THREAD_ID_SIZE];
18582 + sprintf(tmpstr, "Shadow task %d"
18584 + (int)(threadid - pid_max));
18585 + kgdb_mem2hex(tmpstr, remcom_out_buffer,
18592 + /* task related */
18594 + switch (remcom_in_buffer[1]) {
18596 + ptr = &remcom_in_buffer[2];
18597 + kgdb_hex2long(&ptr, &threadid);
18598 + thread = getthread(linux_regs, threadid);
18599 + if (!thread && threadid > 0) {
18600 + error_packet(remcom_out_buffer,
18604 + kgdb_usethread = thread;
18605 + kgdb_usethreadid = threadid;
18606 + strcpy(remcom_out_buffer, "OK");
18610 + ptr = &remcom_in_buffer[2];
18611 + kgdb_hex2long(&ptr, &threadid);
18613 + kgdb_contthread = NULL;
18615 + thread = getthread(linux_regs,
18617 + if (!thread && threadid > 0) {
18618 + error_packet(remcom_out_buffer,
18622 + kgdb_contthread = thread;
18624 + strcpy(remcom_out_buffer, "OK");
18629 + /* Query thread status */
18631 + ptr = &remcom_in_buffer[1];
18632 + kgdb_hex2long(&ptr, &threadid);
18633 + thread = getthread(linux_regs, threadid);
18635 + strcpy(remcom_out_buffer, "OK");
18637 + error_packet(remcom_out_buffer, -EINVAL);
18639 + /* Since GDB-5.3, it's been drafted that '0' is a software
18640 + * breakpoint, '1' is a hardware breakpoint, so let's do
18645 + bpt_type = &remcom_in_buffer[1];
18646 + ptr = &remcom_in_buffer[2];
18648 + if (kgdb_ops->set_hw_breakpoint && *bpt_type >= '1') {
18649 + /* Unsupported */
18650 + if (*bpt_type > '4')
18652 + } else if (*bpt_type != '0' && *bpt_type != '1')
18653 + /* Unsupported. */
18655 + /* Test if this is a hardware breakpoint, and
18656 + * if we support it. */
18657 + if (*bpt_type == '1' &&
18658 + !kgdb_ops->flags & KGDB_HW_BREAKPOINT)
18659 + /* Unsupported. */
18662 + if (*(ptr++) != ',') {
18663 + error_packet(remcom_out_buffer, -EINVAL);
18665 + } else if (kgdb_hex2long(&ptr, &addr)) {
18666 + if (*(ptr++) != ',' ||
18667 + !kgdb_hex2long(&ptr, &length)) {
18668 + error_packet(remcom_out_buffer,
18673 + error_packet(remcom_out_buffer, -EINVAL);
18677 + if (remcom_in_buffer[0] == 'Z' && *bpt_type == '0')
18678 + error = kgdb_set_sw_break(addr);
18679 + else if (remcom_in_buffer[0] == 'Z' && *bpt_type == '1')
18680 + error = kgdb_set_hw_break(addr);
18681 + else if (remcom_in_buffer[0] == 'z' && *bpt_type == '0')
18682 + error = kgdb_remove_sw_break(addr);
18683 + else if (remcom_in_buffer[0] == 'z' && *bpt_type == '1')
18684 + error = kgdb_remove_hw_break(addr);
18685 + else if (remcom_in_buffer[0] == 'Z')
18686 + error = kgdb_ops->set_hw_breakpoint(addr,
18689 + else if (remcom_in_buffer[0] == 'z')
18690 + error = kgdb_ops->remove_hw_breakpoint(addr,
18696 + strcpy(remcom_out_buffer, "OK");
18698 + error_packet(remcom_out_buffer, error);
18703 + if (kgdb_contthread && kgdb_contthread != current) {
18704 + /* Can't switch threads in kgdb */
18705 + error_packet(remcom_out_buffer, -EINVAL);
18708 + kgdb_activate_sw_breakpoints();
18709 + /* Followthrough to default processing */
18712 + error = kgdb_arch_handle_exception(ex_vector, signo,
18714 + remcom_in_buffer,
18715 + remcom_out_buffer,
18718 + if (error >= 0 || remcom_in_buffer[0] == 'D' ||
18719 + remcom_in_buffer[0] == 'k')
18724 + /* reply to the request */
18725 + put_packet(remcom_out_buffer);
18729 + /* Call the I/O driver's post_exception routine if the I/O
18730 + * driver defined one.
18732 + if (kgdb_io_ops.post_exception)
18733 + kgdb_io_ops.post_exception();
18735 + kgdb_info[processor].debuggerinfo = NULL;
18736 + kgdb_info[processor].task = NULL;
18737 + atomic_set(&procindebug[processor], 0);
18739 + if (!debugger_step || !kgdb_contthread) {
18740 + for (i = 0; i < NR_CPUS; i++)
18741 + spin_unlock(&slavecpulocks[i]);
18742 + /* Wait till all the processors have quit
18743 + * from the debugger. */
18744 + for (i = 0; i < NR_CPUS; i++) {
18745 + while (atomic_read(&procindebug[i])) {
18746 + int j = 10; /* an arbitrary number */
18755 + /* This delay has a real purpose. The problem is that if you
18756 + * are single-stepping, you are sending an NMI to all the
18757 + * other processors to stop them. Interrupts come in, but
18758 + * don't get handled. Then you let them go just long enough
18759 + * to get into their interrupt routines and use up some stack.
18760 + * You stop them again, and then do the same thing. After a
18761 + * while you blow the stack on the other processors. This
18762 + * delay gives some time for interrupts to be cleared out on
18763 + * the other processors.
18765 + if (debugger_step)
18769 + /* Free debugger_active */
18770 + atomic_set(&debugger_active, 0);
18771 + local_irq_restore(flags);
18777 + * GDB places a breakpoint at this function to know dynamically
18778 + * loaded objects. It's not defined static so that only one instance with this
18779 + * name exists in the kernel.
18782 +int module_event(struct notifier_block *self, unsigned long val, void *data)
18787 +static struct notifier_block kgdb_module_load_nb = {
18788 + .notifier_call = module_event,
18791 +void kgdb_nmihook(int cpu, void *regs)
18794 + if (!atomic_read(&procindebug[cpu]) && atomic_read(&debugger_active) != (cpu + 1))
18795 + kgdb_wait((struct pt_regs *)regs);
18800 + * This is called when a panic happens. All we need to do is
18803 +static int kgdb_panic_notify(struct notifier_block *self, unsigned long cmd,
18811 +static struct notifier_block kgdb_panic_notifier = {
18812 + .notifier_call = kgdb_panic_notify,
18816 + * Initialization that needs to be done in either of our entry points.
18818 +static void __init kgdb_internal_init(void)
18822 + /* Initialize our spinlocks. */
18823 + for (i = 0; i < NR_CPUS; i++)
18824 + spin_lock_init(&slavecpulocks[i]);
18826 + for (i = 0; i < MAX_BREAKPOINTS; i++)
18827 + kgdb_break[i].state = bp_none;
18829 + /* Initialize the I/O handles */
18830 + memset(&kgdb_io_ops_prev, 0, sizeof(kgdb_io_ops_prev));
18832 + /* We can't do much if this fails */
18833 + register_module_notifier(&kgdb_module_load_nb);
18835 + kgdb_initialized = 1;
18838 +static void kgdb_register_for_panic(void)
18840 + /* Register for panics(). */
18841 + /* The registration is done in the kgdb_register_for_panic
18842 + * routine because KGDB should not try to handle a panic when
18843 + * there are no kgdb_io_ops setup. It is assumed that the
18844 + * kgdb_io_ops are setup at the time this method is called.
18846 + if (!kgdb_from_module_registered) {
18847 + atomic_notifier_chain_register(&panic_notifier_list,
18848 + &kgdb_panic_notifier);
18849 + kgdb_from_module_registered = 1;
18853 +static void kgdb_unregister_for_panic(void)
18855 + /* When this routine is called KGDB should unregister from the
18856 + * panic handler and clean up, making sure it is not handling any
18857 + * break exceptions at the time.
18859 + if (kgdb_from_module_registered) {
18860 + kgdb_from_module_registered = 0;
18861 + atomic_notifier_chain_unregister(&panic_notifier_list,
18862 + &kgdb_panic_notifier);
18866 +int kgdb_register_io_module(struct kgdb_io *local_kgdb_io_ops)
18869 + if (kgdb_connected) {
18870 + printk(KERN_ERR "kgdb: Cannot load I/O module while KGDB "
18875 + /* Save the old values so they can be restored */
18876 + if (kgdb_io_handler_cnt >= MAX_KGDB_IO_HANDLERS) {
18877 + printk(KERN_ERR "kgdb: No more I/O handles available.\n");
18881 + /* Check to see if there is an existing driver and if so save its
18882 + * values. Also check to make sure the same driver was not trying
18883 + * to re-register.
18885 + if (kgdb_io_ops.read_char != NULL &&
18886 + kgdb_io_ops.read_char != local_kgdb_io_ops->read_char) {
18887 + memcpy(&kgdb_io_ops_prev[kgdb_io_handler_cnt],
18888 + &kgdb_io_ops, sizeof(struct kgdb_io));
18889 + kgdb_io_handler_cnt++;
18892 + /* Initialize the io values for this module */
18893 + memcpy(&kgdb_io_ops, local_kgdb_io_ops, sizeof(struct kgdb_io));
18895 + /* Make the call to register kgdb if is not initialized */
18896 + kgdb_register_for_panic();
18901 +void kgdb_unregister_io_module(struct kgdb_io *local_kgdb_io_ops)
18905 + /* Unregister KGDB if there were no other prior io hooks, else
18906 + * restore the io hooks.
18908 + if (kgdb_io_handler_cnt > 0 && kgdb_io_ops_prev[0].read_char != NULL) {
18909 + /* First check if the hook that is in use is the one being
18911 + if (kgdb_io_ops.read_char == local_kgdb_io_ops->read_char) {
18912 + /* Set 'i' to the value of where the list should be
18914 + i = kgdb_io_handler_cnt - 1;
18915 + memcpy(&kgdb_io_ops, &kgdb_io_ops_prev[i],
18916 + sizeof(struct kgdb_io));
18918 + /* Simple case to remove an entry for an I/O handler
18919 + * that is not in use */
18920 + for (i = 0; i < kgdb_io_handler_cnt; i++) {
18921 + if (kgdb_io_ops_prev[i].read_char ==
18922 + local_kgdb_io_ops->read_char)
18927 + /* Shift all the entries in the handler array so it is
18928 + * ordered from oldest to newest.
18930 + kgdb_io_handler_cnt--;
18931 + for (; i < kgdb_io_handler_cnt; i++) {
18932 + memcpy(&kgdb_io_ops_prev[i], &kgdb_io_ops_prev[i + 1],
18933 + sizeof(struct kgdb_io));
18935 + /* Handle the case if we are on the last element and set it
18937 + memset(&kgdb_io_ops_prev[kgdb_io_handler_cnt], 0,
18938 + sizeof(struct kgdb_io));
18940 + if (kgdb_connected)
18941 + printk(KERN_ERR "kgdb: WARNING: I/O method changed "
18942 + "while kgdb was connected state.\n");
18944 + /* KGDB is no longer able to communicate out, so
18945 + * unregister our hooks and reset state. */
18946 + kgdb_unregister_for_panic();
18947 + if (kgdb_connected) {
18948 + printk(KERN_CRIT "kgdb: I/O module was unloaded while "
18949 + "a debugging session was running. "
18950 + "KGDB will be reset.\n");
18951 + if (remove_all_break() < 0)
18952 + printk(KERN_CRIT "kgdb: Reset failed.\n");
18953 + kgdb_connected = 0;
18955 + memset(&kgdb_io_ops, 0, sizeof(struct kgdb_io));
18960 + * There are times we need to call a tasklet to cause a breakpoint
18961 + * as calling breakpoint() at that point might be fatal. We have to
18962 + * check that the exception stack is setup, as tasklets may be scheduled
18963 + * prior to this. When that happens, it is up to the architecture to
18964 + * schedule this when it is safe to run.
18966 +static void kgdb_tasklet_bpt(unsigned long ing)
18968 + if(CHECK_EXCEPTION_STACK())
18972 +DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
18975 + * This function can be called very early, either via early_param() or
18976 + * an explicit breakpoint() early on.
18978 +static void __init kgdb_early_entry(void)
18981 + * Don't try and do anything until the architecture is able to
18982 + * setup the exception stack. In this case, it is up to the
18983 + * architecture to hook in and look at us when they are ready.
18985 + if(!CHECK_EXCEPTION_STACK()) {
18986 + kgdb_initialized = -1;
18987 + tasklet_schedule(&kgdb_tasklet_breakpoint);
18991 + /* Let the architecture do any setup that it needs to. */
18992 + kgdb_arch_init();
18994 + /* Now try the I/O. */
18995 + /* For early entry kgdb_io_ops.init must be defined */
18996 + if (!kgdb_io_ops.init || kgdb_io_ops.init()) {
18997 + /* Try again later. */
18998 + kgdb_initialized = -1;
19003 + kgdb_internal_init();
19005 + /* KGDB can assume that if kgdb_io_ops.init was defined that the
19006 + * panic registion should be performed at this time. This means
19007 + * kgdb_io_ops.init did not come from a kernel module and was
19008 + * initialized statically by a built in.
19010 + if (kgdb_io_ops.init)
19011 + kgdb_register_for_panic();
19015 + * This function will always be invoked to make sure that KGDB will grab
19016 + * what it needs to so that if something happens while the system is
19017 + * running, KGDB will get involved. If kgdb_early_entry() has already
19018 + * been invoked, there is little we need to do.
19020 +static int __init kgdb_late_entry(void)
19022 + int need_break = 0;
19024 + /* If kgdb_initialized is -1 then we were passed kgdbwait. */
19025 + if (kgdb_initialized == -1)
19029 + * If we haven't tried to initialize KGDB yet, we need to call
19030 + * kgdb_arch_init before moving onto the I/O.
19032 + if (!kgdb_initialized)
19033 + kgdb_arch_init();
19035 + if (kgdb_initialized != 1) {
19036 + if (kgdb_io_ops.init && kgdb_io_ops.init()) {
19037 + /* When KGDB allows I/O via modules and the core
19038 + * I/O init fails KGDB must default to defering the
19039 + * I/O setup, and appropriately print an error about
19042 + printk(KERN_ERR "kgdb: Could not setup core I/O "
19044 + printk(KERN_INFO "kgdb: Defering I/O setup to kernel "
19046 + memset(&kgdb_io_ops, 0, sizeof(struct kgdb_io));
19049 + kgdb_internal_init();
19051 + /* KGDB can assume that if kgdb_io_ops.init was defined that
19052 + * panic registion should be performed at this time. This means
19053 + * kgdb_io_ops.init did not come from a kernel module and was
19054 + * initialized statically by a built in.
19056 + if (kgdb_io_ops.init)
19057 + kgdb_register_for_panic();
19060 + /* Registering to reboot notifier list*/
19061 + register_reboot_notifier(&kgdb_reboot_notifier);
19063 + /* Now do any late init of the I/O. */
19064 + if (kgdb_io_ops.late_init)
19065 + kgdb_io_ops.late_init();
19067 + if (need_break) {
19068 + printk(KERN_CRIT "kgdb: Waiting for connection from remote"
19076 +late_initcall(kgdb_late_entry);
19079 + * This function will generate a breakpoint exception. It is used at the
19080 + * beginning of a program to sync up with a debugger and can be used
19081 + * otherwise as a quick means to stop program execution and "break" into
19084 +void breakpoint(void)
19086 + if (kgdb_initialized != 1) {
19087 + kgdb_early_entry();
19088 + if (kgdb_initialized == 1)
19089 + printk(KERN_CRIT "Waiting for connection from remote "
19092 + printk(KERN_CRIT "KGDB cannot initialize I/O yet.\n");
19097 + atomic_set(&kgdb_setting_breakpoint, 1);
19101 + atomic_set(&kgdb_setting_breakpoint, 0);
19104 +EXPORT_SYMBOL(breakpoint);
19106 +#ifdef CONFIG_MAGIC_SYSRQ
19107 +static void sysrq_handle_gdb(int key, struct pt_regs *pt_regs,
19108 + struct tty_struct *tty)
19110 + printk("Entering GDB stub\n");
19113 +static struct sysrq_key_op sysrq_gdb_op = {
19114 + .handler = sysrq_handle_gdb,
19115 + .help_msg = "Gdb",
19116 + .action_msg = "GDB",
19119 +static int gdb_register_sysrq(void)
19121 + printk("Registering GDB sysrq handler\n");
19122 + register_sysrq_key('g', &sysrq_gdb_op);
19126 +module_init(gdb_register_sysrq);
19129 +static int kgdb_notify_reboot(struct notifier_block *this,
19130 + unsigned long code, void *x)
19133 + unsigned long flags;
19135 + /* If we're debugging, or KGDB has not connected, don't try
19137 + if (!kgdb_connected || atomic_read(&debugger_active) != 0)
19139 + if ((code == SYS_RESTART) || (code == SYS_HALT) || (code == SYS_POWER_OFF)){
19140 + local_irq_save(flags);
19141 + put_packet("X00");
19142 + local_irq_restore(flags);
19144 + return NOTIFY_DONE;
19147 +#ifdef CONFIG_KGDB_CONSOLE
19148 +void kgdb_console_write(struct console *co, const char *s, unsigned count)
19150 + unsigned long flags;
19152 + /* If we're debugging, or KGDB has not connected, don't try
19154 + if (!kgdb_connected || atomic_read(&debugger_active) != 0)
19157 + local_irq_save(flags);
19158 + kgdb_msg_write(s, count);
19159 + local_irq_restore(flags);
19162 +struct console kgdbcons = {
19164 + .write = kgdb_console_write,
19165 + .flags = CON_PRINTBUFFER | CON_ENABLED,
19167 +static int __init kgdb_console_init(void)
19169 + register_console(&kgdbcons);
19173 +console_initcall(kgdb_console_init);
19176 +static int __init opt_kgdb_enter(char *str)
19178 + /* We've already done this by an explicit breakpoint() call. */
19179 + if (kgdb_initialized)
19182 + /* Call breakpoint() which will take care of init. */
19188 +early_param("kgdbwait", opt_kgdb_enter);
19189 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/kernel/kgdbarchlib.c linux-2.6.18.kgdb/kernel/kgdbarchlib.c
19190 --- linux-2.6.18/kernel/kgdbarchlib.c 1970-01-01 03:00:00.000000000 +0300
19191 +++ linux-2.6.18.kgdb/kernel/kgdbarchlib.c 2008-06-10 16:18:58.000000000 +0400
19193 +#include <linux/kgdb.h>
19195 +struct kgdb_arch *kgdb_ops = &arch_kgdb_ops;
19198 + * kgdb_arch_init - Perform any architecture specific initalization.
19201 + * The return value is ignored.
19203 + * This function will handle the initalization of any architecture
19204 + * specific hooks.
19206 +int __attribute__ ((weak))
19207 + kgdb_arch_init(void)
19213 + * kgdb_disable_hw_debug - Disable hardware debugging while we in kgdb.
19214 + * @regs: Current &struct pt_regs.
19216 + * This function will be called if the particular architecture must
19217 + * disable hardware debugging while it is processing gdb packets or
19218 + * handling exception.
19220 +void __attribute__ ((weak))
19221 + kgdb_disable_hw_debug(struct pt_regs *regs)
19226 + * Skip an int3 exception when it occurs after a breakpoint has been
19227 + * removed. Backtrack eip by 1 since the int3 would have caused it to
19228 + * increment by 1.
19230 +int __attribute__ ((weak))
19231 + kgdb_skipexception(int exception, struct pt_regs *regs)
19237 + * kgdb_set_hw_break - Set a hardware breakpoint at @addr.
19238 + * @addr: The address to set a hardware breakpoint at.
19240 +int __attribute__ ((weak))
19241 + kgdb_set_hw_break(unsigned long addr)
19247 + * kgdb_remove_hw_break - Remove a hardware breakpoint at @addr.
19248 + * @addr: The address to remove a hardware breakpoint from.
19250 +int __attribute__ ((weak))
19251 + kgdb_remove_hw_break(unsigned long addr)
19257 + * kgdb_remove_all_hw_break - Clear all hardware breakpoints.
19259 +void __attribute__ ((weak))
19260 + kgdb_remove_all_hw_break(void)
19265 + * kgdb_correct_hw_break - Correct hardware breakpoints.
19267 + * A hook to allow for changes to the hardware breakpoint, called
19268 + * after a single step (s) or continue (c) packet, and once we're about
19269 + * to let the kernel continue running.
19271 + * This is used to set the hardware breakpoint registers for all the
19272 + * slave cpus on an SMP configuration. This must be called after any
19273 + * changes are made to the hardware breakpoints (such as by a single
19274 + * step (s) or continue (c) packet. This is only required on
19275 + * architectures that support SMP and every processor has its own set
19276 + * of breakpoint registers.
19278 +void __attribute__ ((weak))
19279 + kgdb_correct_hw_break(void)
19284 + * kgdb_post_master_code - Save error vector/code numbers.
19285 + * @regs: Original pt_regs.
19286 + * @e_vector: Original error vector.
19287 + * @err_code: Original error code.
19289 + * This is needed on architectures which support SMP and KGDB.
19290 + * This function is called after all the slave cpus have been put
19291 + * to a know spin state and the master CPU has control over KGDB.
19294 +void __attribute__ ((weak))
19295 + kgdb_post_master_code(struct pt_regs *regs, int e_vector, int err_code)
19300 + * kgdb_roundup_cpus - Get other CPUs into a holding pattern
19301 + * @flags: Current IRQ state
19303 + * On SMP systems, we need to get the attention of the other CPUs
19304 + * and get them be in a known state. This should do what is needed
19305 + * to get the other CPUs to call kgdb_wait(). Note that on some arches,
19306 + * the NMI approach is not used for rounding up all the CPUs. For example,
19307 + * in case of MIPS, smp_call_function() is used to roundup CPUs. In
19308 + * this case, we have to make sure that interrupts are enabled before
19309 + * calling smp_call_function(). The argument to this function is
19310 + * the flags that will be used when restoring the interrupts. There is
19311 + * local_irq_save() call before kgdb_roundup_cpus().
19313 +void __attribute__ ((weak))
19314 + kgdb_roundup_cpus(unsigned long flags)
19319 + * kgdb_shadowinfo - Get shadowed information on @threadid.
19320 + * @regs: The &struct pt_regs of the current process.
19321 + * @buffer: A buffer of %BUFMAX size.
19322 + * @threadid: The thread id of the shadowed process to get information on.
19324 +void __attribute__ ((weak))
19325 + kgdb_shadowinfo(struct pt_regs *regs, char *buffer, unsigned threadid)
19330 + * kgdb_get_shadow_thread - Get the shadowed &task_struct of @threadid.
19331 + * @regs: The &struct pt_regs of the current thread.
19332 + * @threadid: The thread id of the shadowed process to get information on.
19335 + * This returns a pointer to the &struct task_struct of the shadowed
19336 + * thread, @threadid.
19338 +struct task_struct __attribute__ ((weak))
19339 + * kgdb_get_shadow_thread(struct pt_regs *regs, int threadid)
19345 + * kgdb_shadow_regs - Return the shadowed registers of @threadid.
19346 + * @regs: The &struct pt_regs of the current thread.
19347 + * @threadid: The thread id we want the &struct pt_regs for.
19350 + * The a pointer to the &struct pt_regs of the shadowed thread @threadid.
19352 +struct pt_regs __attribute__ ((weak))
19353 + * kgdb_shadow_regs(struct pt_regs *regs, int threadid)
19358 +int __attribute__ ((weak))
19359 + kgdb_validate_break_address(unsigned long addr)
19362 + char tmp_variable[BREAK_INSTR_SIZE];
19363 + error = kgdb_get_mem((char *)addr, tmp_variable, BREAK_INSTR_SIZE);
19367 +int __attribute__ ((weak))
19368 + kgdb_arch_set_breakpoint(unsigned long addr, char *saved_instr)
19371 + if ((error = kgdb_get_mem((char *)addr,
19372 + saved_instr, BREAK_INSTR_SIZE)) < 0)
19375 + if ((error = kgdb_set_mem((char *)addr, kgdb_ops->gdb_bpt_instr,
19376 + BREAK_INSTR_SIZE)) < 0)
19381 +int __attribute__ ((weak))
19382 + kgdb_arch_remove_breakpoint(unsigned long addr, char *bundle)
19386 + if ((error =kgdb_set_mem((char *)addr, (char *)bundle,
19387 + BREAK_INSTR_SIZE)) < 0)
19391 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/kernel/module.c linux-2.6.18.kgdb/kernel/module.c
19392 --- linux-2.6.18/kernel/module.c 2006-09-20 07:42:06.000000000 +0400
19393 +++ linux-2.6.18.kgdb/kernel/module.c 2008-06-10 16:20:07.000000000 +0400
19394 @@ -64,6 +64,7 @@ static DEFINE_SPINLOCK(modlist_lock);
19395 /* List of modules, protected by module_mutex AND modlist_lock */
19396 static DEFINE_MUTEX(module_mutex);
19397 static LIST_HEAD(modules);
19398 +static DECLARE_MUTEX(notify_mutex);
19400 static BLOCKING_NOTIFIER_HEAD(module_notify_list);
19402 @@ -700,6 +701,12 @@ sys_delete_module(const char __user *nam
19406 + down(¬ify_mutex);
19407 + blocking_notifier_call_chain(&module_notify_list, MODULE_STATE_GOING,
19409 + up(¬ify_mutex);
19412 /* Never wait if forced. */
19413 if (!forced && module_refcount(mod) != 0)
19414 wait_for_zero_refcount(mod);
19415 @@ -712,6 +719,11 @@ sys_delete_module(const char __user *nam
19419 + down(¬ify_mutex);
19420 + blocking_notifier_call_chain(&module_notify_list, MODULE_STATE_GONE,
19422 + up(¬ify_mutex);
19425 mutex_unlock(&module_mutex);
19427 @@ -1112,6 +1124,11 @@ static void free_module(struct module *m
19428 /* Arch-specific cleanup. */
19429 module_arch_cleanup(mod);
19431 +#ifdef CONFIG_KGDB
19433 + vfree(mod->mod_sections);
19436 /* Module unload stuff */
19437 module_unload_free(mod);
19439 @@ -1371,6 +1388,31 @@ static void setup_modinfo(struct module
19443 +#ifdef CONFIG_KGDB
19444 +int add_modsects (struct module *mod, Elf_Ehdr *hdr, Elf_Shdr *sechdrs, const
19445 + char *secstrings)
19449 + mod->num_sections = hdr->e_shnum - 1;
19450 + mod->mod_sections = vmalloc((hdr->e_shnum - 1)*
19451 + sizeof (struct mod_section));
19453 + if (mod->mod_sections == NULL) {
19457 + for (i = 1; i < hdr->e_shnum; i++) {
19458 + mod->mod_sections[i - 1].address = (void *)sechdrs[i].sh_addr;
19459 + strncpy(mod->mod_sections[i - 1].name, secstrings +
19460 + sechdrs[i].sh_name, MAX_SECTNAME);
19461 + mod->mod_sections[i - 1].name[MAX_SECTNAME] = '\0';
19468 #ifdef CONFIG_KALLSYMS
19469 int is_exported(const char *name, const struct module *mod)
19471 @@ -1782,6 +1824,12 @@ static struct module *load_module(void _
19473 add_kallsyms(mod, sechdrs, symindex, strindex, secstrings);
19475 +#ifdef CONFIG_KGDB
19476 + if ((err = add_modsects(mod, hdr, sechdrs, secstrings)) < 0) {
19477 + goto nomodsectinfo;
19481 err = module_finalize(hdr, sechdrs, mod);
19484 @@ -1842,6 +1890,11 @@ static struct module *load_module(void _
19486 module_arch_cleanup(mod);
19489 +#ifdef CONFIG_KGDB
19491 + vfree(mod->mod_sections);
19493 module_unload_free(mod);
19494 module_free(mod, mod->module_init);
19496 @@ -1913,6 +1966,10 @@ sys_init_module(void __user *umod,
19497 /* Init routine failed: abort. Try to protect us from
19498 buggy refcounters. */
19499 mod->state = MODULE_STATE_GOING;
19500 + down(¬ify_mutex);
19501 + blocking_notifier_call_chain(&module_notify_list, MODULE_STATE_GOING,
19503 + up(¬ify_mutex);
19504 synchronize_sched();
19506 printk(KERN_ERR "%s: module is now stuck!\n",
19507 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/kernel/sched.c linux-2.6.18.kgdb/kernel/sched.c
19508 --- linux-2.6.18/kernel/sched.c 2006-09-20 07:42:06.000000000 +0400
19509 +++ linux-2.6.18.kgdb/kernel/sched.c 2008-06-10 16:18:58.000000000 +0400
19511 #include <linux/acct.h>
19512 #include <linux/kprobes.h>
19513 #include <linux/delayacct.h>
19514 +#include <linux/kgdb.h>
19515 #include <asm/tlb.h>
19517 #include <asm/unistd.h>
19518 @@ -6790,6 +6791,9 @@ void __might_sleep(char *file, int line)
19520 static unsigned long prev_jiffy; /* ratelimiting */
19522 + if (atomic_read(&debugger_active))
19525 if ((in_atomic() || irqs_disabled()) &&
19526 system_state == SYSTEM_RUNNING && !oops_in_progress) {
19527 if (time_before(jiffies, prev_jiffy + HZ) && prev_jiffy)
19528 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/kernel/softlockup.c linux-2.6.18.kgdb/kernel/softlockup.c
19529 --- linux-2.6.18/kernel/softlockup.c 2006-09-20 07:42:06.000000000 +0400
19530 +++ linux-2.6.18.kgdb/kernel/softlockup.c 2008-06-10 16:20:11.000000000 +0400
19532 #include <linux/kthread.h>
19533 #include <linux/notifier.h>
19534 #include <linux/module.h>
19535 +#include <linux/kgdb.h>
19537 static DEFINE_SPINLOCK(print_lock);
19539 @@ -37,6 +38,9 @@ static struct notifier_block panic_block
19540 void touch_softlockup_watchdog(void)
19542 __raw_get_cpu_var(touch_timestamp) = jiffies;
19543 +#ifdef CONFIG_KGDB
19544 + atomic_set(&kgdb_sync_softlockup[raw_smp_processor_id()], 0);
19547 EXPORT_SYMBOL(touch_softlockup_watchdog);
19549 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/kernel/timer.c linux-2.6.18.kgdb/kernel/timer.c
19550 --- linux-2.6.18/kernel/timer.c 2006-09-20 07:42:06.000000000 +0400
19551 +++ linux-2.6.18.kgdb/kernel/timer.c 2008-06-10 16:20:11.000000000 +0400
19553 #include <linux/cpu.h>
19554 #include <linux/syscalls.h>
19555 #include <linux/delay.h>
19556 +#include <linux/kgdb.h>
19558 #include <asm/uaccess.h>
19559 #include <asm/unistd.h>
19560 @@ -1257,7 +1258,11 @@ static void run_timer_softirq(struct sof
19562 void run_local_timers(void)
19564 + int this_cpu = smp_processor_id();
19565 raise_softirq(TIMER_SOFTIRQ);
19566 +#ifdef CONFIG_KGDB
19567 + if(!atomic_read(&kgdb_sync_softlockup[this_cpu]))
19572 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/lib/Kconfig.debug linux-2.6.18.kgdb/lib/Kconfig.debug
19573 --- linux-2.6.18/lib/Kconfig.debug 2006-09-20 07:42:06.000000000 +0400
19574 +++ linux-2.6.18.kgdb/lib/Kconfig.debug 2008-06-10 16:19:51.000000000 +0400
19575 @@ -315,7 +315,7 @@ config DEBUG_VM
19577 config FRAME_POINTER
19578 bool "Compile the kernel with frame pointers"
19579 - depends on DEBUG_KERNEL && (X86 || CRIS || M68K || M68KNOMMU || FRV || UML || S390)
19580 + depends on DEBUG_KERNEL && (X86 || CRIS || M68K || M68KNOMMU || FRV || UML || S390 || SUPERH)
19581 default y if DEBUG_INFO && UML
19583 If you say Y here the resulting kernel image will be slightly larger
19584 @@ -368,3 +368,158 @@ config RCU_TORTURE_TEST
19585 at boot time (you probably don't).
19586 Say M if you want the RCU torture tests to build as a module.
19587 Say N if you are unsure.
19589 +config WANT_EXTRA_DEBUG_INFORMATION
19591 + select DEBUG_INFO
19592 + select FRAME_POINTER if X86 || SUPERH
19596 + bool "KGDB: kernel debugging with remote gdb"
19597 + select WANT_EXTRA_DEBUG_INFORMATION
19598 + depends on DEBUG_KERNEL && (ARM || X86 || MIPS || (SUPERH && !SUPERH64) || IA64 || X86_64 || PPC)
19600 + If you say Y here, it will be possible to remotely debug the
19601 + kernel using gdb. It is strongly suggested that you enable
19602 + DEBUG_INFO, and if available on your platform, FRAME_POINTER.
19603 + Documentation of kernel debugger available at
19604 + http://kgdb.sourceforge.net as well as in DocBook form
19605 + in Documentation/DocBook/. If unsure, say N.
19607 +config KGDB_CONSOLE
19608 + bool "KGDB: Console messages through gdb"
19611 + If you say Y here, console messages will appear through gdb.
19612 + Other consoles such as tty or ttyS will continue to work as usual.
19613 + Note, that if you use this in conjunction with KGDB_ETH, if the
19614 + ethernet driver runs into an error condition during use with KGDB
19615 + it is possible to hit an infinite recusrion, causing the kernel
19616 + to crash, and typically reboot. For this reason, it is preferable
19617 + to use NETCONSOLE in conjunction with KGDB_ETH instead of
19621 + prompt "Method for KGDB communication"
19623 + default KGDB_8250_NOMODULE
19624 + default KGDB_MPSC if SERIAL_MPSC
19625 + default KGDB_CPM_UART if (8xx || 8260)
19626 + default KGDB_SIBYTE if SIBYTE_SB1xxx_SOC
19628 + There are a number of different ways in which you can communicate
19629 + with KGDB. The most common is via serial, with the 8250 driver
19630 + (should your hardware have an 8250, or ns1655x style uart).
19631 + Another option is to use the NETPOLL framework and UDP, should
19632 + your ethernet card support this. Other options may exist.
19633 + You can elect to have one core I/O driver that is built into the
19634 + kernel for debugging as the kernel is booting, or using only
19637 +config KGDB_ONLY_MODULES
19638 + bool "KGDB: Use only kernel modules for I/O"
19639 + depends on MODULES
19641 + Use only kernel modules to configure KGDB I/O after the
19642 + kernel is booted.
19644 +config KGDB_8250_NOMODULE
19645 + bool "KGDB: On generic serial port (8250)"
19648 + Uses generic serial port (8250) to communicate with the host
19649 + GDB. This is independent of the normal (SERIAL_8250) driver
19650 + for this chipset.
19652 +config KGDBOE_NOMODULE
19653 + bool "KGDB: On ethernet - in kernel"
19656 + select NETPOLL_TRAP
19657 + select NETPOLL_RX
19659 + Uses the NETPOLL API to communicate with the host GDB via UDP.
19660 + In order for this to work, the ethernet interface specified must
19661 + support the NETPOLL API, and this must be initialized at boot.
19662 + See the documentation for syntax.
19665 + bool "KGDB on MV64x60 MPSC"
19666 + depends on SERIAL_MPSC
19668 + Uses a Marvell GT64260B or MV64x60 Multi-Purpose Serial
19669 + Controller (MPSC) channel. Note that the GT64260A is not
19672 +config KGDB_CPM_UART
19673 + bool "KGDB: On CPM UART"
19674 + depends on PPC && (CPM2 || 8xx)
19676 + Uses CPM UART to communicate with the host GDB.
19678 +config KGDB_SIBYTE
19679 + bool "KGDB: On the Broadcom SWARM serial port"
19680 + depends on MIPS && SIBYTE_SB1xxx_SOC
19684 + tristate "KGDB: On ethernet" if !KGDBOE_NOMODULE
19685 + depends on m && KGDB
19687 + select NETPOLL_TRAP
19688 + select NETPOLL_RX
19690 + Uses the NETPOLL API to communicate with the host GDB via UDP.
19691 + In order for this to work, the ethernet interface specified must
19692 + support the NETPOLL API, and this must be initialized at boot.
19693 + See the documentation for syntax.
19696 + tristate "KGDB: On generic serial port (8250)" if !KGDB_8250_NOMODULE
19697 + depends on m && KGDB_ONLY_MODULES
19699 + Uses generic serial port (8250) to communicate with the host
19700 + GDB. This is independent of the normal (SERIAL_8250) driver
19701 + for this chipset.
19703 +config KGDB_SIMPLE_SERIAL
19704 + bool "Simple selection of KGDB serial port"
19705 + depends on KGDB_8250_NOMODULE
19708 + If you say Y here, you will only have to pick the baud rate
19709 + and port number that you wish to use for KGDB. Note that this
19710 + only works on architectures that register known serial ports
19711 + early on. If you say N, you will have to provide, either here
19712 + or on the command line, the type (I/O or MMIO), IRQ and
19713 + address to use. If in doubt, say Y.
19715 +config KGDB_BAUDRATE
19716 + int "Debug serial port baud rate"
19717 + depends on (KGDB_8250 && KGDB_SIMPLE_SERIAL)
19720 + gdb and the kernel stub need to agree on the baud rate to be
19721 + used. Standard rates from 9600 to 115200 are allowed, and this
19722 + may be overridden via the commandline.
19724 +config KGDB_PORT_NUM
19725 + int "Serial port number for KGDB"
19726 + range 0 1 if KGDB_MPSC
19728 + depends on (KGDB_8250 && KGDB_SIMPLE_SERIAL) || KGDB_MPSC
19731 + Pick the port number (0 based) for KGDB to use.
19733 +config KGDB_8250_CONF_STRING
19734 + string "Configuration string for KGDB"
19735 + depends on KGDB_8250_NOMODULE && !KGDB_SIMPLE_SERIAL
19736 + default "io,2f8,115200,3" if X86
19738 + The format of this string should be <io or
19739 + mmio>,<address>,<baud rate>,<irq>. For example, to use the
19740 + serial port on an i386 box located at 0x2f8 and 115200 baud
19743 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/net/core/netpoll.c linux-2.6.18.kgdb/net/core/netpoll.c
19744 --- linux-2.6.18/net/core/netpoll.c 2006-09-20 07:42:06.000000000 +0400
19745 +++ linux-2.6.18.kgdb/net/core/netpoll.c 2008-06-10 16:19:07.000000000 +0400
19746 @@ -519,7 +519,8 @@ int __netpoll_rx(struct sk_buff *skb)
19748 np->rx_hook(np, ntohs(uh->source),
19750 - ulen - sizeof(struct udphdr));
19751 + ulen - sizeof(struct udphdr),
19756 diff -rupN -X ../client-cleanup/dontdiff linux-2.6.18/scripts/dwarfh.awk linux-2.6.18.kgdb/scripts/dwarfh.awk
19757 --- linux-2.6.18/scripts/dwarfh.awk 1970-01-01 03:00:00.000000000 +0300
19758 +++ linux-2.6.18.kgdb/scripts/dwarfh.awk 2008-06-10 16:19:58.000000000 +0400
19761 + print "#ifndef _ELF_DWARF_H"
19762 + print "/* Machine generated from dwarf2.h by scripts/dwarfh.awk */"
19765 + gsub(/,/, "", $3)
19766 + print "#define " $1 "\t " $3
19770 + while( index($0,"\\") == length($0)){