PERFORCE change 76664 for review

Marcel Moolenaar marcel at FreeBSD.org
Sat May 7 14:42:05 PDT 2005


http://perforce.freebsd.org/chv.cgi?CH=76664

Change 76664 by marcel at marcel_nfs on 2005/05/07 21:41:29

	A bunch of changes. Most importantly:
	o  Add dev/ic/vga.h for register definitions and the likes.
	o  Design the hardware interface around bitblt. The vtc(4)
	   driver will deal with cursors, fonts and the likes.
	o  Revamp the vga(4) driver accordingly.
	
	This change makes the vtc(4) and vga(4) code non-functional,
	but instead paves the way towards the final goal.
	
	Compiles on: ia64.

Affected files ...

.. //depot/projects/tty/sys/conf/files#24 edit
.. //depot/projects/tty/sys/dev/ic/vga.h#1 add
.. //depot/projects/tty/sys/dev/vga/vga.c#4 edit
.. //depot/projects/tty/sys/dev/vga/vga.h#4 edit
.. //depot/projects/tty/sys/dev/vga/vga_bus_isa.c#2 edit
.. //depot/projects/tty/sys/dev/vga/vga_bus_pci.c#2 edit
.. //depot/projects/tty/sys/dev/vga/vga_con.c#1 add
.. //depot/projects/tty/sys/dev/vga/vga_cons.c#6 delete
.. //depot/projects/tty/sys/dev/vga/vga_cpu_alpha.c#3 edit
.. //depot/projects/tty/sys/dev/vga/vga_cpu_amd64.c#3 edit
.. //depot/projects/tty/sys/dev/vga/vga_cpu_i386.c#4 edit
.. //depot/projects/tty/sys/dev/vga/vga_cpu_ia64.c#3 edit
.. //depot/projects/tty/sys/dev/vga/vga_cpu_sparc64.c#2 edit
.. //depot/projects/tty/sys/dev/vga/vga_vid.c#3 delete
.. //depot/projects/tty/sys/dev/vtc/vtc_con.c#1 add
.. //depot/projects/tty/sys/dev/vtc/vtc_con.h#1 add
.. //depot/projects/tty/sys/dev/vtc/vtc_core.c#2 edit
.. //depot/projects/tty/sys/dev/vtc/vtc_tty.c#1 add

Differences ...

==== //depot/projects/tty/sys/conf/files#24 (text+ko) ====

@@ -916,9 +916,10 @@
 dev/vga/vga.c			optional vga
 dev/vga/vga_bus_isa.c		optional vga isa
 dev/vga/vga_bus_pci.c		optional vga pci
-dev/vga/vga_cons.c		optional vga
+dev/vga/vga_con.c		optional vga
 dev/vge/if_vge.c		optional vge
 dev/vkbd/vkbd.c			optional vkbd
+dev/vtc/vtc_con.c		optional vtc
 dev/vtc/vtc_core.c		optional vtc
 dev/vx/if_vx.c			optional vx
 dev/vx/if_vx_eisa.c		optional vx eisa

==== //depot/projects/tty/sys/dev/vga/vga.c#4 (text+ko) ====

@@ -34,158 +34,60 @@
 #include <sys/bus.h>
 #include <sys/rman.h>
 
+#include <dev/ic/vga.h>
 #include <dev/vga/vga.h>
 
 struct vga_softc vga_console;
 devclass_t vga_devclass;
 char vga_device_name[] = "vga";
 
-int vga_curcol;
-int vga_currow;
-
-static void
-vga_write(struct vga_softc *sc, int y, int x, int ascii, int color)
+int
+vga_probe(struct vga_softc *sc)
 {
-	uint32_t ofs;
-	uint16_t w;
 
-	ofs = y * 160 + x * 2;
-	w = color * 256 + ascii;
-	bus_space_write_2(sc->vga_screen.bst, sc->vga_screen.bsh, ofs, w);
+	return (1);
 }
 
