From c6b81477957194a276e75a185a4b2e87ac43f413 Mon Sep 17 00:00:00 2001 From: Aaron Campbell Date: Wed, 15 Nov 2000 20:17:39 +0000 Subject: Updated VGA driver; from NetBSD. Needed for wscons on i386 and alpha. These files could probably be updated even a bit further (they are from mid-summer). In addition, I've added support for console scrollback, somewhat inspired by Linux's vgacon driver. Basically, instead of allocating our own buffer and doing lots of copies, we take advantage of Video RAM and just modify the VGA display origin register as appropriate. This approach has a few advantages: simple to implement, no wasted KVM, it's fast, and after a boot you can now scroll back all the way to the BIOS messages (assuming your msgbuf is of a typical length :). Disadvantages are that the VRAM buffer is relatively small (only 32k) and we do not support raster devices through this method. (thanks to mickey@ for pointing this out). The code for this is fairly unobtrusive, so should we come up with a better approach to console scrollback at a later time (i.e., even more platform independent) it should be easy to revert this. We're one step further in porting nice features of PCVT over to wscons. --- sys/dev/pci/vga_pci.c | 104 +++++++++++++---------------------------------- sys/dev/pci/vga_pcivar.h | 8 ++-- 2 files changed, 32 insertions(+), 80 deletions(-) (limited to 'sys/dev/pci') diff --git a/sys/dev/pci/vga_pci.c b/sys/dev/pci/vga_pci.c index 33f88528697..9b68e49d45f 100644 --- a/sys/dev/pci/vga_pci.c +++ b/sys/dev/pci/vga_pci.c @@ -1,5 +1,5 @@ -/* $OpenBSD: vga_pci.c,v 1.7 1998/01/05 13:35:27 deraadt Exp $ */ -/* $NetBSD: vga_pci.c,v 1.4 1996/12/05 01:39:38 cgd Exp $ */ +/* $OpenBSD: vga_pci.c,v 1.8 2000/11/15 20:17:38 aaron Exp $ */ +/* $NetBSD: vga_pci.c,v 1.3 1998/06/08 06:55:58 thorpej Exp $ */ /* * Copyright (c) 1995, 1996 Carnegie-Mellon University. @@ -34,50 +34,39 @@ #include #include -#ifndef i386 -#include -#endif -#include - #include #include #include +#include +#include +#include #include #include +#include +#include + struct vga_pci_softc { struct device sc_dev; pcitag_t sc_pcitag; /* PCI tag, in case we need it. */ - struct vga_config *sc_vc; /* VGA configuration */ +#if 0 + struct vga_config *sc_vc; /* VGA configuration */ +#endif }; -#ifdef __BROKEN_INDIRECT_CONFIG int vga_pci_match __P((struct device *, void *, void *)); -#else -int vga_pci_match __P((struct device *, struct cfdata *, void *)); -#endif void vga_pci_attach __P((struct device *, struct device *, void *)); -int vgapcimmap __P((void *, off_t, int)); -int vgapciioctl __P((void *, u_long, caddr_t, int, struct proc *)); - struct cfattach vga_pci_ca = { - sizeof(struct vga_pci_softc), (cfmatch_t)vga_pci_match, vga_pci_attach, + sizeof(struct vga_pci_softc), vga_pci_match, vga_pci_attach, }; -pcitag_t vga_pci_console_tag; -struct vga_config vga_pci_console_vc; - int vga_pci_match(parent, match, aux) struct device *parent; -#ifdef __BROKEN_INDIRECT_CONFIG void *match; -#else - struct cfdata *match; -#endif void *aux; { struct pci_attach_args *pa = aux; @@ -99,8 +88,14 @@ vga_pci_match(parent, match, aux) if (!potential) return (0); + /* check whether it is disabled by firmware */ + if ((pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG) + & (PCI_COMMAND_IO_ENABLE | PCI_COMMAND_MEM_ENABLE)) + != (PCI_COMMAND_IO_ENABLE | PCI_COMMAND_MEM_ENABLE)) + return (0); + /* If it's the console, we have a winner! */ - if (!bcmp(&pa->pa_tag, &vga_pci_console_tag, sizeof(pa->pa_tag))) + if (vga_is_console(pa->pa_iot, WSDISPLAY_TYPE_PCIVGA)) return (1); /* @@ -119,66 +114,23 @@ vga_pci_attach(parent, self, aux) { struct pci_attach_args *pa = aux; struct vga_pci_softc *sc = (struct vga_pci_softc *)self; - struct vga_config *vc; - int console; - - console = (!bcmp(&pa->pa_tag, &vga_pci_console_tag, sizeof(pa->pa_tag))); - if (console) - vc = sc->sc_vc = &vga_pci_console_vc; - else { - vc = sc->sc_vc = (struct vga_config *) - malloc(sizeof(struct vga_config), M_DEVBUF, M_WAITOK); - - /* set up bus-independent VGA configuration */ - vga_common_setup(pa->pa_iot, pa->pa_memt, vc); - } - vc->vc_mmap = vgapcimmap; - vc->vc_ioctl = vgapciioctl; + char devinfo[256]; sc->sc_pcitag = pa->pa_tag; - printf("\n"); + pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo); + printf(": %s (rev. 0x%02x)\n", devinfo, + PCI_REVISION(pa->pa_class)); - vga_wscons_attach(self, vc, console); + vga_common_attach(self, pa->pa_iot, pa->pa_memt, + WSDISPLAY_TYPE_PCIVGA); } -void -vga_pci_console(iot, memt, pc, bus, device, function) +int +vga_pci_cnattach(iot, memt, pc, bus, device, function) bus_space_tag_t iot, memt; pci_chipset_tag_t pc; int bus, device, function; { - struct vga_config *vc = &vga_pci_console_vc; - - /* for later recognition */ - vga_pci_console_tag = pci_make_tag(pc, bus, device, function); - - /* set up bus-independent VGA configuration */ - vga_common_setup(iot, memt, vc); - - vga_wscons_console(vc); -} - -int -vgapciioctl(v, cmd, data, flag, p) - void *v; - u_long cmd; - caddr_t data; - int flag; - struct proc *p; -{ - struct vga_pci_softc *sc = v; - - return (vgaioctl(sc->sc_vc, cmd, data, flag, p)); -} - -int -vgapcimmap(v, offset, prot) - void *v; - off_t offset; - int prot; -{ - struct vga_pci_softc *sc = v; - - return (vgammap(sc->sc_vc, offset, prot)); + return (vga_cnattach(iot, memt, WSDISPLAY_TYPE_PCIVGA, 0)); } diff --git a/sys/dev/pci/vga_pcivar.h b/sys/dev/pci/vga_pcivar.h index cc9d50295a8..6e968d5f1c9 100644 --- a/sys/dev/pci/vga_pcivar.h +++ b/sys/dev/pci/vga_pcivar.h @@ -1,5 +1,5 @@ -/* $OpenBSD: vga_pcivar.h,v 1.2 1997/11/06 12:26:56 niklas Exp $ */ -/* $NetBSD: vga_pcivar.h,v 1.1 1996/11/19 04:38:36 cgd Exp $ */ +/* $OpenBSD: vga_pcivar.h,v 1.3 2000/11/15 20:17:38 aaron Exp $ */ +/* $NetBSD: vga_pcivar.h,v 1.1 1998/03/22 15:16:19 drochner Exp $ */ /* * Copyright (c) 1995, 1996 Carnegie-Mellon University. @@ -34,5 +34,5 @@ (PCI_CLASS(class) == PCI_CLASS_PREHISTORIC && \ PCI_SUBCLASS(class) == PCI_SUBCLASS_PREHISTORIC_VGA)) ? 1 : 0) -void vga_pci_console __P((bus_space_tag_t, bus_space_tag_t, - pci_chipset_tag_t, int, int, int)); +int vga_pci_cnattach __P((bus_space_tag_t, bus_space_tag_t, + pci_chipset_tag_t, int, int, int)); -- cgit v1.2.3