freebsd-skq/sys/isa/vga_isa.c
yokota 4f4eb0cfe5 The second phase of syscons reorganization.
- Split syscons source code into manageable chunks and reorganize
  some of complicated functions.

- Many static variables are moved to the softc structure.

- Added a new key function, PREV.  When this key is pressed, the vty
  immediately before the current vty will become foreground.  Analogue
  to PREV, which is usually assigned to the PrntScrn key.
  PR: kern/10113
  Submitted by: Christian Weisgerber <naddy@mips.rhein-neckar.de>

- Modified the kernel console input function sccngetc() so that it
  handles function keys properly.

- Reorganized the screen update routine.

- VT switching code is reorganized.  It now should be slightly more
  robust than before.

- Added the DEVICE_RESUME function so that syscons no longer hooks the
  APM resume event directly.

- New kernel configuration options: SC_NO_CUTPASTE, SC_NO_FONT_LOADING,
  SC_NO_HISTORY and SC_NO_SYSMOUSE.
  Various parts of syscons can be omitted so that the kernel size is
  reduced.

  SC_PIXEL_MODE
  Made the VESA 800x600 mode an option, rather than a standard part of
  syscons.

  SC_DISABLE_DDBKEY
  Disables the `debug' key combination.

  SC_ALT_MOUSE_IMAGE
  Inverse the character cell at the mouse cursor position in the text
  console, rather than drawing an arrow on the screen.
  Submitted by: Nick Hibma (n_hibma@FreeBSD.ORG)

  SC_DFLT_FONT
  makeoptions "SC_DFLT_FONT=_font_name_"
  Include the named font as the default font of syscons.  16-line,
  14-line and 8-line font data will be compiled in.  This option replaces
  the existing STD8X16FONT option, which loads 16-line font data only.

- The VGA driver is split into /sys/dev/fb/vga.c and /sys/isa/vga_isa.c.

- The video driver provides a set of ioctl commands to manipulate the
  frame buffer.

- New kernel configuration option: VGA_WIDTH90
  Enables 90 column modes: 90x25, 90x30, 90x43, 90x50, 90x60.  These
  modes are mot always supported by the video card.
  PR: i386/7510
  Submitted by: kbyanc@freedomnet.com and alexv@sui.gda.itesm.mx.

- The header file machine/console.h is reorganized; its contents is now
  split into sys/fbio.h, sys/kbio.h (a new file) and sys/consio.h
  (another new file).  machine/console.h is still maintained for
  compatibility reasons.

- Kernel console selection/installation routines are fixed and
  slightly rebumped so that it should now be possible to switch between
  the interanl kernel console (sc or vt) and a remote kernel console
  (sio) again, as it was in 2.x, 3.0 and 3.1.

- Screen savers and splash screen decoders
  Because of the header file reorganization described above, screen
  savers and splash screen decoders are slightly modified.  After this
  update, /sys/modules/syscons/saver.h is no longer necessary and is
  removed.
1999-06-22 14:14:06 +00:00

229 lines
5.6 KiB
C

/*-
* Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
* 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 as
* the first lines of this file unmodified.
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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.
*
* $Id: vga_isa.c,v 1.10 1999/05/30 16:52:49 phk Exp $
*/
#include "vga.h"
#include "opt_vga.h"
#include "opt_fb.h"
#include "opt_syscons.h" /* should be removed in the future, XXX */
#if NVGA > 0
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/conf.h>
#include <sys/bus.h>
#include <sys/fbio.h>
#include <machine/bus.h>
#include <machine/resource.h>
#include <sys/rman.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <machine/md_var.h>
#include <machine/pc/bios.h>
#include <dev/fb/fbreg.h>
#include <dev/fb/vgareg.h>
#include <isa/isareg.h>
#include <isa/isavar.h>
#define VGA_SOFTC(unit) \
((vga_softc_t *)devclass_get_softc(isavga_devclass, unit))
static devclass_t isavga_devclass;
static int isavga_probe(device_t dev);
static int isavga_attach(device_t dev);
static device_method_t isavga_methods[] = {
DEVMETHOD(device_probe, isavga_probe),
DEVMETHOD(device_attach, isavga_attach),
DEVMETHOD(bus_print_child, bus_generic_print_child),
{ 0, 0 }
};
static driver_t isavga_driver = {
VGA_DRIVER_NAME,
isavga_methods,
sizeof(vga_softc_t),
};
DRIVER_MODULE(vga, isa, isavga_driver, isavga_devclass, 0, 0);
#ifdef FB_INSTALL_CDEV
static d_open_t isavga_open;
static d_close_t isavga_close;
static d_read_t isavga_read;
static d_write_t isavga_write;
static d_ioctl_t isavga_ioctl;
static d_mmap_t isavga_mmap;
static struct cdevsw isavga_cdevsw = {
/* open */ isavga_open,
/* close */ isavga_close,
/* read */ isavga_read,
/* write */ isavga_write,
/* ioctl */ isavga_ioctl,
/* stop */ nostop,
/* reset */ noreset,
/* devtotty */ nodevtotty,
/* poll */ nopoll,
/* mmap */ isavga_mmap,
/* strategy */ nostrategy,
/* name */ VGA_DRIVER_NAME,
/* parms */ noparms,
/* maj */ -1,
/* dump */ nodump,
/* psize */ nopsize,
/* flags */ 0,
/* maxio */ 0,
/* bmaj */ -1
};
#endif /* FB_INSTALL_CDEV */
static int
isavga_probe(device_t dev)
{
video_adapter_t adp;
device_t bus;
int error;
/* No pnp support */
if (isa_get_vendorid(dev))
return (ENXIO);
device_set_desc(dev, "Generic ISA VGA");
error = vga_probe_unit(device_get_unit(dev), &adp, isa_get_flags(dev));
if (error == 0) {
bus = device_get_parent(dev);
ISA_SET_RESOURCE(bus, dev, SYS_RES_IOPORT, 0,
adp.va_io_base, adp.va_io_size);
ISA_SET_RESOURCE(bus, dev, SYS_RES_MEMORY, 0,
adp.va_mem_base, adp.va_mem_size);
#if 0
isa_set_port(dev, adp.va_io_base);
isa_set_portsize(dev, adp.va_io_size);
isa_set_maddr(dev, adp.va_mem_base);
isa_set_msize(dev, adp.va_mem_size);
#endif
}
return error;
}
static int
isavga_attach(device_t dev)
{
vga_softc_t *sc;
struct resource *port;
struct resource *mem;
int unit;
int rid;
int error;
unit = device_get_unit(dev);
sc = device_get_softc(dev);
rid = 0;
port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
0, ~0, 0, RF_ACTIVE | RF_SHAREABLE);
rid = 0;
mem = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid,
0, ~0, 0, RF_ACTIVE | RF_SHAREABLE);
error = vga_attach_unit(unit, sc, isa_get_flags(dev));
if (error)
return error;
#ifdef FB_INSTALL_CDEV
/* attach a virtual frame buffer device */
error = fb_attach(makedev(0, VGA_MKMINOR(unit)), sc->adp, &isavga_cdevsw);
if (error)
return error;
#endif /* FB_INSTALL_CDEV */
if (bootverbose)
(*vidsw[sc->adp->va_index]->diag)(sc->adp, bootverbose);
#if experimental
device_add_child(dev, "fb", -1, NULL);
bus_generic_attach(dev);
#endif
return 0;
}
#ifdef FB_INSTALL_CDEV
static int
isavga_open(dev_t dev, int flag, int mode, struct proc *p)
{
return vga_open(dev, VGA_SOFTC(VGA_UNIT(dev)), flag, mode, p);
}
static int
isavga_close(dev_t dev, int flag, int mode, struct proc *p)
{
return vga_close(dev, VGA_SOFTC(VGA_UNIT(dev)), flag, mode, p);
}
static int
isavga_read(dev_t dev, struct uio *uio, int flag)
{
return vga_read(dev, VGA_SOFTC(VGA_UNIT(dev)), uio, flag);
}
static int
isavga_write(dev_t dev, struct uio *uio, int flag)
{
return vga_write(dev, VGA_SOFTC(VGA_UNIT(dev)), uio, flag);
}
static int
isavga_ioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct proc *p)
{
return vga_ioctl(dev, VGA_SOFTC(VGA_UNIT(dev)), cmd, arg, flag, p);
}
static int
isavga_mmap(dev_t dev, vm_offset_t offset, int prot)
{
return vga_mmap(dev, VGA_SOFTC(VGA_UNIT(dev)), offset, prot);
}
#endif /* FB_INSTALL_CDEV */
#endif /* NVGA > 0 */