-static void
-vga_scrollup(struct vga_softc *sc)
+int
+vga_init(struct vga_softc *sc)
 {
-	uint32_t count, ofs;
-	uint16_t w;
+	int error;
 
-	ofs = 0;
+	sc->vga_screen = sc->vga_fb;
+	error = bus_space_subregion(sc->vga_fb.bst, sc->vga_fb.bsh,
+	    (sc->vga_mono) ? 0x10000 : 0x18000, 4096, &sc->vga_screen.bsh);
+	if (error)
+		return (error);
 
-	/* Copy data on lower 24 lines 1 line up. */
-	count = 24*80;
-	while (count--) {
-		w = bus_space_read_2(sc->vga_screen.bst, sc->vga_screen.bsh,
-		    ofs + 160);
-		bus_space_write_2(sc->vga_screen.bst, sc->vga_screen.bsh,
-		    ofs, w);
-		ofs += 2;
-	}
+	/* TODO -- set the VGA adapter in 640x480x16 mode */
 
-	/* Clear bottom line. Use BG color of last character copied. */
-	count = 80;
-	w = (w & 0xff00) | 0x20;
-	while (count--) {
-		bus_space_write_2(sc->vga_screen.bst, sc->vga_screen.bsh,
-		    ofs, w);
-		ofs += 2;
-	}
+	sc->vga_enable = 1;
+	return (0);
 }
 
-void
-vga_setpos(struct vga_softc *sc, int row, int col)
+int
+vga_bitblt(struct vga_softc *sc, int x, int y)
 {
-	uint16_t ofs;
 
-	ofs = row * 80 + col;
-	bus_space_write_1(sc->vga_crtc.bst, sc->vga_crtc.bsh, 0, 14);
-	bus_space_write_1(sc->vga_crtc.bst, sc->vga_crtc.bsh, 1, ofs >> 8);
-	bus_space_write_1(sc->vga_crtc.bst, sc->vga_crtc.bsh, 0, 15);
-	bus_space_write_1(sc->vga_crtc.bst, sc->vga_crtc.bsh, 1, ofs & 0xff);
-}
-
-void
-vga_getpos(struct vga_softc *sc, int *row, int *col)
-{
-	uint16_t ofs;
-
-	bus_space_write_1(sc->vga_crtc.bst, sc->vga_crtc.bsh, 0, 14);
-	ofs = bus_space_read_1(sc->vga_crtc.bst, sc->vga_crtc.bsh, 1) << 8;
-	bus_space_write_1(sc->vga_crtc.bst, sc->vga_crtc.bsh, 0, 15);
-	ofs |= bus_space_read_1(sc->vga_crtc.bst, sc->vga_crtc.bsh, 1) & 0xff;
-	*row = ofs / 80;
-	*col = ofs % 80;
+	return (0);
 }
 
-void
-vga_putc(struct vga_softc *sc, int c)
-{
-	int d;
-
-	d = 1;
-	switch (c) {
-	case 0x07:	/* bell */
-		return;
-	case 0x08:	/* backspace */
-		c = ' ';
-		if (vga_curcol)
-			vga_curcol--;
-		d = 0;
-		break;
-	case 0x09:	/* tab */
-		vga_curcol = (vga_curcol + 8) & ~7;
-		if (vga_curcol < 80) {
-			vga_setpos(sc, vga_currow, vga_curcol);
-			return;
-		}
-		/* FALLTHOUGH */
-	case 0x0a:	/* linefeed */
-		if (vga_currow == 24)
-			vga_scrollup(sc);
-		else
-			vga_currow++;
-		/* FALLTHROUGH */
-	case 0x0d:	/* carriage return */
-		vga_curcol = 0;
-		vga_setpos(sc, vga_currow, vga_curcol);
-		return;
-	}
-	vga_write(sc, vga_currow, vga_curcol, c, 0x0f);
-	vga_curcol += d;
-	if (vga_curcol >= 80) {
-		vga_curcol = 0;
-		if (vga_currow == 24)
-			vga_scrollup(sc);
-		else
-			vga_currow++;
-	}
-	vga_setpos(sc, vga_currow, vga_curcol);
-}
-
-void
-vga_puts(struct vga_softc *sc, const char *s)
-{
-
-	while (*s)
-		vga_putc(sc, *s++);
-}
-
 int
 vga_attach(device_t dev)
 {
 	struct vga_softc *sc;
 	int error;
-	uint32_t x, y;
 
 	sc = device_get_softc(dev);
 
-	sc->vga_screen = sc->vga_fb;
-	error = bus_space_subregion(sc->vga_fb.bst, sc->vga_fb.bsh,
-	    (sc->vga_mono) ? 0x10000 : 0x18000, 4096, &sc->vga_screen.bsh);
-	if (error)
-		return (error);
-
-	sc->vga_enable = 1;
-
 	if (sc->vga_console)
 		return (0);
 
-	for (y = 0; y < 25; y++)
-		for (x = 0; x < 80; x++)
-			vga_write(sc, y, x, ' ', 7);
+	error = vga_init(sc);
+	if (error)
+		return (error);
 
-	vga_currow = vga_curcol = 0;
-	vga_puts(sc, "Please wait...\r");
+	/* TODO -- show beastie logo */
 
 	return (0);
 }

