Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/i386 machdep.c is becoming an unmaintainable mess



details:   https://anonhg.NetBSD.org/src/rev/008f51fe4c1e
branches:  trunk
changeset: 479792:008f51fe4c1e
user:      drochner <drochner%NetBSD.org@localhost>
date:      Tue Dec 21 12:34:11 1999 +0000

description:
machdep.c is becoming an unmaintainable mess
put console initialisation into a separate file

diffstat:

 sys/arch/i386/conf/files.i386 |    3 +-
 sys/arch/i386/i386/consinit.c |  191 +++++++++++++++++++++++++++++++++++++++++
 sys/arch/i386/i386/machdep.c  |  195 +-----------------------------------------
 sys/arch/i386/include/cpu.h   |    6 +-
 4 files changed, 200 insertions(+), 195 deletions(-)

diffs (truncated from 480 to 300 lines):

diff -r 9aec7673a235 -r 008f51fe4c1e sys/arch/i386/conf/files.i386
--- a/sys/arch/i386/conf/files.i386     Tue Dec 21 12:02:04 1999 +0000
+++ b/sys/arch/i386/conf/files.i386     Tue Dec 21 12:34:11 1999 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.i386,v 1.144 1999/12/08 16:46:32 joda Exp $
+#      $NetBSD: files.i386,v 1.145 1999/12/21 12:34:13 drochner Exp $
 #
 # new style config file for i386 architecture
 #
@@ -43,6 +43,7 @@
 
 file   arch/i386/i386/autoconf.c
 file   arch/i386/i386/conf.c
+file   arch/i386/i386/consinit.c
 file   arch/i386/i386/db_dbgreg.s      ddb
 file   arch/i386/i386/db_disasm.c      ddb
 file   arch/i386/i386/db_interface.c   ddb
diff -r 9aec7673a235 -r 008f51fe4c1e sys/arch/i386/i386/consinit.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/i386/i386/consinit.c     Tue Dec 21 12:34:11 1999 +0000
@@ -0,0 +1,191 @@
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <machine/bus.h>
+#include <machine/bootinfo.h>
+
+#include "vga.h"
+#include "ega.h"
+#include "pcdisplay.h"
+#if (NVGA > 0) || (NEGA > 0) || (NPCDISPLAY > 0)
+#include <dev/ic/mc6845reg.h>
+#include <dev/ic/pcdisplayvar.h>
+#if (NVGA > 0)
+#include <dev/ic/vgareg.h>
+#include <dev/ic/vgavar.h>
+#endif
+#if (NEGA > 0)
+#include <dev/isa/egavar.h>
+#endif
+#if (NPCDISPLAY > 0)
+#include <dev/isa/pcdisplayvar.h>
+#endif
+#endif
+
+#include "pckbc.h"
+#if (NPCKBC > 0)
+#include <dev/isa/isareg.h>
+#include <dev/ic/pckbcvar.h>
+#endif
+
+#include "pc.h"
+#if (NPC > 0)
+#include <machine/pccons.h>
+#endif
+
+#include "vt.h"
+#if (NVT > 0)
+#include <i386/isa/pcvt/pcvt_cons.h>
+#endif
+
+#include "com.h"
+#if (NCOM > 0)
+#include <sys/termios.h>
+#include <dev/ic/comreg.h>
+#include <dev/ic/comvar.h>
+#endif
+
+#ifndef CONSDEVNAME
+#define CONSDEVNAME "pc"
+#endif
+
+#if (NCOM > 0)
+#ifndef CONADDR
+#define CONADDR 0x3f8
+#endif
+#ifndef CONSPEED
+#define CONSPEED TTYDEF_SPEED
+#endif
+#ifndef CONMODE
+#define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
+#endif
+int comcnmode = CONMODE;
+#endif /* NCOM */
+
+struct btinfo_console default_consinfo = {
+       {0, 0},
+       CONSDEVNAME,
+#if (NCOM > 0)
+       CONADDR, CONSPEED
+#else
+       0, 0
+#endif
+};
+
+#ifdef KGDB
+#ifndef KGDB_DEVNAME
+#define KGDB_DEVNAME "com"
+#endif
+char kgdb_devname[] = KGDB_DEVNAME;
+
+#if (NCOM > 0)
+#ifndef KGDBADDR
+#define KGDBADDR 0x3f8
+#endif
+int comkgdbaddr = KGDBADDR;
+#ifndef KGDBRATE
+#define KGDBRATE TTYDEF_SPEED
+#endif
+int comkgdbrate = KGDBRATE;
+#ifndef KGDBMODE
+#define KGDBMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
+#endif
+int comkgdbmode = KGDBMODE;
+#endif /* NCOM */
+
+#endif /* KGDB */
+
+/*
+ * consinit:
+ * initialize the system console.
+ * XXX - shouldn't deal with this initted thing, but then,
+ * it shouldn't be called from init386 either.
+ */
+void
+consinit()
+{
+       struct btinfo_console *consinfo;
+       static int initted;
+
+       if (initted)
+               return;
+       initted = 1;
+
+#ifndef CONS_OVERRIDE
+       consinfo = lookup_bootinfo(BTINFO_CONSOLE);
+       if (!consinfo)
+#endif
+               consinfo = &default_consinfo;
+
+#if (NPC > 0) || (NVT > 0) || (NVGA > 0) || (NEGA > 0) || (NPCDISPLAY > 0)
+       if (!strcmp(consinfo->devname, "pc")) {
+#if (NVGA > 0)
+               if (!vga_cnattach(I386_BUS_SPACE_IO, I386_BUS_SPACE_MEM,
+                                 -1, 1))
+                       goto dokbd;
+#endif
+#if (NEGA > 0)
+               if (!ega_cnattach(I386_BUS_SPACE_IO, I386_BUS_SPACE_MEM))
+                       goto dokbd;
+#endif
+#if (NPCDISPLAY > 0)
+               if (!pcdisplay_cnattach(I386_BUS_SPACE_IO, I386_BUS_SPACE_MEM))
+                       goto dokbd;
+#endif
+#if (NPC > 0) || (NVT > 0)
+               pccnattach();
+#endif
+               if (0) goto dokbd; /* XXX stupid gcc */
+dokbd:
+#if (NPCKBC > 0)
+               pckbc_cnattach(I386_BUS_SPACE_IO, IO_KBD, PCKBC_KBD_SLOT);
+#endif
+               return;
+       }
+#endif /* PC | VT | VGA | PCDISPLAY */
+#if (NCOM > 0)
+       if (!strcmp(consinfo->devname, "com")) {
+               bus_space_tag_t tag = I386_BUS_SPACE_IO;
+
+               if (comcnattach(tag, consinfo->addr, consinfo->speed,
+                               COM_FREQ, comcnmode))
+                       panic("can't init serial console @%x", consinfo->addr);
+
+               return;
+       }
+#endif
+       panic("invalid console device %s", consinfo->devname);
+}
+
+#if (NPCKBC > 0) && (NPCKBD == 0)
+/*
+ * glue code to support old console code with the
+ * mi keyboard controller driver
+ */
+int
+pckbc_machdep_cnattach(kbctag, kbcslot)
+       pckbc_tag_t kbctag;
+       pckbc_slot_t kbcslot;
+{
+#if (NPC > 0) && (NPCCONSKBD > 0)
+       return (pcconskbd_cnattach(kbctag, kbcslot));
+#else
+       return (ENXIO);
+#endif
+}
+#endif
+
+#ifdef KGDB
+void
+kgdb_port_init()
+{
+#if (NCOM > 0)
+       if(!strcmp(kgdb_devname, "com")) {
+               bus_space_tag_t tag = I386_BUS_SPACE_IO;
+
+               com_kgdb_attach(tag, comkgdbaddr, comkgdbrate, COM_FREQ, 
+                   comkgdbmode);
+       }
+#endif
+}
+#endif
diff -r 9aec7673a235 -r 008f51fe4c1e sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c      Tue Dec 21 12:02:04 1999 +0000
+++ b/sys/arch/i386/i386/machdep.c      Tue Dec 21 12:34:11 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.371 1999/12/13 16:30:15 drochner Exp $   */
+/*     $NetBSD: machdep.c,v 1.372 1999/12/21 12:34:11 drochner Exp $   */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -101,7 +101,6 @@
 #include <sys/msgbuf.h>
 #include <sys/mount.h>
 #include <sys/vnode.h>
