Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Make IPKDB working again.
details: https://anonhg.NetBSD.org/src/rev/a82ac4d096f3
branches: trunk
changeset: 484002:a82ac4d096f3
user: ws <ws%NetBSD.org@localhost>
date: Wed Mar 22 20:58:25 2000 +0000
description:
Make IPKDB working again.
Add support for i386 debugging and pci-based ne2000 boards.
diffstat:
sys/arch/i386/conf/files.i386 | 3 +-
sys/arch/i386/i386/ipkdb_glue.c | 144 +++++++++++++++++
sys/arch/i386/i386/locore.s | 93 ++++++++++-
sys/arch/i386/i386/machdep.c | 12 +-
sys/arch/i386/i386/mainbus.c | 3 +-
sys/arch/i386/include/ipkdb.h | 53 ++++++
sys/conf/files | 24 +-
sys/dev/ic/dp8390.c | 277 ++++++++++++++++++++++++++++++++-
sys/dev/ic/dp8390var.h | 6 +-
sys/dev/ic/ne2000.c | 107 ++++++++++++-
sys/dev/ic/ne2000var.h | 6 +-
sys/dev/pci/files.pci | 6 +-
sys/dev/pci/if_ne_pci.c | 94 +++++++++++-
sys/ipkdb/README.port | 109 ++++--------
sys/ipkdb/TODO | 5 +-
sys/ipkdb/debuggers.h | 23 --
sys/ipkdb/ipkdb.h | 141 ++++++---------
sys/ipkdb/ipkdb_if.c | 279 +--------------------------------
sys/ipkdb/ipkdb_ipkdb.c | 336 ++++++++++++++++++---------------------
sys/ipkdb/ipkdb_slip.c | 136 ----------------
sys/kern/subr_prf.c | 10 +-
sys/netinet/udp_usrreq.c | 15 +-
22 files changed, 1070 insertions(+), 812 deletions(-)
diffs (truncated from 2750 to 300 lines):
diff -r d197e1af80f5 -r a82ac4d096f3 sys/arch/i386/conf/files.i386
--- a/sys/arch/i386/conf/files.i386 Wed Mar 22 20:38:22 2000 +0000
+++ b/sys/arch/i386/conf/files.i386 Wed Mar 22 20:58:25 2000 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.i386,v 1.151 2000/03/16 14:53:29 ad Exp $
+# $NetBSD: files.i386,v 1.152 2000/03/22 20:58:25 ws Exp $
#
# new style config file for i386 architecture
#
@@ -54,6 +54,7 @@
file arch/i386/i386/gdt.c
file arch/i386/i386/in_cksum.s inet
file netinet/in4_cksum.c inet
+file arch/i386/i386/ipkdb_glue.c ipkdb
file arch/i386/i386/kgdb_machdep.c kgdb
file arch/i386/i386/machdep.c
file arch/i386/i386/math_emulate.c math_emulate
diff -r d197e1af80f5 -r a82ac4d096f3 sys/arch/i386/i386/ipkdb_glue.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/i386/i386/ipkdb_glue.c Wed Mar 22 20:58:25 2000 +0000
@@ -0,0 +1,144 @@
+/* $NetBSD: ipkdb_glue.c,v 1.1 2000/03/22 20:58:27 ws Exp $ */
+
+/*
+ * Copyright (C) 2000 Wolfgang Solfrank.
+ * Copyright (C) 2000 TooLs GmbH.
+ * All rights reserved.
+ *
+ * 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 TooLs GmbH.
+ * 4. The name of TooLs GmbH may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NO TLIMITED 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, STRUCT 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.
+ */
+#include "opt_ipkdb.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+
+#include <ipkdb/ipkdb.h>
+
+#include <machine/ipkdb.h>
+#include <machine/psl.h>
+
+int ipkdbregs[NREG];
+
+int ipkdb_trap_glue __P((struct trapframe));
+
+#ifdef IPKDB_NE_PCI
+#include <dev/pci/pcivar.h>
+
+int ne_pci_ipkdb_attach __P((struct ipkdb_if *, bus_space_tag_t, /* XXX */
+ pci_chipset_tag_t, int, int));
+#endif
+
+static char ipkdb_mode = IPKDB_CMD_EXIT;
+
+void
+ipkdbinit()
+{
+}
+
+int
+ipkdb_poll()
+{
+ /* For now */
+ return 0;
+}
+
+void
+ipkdb_trap()
+{
+ ipkdb_mode = IPKDB_CMD_STEP;
+ __asm __volatile ("pushf; pop %%eax; orl %0,%%eax; push %%eax; popf"
+ :: "i"(PSL_T));
+}
+
+int
+ipkdb_trap_glue(frame)
+ struct trapframe frame;
+{
+ if (ISPL(frame.tf_cs) != SEL_KPL)
+ return 0;
+
+ if (ipkdb_mode == IPKDB_CMD_EXIT
+ || (ipkdb_mode != IPKDB_CMD_STEP && frame.tf_trapno == T_TRCTRAP))
+ return 0;
+
+ __asm __volatile ("cli"); /* Interrupts need to be disabled while in IPKDB */
+ ipkdbregs[EAX] = frame.tf_eax;
+ ipkdbregs[ECX] = frame.tf_ecx;
+ ipkdbregs[EDX] = frame.tf_edx;
+ ipkdbregs[EBX] = frame.tf_ebx;
+ ipkdbregs[ESP] = (int)&frame.tf_esp;
+ ipkdbregs[EBP] = frame.tf_ebp;
+ ipkdbregs[ESI] = frame.tf_esi;
+ ipkdbregs[EDI] = frame.tf_edi;
+ ipkdbregs[EIP] = frame.tf_eip;
+ ipkdbregs[EFLAGS] = frame.tf_eflags;
+ ipkdbregs[CS] = frame.tf_cs;
+ ipkdbregs[SS] = 0x10;
+ ipkdbregs[DS] = frame.tf_ds;
+ ipkdbregs[ES] = frame.tf_es;
+ __asm ("movl %%fs,%0; movl %%gs,%1"
+ : "=r"(ipkdbregs[FS]), "=r"(ipkdbregs[GS]));
+
+ switch ((ipkdb_mode = ipkdbcmds())) {
+ case IPKDB_CMD_EXIT:
+ case IPKDB_CMD_RUN:
+ ipkdbregs[EFLAGS] &= ~PSL_T;
+ break;
+ case IPKDB_CMD_STEP:
+ ipkdbregs[EFLAGS] |= PSL_T;
+ break;
+ }
+ frame.tf_eax = ipkdbregs[EAX];
+ frame.tf_ecx = ipkdbregs[ECX];
+ frame.tf_edx = ipkdbregs[EDX];
+ frame.tf_ebx = ipkdbregs[EBX];
+ frame.tf_ebp = ipkdbregs[EBP];
+ frame.tf_esi = ipkdbregs[ESI];
+ frame.tf_edi = ipkdbregs[EDI];
+ frame.tf_eip = ipkdbregs[EIP];
+ frame.tf_eflags = ipkdbregs[EFLAGS];
+ frame.tf_cs = ipkdbregs[CS];
+ frame.tf_ds = ipkdbregs[DS];
+ frame.tf_es = ipkdbregs[ES];
+ __asm __volatile ("movl %0,%%fs; movl %1,%%gs"
+ :: "r"(ipkdbregs[FS]), "r"(ipkdbregs[GS]));
+
+ return 1;
+}
+
+int
+ipkdbif_init(kip)
+ struct ipkdb_if *kip;
+{
+#ifdef IPKDB_NE_PCI
+ pci_mode_detect(); /* XXX */
+ if (ne_pci_ipkdb_attach(kip, I386_BUS_SPACE_IO, NULL, 0, IPKDB_NE_PCISLOT) == 0) {
+ printf("IPKDB on %s\n", kip->name);
+ return 0;
+ }
+#endif
+ return -1;
+}
diff -r d197e1af80f5 -r a82ac4d096f3 sys/arch/i386/i386/locore.s
--- a/sys/arch/i386/i386/locore.s Wed Mar 22 20:38:22 2000 +0000
+++ b/sys/arch/i386/i386/locore.s Wed Mar 22 20:58:25 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.s,v 1.216 2000/02/21 20:06:08 dbj Exp $ */
+/* $NetBSD: locore.s,v 1.217 2000/03/22 20:58:27 ws Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -76,6 +76,7 @@
#include "opt_cputype.h"
#include "opt_ddb.h"
+#include "opt_ipkdb.h"
#include "opt_vm86.h"
#include "opt_user_ldt.h"
#include "opt_dummy_nops.h"
@@ -2156,15 +2157,21 @@
#define TRAP(a) pushl $(a) ; jmp _C_LABEL(alltraps)
#define ZTRAP(a) pushl $0 ; TRAP(a)
+#ifdef IPKDB
+#define BPTTRAP(a) pushl $0; pushl $(a); jmp _C_LABEL(bpttraps)
+#else
+#define BPTTRAP(a) ZTRAP(a)
+#endif
+
.text
IDTVEC(trap00)
ZTRAP(T_DIVIDE)
IDTVEC(trap01)
- ZTRAP(T_TRCTRAP)
+ BPTTRAP(T_TRCTRAP)
IDTVEC(trap02)
ZTRAP(T_NMI)
IDTVEC(trap03)
- ZTRAP(T_BPTFLT)
+ BPTTRAP(T_BPTFLT)
IDTVEC(trap04)
ZTRAP(T_OFLOW)
IDTVEC(trap05)
@@ -2329,6 +2336,86 @@
4: .asciz "WARNING: SPL NOT LOWERED ON TRAP EXIT\n"
#endif /* DIAGNOSTIC */
+#ifdef IPKDB
+NENTRY(bpttraps)
+ INTRENTRY
+ call _C_LABEL(ipkdb_trap_glue)
+ testl %eax,%eax
+ jz calltrap
+ INTRFASTEXIT
+
+ipkdbsetup:
+ popl %ecx
+
+ /* Disable write protection: */
+ movl %cr0,%eax
+ pushl %eax
+ andl $~CR0_WP,%eax
+ movl %eax,%cr0
+
+ /* Substitute Protection & Page Fault handlers: */
+ movl _C_LABEL(idt),%edx
+ pushl 13*8(%edx)
+ pushl 13*8+4(%edx)
+ pushl 14*8(%edx)
+ pushl 14*8+4(%edx)
+ movl $fault,%eax
+ movw %ax,13*8(%edx)
+ movw %ax,14*8(%edx)
+ shrl $16,%eax
+ movw %ax,13*8+6(%edx)
+ movw %ax,14*8+6(%edx)
+
+ pushl %ecx
+ ret
+
+ipkdbrestore:
+ popl %ecx
+
+ /* Restore Protection & Page Fault handlers: */
+ movl _C_LABEL(idt),%edx
+ popl 14*8+4(%edx)
+ popl 14*8(%edx)
+ popl 13*8+4(%edx)
+ popl 13*8(%edx)
+
+ /* Restore write protection: */
+ popl %edx
+ movl %edx,%cr0
+
+ pushl %ecx
+ ret
+
+NENTRY(ipkdbfbyte)
+ pushl %ebp
+ movl %esp,%ebp
+ call ipkdbsetup
+ movl 8(%ebp),%edx
+ movzbl (%edx),%eax
+faultexit:
+ call ipkdbrestore
+ popl %ebp
+ ret
+
+NENTRY(ipkdbsbyte)
+ pushl %ebp
+ movl %esp,%ebp
+ call ipkdbsetup
+ movl 8(%ebp),%edx
+ movl 12(%ebp),%eax
+ movb %al,(%edx)
+ call ipkdbrestore
+ popl %ebp
+ ret
+
+fault:
+ popl %eax /* error code */
+ movl $faultexit,%eax
+ movl %eax,(%esp)
+ movl $-1,%eax
+ iret
+#endif /* IPKDB */
+
/*
* Old call gate entry for syscall
*/
diff -r d197e1af80f5 -r a82ac4d096f3 sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c Wed Mar 22 20:38:22 2000 +0000
+++ b/sys/arch/i386/i386/machdep.c Wed Mar 22 20:58:25 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.376 2000/02/04 14:21:33 minoura Exp $ */
+/* $NetBSD: machdep.c,v 1.377 2000/03/22 20:58:27 ws Exp $ */
Home |
Main Index |
Thread Index |
Old Index