==== //depot/projects/tty/sys/dev/vga/vga.h#4 (text+ko) ====

@@ -29,9 +29,7 @@
 #ifndef _DEV_VGA_VGA_H_
 #define	_DEV_VGA_VGA_H_
 
-#define	VGA_REG_MISC		0x1c		/* 0x3CC */
-
-struct vga_space
+struct vga_spc
 {
 	bus_space_tag_t		bst;
 	bus_space_handle_t	bsh;
@@ -39,35 +37,34 @@
 
 struct vga_softc
 {
-	struct consdev *	vga_consdev;
-	device_t		vga_dev;
-	dev_t			vga_node;
+	device_t	vga_dev;
+	dev_t		vga_node;
 
 	/* Device flags and state. */
-	int			vga_bustype:2;
+	int		vga_bustype:2;
 #define	VGA_BUSTYPE_ISA		1
 #define	VGA_BUSTYPE_PCI		2
-	int			vga_console:1;
-	int			vga_enable:1;
-	int			vga_mono:1;
+	int		vga_console:1;
+	int		vga_enable:1;
+	int		vga_mono:1;
 
 	/* Bus spaces */
-	struct vga_space	vga_space[4];
+	struct vga_spc	vga_spc[4];
 #define	VGA_RES_FB		0
 #define	VGA_RES_SCREEN		1
 #define	VGA_RES_REG		2
 #define	VGA_RES_CRTC		3
 };
 
-#define	vga_fb		vga_space[VGA_RES_FB]
-#define	vga_screen	vga_space[VGA_RES_SCREEN]
-#define	vga_reg		vga_space[VGA_RES_REG]
-#define	vga_crtc	vga_space[VGA_RES_CRTC]
+#define	vga_fb		vga_spc[VGA_RES_FB]
+#define	vga_screen	vga_spc[VGA_RES_SCREEN]
+#define	vga_reg		vga_spc[VGA_RES_REG]
+#define	vga_crtc	vga_spc[VGA_RES_CRTC]
 
 struct vga_consdata {
-	struct vga_space	fb;
-	struct vga_space	reg;
-	struct vga_space	crtc;
+	struct vga_spc	fb;
+	struct vga_spc	reg;
+	struct vga_spc	crtc;
 };
 
 int vga_get_console(struct vga_consdata*);
@@ -76,14 +73,18 @@
 extern devclass_t vga_devclass;
 extern char vga_device_name[];
 
-extern int vga_curcol;
-extern int vga_currow;
+static __inline int
+vga_is_mono(struct vga_spc *sp)
+{
+	uint8_t misc;
+
+	misc = bus_space_read_1(sp->bst, sp->bsh, VGA_GEN_MISC_OUTPUT_R);
+	return ((misc & VGA_GEN_MO_IOA) ? 0 : 1);
+}
 
 int vga_attach(device_t);
-
-void vga_getpos(struct vga_softc *, int *, int *);
-void vga_putc(struct vga_softc *, int);
-void vga_puts(struct vga_softc *, const char *);
-void vga_setpos(struct vga_softc *, int, int);
+int vga_bitblt(struct vga_softc *, int, int);
+int vga_init(struct vga_softc *);
+int vga_probe(struct vga_softc *);
 
 #endif /* _DEV_VGA_VGA_H_ */

==== //depot/projects/tty/sys/dev/vga/vga_bus_isa.c#2 (text+ko) ====

@@ -39,6 +39,7 @@
 #include <isa/isareg.h>
 #include <isa/isavar.h>
 
+#include <dev/ic/vga.h>
 #include <dev/vga/vga.h>
 
 static int vga_isa_attach(device_t);

==== //depot/projects/tty/sys/dev/vga/vga_bus_pci.c#2 (text+ko) ====

@@ -39,6 +39,7 @@
 #include <dev/pci/pcireg.h>
 #include <dev/pci/pcivar.h>
 
+#include <dev/ic/vga.h>
 #include <dev/vga/vga.h>
 
 static int vga_pci_attach(device_t dev);
@@ -66,8 +67,8 @@
 	if (res == NULL)
 		return (ENXIO);
 
-	sc->vga_space[rid].bsh = rman_get_bushandle(res);
-	sc->vga_space[rid].bst = rman_get_bustag(res);
+	sc->vga_spc[rid].bsh = rman_get_bushandle(res);
+	sc->vga_spc[rid].bst = rman_get_bustag(res);
 	return (0);
 }
 