-#include <sys/device.h>
 #include <sys/extent.h>
 #include <sys/syscallargs.h>
 #include <sys/core.h>
@@ -116,9 +115,6 @@
 
 #include <vm/vm.h>
 #include <vm/vm_kern.h>
-#include <vm/vm_page.h>
-
-#include <uvm/uvm_extern.h>
 
 #include <sys/sysctl.h>
 
@@ -135,15 +131,11 @@
 #include <machine/bootinfo.h>
 
 #include <dev/isa/isareg.h>
-#include <dev/isa/isavar.h>
+#include <machine/isa_machdep.h>
 #include <dev/ic/i8042reg.h>
-#include <dev/ic/mc146818reg.h>
-#include <i386/isa/nvram.h>
 
 #ifdef DDB
 #include <machine/db_machdep.h>
-#include <ddb/db_access.h>
-#include <ddb/db_sym.h>
 #include <ddb/db_extern.h>
 #endif
 
@@ -169,46 +161,6 @@
 extern struct proc *npxproc;
 #endif
 
-#include "vga.h"
-#include "ega.h"
-#include "pcdisplay.h"
-#if (NVGA > 0) || (NPCDISPLAY > 0)
-#include <dev/ic/mc6845reg.h>
-#include <dev/ic/pcdisplayvar.h>
-#if (NVGA > 0)
-#include <dev/ic/vgareg.h>
-#include <dev/ic/vgavar.h>
-#endif
-#if (NEGA > 0)
-#include <dev/isa/egavar.h>
-#endif
-#if (NPCDISPLAY > 0)
-#include <dev/isa/pcdisplayvar.h>
-#endif
-#endif
-
-#include "pckbc.h"
-#if (NPCKBC > 0)
-#include <dev/ic/pckbcvar.h>
-#endif
-
-#include "pc.h"
-#if (NPC > 0)
-#include <machine/pccons.h>
-#endif
-
-#include "vt.h"
-#if (NVT > 0)
-#include <i386/isa/pcvt/pcvt_cons.h>
-#endif
-
-#include "com.h"
-#if (NCOM > 0)
-#include <sys/termios.h>
-#include <dev/ic/comreg.h>
-#include <dev/ic/comvar.h>
-#endif
-



Home | Main Index | Thread Index | Old Index