Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/nathanw_sa]: src/sys/arch add missing #include "opt_kgdb.h"



details:   https://anonhg.NetBSD.org/src/rev/3da42f4281f5
branches:  nathanw_sa
changeset: 504701:3da42f4281f5
user:      lukem <lukem%NetBSD.org@localhost>
date:      Wed May 30 15:24:28 2001 +0000

description:
add missing   #include "opt_kgdb.h"

diffstat:

 sys/arch/alpha/alpha/debug.s   |  130 ++++++++++++++++++++++++++++++++++
 sys/arch/x68k/x68k/kgdb_glue.c |  155 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 285 insertions(+), 0 deletions(-)

diffs (293 lines):

diff -r c01c029aa8db -r 3da42f4281f5 sys/arch/alpha/alpha/debug.s
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/alpha/alpha/debug.s      Wed May 30 15:24:28 2001 +0000
@@ -0,0 +1,130 @@
+/* $NetBSD: debug.s,v 1.8.4.2 2001/05/30 15:24:28 lukem Exp $ */
+
+/*-
+ * Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the NetBSD
+ *     Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+__KERNEL_RCSID(6, "$NetBSD: debug.s,v 1.8.4.2 2001/05/30 15:24:28 lukem Exp $")
+
+#include "opt_kgdb.h"
+
+/*
+ * Debugger glue.
+ */
+
+       .text
+inc6:  .stabs  __FILE__,132,0,0,inc6; .loc     1 __LINE__
+
+/*
+ * Debugger stack.
+ */
+BSS(debug_stack_bottom, NBPG)
+ABS(debug_stack_top, debug_stack_bottom + NBPG)
+
+/*
+ * alpha_debug:
+ *
+ *     Single debugger entry point, handling the housekeeping
+ *     chores we need to deal with.
+ *
+ *     Arguments are:
+ *
+ *             a0      a0 from trap
+ *             a1      a1 from trap
+ *             a2      a2 from trap
+ *             a3      kernel trap entry point
+ *             a4      frame pointer
+ */
+NESTED_NOPROFILE(alpha_debug, 5, 32, ra, IM_RA|IM_S0, 0)
+       br      pv, 1f
+1:     LDGP(pv)
+       lda     t0, FRAME_SIZE*8(a4)    /* what would sp have been? */
+       stq     t0, FRAME_SP*8(a4)      /* belatedly save sp for ddb view */
+       lda     sp, -32(sp)             /* set up stack frame */
+       stq     ra, (32-8)(sp)          /* save ra */
+       stq     s0, (32-16)(sp)         /* save s0 */
+
+       /* Remember our current stack pointer. */
+       mov     sp, s0
+
+#if defined(MULTIPROCESSOR)
+       /* Pause all other CPUs. */
+       ldiq    a0, 1
+       CALL(cpu_pause_resume_all)
+#endif
+
+       /*
+        * Switch to the debug stack if we're not on it already.
+        */
+       lda     t0, debug_stack_bottom
+       cmpule  sp, t0, t1              /* sp <= debug_stack_bottom */
+       bne     t1, 2f                  /* yes, switch now */
+
+       lda     t0, debug_stack_top
+       cmpule  t0, sp, t1              /* debug_stack_top <= sp? */
+       bne     t1, 3f                  /* yes, we're on the debug stack */
+
+2:     lda     sp, debug_stack_top     /* sp <- debug_stack_top */
+
+3:     /* Dispatch to the debugger - arguments are already in place. */
+#if defined(KGDB)
+       mov     a3, a0                  /* a0 == entry (trap type) */
+       mov     a4, a1                  /* a1 == frame pointer */
+       CALL(kgdb_trap)
+       br      9f
+#endif
+#if defined(DDB)
+       CALL(ddb_trap)
+       br      9f
+#endif
+9:     /* Debugger return value in v0; switch back to our previous stack. */
+       mov     s0, sp
+
+#if defined(MULTIPROCESSOR)
+       mov     v0, s0
+
+       /* Resume all other CPUs. */
+       mov     zero, a0
+       CALL(cpu_pause_resume_all)
+
+       mov     s0, v0
+#endif
+
+       ldq     ra, (32-8)(sp)          /* restore ra */
+       ldq     s0, (32-16)(sp)         /* restore s0 */
+       lda     sp, 32(sp)              /* pop stack frame */
+       RET
+       END(alpha_debug)
diff -r c01c029aa8db -r 3da42f4281f5 sys/arch/x68k/x68k/kgdb_glue.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/x68k/x68k/kgdb_glue.c    Wed May 30 15:24:28 2001 +0000
@@ -0,0 +1,155 @@
+/*     $NetBSD: kgdb_glue.c,v 1.3.8.2 2001/05/30 15:24:41 lukem Exp $  */
+
+/*
+ * Copyright (c) 1991, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Lawrence Berkeley Laboratories.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)kgdb_glue.c 8.2 (Berkeley) 1/12/94
+ */
+
+/*
+ * This file must be compiled with gcc -fno-defer-pop.
+ */
+
+#include "opt_kgdb.h"
+
+#ifdef KGDB
+
+#include <sys/param.h>
+
+#include <machine/frame.h>
+#include <machine/reg.h>
+
+#ifndef lint
+static char rcsid[] = "$NetBSD: kgdb_glue.c,v 1.3.8.2 2001/05/30 15:24:41 lukem Exp $";
+#endif
+
+#define KGDB_STACKSIZE 0x800
+#define KGDB_STACKWORDS (KGDB_STACKSIZE / sizeof(u_long))
+
+u_long kgdb_stack[KGDB_STACKWORDS];
+
+#define getsp(v) asm("movl %%sp, %0" : "=r" (v))
+#define setsp(v) asm("movl %0, %%sp" :: "r" (v))
+
+static inline void
+copywords(src, dst, nbytes)
+       register u_long *src, *dst;
+       register u_int nbytes;
+{
+       u_long *limit = src + (nbytes / sizeof(u_long));
+
+       do {
+               *dst++ = *src++;
+       } while (src < limit);
+       if (nbytes & 2)
+               *(u_short *)dst = *(u_short *)src;
+}
+
+kgdb_trap_glue(type, frame)
+       int type;
+       struct frame frame;
+{
+       u_long osp, nsp;
+       u_int fsize, s;
+       extern short exframesize[];
+
+       /*
+        * After a kernel mode trap, the saved sp doesn't point to the right
+        * place.  The correct value is the top of the frame (i.e. before the
+        * KGDB trap).
+        *
+        * XXX this may have to change if we implement an interrupt stack.
+        */
+       fsize = sizeof(frame) - sizeof(frame.F_u) + exframesize[frame.f_format];
+       frame.f_regs[SP] = (u_long)&frame + fsize;
+
+       /*
+        * Copy the interrupt context and frame to the new stack.
+        * We're throwing away trap()'s frame since we're going to do
+        * our own rte.
+        */
+       nsp = (u_long)&kgdb_stack[KGDB_STACKWORDS] -
+             roundup(fsize, sizeof(u_long));
+
+       copywords((u_long *)&frame, (u_long *)nsp, fsize);
+
+       s = splhigh();
+
+       getsp(osp);
+       setsp(nsp);
+
+       if (kgdb_trap(type, (struct frame *)nsp) == 0) {
+               /*
+                * Get back on kernel stack.  This thread of control
+                * will return back up through trap().  If kgdb_trap()
+                * returns 0, it didn't handle the trap at all so
+                * the stack is still intact and everything will
+                * unwind okay from here up.
+                */
+               setsp(osp);
+               splx(s);
+               return 0;
+       }
+       /*
+        * Copy back context, which has possibly changed.  Even the
+        * sp might have changed.
+        */
+       osp = ((struct frame *)nsp)->f_regs[SP] - fsize;
+       copywords((u_long *)nsp, (u_long *)osp, fsize);
+       setsp(osp);
+
+       /*
+        * Restore the possible new context from frame, pop the
+        * unneeded usp (we trapped from kernel mode) and pad word,
+        * and return to the trapped thread.
+        */
+       asm("moveml %sp@+,#0x7FFF; addql #8,sp; rte");
+}
+
+int kgdb_testval;
+
+kgdb_test(i)
+       int i;
+{
+        ++kgdb_testval;
+        return (i + 1);
+}
+#endif /* KGDB */



Home | Main Index | Thread Index | Old Index