@@ -76,8 +77,6 @@
 {
 	struct vga_softc *sc;
 	int error;
-	uint32_t crtc;
-	uint8_t x;
 
 	/*
 	 * If VGA is the console, this device must be it.  If not, then
@@ -90,8 +89,10 @@
 	sc->vga_bustype = VGA_BUSTYPE_PCI;
 
 	/* Set the legacy resources */
-	bus_set_resource(dev, SYS_RES_MEMORY, VGA_RES_FB, 0xA0000, 0x20000);
-	bus_set_resource(dev, SYS_RES_IOPORT, VGA_RES_REG, 0x3c0, 0x10);
+	bus_set_resource(dev, SYS_RES_MEMORY, VGA_RES_FB, VGA_MEM_BASE,
+	    VGA_MEM_SIZE);
+	bus_set_resource(dev, SYS_RES_IOPORT, VGA_RES_REG, VGA_IO0_BASE,
+	    VGA_IO0_SIZE);
 
 	error = vga_pci_alloc(dev, sc, SYS_RES_MEMORY, VGA_RES_FB);
 	if (error)
@@ -100,12 +101,11 @@
 	if (error)
 		return (error);
 
-	/* Determine if the VGA controller is in colour or monochrome mode. */
-	x = bus_space_read_1(sc->vga_reg.bst, sc->vga_reg.bsh, VGA_REG_MISC);
-	sc->vga_mono = (x & 1) ? 0 : 1;
+	/* Determine if the VGA controller is in color or monochrome mode. */
+	sc->vga_mono = vga_is_mono(&sc->vga_reg);
 
-	crtc = (sc->vga_mono) ? 0x3b0 : 0x3d0;
-	bus_set_resource(dev, SYS_RES_IOPORT, VGA_RES_CRTC, crtc, 0x0c);
+	bus_set_resource(dev, SYS_RES_IOPORT, VGA_RES_CRTC,
+	    (sc->vga_mono) ? VGA_IO1_MONO : VGA_IO1_COLOR, VGA_IO1_SIZE);
 	error = vga_pci_alloc(dev, sc, SYS_RES_IOPORT, VGA_RES_CRTC);
 	if (error)
 		return (error);

==== //depot/projects/tty/sys/dev/vga/vga_cpu_alpha.c#3 (text+ko) ====

@@ -32,28 +32,18 @@
 
 #include <machine/bus.h>
 
+#include <dev/ic/vga.h>
 #include <dev/vga/vga.h>
 
 int
 vga_get_console(struct vga_consdata *cd)
 {
-	int mono;
-	uint8_t misc;
 
 	cd->fb.bst = busspace_isa_mem;
-	cd->fb.bsh = 0xA0000;
+	cd->fb.bsh = VGA_MEM_BASE;
 	cd->reg.bst = busspace_isa_io;
-	cd->reg.bsh = 0x3c0;
-
-	/*
-	 * Determine if the VGA controller is in colour or monochrome mode.
-	 * That way we know where the CRTC registers are.
-	 */
-	misc = bus_space_read_1(cd->reg.bst, cd->reg.bsh, VGA_REG_MISC);
-	mono = (misc & 1) ? 0 : 1;
-
+	cd->reg.bsh = VGA_IO0_BASE;
 	cd->crtc.bst = busspace_isa_io;
-	cd->crtc.bsh = (mono) ? 0x3b4 : 0x3d4;
-
+	cd->crtc.bsh = (vga_is_mono(&cd->reg)) ? VGA_IO1_MONO : VGA_IO1_COLOR;
 	return (0);
 }

==== //depot/projects/tty/sys/dev/vga/vga_cpu_amd64.c#3 (text+ko) ====

@@ -38,28 +38,18 @@
 #include <machine/pmap.h>
 #include <machine/vmparam.h>
 
+#include <dev/ic/vga.h>
 #include <dev/vga/vga.h>
 
 int
 vga_get_console(struct vga_consdata *cd)
 {
-	int mono;
-	uint8_t misc;
 
 	cd->fb.bst = AMD64_BUS_SPACE_MEM;
-	cd->fb.bsh = 0xA0000 + KERNBASE;
+	cd->fb.bsh = KERNBASE + VGA_MEM_BASE;
 	cd->reg.bst = AMD64_BUS_SPACE_IO;
-	cd->reg.bsh = 0x3c0;
-
-	/*
-	 * Determine if the VGA controller is in colour or monochrome mode.
-	 * That way we know where the CRTC registers are.
-	 */
-	misc = bus_space_read_1(cd->reg.bst, cd->reg.bsh, VGA_REG_MISC);
-	mono = (misc & 1) ? 0 : 1;
-
+	cd->reg.bsh = VGA_IO0_BASE;
 	cd->crtc.bst = AMD64_BUS_SPACE_IO;
-	cd->crtc.bsh = (mono) ? 0x3b4 : 0x3d4;
-
+	cd->crtc.bsh = (vga_is_mono(&cd->reg)) ? VGA_IO1_MONO : VGA_IO1_COLOR;
 	return (0);
 }

==== //depot/projects/tty/sys/dev/vga/vga_cpu_i386.c#4 (text+ko) ====

@@ -38,28 +38,18 @@
 #include <machine/pmap.h>
 #include <machine/vmparam.h>
 
+#include <dev/ic/vga.h>
 #include <dev/vga/vga.h>
 
 int
 vga_get_console(struct vga_consdata *cd)
 {
-	int mono;
-	uint8_t misc;
 
 	cd->fb.bst = I386_BUS_SPACE_MEM;
-	cd->fb.bsh = 0xA0000 + KERNBASE;
+	cd->fb.bsh = KERNBASE + VGA_MEM_BASE;
 	cd->reg.bst = I386_BUS_SPACE_IO;
-	cd->reg.bsh = 0x3c0;
-
-	/*
-	 * Determine if the VGA controller is in colour or monochrome mode.
-	 * That way we know where the CRTC registers are.
-	 */
-	misc = bus_space_read_1(cd->reg.bst, cd->reg.bsh, VGA_REG_MISC);
-	mono = (misc & 1) ? 0 : 1;
-
+	cd->reg.bsh = VGA_IO0_BASE;
 	cd->crtc.bst = I386_BUS_SPACE_IO;
-	cd->crtc.bsh = (mono) ? 0x3b4 : 0x3d4;
-
+	cd->crtc.bsh = (vga_is_mono(&cd->reg)) ? VGA_IO1_MONO : VGA_IO1_COLOR;
 	return (0);
 }

==== //depot/projects/tty/sys/dev/vga/vga_cpu_ia64.c#3 (text+ko) ====

@@ -32,28 +32,18 @@
 
 #include <machine/bus.h>
 
+#include <dev/ic/vga.h>
 #include <dev/vga/vga.h>
 
 int
 vga_get_console(struct vga_consdata *cd)
 {
-	int mono;
-	uint8_t misc;
 
 	cd->fb.bst = IA64_BUS_SPACE_MEM;
-	cd->fb.bsh = IA64_PHYS_TO_RR6(0xA0000);		/* XXX */
+	cd->fb.bsh = IA64_PHYS_TO_RR6(VGA_MEM_BASE);
 	cd->reg.bst = IA64_BUS_SPACE_IO;
-	cd->reg.bsh = 0x3c0;
-
-	/*
-	 * Determine if the VGA controller is in colour or monochrome mode.
-	 * That way we know where the CRTC registers are.
-	 */
-	misc = bus_space_read_1(cd->reg.bst, cd->reg.bsh, VGA_REG_MISC);
-	mono = (misc & 1) ? 0 : 1;
-
+	cd->reg.bsh = VGA_IO0_BASE;
 	cd->crtc.bst = IA64_BUS_SPACE_IO;
-	cd->crtc.bsh = (mono) ? 0x3b4 : 0x3d4;
-
+	cd->crtc.bsh = (vga_is_mono(&cd->reg)) ? VGA_IO1_MONO : VGA_IO1_COLOR;
 	return (0);
 }

==== //depot/projects/tty/sys/dev/vga/vga_cpu_sparc64.c#2 (text+ko) ====

@@ -28,15 +28,56 @@
 __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
-#include <sys/bus.h>
+#include <sys/systm.h>
 
 #include <machine/bus.h>
+#include <machine/bus_private.h>
+
+#include <dev/ofw/openfirm.h>
+#include <machine/ofw_machdep.h>
 
+#include <dev/ic/vga.h>
 #include <dev/vga/vga.h>
 
 int
 vga_get_console(struct vga_consdata *cd)
 {
+	static struct bus_space_tag bst_store[3];
+	char odev[32];
+	ihandle_t stdout;
+	phandle_t chosen, oh, options;
 
-	return (ENXIO);
+	/*
+	 * Query OFW to see if we have a graphical console and whether
+	 * it's actually a VGA.
+	 */
+	if ((options = OF_finddevice("/options")) == -1)
+		return (ENXIO);
+	if (OF_getprop(options, "output-device", odev, sizeof(odev)) == -1)
+		return (ENXIO);
+	if (strcmp(odev, "screen") != 0)
+		return (ENODEV);
+	if ((oh = OF_finddevice(odev)) == -1)
+		return (ENXIO);
+	if ((chosen = OF_finddevice("/chosen")) == -1)
+		return (ENXIO);
+	if (OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1)
+		return (ENXIO);
+	if (OF_instance_to_package(stdout) != oh)
+		return (ENODEV);
+
+	/* XXX check if it's a VGA. */
+
+	/* Construct the bus tags and handles. */
+	cd->fb.bst = &bst_store[0];
+	cd->fb.bsh = sparc64_fake_bustag(PCI_MEMORY_BUS_SPACE, 0x1ff000a0000,
+	    cd->fb.bst);
+	cd->reg.bst = &bst_store[1];
+	cd->reg.bsh = sparc64_fake_bustag(PCI_IO_BUS_SPACE, 0x1fe020003c0,
+	    cd->reg.bst);
+	cd->crtc.bst = &bst_store[2];
+	cd->crtc.bsh = (vga_is_mono(&cd->reg)) ?
+	    sparc64_fake_bustag(PCI_IO_BUS_SPACE, 0x1fe020003b0, cd->crtc.bst) :
+	    sparc64_fake_bustag(PCI_IO_BUS_SPACE, 0x1fe020003d0, cd->crtc.bst);
+	return (0);
 }

==== //depot/projects/tty/sys/dev/vtc/vtc_core.c#2 (text+ko) ====

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2004 Marcel Moolenaar
+ * Copyright (c) 2003-2005 Marcel Moolenaar
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -30,154 +30,19 @@
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/conf.h>
-#include <sys/uio.h>
 #include <sys/kernel.h>
-#include <sys/malloc.h>
 #include <sys/module.h>
-#include <sys/disk.h>
-#include <sys/bus.h>
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <sys/rman.h>
-
-static d_close_t vtc_close;
-static d_ioctl_t vtc_ioctl;
-static d_mmap_t vtc_mmap;
-static d_open_t vtc_open;
-
-static struct cdevsw vtc_cdevsw = {
-	.d_version = D_VERSION,
-	.d_open = vtc_open;
-	.d_close = vtc_close;
-	.d_ioctl = vtc_ioctl;
-	.d_mmap = vtc_mmap;
-	.d_name = "vtc",
-	.d_flags = D_TTY | D_NEEDGIANT,
-};
-
-static dev_t vtc_console;
 
 static int
-vtc_open(dev_t dev, int flag, int mode, struct thread *td)
-{
-  struct uart_softc *sc;
-	struct tty *tp;
-	int error;
-
-	sc = dev->si_drv1;
-	if (sc == NULL || sc->sc_leaving)
-		return (ENODEV);
-
-	tp = dev->si_tty;
-
- loop:
-	if (sc->sc_opened) {
-		KASSERT(tp->t_state & TS_ISOPEN, ("foo"));
-		/*
-		 * The device is open, so everything has been initialized.
-		 * Handle conflicts.
-		 */
-		if (minor(dev) & UART_MINOR_CALLOUT) {
-			if (!sc->sc_callout)
-				return (EBUSY);
-		} else {
-			if (sc->sc_callout) {
-				if (flags & O_NONBLOCK)
-					return (EBUSY);
-				error =	tsleep(sc, TTIPRI|PCATCH, "uartbi", 0);
-				if (error)
-					return (error);
-				sc = dev->si_drv1;
-				if (sc == NULL || sc->sc_leaving)
-					return (ENODEV);
-				goto loop;
-			}
-		}
-		if (tp->t_state & TS_XCLUDE && suser(td) != 0)
-			return (EBUSY);
-	} else {
-		KASSERT(!(tp->t_state & TS_ISOPEN), ("foo"));
-		/*
-		 * The device isn't open, so there are no conflicts.
-		 * Initialize it.  Initialization is done twice in many
-		 * cases: to preempt sleeping callin opens if we are
-		 * callout, and to complete a callin open after DCD rises.
-		 */
-		sc->sc_callout = (minor(dev) & UART_MINOR_CALLOUT) ? 1 : 0;
-		tp->t_dev = dev;
-
-		tp->t_cflag = TTYDEF_CFLAG;
-		tp->t_iflag = TTYDEF_IFLAG;
-		tp->t_lflag = TTYDEF_LFLAG;
-		tp->t_oflag = TTYDEF_OFLAG;
-		tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
-		ttychars(tp);
-		error = uart_tty_param(tp, &tp->t_termios);
-		if (error)
-			return (error);
-		/*
-		 * Handle initial DCD.
-		 */
-		if ((sc->sc_hwsig & UART_SIG_DCD) || sc->sc_callout)
-			ttyld_modem(tp, 1);
-	}
-	/*
-	 * Wait for DCD if necessary.
-	 */
-	if (!(tp->t_state & TS_CARR_ON) && !sc->sc_callout &&
-	    !(tp->t_cflag & CLOCAL) && !(flags & O_NONBLOCK)) {
-		error = tsleep(TSA_CARR_ON(tp), TTIPRI|PCATCH, "uartdcd", 0);
-		if (error)
-			return (error);
-		sc = dev->si_drv1;
-		if (sc == NULL || sc->sc_leaving)
-			return (ENODEV);
-		goto loop;
-	}
-	error = ttyopen(dev, tp);
-	if (error)
-		return (error);
-	error = ttyld_open(tp, dev);
-	if (error)
-		return (error);
-
-	KASSERT(tp->t_state & TS_ISOPEN, ("foo"));
-	sc->sc_opened = 1;
-	return (0);
-}
-
-static int
-vtc_close(dev_t dev, int flag, int mode, struct thread *td)
-{
-}
-
-static int
-vtc_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td)
-{
-
-	return (ttyioctl(dev, cmd, data, flag, td));
-}
-
-static int
-vtc_mmap(dev_t dev, vm_offset_t offset, vm_paddr_t *paddr, int nprot)
-{
-
-	return (-1);
-}
-
-static int
 vtc_modevent(module_t mod, int type, void *data)
 {
 
-	switch(type) {
+	switch (type) {
 	case MOD_LOAD:
-		printf("vtc: <console, virtual terminals>\n");
-		vtc_console = make_dev(&vtc_cdevsw, 0, UID_ROOT, GID_WHEEL,
-		    0666, "console");
+		printf("vtc: <console, virtual terminal>\n");
 		return (0);
 
 	case MOD_UNLOAD:
-		destroy_dev(vtc_console);
 		return (0);
 
 	case MOD_SHUTDOWN:


More information about the p4-projects mailing list