Add VESA support to syscons.

Kazu writes:

The VESA support code requires vm86 support. Make sure your kernel
configuration file has the following line.
        options "VM86"
If you want to statically link the VESA support code to the kernel,
add the following option to the kernel configuration file.
        options "VESA"

The vidcontrol command now accepts the following video mode names:
VESA_132x25, VESA_132x43, VESA_132x50, VESA_132x60, VESA_800x600

The VESA_800x600 mode is a raster display mode. The 80x25 text will
be displayed on the 800x600 screen. Useful for some laptop computers.

vidcontrol accepts the new `-i <info>' option, where <info> must be
either `adapter' or `mode'.  When the `-i adapter' option is given,
vidcontrol will print basic information (not much) on the video
adapter. When the `-i mode' option is specified, vidcontrol will
list video modes which are actually supported by the video adapter.

Submitted by:   Kazutaka YOKOTA yokota@FreeBSD.ORG
This commit is contained in:
sos 1998-09-15 18:16:39 +00:00
parent 006c4708c8
commit ee7d2bce39
47 changed files with 5518 additions and 2877 deletions

View File

@ -1,18 +1,18 @@
/*-
* Copyright (c) 1995 Søren Schmidt
* Copyright (c) 1995-1998 Søren Schmidt
* 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
* in this position and unchanged.
* notice, this list of conditions and the following disclaimer,
* without modification, immediately at the beginning of the file.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software withough specific prior written permission
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@ -25,7 +25,7 @@
* (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: blank_saver.c,v 1.10 1997/07/15 14:49:09 yokota Exp $
* $Id$
*/
#include <sys/param.h>

View File

@ -25,7 +25,7 @@
* (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: daemon_saver.c,v 1.8 1998/01/16 17:58:43 bde Exp $
* $Id: daemon_saver.c,v 1.9 1998/08/06 09:14:20 yokota Exp $
*/
#include <sys/param.h>
@ -205,7 +205,7 @@ daemon_saver(int blank)
/* clear the screen and set the border color */
fillw(((FG_LIGHTGREY|BG_BLACK) << 8) | scr_map[0x20],
Crtat, scp->xsize * scp->ysize);
set_border(0);
set_border(scp, 0);
xlen = ylen = tlen = 0;
}
if (scrn_blanked++ < 2)
@ -322,7 +322,7 @@ daemon_saver(int blank)
draw_string(txpos, typos, toff, (char *)message, tlen);
} else {
if (scrn_blanked > 0) {
set_border(scp->border);
set_border(scp, scp->border);
scrn_blanked = 0;
}
}

View File

@ -1,18 +1,18 @@
/*-
* Copyright (c) 1995-1997 Søren Schmidt
* Copyright (c) 1995-1998 Søren Schmidt
* 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
* in this position and unchanged.
* notice, this list of conditions and the following disclaimer,
* without modification, immediately at the beginning of the file.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software withough specific prior written permission
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@ -25,7 +25,7 @@
* (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: fade_saver.c,v 1.11 1997/07/15 14:49:25 yokota Exp $
* $Id$
*/
#include <sys/param.h>
@ -84,7 +84,7 @@ fade_saver(int blank)
else {
switch (crtc_type) {
case KD_VGA:
load_palette(palette);
load_palette(cur_console, palette);
count = 0;
break;
case KD_EGA:

View File

@ -1,18 +1,18 @@
/*-
* Copyright (c) 1995 Søren Schmidt
* Copyright (c) 1995-1998 Søren Schmidt
* 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
* in this position and unchanged.
* notice, this list of conditions and the following disclaimer,
* without modification, immediately at the beginning of the file.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software withough specific prior written permission
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@ -25,7 +25,7 @@
* (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: green_saver.c,v 1.10 1997/07/15 14:49:29 yokota Exp $
* $Id$
*/
#include <sys/param.h>

View File

@ -1,18 +1,18 @@
/*-
* Copyright (c) 1995-1997 Søren Schmidt
* Copyright (c) 1995-1998 Søren Schmidt
* 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
* in this position and unchanged.
* notice, this list of conditions and the following disclaimer,
* without modification, immediately at the beginning of the file.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software withough specific prior written permission
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@ -25,12 +25,12 @@
* (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: saver.h,v 1.9 1997/07/15 14:48:11 yokota Exp $
* $Id$
*/
#include <machine/apm_bios.h>
#include <machine/console.h>
#include <i386/isa/videoio.h>
#include <i386/isa/syscons.h>
extern scr_stat *cur_console;

View File

@ -1,18 +1,18 @@
/*-
* Copyright (c) 1995 Søren Schmidt
* Copyright (c) 1995-1998 Søren Schmidt
* 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
* in this position and unchanged.
* notice, this list of conditions and the following disclaimer,
* without modification, immediately at the beginning of the file.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software withough specific prior written permission
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@ -25,7 +25,7 @@
* (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: snake_saver.c,v 1.16 1998/01/16 17:58:50 bde Exp $
* $Id$
*/
#include <sys/param.h>
@ -63,7 +63,7 @@ snake_saver(int blank)
if (scrn_blanked <= 0) {
fillw((FG_LIGHTGREY|BG_BLACK)<<8 | scr_map[0x20],
Crtat, scp->xsize * scp->ysize);
set_border(0);
set_border(scp, 0);
dirx = (scp->xpos ? 1 : -1);
diry = (scp->ypos ?
scp->xsize : -scp->xsize);
@ -99,7 +99,7 @@ snake_saver(int blank)
}
else {
if (scrn_blanked > 0) {
set_border(scp->border);
set_border(scp, scp->border);
scrn_blanked = 0;
}
}

View File

@ -1,18 +1,18 @@
/*-
* Copyright (c) 1995 Søren Schmidt
* Copyright (c) 1995-1998 Søren Schmidt
* 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
* in this position and unchanged.
* notice, this list of conditions and the following disclaimer,
* without modification, immediately at the beginning of the file.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software withough specific prior written permission
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@ -25,7 +25,7 @@
* (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: star_saver.c,v 1.13 1998/01/16 17:58:55 bde Exp $
* $Id$
*/
#include <sys/param.h>
@ -62,7 +62,7 @@ star_saver(int blank)
scrn_blanked = 1;
fillw((FG_LIGHTGREY|BG_BLACK)<<8|scr_map[0x20], Crtat,
scp->xsize * scp->ysize);
set_border(0);
set_border(scp, 0);
for(i=0; i<NUM_STARS; i++) {
stars[i][0] =
random() % (scp->xsize*scp->ysize);
@ -80,7 +80,7 @@ star_saver(int blank)
}
else {
if (scrn_blanked > 0) {
set_border(scp->border);
set_border(scp, scp->border);
scrn_blanked = 0;
}
}

View File

@ -2,7 +2,7 @@
# LINT -- config file for checking all the sources, tries to pull in
# as much of the source tree as it can.
#
# $Id: LINT,v 1.464 1998/09/15 10:01:13 gibbs Exp $
# $Id: LINT,v 1.465 1998/09/15 11:44:43 phk Exp $
#
# NB: You probably don't want to try running a kernel built from this
# file. Instead, you should start from GENERIC, and add options from
@ -803,6 +803,9 @@ options SC_HISTORY_SIZE=200 # number of history buffer lines
options SC_DISABLE_REBOOT # disable reboot key sequence
# If the screen flickers badly when the mouse pointer is moved, try this.
options SC_BAD_FLICKER
# To include support for VESA video modes
# Dont use together with SMP!!
options VESA # needs VM86 defined too!!
#
# `flags' for sc0:

View File

@ -1,7 +1,7 @@
# This file tells config what files go into building a kernel,
# files marked standard are always included.
#
# $Id: files.i386,v 1.202 1998/09/08 20:57:46 sos Exp $
# $Id: files.i386,v 1.203 1998/09/15 10:01:13 gibbs Exp $
#
# The long compile-with and dependency lines are required because of
# limitations in config: backslash-newline doesn't work in strings, and
@ -240,6 +240,10 @@ i386/isa/spigot.c optional spigot device-driver
i386/isa/spkr.c optional speaker device-driver
i386/isa/stallion.c optional stl device-driver
i386/isa/syscons.c optional sc device-driver
i386/isa/scvidctl.c optional sc device-driver
i386/isa/scvesactl.c optional sc device-driver
i386/isa/videoio.c optional sc device-driver
i386/isa/vesa.c optional sc device-driver
i386/isa/tw.c optional tw device-driver
#i386/isa/ultra14f.c optional uha device-driver
i386/isa/wd.c optional wdc device-driver

View File

@ -1,4 +1,4 @@
# $Id: options.i386,v 1.85 1998/09/08 18:09:50 brian Exp $
# $Id: options.i386,v 1.86 1998/09/15 10:01:14 gibbs Exp $
BOUNCEPAGES opt_bounce.h
DISABLE_PSE
@ -77,6 +77,8 @@ SC_DISABLE_REBOOT opt_syscons.h
SC_MOUSE_CHAR opt_syscons.h
SC_BAD_FLICKER opt_syscons.h
VESA opt_vesa.h
PSM_HOOKAPM opt_psm.h
PSM_RESETAFTERSUSPEND opt_psm.h
PSM_DEBUG opt_psm.h

View File

@ -1,18 +1,18 @@
/*-
* Copyright (c) 1992-1995 Søren Schmidt
* Copyright (c) 1992-1998 Søren Schmidt
* 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
* in this position and unchanged.
* notice, this list of conditions and the following disclaimer,
* without modification, immediately at the beginning of the file.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software withough specific prior written permission
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@ -25,7 +25,7 @@
* (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: kbdtables.h,v 1.39 1998/01/28 08:45:18 yokota Exp $
* $Id$
*/
#define SET8 0x80 /* set eight bit on */

View File

@ -1,18 +1,18 @@
/*-
* Copyright (c) 1995 Søren Schmidt
* Copyright (c) 1995-1998 Søren Schmidt
* 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
* in this position and unchanged.
* notice, this list of conditions and the following disclaimer,
* without modification, immediately at the beginning of the file.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software withough specific prior written permission
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@ -25,7 +25,7 @@
* (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: blank_saver.c,v 1.10 1997/07/15 14:49:09 yokota Exp $
* $Id$
*/
#include <sys/param.h>

View File

@ -25,7 +25,7 @@
* (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: daemon_saver.c,v 1.8 1998/01/16 17:58:43 bde Exp $
* $Id: daemon_saver.c,v 1.9 1998/08/06 09:14:20 yokota Exp $
*/
#include <sys/param.h>
@ -205,7 +205,7 @@ daemon_saver(int blank)
/* clear the screen and set the border color */
fillw(((FG_LIGHTGREY|BG_BLACK) << 8) | scr_map[0x20],
Crtat, scp->xsize * scp->ysize);
set_border(0);
set_border(scp, 0);
xlen = ylen = tlen = 0;
}
if (scrn_blanked++ < 2)
@ -322,7 +322,7 @@ daemon_saver(int blank)
draw_string(txpos, typos, toff, (char *)message, tlen);
} else {
if (scrn_blanked > 0) {
set_border(scp->border);
set_border(scp, scp->border);
scrn_blanked = 0;
}
}

View File

@ -1,18 +1,18 @@
/*-
* Copyright (c) 1995-1997 Søren Schmidt
* Copyright (c) 1995-1998 Søren Schmidt
* 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
* in this position and unchanged.
* notice, this list of conditions and the following disclaimer,
* without modification, immediately at the beginning of the file.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software withough specific prior written permission
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@ -25,7 +25,7 @@
* (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: fade_saver.c,v 1.11 1997/07/15 14:49:25 yokota Exp $
* $Id$
*/
#include <sys/param.h>
@ -84,7 +84,7 @@ fade_saver(int blank)
else {
switch (crtc_type) {
case KD_VGA:
load_palette(palette);
load_palette(cur_console, palette);
count = 0;
break;
case KD_EGA:

View File

@ -1,18 +1,18 @@
/*-
* Copyright (c) 1995 Søren Schmidt
* Copyright (c) 1995-1998 Søren Schmidt
* 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
* in this position and unchanged.
* notice, this list of conditions and the following disclaimer,
* without modification, immediately at the beginning of the file.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software withough specific prior written permission
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@ -25,7 +25,7 @@
* (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: green_saver.c,v 1.10 1997/07/15 14:49:29 yokota Exp $
* $Id$
*/
#include <sys/param.h>

150
sys/dev/syscons/scvesactl.c Normal file
View File

@ -0,0 +1,150 @@
/*-
* Copyright (c) 1998 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.
* 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. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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$
*/
#include "sc.h"
#include "opt_vesa.h"
#include "opt_vm86.h"
#if (NSC > 0 && defined(VESA) && defined(VM86)) || defined(VESA_MODULE)
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/tty.h>
#include <sys/kernel.h>
#include <machine/apm_bios.h>
#include <machine/console.h>
#include <machine/pc/vesa.h>
#include <i386/isa/videoio.h>
#include <i386/isa/syscons.h>
static int (*prev_user_ioctl)(dev_t dev, int cmd, caddr_t data, int flag,
struct proc *p);
extern struct tty *scdevtotty(dev_t dev);
int
vesa_ioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
{
scr_stat *scp;
struct tty *tp;
video_info_t info;
video_adapter_t *adp;
int mode;
int error;
int s;
tp = scdevtotty(dev);
if (!tp)
return ENXIO;
scp = sc_get_scr_stat(tp->t_dev);
switch (cmd) {
case SW_VESA_USER:
mode = (int)data;
if ((*biosvidsw.get_info)(scp->adp, mode, &info))
return ENODEV;
if (info.vi_flags & V_INFO_GRAPHICS)
goto vesa_graphics;
else
goto vesa_text;
/* text modes */
case SW_VESA_C80x60:
case SW_VESA_C132x25:
case SW_VESA_C132x43:
case SW_VESA_C132x50:
case SW_VESA_C132x60:
adp = get_adapter(scp);
if (!(adp->va_flags & V_ADP_MODECHANGE))
return ENODEV;
mode = (cmd & 0xff) + M_VESA_BASE;
vesa_text:
return sc_set_text_mode(scp, tp, mode, 0, 0, 0);
/* graphics modes */
case SW_VESA_32K_320: case SW_VESA_64K_320:
case SW_VESA_FULL_320:
case SW_VESA_CG640x400:
case SW_VESA_CG640x480:
case SW_VESA_32K_640: case SW_VESA_64K_640:
case SW_VESA_FULL_640:
case SW_VESA_800x600: case SW_VESA_CG800x600:
case SW_VESA_32K_800: case SW_VESA_64K_800:
case SW_VESA_FULL_800:
case SW_VESA_1024x768: case SW_VESA_CG1024x768:
case SW_VESA_32K_1024: case SW_VESA_64K_1024:
case SW_VESA_FULL_1024:
case SW_VESA_1280x1024: case SW_VESA_CG1280x1024:
case SW_VESA_32K_1280: case SW_VESA_64K_1280:
case SW_VESA_FULL_1280:
adp = get_adapter(scp);
if (!(adp->va_flags & V_ADP_MODECHANGE))
return ENODEV;
mode = (cmd & 0xff) + M_VESA_BASE;
vesa_graphics:
return sc_set_graphics_mode(scp, tp, mode);
}
if (prev_user_ioctl)
return (*prev_user_ioctl)(dev, cmd, data, flag, p);
else
return ENOIOCTL;
}
int
vesa_load_ioctl(void)
{
if (prev_user_ioctl)
return EBUSY;
prev_user_ioctl = sc_user_ioctl;
sc_user_ioctl = vesa_ioctl;
return 0;
}
int
vesa_unload_ioctl(void)
{
if (sc_user_ioctl != vesa_ioctl)
return EBUSY;
sc_user_ioctl = prev_user_ioctl;
prev_user_ioctl = NULL;
return 0;
}
#endif /* (NSC > 0 && VESA && VM86) || VESA_MODULE */

486
sys/dev/syscons/scvidctl.c Normal file
View File

@ -0,0 +1,486 @@
/*-
* Copyright (c) 1998 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.
* 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. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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$
*/
#include "sc.h"
#include "opt_syscons.h"
#if NSC > 0
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/signalvar.h>
#include <sys/tty.h>
#include <sys/kernel.h>
#include <machine/apm_bios.h>
#include <machine/console.h>
#include <i386/isa/videoio.h>
#include <i386/isa/syscons.h>
/* video ioctl */
extern scr_stat *cur_console;
extern u_short *Crtat;
extern int fonts_loaded;
extern int sc_history_size;
extern u_char palette[];
int
sc_set_text_mode(scr_stat *scp, struct tty *tp, int mode, int xsize, int ysize,
int fontsize)
{
video_adapter_t *adp;
video_info_t info;
int error;
int s;
int i;
if ((*biosvidsw.get_info)(scp->adp, mode, &info))
return ENODEV;
adp = get_adapter(scp);
/* adjust argument values */
if (fontsize <= 0)
fontsize = info.vi_cheight;
if (fontsize < 14) {
fontsize = 8;
if (!(fonts_loaded & FONT_8))
return EINVAL;
} else if (fontsize >= 16) {
fontsize = 16;
if (!(fonts_loaded & FONT_16))
return EINVAL;
} else {
fontsize = 14;
if (!(fonts_loaded & FONT_14))
return EINVAL;
}
if ((xsize <= 0) || (xsize > info.vi_width))
xsize = info.vi_width;
if ((ysize <= 0) || (ysize > info.vi_height))
ysize = info.vi_height;
/* stop screen saver, etc */
s = spltty();
if ((error = sc_clean_up(scp))) {
splx(s);
return error;
}
/* set up scp */
if (scp->history != NULL)
i = imax(scp->history_size / scp->xsize
- imax(sc_history_size, scp->ysize), 0);
else
i = 0;
/*
* This is a kludge to fend off scrn_update() while we
* muck around with scp. XXX
*/
scp->status |= UNKNOWN_MODE;
scp->status &= ~(GRAPHICS_MODE | PIXEL_MODE);
scp->mode = mode;
scp->font_size = fontsize;
scp->xsize = xsize;
scp->ysize = ysize;
scp->xpixel = scp->xsize*8;
scp->ypixel = scp->ysize*fontsize;
/* allocate buffers */
sc_alloc_scr_buffer(scp, TRUE, TRUE);
if (ISMOUSEAVAIL(adp->va_flags))
sc_alloc_cut_buffer(scp, FALSE);
sc_alloc_history_buffer(scp, sc_history_size, i, FALSE);
splx(s);
if (scp == cur_console)
set_mode(scp);
scp->status &= ~UNKNOWN_MODE;
if (tp == NULL)
return 0;
if (tp->t_winsize.ws_col != scp->xsize
|| tp->t_winsize.ws_row != scp->ysize) {
tp->t_winsize.ws_col = scp->xsize;
tp->t_winsize.ws_row = scp->ysize;
pgsignal(tp->t_pgrp, SIGWINCH, 1);
}
return 0;
}
int
sc_set_graphics_mode(scr_stat *scp, struct tty *tp, int mode)
{
video_adapter_t *adp;
video_info_t info;
int error;
int s;
if ((*biosvidsw.get_info)(scp->adp, mode, &info))
return ENODEV;
adp = get_adapter(scp);
/* stop screen saver, etc */
s = spltty();
if ((error = sc_clean_up(scp))) {
splx(s);
return error;
}
/* set up scp */
scp->status |= (UNKNOWN_MODE | GRAPHICS_MODE);
scp->status &= ~PIXEL_MODE;
scp->mode = mode;
scp->xpixel = info.vi_width;
scp->ypixel = info.vi_height;
scp->xsize = info.vi_width/8;
scp->ysize = info.vi_height/info.vi_cheight;
scp->font_size = FONT_NONE;
/* move the mouse cursor at the center of the screen */
sc_move_mouse(scp, scp->xpixel / 2, scp->ypixel / 2);
splx(s);
if (scp == cur_console)
set_mode(scp);
/* clear_graphics();*/
scp->status &= ~UNKNOWN_MODE;
if (tp == NULL)
return 0;
if (tp->t_winsize.ws_xpixel != scp->xpixel
|| tp->t_winsize.ws_ypixel != scp->ypixel) {
tp->t_winsize.ws_xpixel = scp->xpixel;
tp->t_winsize.ws_ypixel = scp->ypixel;
pgsignal(tp->t_pgrp, SIGWINCH, 1);
}
return 0;
}
int
sc_set_pixel_mode(scr_stat *scp, struct tty *tp, int xsize, int ysize,
int fontsize)
{
video_adapter_t *adp;
video_info_t info;
int error;
int s;
int i;
if ((*biosvidsw.get_info)(scp->adp, scp->mode, &info))
return ENODEV; /* this shouldn't happen */
adp = get_adapter(scp);
#ifdef SC_VIDEO_DEBUG
if (scp->scr_buf != NULL) {
printf("set_pixel_mode(): mode:%x, col:%d, row:%d, font:%d\n",
scp->mode, xsize, ysize, fontsize);
}
#endif
/* adjust argument values */
if ((fontsize <= 0) || (fontsize == FONT_NONE))
fontsize = info.vi_cheight;
if (fontsize < 14) {
fontsize = 8;
if (!(fonts_loaded & FONT_8))
return EINVAL;
} else if (fontsize >= 16) {
fontsize = 16;
if (!(fonts_loaded & FONT_16))
return EINVAL;
} else {
fontsize = 14;
if (!(fonts_loaded & FONT_14))
return EINVAL;
}
if (xsize <= 0)
xsize = info.vi_width/8;
if (ysize <= 0)
ysize = info.vi_height/fontsize;
#ifdef SC_VIDEO_DEBUG
if (scp->scr_buf != NULL) {
printf("set_pixel_mode(): mode:%x, col:%d, row:%d, font:%d\n",
scp->mode, xsize, ysize, fontsize);
printf("set_pixel_mode(): Crtat:%x, %dx%d, xoff:%d, yoff:%d\n",
Crtat, info.vi_width, info.vi_height,
(info.vi_width/8 - xsize)/2,
(info.vi_height/fontsize - ysize)/2);
}
#endif
/* stop screen saver, etc */
s = spltty();
if ((error = sc_clean_up(scp))) {
splx(s);
return error;
}
/* set up scp */
if (scp->history != NULL)
i = imax(scp->history_size / scp->xsize
- imax(sc_history_size, scp->ysize), 0);
else
i = 0;
scp->status |= (UNKNOWN_MODE | PIXEL_MODE);
scp->status &= ~(GRAPHICS_MODE | MOUSE_ENABLED);
scp->xsize = xsize;
scp->ysize = ysize;
scp->font_size = fontsize;
scp->xoff = (scp->xpixel/8 - xsize)/2;
scp->yoff = (scp->ypixel/fontsize - ysize)/2;
/* allocate buffers */
sc_alloc_scr_buffer(scp, TRUE, TRUE);
if (ISMOUSEAVAIL(adp->va_flags))
sc_alloc_cut_buffer(scp, FALSE);
sc_alloc_history_buffer(scp, sc_history_size, i, FALSE);
splx(s);
/* FIXME */
if (scp == cur_console)
bzero(Crtat, scp->xpixel*scp->ypixel/8);
scp->status &= ~UNKNOWN_MODE;
#ifdef SC_VIDEO_DEBUG
printf("set_pixel_mode(): status:%x\n", scp->status);
#endif
if (tp == NULL)
return 0;
if (tp->t_winsize.ws_col != scp->xsize
|| tp->t_winsize.ws_row != scp->ysize) {
tp->t_winsize.ws_col = scp->xsize;
tp->t_winsize.ws_row = scp->ysize;
pgsignal(tp->t_pgrp, SIGWINCH, 1);
}
return 0;
}
int
sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct proc *p)
{
scr_stat *scp;
video_adapter_t *adp;
int error;
int s;
scp = sc_get_scr_stat(tp->t_dev);
switch (cmd) {
case CONS_CURRENT: /* get current adapter type */
adp = get_adapter(scp);
*(int *)data = adp->va_type;
return 0;
case CONS_CURRENTADP: /* get current adapter index */
*(int *)data = scp->adp;
return 0;
case CONS_ADPINFO: /* adapter information */
adp = (*biosvidsw.adapter)(((video_adapter_t *)data)->va_index);
if (adp == NULL)
return ENODEV;
bcopy(adp, data, sizeof(*adp));
return 0;
case CONS_GET: /* get current video mode */
*(int *)data = scp->mode;
return 0;
case CONS_MODEINFO: /* get mode information */
return ((*biosvidsw.get_info)(scp->adp,
((video_info_t *)data)->vi_mode, (video_info_t *)data)
? ENODEV : 0);
case CONS_FINDMODE: /* find a matching video mode */
return ((*biosvidsw.query_mode)(scp->adp, (video_info_t *)data)
? ENODEV : 0);
case CONS_SETWINORG:
return ((*biosvidsw.set_win_org)(scp->adp, *(u_int *)data)
? ENODEV : 0);
/* VGA TEXT MODES */
case SW_VGA_C40x25:
case SW_VGA_C80x25: case SW_VGA_M80x25:
case SW_VGA_C80x30: case SW_VGA_M80x30:
case SW_VGA_C80x50: case SW_VGA_M80x50:
case SW_VGA_C80x60: case SW_VGA_M80x60:
case SW_B40x25: case SW_C40x25:
case SW_B80x25: case SW_C80x25:
case SW_ENH_B40x25: case SW_ENH_C40x25:
case SW_ENH_B80x25: case SW_ENH_C80x25:
case SW_ENH_B80x43: case SW_ENH_C80x43:
case SW_EGAMONO80x25:
adp = get_adapter(scp);
if (!(adp->va_flags & V_ADP_MODECHANGE))
return ENODEV;
return sc_set_text_mode(scp, tp, cmd & 0xff, 0, 0, 0);
/* GRAPHICS MODES */
case SW_BG320: case SW_BG640:
case SW_CG320: case SW_CG320_D: case SW_CG640_E:
case SW_CG640x350: case SW_ENH_CG640:
case SW_BG640x480: case SW_CG640x480: case SW_VGA_CG320:
case SW_VGA_MODEX:
adp = get_adapter(scp);
if (!(adp->va_flags & V_ADP_MODECHANGE))
return ENODEV;
return sc_set_graphics_mode(scp, tp, cmd & 0xff);
case KDSETMODE: /* set current mode of this (virtual) console */
switch (*data) {
case KD_TEXT: /* switch to TEXT (known) mode */
/*
* If scp->mode is of graphics modes, we don't know which
* text mode to switch back to...
*/
if (scp->status & GRAPHICS_MODE)
return EINVAL;
/* restore fonts & palette ! */
#if 0
adp = get_adapter(scp);
if (ISFONTAVAIL(adp->va_flags)
&& !(scp->status & (GRAPHICS_MODE | PIXEL_MODE)))
/*
* FONT KLUDGE
* Don't load fonts for now... XXX
*/
if (fonts_loaded & FONT_8)
copy_font(scp, LOAD, 8, font_8);
if (fonts_loaded & FONT_14)
copy_font(scp, LOAD, 14, font_14);
if (fonts_loaded & FONT_16)
copy_font(scp, LOAD, 16, font_16);
}
#endif
load_palette(scp, palette);
/* move hardware cursor out of the way */
(*biosvidsw.set_hw_cursor)(scp->adp, -1, -1);
/* FALL THROUGH */
case KD_TEXT1: /* switch to TEXT (known) mode */
/*
* If scp->mode is of graphics modes, we don't know which
* text/pixel mode to switch back to...
*/
if (scp->status & GRAPHICS_MODE)
return EINVAL;
s = spltty();
if ((error = sc_clean_up(scp))) {
splx(s);
return error;
}
scp->status |= UNKNOWN_MODE;
splx(s);
/* no restore fonts & palette */
if (scp == cur_console) {
set_mode(scp);
/* FIXME */
if (scp->status & PIXEL_MODE)
bzero(Crtat, scp->xpixel*scp->ypixel/8);
}
sc_clear_screen(scp);
scp->status &= ~UNKNOWN_MODE;
return 0;
case KD_PIXEL: /* pixel (raster) display */
if (!(scp->status & (GRAPHICS_MODE | PIXEL_MODE)))
return EINVAL;
if (!(scp->status & PIXEL_MODE))
return sc_set_pixel_mode(scp, tp, scp->xsize, scp->ysize,
scp->font_size);
s = spltty();
if ((error = sc_clean_up(scp))) {
splx(s);
return error;
}
scp->status |= (UNKNOWN_MODE | PIXEL_MODE);
splx(s);
if (scp == cur_console) {
set_mode(scp);
load_palette(scp, palette);
/* FIXME */
bzero(Crtat, scp->xpixel*scp->ypixel/8);
}
sc_clear_screen(scp);
scp->status &= ~UNKNOWN_MODE;
return 0;
case KD_GRAPHICS: /* switch to GRAPHICS (unknown) mode */
s = spltty();
if ((error = sc_clean_up(scp))) {
splx(s);
return error;
}
scp->status |= UNKNOWN_MODE;
splx(s);
return 0;
default:
return EINVAL;
}
/* NOT REACHED */
case KDRASTER: /* set pixel (raster) display mode */
if (ISUNKNOWNSC(scp) || ISTEXTSC(scp))
return ENODEV;
return sc_set_pixel_mode(scp, tp, ((int *)data)[0], ((int *)data)[1],
((int *)data)[2]);
case KDGETMODE: /* get current mode of this (virtual) console */
/*
* From the user program's point of view, KD_PIXEL is the same
* as KD_TEXT...
*/
*data = ISGRAPHSC(scp) ? KD_GRAPHICS : KD_TEXT;
return 0;
case KDSBORDER: /* set border color of this (virtual) console */
scp->border = *data;
if (scp == cur_console)
set_border(cur_console, scp->border);
return 0;
}
return ENOIOCTL;
}
#endif /* NSC > 0 */

View File

@ -1,18 +1,18 @@
/*-
* Copyright (c) 1995 Søren Schmidt
* Copyright (c) 1995-1998 Søren Schmidt
* 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
* in this position and unchanged.
* notice, this list of conditions and the following disclaimer,
* without modification, immediately at the beginning of the file.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software withough specific prior written permission
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@ -25,7 +25,7 @@
* (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: snake_saver.c,v 1.16 1998/01/16 17:58:50 bde Exp $
* $Id$
*/
#include <sys/param.h>
@ -63,7 +63,7 @@ snake_saver(int blank)
if (scrn_blanked <= 0) {
fillw((FG_LIGHTGREY|BG_BLACK)<<8 | scr_map[0x20],
Crtat, scp->xsize * scp->ysize);
set_border(0);
set_border(scp, 0);
dirx = (scp->xpos ? 1 : -1);
diry = (scp->ypos ?
scp->xsize : -scp->xsize);
@ -99,7 +99,7 @@ snake_saver(int blank)
}
else {
if (scrn_blanked > 0) {
set_border(scp->border);
set_border(scp, scp->border);
scrn_blanked = 0;
}
}

View File

@ -1,18 +1,18 @@
/*-
* Copyright (c) 1995 Søren Schmidt
* Copyright (c) 1995-1998 Søren Schmidt
* 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
* in this position and unchanged.
* notice, this list of conditions and the following disclaimer,
* without modification, immediately at the beginning of the file.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software withough specific prior written permission
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@ -25,7 +25,7 @@
* (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: star_saver.c,v 1.13 1998/01/16 17:58:55 bde Exp $
* $Id$
*/
#include <sys/param.h>
@ -62,7 +62,7 @@ star_saver(int blank)
scrn_blanked = 1;
fillw((FG_LIGHTGREY|BG_BLACK)<<8|scr_map[0x20], Crtat,
scp->xsize * scp->ysize);
set_border(0);
set_border(scp, 0);
for(i=0; i<NUM_STARS; i++) {
stars[i][0] =
random() % (scp->xsize*scp->ysize);
@ -80,7 +80,7 @@ star_saver(int blank)
}
else {
if (scrn_blanked > 0) {
set_border(scp->border);
set_border(scp, scp->border);
scrn_blanked = 0;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +1,18 @@
/*-
* Copyright (c) 1995-1997 Søren Schmidt
* Copyright (c) 1995-1998 Søren Schmidt
* 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
* in this position and unchanged.
* notice, this list of conditions and the following disclaimer,
* without modification, immediately at the beginning of the file.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@ -25,7 +25,7 @@
* (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: syscons.h,v 1.38 1998/08/03 09:09:35 yokota Exp $
* $Id$
*/
#ifndef _I386_ISA_SYSCONS_H_
@ -65,6 +65,9 @@
#define MOUSE_MOVED 0x01000
#define MOUSE_CUTTING 0x02000
#define MOUSE_VISIBLE 0x04000
#define GRAPHICS_MODE 0x08000
#define PIXEL_MODE 0x10000
#define SAVER_RUNNING 0x20000
/* configuration flags */
#define VISUAL_BELL 0x00001
@ -74,6 +77,7 @@
#define XT_KEYBD 0x00010
#define KBD_NORESET 0x00020
#define QUIET_BELL 0x00040
#define VESA800X600 0x00080
/* attribute flags */
#define NORMAL_ATTR 0x00
@ -84,9 +88,6 @@
#define FOREGROUND_CHANGED 0x10
#define BACKGROUND_CHANGED 0x20
/* video hardware memory addresses */
#define VIDEOMEM 0x000A0000
/* misc defines */
#define FALSE 0
#define TRUE 1
@ -104,20 +105,6 @@
#define FONT_14 4
#define FONT_16 8
/* defines related to hardware addresses */
#define MONO_BASE 0x3B4 /* crt controller base mono */
#define COLOR_BASE 0x3D4 /* crt controller base color */
#define MISC 0x3C2 /* misc output register */
#define ATC IO_VGA+0x00 /* attribute controller */
#define TSIDX IO_VGA+0x04 /* timing sequencer idx */
#define TSREG IO_VGA+0x05 /* timing sequencer data */
#define PIXMASK IO_VGA+0x06 /* pixel write mask */
#define PALRADR IO_VGA+0x07 /* palette read address */
#define PALWADR IO_VGA+0x08 /* palette write address */
#define PALDATA IO_VGA+0x09 /* palette data register */
#define GDCIDX IO_VGA+0x0E /* graph data controller idx */
#define GDCREG IO_VGA+0x0F /* graph data controller data */
/* special characters */
#define cntlc 0x03
#define cntld 0x04
@ -141,6 +128,7 @@ typedef struct term_stat {
} term_stat;
typedef struct scr_stat {
int adp; /* video adapter index */
u_short *scr_buf; /* buffer when off screen */
int xpos; /* current X position */
int ypos; /* current Y position */
@ -150,6 +138,8 @@ typedef struct scr_stat {
int ysize; /* Y text size */
int xpixel; /* X graphics size */
int ypixel; /* Y graphics size */
int xoff; /* X offset in pixel mode */
int yoff; /* Y offset in pixel mode */
int font_size; /* fontsize in Y direction */
int start; /* modified area start */
int end; /* modified area end */
@ -186,7 +176,8 @@ typedef struct scr_stat {
int history_size; /* size of history buffer */
struct apmhook r_hook; /* reconfiguration support */
#ifdef SC_SPLASH_SCREEN
u_char splash_save_mode; /* saved mode for splash screen */
int splash_save_mode; /* saved mode for splash screen */
int splash_save_status; /* saved status for splash screen */
#endif
} scr_stat;
@ -195,18 +186,59 @@ typedef struct default_attr {
int rev_color; /* reverse hardware color */
} default_attr;
#define ISTEXTSC(scp) (!((scp)->status \
& (UNKNOWN_MODE | GRAPHICS_MODE | PIXEL_MODE)))
#define ISGRAPHSC(scp) (((scp)->status \
& (UNKNOWN_MODE | GRAPHICS_MODE)))
#define ISPIXELSC(scp) (((scp)->status \
& (UNKNOWN_MODE | GRAPHICS_MODE | PIXEL_MODE))\
== PIXEL_MODE)
#define ISUNKNOWNSC(scp) ((scp)->status & UNKNOWN_MODE)
#define ISFONTAVAIL(af) ((af) & V_ADP_FONT)
#define ISMOUSEAVAIL(af) ((af) & V_ADP_FONT)
#define ISPALAVAIL(af) ((af) & V_ADP_PALETTE)
/* misc prototypes used by different syscons related LKM's */
void set_border(u_char color);
void set_mode(scr_stat *scp);
void copy_font(int operation, int font_type, char* font_image);
void load_palette(char *palette);
/* syscons.c */
extern int (*sc_user_ioctl)(dev_t dev, int cmd, caddr_t data, int flag,
struct proc *p);
int set_mode(scr_stat *scp);
scr_stat *sc_get_scr_stat(dev_t dev);
void copy_font(scr_stat *scp, int operation, int font_size, u_char *font_image);
#define save_palette(scp, pal) (*biosvidsw.save_palette)((scp)->adp, pal)
#define load_palette(scp, pal) (*biosvidsw.load_palette)((scp)->adp, pal)
#define set_border(scp, col) (*biosvidsw.set_border)((scp)->adp, col)
#define get_adapter(scp) (*biosvidsw.adapter)((scp)->adp)
int add_scrn_saver(void (*this)(int));
int remove_scrn_saver(void (*this)(int));
void sc_clear_screen(scr_stat *scp);
void sc_move_mouse(scr_stat *scp, int x, int y);
int sc_clean_up(scr_stat *scp);
void sc_alloc_scr_buffer(scr_stat *scp, int wait, int clear);
void sc_alloc_cut_buffer(scr_stat *scp, int wait);
void sc_alloc_history_buffer(scr_stat *scp, int lines, int extra, int wait);
/* scvidctl.c */
int sc_set_text_mode(scr_stat *scp, struct tty *tp, int mode,
int xsize, int ysize, int fontsize);
int sc_set_graphics_mode(scr_stat *scp, struct tty *tp, int mode);
int sc_set_pixel_mode(scr_stat *scp, struct tty *tp,
int xsize, int ysize, int fontsize);
int sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag,
struct proc *p);
#ifdef SC_SPLASH_SCREEN
void splash(int);
int splash_load(void);
int splash_unload(void);
/* splash.c */
void scsplash(int);
int scsplash_load(scr_stat *scp);
int scsplash_unload(scr_stat *scp);
#endif
#endif /* !_I386_ISA_SYSCONS_H_ */

View File

@ -2,7 +2,7 @@
# LINT -- config file for checking all the sources, tries to pull in
# as much of the source tree as it can.
#
# $Id: LINT,v 1.464 1998/09/15 10:01:13 gibbs Exp $
# $Id: LINT,v 1.465 1998/09/15 11:44:43 phk Exp $
#
# NB: You probably don't want to try running a kernel built from this
# file. Instead, you should start from GENERIC, and add options from
@ -803,6 +803,9 @@ options SC_HISTORY_SIZE=200 # number of history buffer lines
options SC_DISABLE_REBOOT # disable reboot key sequence
# If the screen flickers badly when the mouse pointer is moved, try this.
options SC_BAD_FLICKER
# To include support for VESA video modes
# Dont use together with SMP!!
options VESA # needs VM86 defined too!!
#
# `flags' for sc0:

View File

@ -2,7 +2,7 @@
# LINT -- config file for checking all the sources, tries to pull in
# as much of the source tree as it can.
#
# $Id: LINT,v 1.464 1998/09/15 10:01:13 gibbs Exp $
# $Id: LINT,v 1.465 1998/09/15 11:44:43 phk Exp $
#
# NB: You probably don't want to try running a kernel built from this
# file. Instead, you should start from GENERIC, and add options from
@ -803,6 +803,9 @@ options SC_HISTORY_SIZE=200 # number of history buffer lines
options SC_DISABLE_REBOOT # disable reboot key sequence
# If the screen flickers badly when the mouse pointer is moved, try this.
options SC_BAD_FLICKER
# To include support for VESA video modes
# Dont use together with SMP!!
options VESA # needs VM86 defined too!!
#
# `flags' for sc0:

View File

@ -1,7 +1,7 @@
# This file tells config what files go into building a kernel,
# files marked standard are always included.
#
# $Id: files.i386,v 1.202 1998/09/08 20:57:46 sos Exp $
# $Id: files.i386,v 1.203 1998/09/15 10:01:13 gibbs Exp $
#
# The long compile-with and dependency lines are required because of
# limitations in config: backslash-newline doesn't work in strings, and
@ -240,6 +240,10 @@ i386/isa/spigot.c optional spigot device-driver
i386/isa/spkr.c optional speaker device-driver
i386/isa/stallion.c optional stl device-driver
i386/isa/syscons.c optional sc device-driver
i386/isa/scvidctl.c optional sc device-driver
i386/isa/scvesactl.c optional sc device-driver
i386/isa/videoio.c optional sc device-driver
i386/isa/vesa.c optional sc device-driver
i386/isa/tw.c optional tw device-driver
#i386/isa/ultra14f.c optional uha device-driver
i386/isa/wd.c optional wdc device-driver

View File

@ -1,4 +1,4 @@
# $Id: options.i386,v 1.85 1998/09/08 18:09:50 brian Exp $
# $Id: options.i386,v 1.86 1998/09/15 10:01:14 gibbs Exp $
BOUNCEPAGES opt_bounce.h
DISABLE_PSE
@ -77,6 +77,8 @@ SC_DISABLE_REBOOT opt_syscons.h
SC_MOUSE_CHAR opt_syscons.h
SC_BAD_FLICKER opt_syscons.h
VESA opt_vesa.h
PSM_HOOKAPM opt_psm.h
PSM_RESETAFTERSUSPEND opt_psm.h
PSM_DEBUG opt_psm.h

View File

@ -25,7 +25,7 @@
* (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: console.h,v 1.37 1998/07/06 06:29:06 imp Exp $
* $Id: console.h,v 1.38 1998/08/03 11:30:28 yokota Exp $
*/
#ifndef _MACHINE_CONSOLE_H_
@ -51,6 +51,7 @@
#define KDGETLED _IOR('K', 65, int)
#define KDSETLED _IO('K', 66 /*, int */)
#define KDSETRAD _IO('K', 67 /*, int */)
#define KDRASTER _IOW('K', 100, scr_size_t)
#define GETFKEY _IOWR('k', 0, fkeyarg_t)
#define SETFKEY _IOWR('k', 1, fkeyarg_t)
@ -84,6 +85,11 @@
#define GIO_FONT8x16 _IOR('c', 69, fnt16_t)
#define CONS_GETINFO _IOWR('c', 73, vid_info_t)
#define CONS_GETVERS _IOR('c', 74, int)
#define CONS_CURRENTADP _IOR('c', 100, int)
#define CONS_ADPINFO _IOWR('c', 101, video_adapter_t)
#define CONS_MODEINFO _IOWR('c', 102, video_info_t)
#define CONS_FINDMODE _IOWR('c', 103, video_info_t)
#define CONS_SETWINORG _IO('c', 104 /* u_int */)
/* CONS_SAVERMODE */
#define CONS_LKM_SAVER 0
@ -169,6 +175,7 @@ struct mouse_info {
#define KD_TEXT0 0 /* ditto */
#define KD_TEXT1 2 /* set text mode !restore fonts */
#define KD_GRAPHICS 1 /* set graphics mode */
#define KD_PIXEL 3 /* set pixel mode */
#define K_RAW 0 /* keyboard returns scancodes */
#define K_XLATE 1 /* keyboard returns ascii */
@ -263,6 +270,55 @@ struct ssaver {
long time;
};
/* adapter infromation block */
struct video_adapter {
int va_index;
int va_type;
int va_flags;
#define V_ADP_COLOR (1<<0)
#define V_ADP_MODECHANGE (1<<1)
#define V_ADP_STATESAVE (1<<2)
#define V_ADP_STATELOAD (1<<3)
#define V_ADP_FONT (1<<4)
#define V_ADP_PALETTE (1<<5)
#define V_ADP_BORDER (1<<6)
#define V_ADP_VESA (1<<7)
int va_crtc_addr;
u_int va_window; /* virtual address */
size_t va_window_size;
size_t va_window_gran;
u_int va_buffer; /* virtual address */
size_t va_buffer_size;
int va_initial_mode;
int va_initial_bios_mode;
int va_mode;
};
#define V_ADP_PRIMARY 0
#define V_ADP_SECONDARY 1
/* video mode information block */
struct video_info {
int vi_mode;
int vi_flags;
#define V_INFO_COLOR (1<<0)
#define V_INFO_GRAPHICS (1<<1)
#define V_INFO_LENEAR (1<<2)
#define V_INFO_VESA (1<<3)
int vi_width;
int vi_height;
int vi_cwidth;
int vi_cheight;
int vi_depth;
int vi_planes;
u_int vi_window; /* physical address */
size_t vi_window_size;
size_t vi_window_gran;
u_int vi_buffer; /* physical address */
size_t vi_buffer_size;
/* XXX pixel format, memory model,... */
};
typedef struct accentmap accentmap_t;
typedef struct fkeytab fkeytab_t;
typedef struct fkeyarg fkeyarg_t;
@ -273,6 +329,9 @@ typedef struct {char fnt8x8[8*256];} fnt8_t;
typedef struct {char fnt8x14[14*256];} fnt14_t;
typedef struct {char fnt8x16[16*256];} fnt16_t;
typedef struct ssaver ssaver_t;
typedef struct video_adapter video_adapter_t;
typedef struct video_info video_info_t;
typedef struct {int scr_size[3];} scr_size_t;
/* defines for "special" keys (spcl bit set in keymap) */
#define NOP 0x00 /* nothing (dead key) */
@ -378,8 +437,6 @@ typedef struct ssaver ssaver_t;
#define M_HGC_P1 0xe1 /* hercules graphics - page 1 @ B8000 */
#define M_MCA_MODE 0xff /* monochrome adapter mode */
#define M_VESA_BASE 0x100 /* VESA mode number base */
#define SW_PC98_80x25 _IO('S', M_PC98_80x25)
#define SW_PC98_80x30 _IO('S', M_PC98_80x30)
#define SW_B40x25 _IO('S', M_B40x25)
@ -421,4 +478,68 @@ typedef struct ssaver ssaver_t;
#define SW_VGA_CG640 _IO('S', M_VGA_CG640)
#define SW_VGA_MODEX _IO('S', M_VGA_MODEX)
#define M_VESA_BASE 0x100 /* VESA mode number base */
#define M_VESA_CG640x400 0x100 /* 640x400, 256 color */
#define M_VESA_CG640x480 0x101 /* 640x480, 256 color */
#define M_VESA_800x600 0x102 /* 800x600, 16 color */
#define M_VESA_CG800x600 0x103 /* 800x600, 256 color */
#define M_VESA_1024x768 0x104 /* 1024x768, 16 color */
#define M_VESA_CG1024x768 0x105 /* 1024x768, 256 color */
#define M_VESA_1280x1024 0x106 /* 1280x1024, 16 color */
#define M_VESA_CG1280x1024 0x107 /* 1280x1024, 256 color */
#define M_VESA_C80x60 0x108 /* 8x8 font */
#define M_VESA_C132x25 0x109 /* 8x16 font */
#define M_VESA_C132x43 0x10a /* 8x14 font */
#define M_VESA_C132x50 0x10b /* 8x8 font */
#define M_VESA_C132x60 0x10c /* 8x8 font */
#define M_VESA_32K_320 0x10d /* 320x200, 5:5:5 */
#define M_VESA_64K_320 0x10e /* 320x200, 5:6:5 */
#define M_VESA_FULL_320 0x10f /* 320x200, 8:8:8 */
#define M_VESA_32K_640 0x110 /* 640x480, 5:5:5 */
#define M_VESA_64K_640 0x111 /* 640x480, 5:6:5 */
#define M_VESA_FULL_640 0x112 /* 640x480, 8:8:8 */
#define M_VESA_32K_800 0x113 /* 800x600, 5:5:5 */
#define M_VESA_64K_800 0x114 /* 800x600, 5:6:5 */
#define M_VESA_FULL_800 0x115 /* 800x600, 8:8:8 */
#define M_VESA_32K_1024 0x116 /* 1024x768, 5:5:5 */
#define M_VESA_64K_1024 0x117 /* 1024x768, 5:6:5 */
#define M_VESA_FULL_1024 0x118 /* 1024x768, 8:8:8 */
#define M_VESA_32K_1280 0x119 /* 1280x1024, 5:5:5 */
#define M_VESA_64K_1280 0x11a /* 1280x1024, 5:6:5 */
#define M_VESA_FULL_1280 0x11b /* 1280x1024, 8:8:8 */
#define M_VESA_MODE_MAX 0x1ff
#define M_VESA_USER 0x1ff
#define SW_VESA_CG640x400 _IO('V', M_VESA_CG640x400 - M_VESA_BASE)
#define SW_VESA_CG640x480 _IO('V', M_VESA_CG640x480 - M_VESA_BASE)
#define SW_VESA_800x600 _IO('V', M_VESA_800x600 - M_VESA_BASE)
#define SW_VESA_CG800x600 _IO('V', M_VESA_CG800x600 - M_VESA_BASE)
#define SW_VESA_1024x768 _IO('V', M_VESA_1024x768 - M_VESA_BASE)
#define SW_VESA_CG1024x768 _IO('V', M_VESA_CG1024x768 - M_VESA_BASE)
#define SW_VESA_1280x1024 _IO('V', M_VESA_1280x1024 - M_VESA_BASE)
#define SW_VESA_CG1280x1024 _IO('V', M_VESA_CG1280x1024 - M_VESA_BASE)
#define SW_VESA_C80x60 _IO('V', M_VESA_C80x60 - M_VESA_BASE)
#define SW_VESA_C132x25 _IO('V', M_VESA_C132x25 - M_VESA_BASE)
#define SW_VESA_C132x43 _IO('V', M_VESA_C132x43 - M_VESA_BASE)
#define SW_VESA_C132x50 _IO('V', M_VESA_C132x50 - M_VESA_BASE)
#define SW_VESA_C132x60 _IO('V', M_VESA_C132x60 - M_VESA_BASE)
#define SW_VESA_32K_320 _IO('V', M_VESA_32K_320 - M_VESA_BASE)
#define SW_VESA_64K_320 _IO('V', M_VESA_64K_320 - M_VESA_BASE)
#define SW_VESA_FULL_320 _IO('V', M_VESA_FULL_320 - M_VESA_BASE)
#define SW_VESA_32K_640 _IO('V', M_VESA_32K_640 - M_VESA_BASE)
#define SW_VESA_64K_640 _IO('V', M_VESA_64K_640 - M_VESA_BASE)
#define SW_VESA_FULL_640 _IO('V', M_VESA_FULL_640 - M_VESA_BASE)
#define SW_VESA_32K_800 _IO('V', M_VESA_32K_800 - M_VESA_BASE)
#define SW_VESA_64K_800 _IO('V', M_VESA_64K_800 - M_VESA_BASE)
#define SW_VESA_FULL_800 _IO('V', M_VESA_FULL_800 - M_VESA_BASE)
#define SW_VESA_32K_1024 _IO('V', M_VESA_32K_1024 - M_VESA_BASE)
#define SW_VESA_64K_1024 _IO('V', M_VESA_64K_1024 - M_VESA_BASE)
#define SW_VESA_FULL_1024 _IO('V', M_VESA_FULL_1024 - M_VESA_BASE)
#define SW_VESA_32K_1280 _IO('V', M_VESA_32K_1280 - M_VESA_BASE)
#define SW_VESA_64K_1280 _IO('V', M_VESA_64K_1280 - M_VESA_BASE)
#define SW_VESA_FULL_1280 _IO('V', M_VESA_FULL_1280 - M_VESA_BASE)
#define SW_VESA_USER _IO('V', M_VESA_USER - M_VESA_BASE)
#endif /* !_MACHINE_CONSOLE_H_ */

127
sys/i386/include/pc/vesa.h Normal file
View File

@ -0,0 +1,127 @@
/*-
* Copyright (c) 1998 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.
* 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. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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$
*/
#ifndef _MACHINE_PC_VESA_H
#define _MACHINE_PC_VESA_H
struct vesa_info
{
/* mandatory fields */
u_int8_t v_sig[4] __attribute__ ((packed)); /* VESA */
u_int16_t v_version __attribute__ ((packed)); /* ver in BCD */
u_int32_t v_oemstr __attribute__ ((packed)); /* OEM string */
u_int32_t v_flags __attribute__ ((packed)); /* flags */
#define V_DAC8 (1<<0)
#define V_NONVGA (1<<1)
#define V_SNOW (1<<2)
u_int32_t v_modetable __attribute__ ((packed)); /* modes */
u_int16_t v_memsize __attribute__ ((packed)); /* in 64K */
/* 2.0 */
u_int16_t v_revision __attribute__ ((packed)); /* software rev */
u_int32_t v_venderstr __attribute__ ((packed)); /* vender */
u_int32_t v_prodstr __attribute__ ((packed)); /* product name */
u_int32_t v_revstr __attribute__ ((packed)); /* product rev */
};
struct vesa_mode
{
/* mandatory fields */
u_int16_t v_modeattr;
#define V_MODESUPP (1<<0) /* VESA mode attributes */
#define V_MODEOPTINFO (1<<1)
#define V_MODEBIOSOUT (1<<2)
#define V_MODECOLOR (1<<3)
#define V_MODEGRAPHICS (1<<4)
#define V_MODENONVGA (1<<5)
#define V_MODENONBANK (1<<6)
#define V_MODELFB (1<<7)
#define V_MODEVESA (1<<16) /* Private attributes */
u_int8_t v_waattr;
u_int8_t v_wbattr;
#define V_WATTREXIST (1<<0)
#define V_WATTRREAD (1<<1)
#define V_WATTRWRITE (1<<2)
u_int16_t v_wgran;
u_int16_t v_wsize;
u_int16_t v_waseg;
u_int16_t v_wbseg;
u_int32_t v_posfunc;
u_int16_t v_bpscanline;
/* fields optional for 1.0/1.1 implementations */
u_int16_t v_width;
u_int16_t v_height;
u_int8_t v_cwidth;
u_int8_t v_cheight;
u_int8_t v_planes;
u_int8_t v_bpp;
u_int8_t v_banks;
u_int8_t v_memmodel;
#define V_MMTEXT 0
#define V_MMCGA 1
#define V_MMHGC 2
#define V_MMEGA 3
#define V_MMPACKED 4
#define V_MMSEQU256 5
#define V_MMDIRCOLOR 6
#define V_MMYUV 7
u_int8_t v_banksize;
u_int8_t v_ipages;
u_int8_t v_reserved0;
/* fields for 1.2+ implementations */
u_int8_t v_redmasksize;
u_int8_t v_redfieldpos;
u_int8_t v_greenmasksize;
u_int8_t v_greenfieldpos;
u_int8_t v_bluemasksize;
u_int8_t v_bluefieldpos;
u_int8_t v_resmasksize;
u_int8_t v_resfieldpos;
u_int8_t v_dircolormode;
/* 2.0 implementations */
u_int32_t v_lfb;
u_int32_t v_offscreen;
u_int8_t v_offscreensize;
};
#ifdef KERNEL
#define VESA_MODE(x) ((x) >= M_VESA_BASE)
int vesa_load_ioctl(void);
int vesa_unload_ioctl(void);
#ifndef VESA_MODULE
int vesa_load(void);
#endif
#endif /* KERNEL */
#endif /* !_MACHINE_PC_VESA_H */

View File

@ -1,18 +1,18 @@
/*-
* Copyright (c) 1992-1995 Søren Schmidt
* Copyright (c) 1992-1998 Søren Schmidt
* 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
* in this position and unchanged.
* notice, this list of conditions and the following disclaimer,
* without modification, immediately at the beginning of the file.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software withough specific prior written permission
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@ -25,7 +25,7 @@
* (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: kbdtables.h,v 1.39 1998/01/28 08:45:18 yokota Exp $
* $Id$
*/
#define SET8 0x80 /* set eight bit on */

View File

@ -1,18 +1,18 @@
/*-
* Copyright (c) 1994 Søren Schmidt
* Copyright (c) 1994-1998 Søren Schmidt
* 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
* in this position and unchanged.
* notice, this list of conditions and the following disclaimer,
* without modification, immediately at the beginning of the file.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software withough specific prior written permission
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@ -25,7 +25,7 @@
* (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: pcaudio.c,v 1.41 1998/06/07 17:10:48 dfr Exp $
* $Id$
*/
#include "pca.h"

150
sys/i386/isa/scvesactl.c Normal file
View File

@ -0,0 +1,150 @@
/*-
* Copyright (c) 1998 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.
* 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. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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$
*/
#include "sc.h"
#include "opt_vesa.h"
#include "opt_vm86.h"
#if (NSC > 0 && defined(VESA) && defined(VM86)) || defined(VESA_MODULE)
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/tty.h>
#include <sys/kernel.h>
#include <machine/apm_bios.h>
#include <machine/console.h>
#include <machine/pc/vesa.h>
#include <i386/isa/videoio.h>
#include <i386/isa/syscons.h>
static int (*prev_user_ioctl)(dev_t dev, int cmd, caddr_t data, int flag,
struct proc *p);
extern struct tty *scdevtotty(dev_t dev);
int
vesa_ioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
{
scr_stat *scp;
struct tty *tp;
video_info_t info;
video_adapter_t *adp;
int mode;
int error;
int s;
tp = scdevtotty(dev);
if (!tp)
return ENXIO;
scp = sc_get_scr_stat(tp->t_dev);
switch (cmd) {
case SW_VESA_USER:
mode = (int)data;
if ((*biosvidsw.get_info)(scp->adp, mode, &info))
return ENODEV;
if (info.vi_flags & V_INFO_GRAPHICS)
goto vesa_graphics;
else
goto vesa_text;
/* text modes */
case SW_VESA_C80x60:
case SW_VESA_C132x25:
case SW_VESA_C132x43:
case SW_VESA_C132x50:
case SW_VESA_C132x60:
adp = get_adapter(scp);
if (!(adp->va_flags & V_ADP_MODECHANGE))
return ENODEV;
mode = (cmd & 0xff) + M_VESA_BASE;
vesa_text:
return sc_set_text_mode(scp, tp, mode, 0, 0, 0);
/* graphics modes */
case SW_VESA_32K_320: case SW_VESA_64K_320:
case SW_VESA_FULL_320:
case SW_VESA_CG640x400:
case SW_VESA_CG640x480:
case SW_VESA_32K_640: case SW_VESA_64K_640:
case SW_VESA_FULL_640:
case SW_VESA_800x600: case SW_VESA_CG800x600:
case SW_VESA_32K_800: case SW_VESA_64K_800:
case SW_VESA_FULL_800:
case SW_VESA_1024x768: case SW_VESA_CG1024x768:
case SW_VESA_32K_1024: case SW_VESA_64K_1024:
case SW_VESA_FULL_1024:
case SW_VESA_1280x1024: case SW_VESA_CG1280x1024:
case SW_VESA_32K_1280: case SW_VESA_64K_1280:
case SW_VESA_FULL_1280:
adp = get_adapter(scp);
if (!(adp->va_flags & V_ADP_MODECHANGE))
return ENODEV;
mode = (cmd & 0xff) + M_VESA_BASE;
vesa_graphics:
return sc_set_graphics_mode(scp, tp, mode);
}
if (prev_user_ioctl)
return (*prev_user_ioctl)(dev, cmd, data, flag, p);
else
return ENOIOCTL;
}
int
vesa_load_ioctl(void)
{
if (prev_user_ioctl)
return EBUSY;
prev_user_ioctl = sc_user_ioctl;
sc_user_ioctl = vesa_ioctl;
return 0;
}
int
vesa_unload_ioctl(void)
{
if (sc_user_ioctl != vesa_ioctl)
return EBUSY;
sc_user_ioctl = prev_user_ioctl;
prev_user_ioctl = NULL;
return 0;
}
#endif /* (NSC > 0 && VESA && VM86) || VESA_MODULE */

486
sys/i386/isa/scvidctl.c Normal file
View File

@ -0,0 +1,486 @@
/*-
* Copyright (c) 1998 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.
* 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. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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$
*/
#include "sc.h"
#include "opt_syscons.h"
#if NSC > 0
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/signalvar.h>
#include <sys/tty.h>
#include <sys/kernel.h>
#include <machine/apm_bios.h>
#include <machine/console.h>
#include <i386/isa/videoio.h>
#include <i386/isa/syscons.h>
/* video ioctl */
extern scr_stat *cur_console;
extern u_short *Crtat;
extern int fonts_loaded;
extern int sc_history_size;
extern u_char palette[];
int
sc_set_text_mode(scr_stat *scp, struct tty *tp, int mode, int xsize, int ysize,
int fontsize)
{
video_adapter_t *adp;
video_info_t info;
int error;
int s;
int i;
if ((*biosvidsw.get_info)(scp->adp, mode, &info))
return ENODEV;
adp = get_adapter(scp);
/* adjust argument values */
if (fontsize <= 0)
fontsize = info.vi_cheight;
if (fontsize < 14) {
fontsize = 8;
if (!(fonts_loaded & FONT_8))
return EINVAL;
} else if (fontsize >= 16) {
fontsize = 16;
if (!(fonts_loaded & FONT_16))
return EINVAL;
} else {
fontsize = 14;
if (!(fonts_loaded & FONT_14))
return EINVAL;
}
if ((xsize <= 0) || (xsize > info.vi_width))
xsize = info.vi_width;
if ((ysize <= 0) || (ysize > info.vi_height))
ysize = info.vi_height;
/* stop screen saver, etc */
s = spltty();
if ((error = sc_clean_up(scp))) {
splx(s);
return error;
}
/* set up scp */
if (scp->history != NULL)
i = imax(scp->history_size / scp->xsize
- imax(sc_history_size, scp->ysize), 0);
else
i = 0;
/*
* This is a kludge to fend off scrn_update() while we
* muck around with scp. XXX
*/
scp->status |= UNKNOWN_MODE;
scp->status &= ~(GRAPHICS_MODE | PIXEL_MODE);
scp->mode = mode;
scp->font_size = fontsize;
scp->xsize = xsize;
scp->ysize = ysize;
scp->xpixel = scp->xsize*8;
scp->ypixel = scp->ysize*fontsize;
/* allocate buffers */
sc_alloc_scr_buffer(scp, TRUE, TRUE);
if (ISMOUSEAVAIL(adp->va_flags))
sc_alloc_cut_buffer(scp, FALSE);
sc_alloc_history_buffer(scp, sc_history_size, i, FALSE);
splx(s);
if (scp == cur_console)
set_mode(scp);
scp->status &= ~UNKNOWN_MODE;
if (tp == NULL)
return 0;
if (tp->t_winsize.ws_col != scp->xsize
|| tp->t_winsize.ws_row != scp->ysize) {
tp->t_winsize.ws_col = scp->xsize;
tp->t_winsize.ws_row = scp->ysize;
pgsignal(tp->t_pgrp, SIGWINCH, 1);
}
return 0;
}
int
sc_set_graphics_mode(scr_stat *scp, struct tty *tp, int mode)
{
video_adapter_t *adp;
video_info_t info;
int error;
int s;
if ((*biosvidsw.get_info)(scp->adp, mode, &info))
return ENODEV;
adp = get_adapter(scp);
/* stop screen saver, etc */
s = spltty();
if ((error = sc_clean_up(scp))) {
splx(s);
return error;
}
/* set up scp */
scp->status |= (UNKNOWN_MODE | GRAPHICS_MODE);
scp->status &= ~PIXEL_MODE;
scp->mode = mode;
scp->xpixel = info.vi_width;
scp->ypixel = info.vi_height;
scp->xsize = info.vi_width/8;
scp->ysize = info.vi_height/info.vi_cheight;
scp->font_size = FONT_NONE;
/* move the mouse cursor at the center of the screen */
sc_move_mouse(scp, scp->xpixel / 2, scp->ypixel / 2);
splx(s);
if (scp == cur_console)
set_mode(scp);
/* clear_graphics();*/
scp->status &= ~UNKNOWN_MODE;
if (tp == NULL)
return 0;
if (tp->t_winsize.ws_xpixel != scp->xpixel
|| tp->t_winsize.ws_ypixel != scp->ypixel) {
tp->t_winsize.ws_xpixel = scp->xpixel;
tp->t_winsize.ws_ypixel = scp->ypixel;
pgsignal(tp->t_pgrp, SIGWINCH, 1);
}
return 0;
}
int
sc_set_pixel_mode(scr_stat *scp, struct tty *tp, int xsize, int ysize,
int fontsize)
{
video_adapter_t *adp;
video_info_t info;
int error;
int s;
int i;
if ((*biosvidsw.get_info)(scp->adp, scp->mode, &info))
return ENODEV; /* this shouldn't happen */
adp = get_adapter(scp);
#ifdef SC_VIDEO_DEBUG
if (scp->scr_buf != NULL) {
printf("set_pixel_mode(): mode:%x, col:%d, row:%d, font:%d\n",
scp->mode, xsize, ysize, fontsize);
}
#endif
/* adjust argument values */
if ((fontsize <= 0) || (fontsize == FONT_NONE))
fontsize = info.vi_cheight;
if (fontsize < 14) {
fontsize = 8;
if (!(fonts_loaded & FONT_8))
return EINVAL;
} else if (fontsize >= 16) {
fontsize = 16;
if (!(fonts_loaded & FONT_16))
return EINVAL;
} else {
fontsize = 14;
if (!(fonts_loaded & FONT_14))
return EINVAL;
}
if (xsize <= 0)
xsize = info.vi_width/8;
if (ysize <= 0)
ysize = info.vi_height/fontsize;
#ifdef SC_VIDEO_DEBUG
if (scp->scr_buf != NULL) {
printf("set_pixel_mode(): mode:%x, col:%d, row:%d, font:%d\n",
scp->mode, xsize, ysize, fontsize);
printf("set_pixel_mode(): Crtat:%x, %dx%d, xoff:%d, yoff:%d\n",
Crtat, info.vi_width, info.vi_height,
(info.vi_width/8 - xsize)/2,
(info.vi_height/fontsize - ysize)/2);
}
#endif
/* stop screen saver, etc */
s = spltty();
if ((error = sc_clean_up(scp))) {
splx(s);
return error;
}
/* set up scp */
if (scp->history != NULL)
i = imax(scp->history_size / scp->xsize
- imax(sc_history_size, scp->ysize), 0);
else
i = 0;
scp->status |= (UNKNOWN_MODE | PIXEL_MODE);
scp->status &= ~(GRAPHICS_MODE | MOUSE_ENABLED);
scp->xsize = xsize;
scp->ysize = ysize;
scp->font_size = fontsize;
scp->xoff = (scp->xpixel/8 - xsize)/2;
scp->yoff = (scp->ypixel/fontsize - ysize)/2;
/* allocate buffers */
sc_alloc_scr_buffer(scp, TRUE, TRUE);
if (ISMOUSEAVAIL(adp->va_flags))
sc_alloc_cut_buffer(scp, FALSE);
sc_alloc_history_buffer(scp, sc_history_size, i, FALSE);
splx(s);
/* FIXME */
if (scp == cur_console)
bzero(Crtat, scp->xpixel*scp->ypixel/8);
scp->status &= ~UNKNOWN_MODE;
#ifdef SC_VIDEO_DEBUG
printf("set_pixel_mode(): status:%x\n", scp->status);
#endif
if (tp == NULL)
return 0;
if (tp->t_winsize.ws_col != scp->xsize
|| tp->t_winsize.ws_row != scp->ysize) {
tp->t_winsize.ws_col = scp->xsize;
tp->t_winsize.ws_row = scp->ysize;
pgsignal(tp->t_pgrp, SIGWINCH, 1);
}
return 0;
}
int
sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct proc *p)
{
scr_stat *scp;
video_adapter_t *adp;
int error;
int s;
scp = sc_get_scr_stat(tp->t_dev);
switch (cmd) {
case CONS_CURRENT: /* get current adapter type */
adp = get_adapter(scp);
*(int *)data = adp->va_type;
return 0;
case CONS_CURRENTADP: /* get current adapter index */
*(int *)data = scp->adp;
return 0;
case CONS_ADPINFO: /* adapter information */
adp = (*biosvidsw.adapter)(((video_adapter_t *)data)->va_index);
if (adp == NULL)
return ENODEV;
bcopy(adp, data, sizeof(*adp));
return 0;
case CONS_GET: /* get current video mode */
*(int *)data = scp->mode;
return 0;
case CONS_MODEINFO: /* get mode information */
return ((*biosvidsw.get_info)(scp->adp,
((video_info_t *)data)->vi_mode, (video_info_t *)data)
? ENODEV : 0);
case CONS_FINDMODE: /* find a matching video mode */
return ((*biosvidsw.query_mode)(scp->adp, (video_info_t *)data)
? ENODEV : 0);
case CONS_SETWINORG:
return ((*biosvidsw.set_win_org)(scp->adp, *(u_int *)data)
? ENODEV : 0);
/* VGA TEXT MODES */
case SW_VGA_C40x25:
case SW_VGA_C80x25: case SW_VGA_M80x25:
case SW_VGA_C80x30: case SW_VGA_M80x30:
case SW_VGA_C80x50: case SW_VGA_M80x50:
case SW_VGA_C80x60: case SW_VGA_M80x60:
case SW_B40x25: case SW_C40x25:
case SW_B80x25: case SW_C80x25:
case SW_ENH_B40x25: case SW_ENH_C40x25:
case SW_ENH_B80x25: case SW_ENH_C80x25:
case SW_ENH_B80x43: case SW_ENH_C80x43:
case SW_EGAMONO80x25:
adp = get_adapter(scp);
if (!(adp->va_flags & V_ADP_MODECHANGE))
return ENODEV;
return sc_set_text_mode(scp, tp, cmd & 0xff, 0, 0, 0);
/* GRAPHICS MODES */
case SW_BG320: case SW_BG640:
case SW_CG320: case SW_CG320_D: case SW_CG640_E:
case SW_CG640x350: case SW_ENH_CG640:
case SW_BG640x480: case SW_CG640x480: case SW_VGA_CG320:
case SW_VGA_MODEX:
adp = get_adapter(scp);
if (!(adp->va_flags & V_ADP_MODECHANGE))
return ENODEV;
return sc_set_graphics_mode(scp, tp, cmd & 0xff);
case KDSETMODE: /* set current mode of this (virtual) console */
switch (*data) {
case KD_TEXT: /* switch to TEXT (known) mode */
/*
* If scp->mode is of graphics modes, we don't know which
* text mode to switch back to...
*/
if (scp->status & GRAPHICS_MODE)
return EINVAL;
/* restore fonts & palette ! */
#if 0
adp = get_adapter(scp);
if (ISFONTAVAIL(adp->va_flags)
&& !(scp->status & (GRAPHICS_MODE | PIXEL_MODE)))
/*
* FONT KLUDGE
* Don't load fonts for now... XXX
*/
if (fonts_loaded & FONT_8)
copy_font(scp, LOAD, 8, font_8);
if (fonts_loaded & FONT_14)
copy_font(scp, LOAD, 14, font_14);
if (fonts_loaded & FONT_16)
copy_font(scp, LOAD, 16, font_16);
}
#endif
load_palette(scp, palette);
/* move hardware cursor out of the way */
(*biosvidsw.set_hw_cursor)(scp->adp, -1, -1);
/* FALL THROUGH */
case KD_TEXT1: /* switch to TEXT (known) mode */
/*
* If scp->mode is of graphics modes, we don't know which
* text/pixel mode to switch back to...
*/
if (scp->status & GRAPHICS_MODE)
return EINVAL;
s = spltty();
if ((error = sc_clean_up(scp))) {
splx(s);
return error;
}
scp->status |= UNKNOWN_MODE;
splx(s);
/* no restore fonts & palette */
if (scp == cur_console) {
set_mode(scp);
/* FIXME */
if (scp->status & PIXEL_MODE)
bzero(Crtat, scp->xpixel*scp->ypixel/8);
}
sc_clear_screen(scp);
scp->status &= ~UNKNOWN_MODE;
return 0;
case KD_PIXEL: /* pixel (raster) display */
if (!(scp->status & (GRAPHICS_MODE | PIXEL_MODE)))
return EINVAL;
if (!(scp->status & PIXEL_MODE))
return sc_set_pixel_mode(scp, tp, scp->xsize, scp->ysize,
scp->font_size);
s = spltty();
if ((error = sc_clean_up(scp))) {
splx(s);
return error;
}
scp->status |= (UNKNOWN_MODE | PIXEL_MODE);
splx(s);
if (scp == cur_console) {
set_mode(scp);
load_palette(scp, palette);
/* FIXME */
bzero(Crtat, scp->xpixel*scp->ypixel/8);
}
sc_clear_screen(scp);
scp->status &= ~UNKNOWN_MODE;
return 0;
case KD_GRAPHICS: /* switch to GRAPHICS (unknown) mode */
s = spltty();
if ((error = sc_clean_up(scp))) {
splx(s);
return error;
}
scp->status |= UNKNOWN_MODE;
splx(s);
return 0;
default:
return EINVAL;
}
/* NOT REACHED */
case KDRASTER: /* set pixel (raster) display mode */
if (ISUNKNOWNSC(scp) || ISTEXTSC(scp))
return ENODEV;
return sc_set_pixel_mode(scp, tp, ((int *)data)[0], ((int *)data)[1],
((int *)data)[2]);
case KDGETMODE: /* get current mode of this (virtual) console */
/*
* From the user program's point of view, KD_PIXEL is the same
* as KD_TEXT...
*/
*data = ISGRAPHSC(scp) ? KD_GRAPHICS : KD_TEXT;
return 0;
case KDSBORDER: /* set border color of this (virtual) console */
scp->border = *data;
if (scp == cur_console)
set_border(cur_console, scp->border);
return 0;
}
return ENOIOCTL;
}
#endif /* NSC > 0 */

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +1,18 @@
/*-
* Copyright (c) 1995-1997 Søren Schmidt
* Copyright (c) 1995-1998 Søren Schmidt
* 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
* in this position and unchanged.
* notice, this list of conditions and the following disclaimer,
* without modification, immediately at the beginning of the file.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@ -25,7 +25,7 @@
* (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: syscons.h,v 1.38 1998/08/03 09:09:35 yokota Exp $
* $Id$
*/
#ifndef _I386_ISA_SYSCONS_H_
@ -65,6 +65,9 @@
#define MOUSE_MOVED 0x01000
#define MOUSE_CUTTING 0x02000
#define MOUSE_VISIBLE 0x04000
#define GRAPHICS_MODE 0x08000
#define PIXEL_MODE 0x10000
#define SAVER_RUNNING 0x20000
/* configuration flags */
#define VISUAL_BELL 0x00001
@ -74,6 +77,7 @@
#define XT_KEYBD 0x00010
#define KBD_NORESET 0x00020
#define QUIET_BELL 0x00040
#define VESA800X600 0x00080
/* attribute flags */
#define NORMAL_ATTR 0x00
@ -84,9 +88,6 @@
#define FOREGROUND_CHANGED 0x10
#define BACKGROUND_CHANGED 0x20
/* video hardware memory addresses */
#define VIDEOMEM 0x000A0000
/* misc defines */
#define FALSE 0
#define TRUE 1
@ -104,20 +105,6 @@
#define FONT_14 4
#define FONT_16 8
/* defines related to hardware addresses */
#define MONO_BASE 0x3B4 /* crt controller base mono */
#define COLOR_BASE 0x3D4 /* crt controller base color */
#define MISC 0x3C2 /* misc output register */
#define ATC IO_VGA+0x00 /* attribute controller */
#define TSIDX IO_VGA+0x04 /* timing sequencer idx */
#define TSREG IO_VGA+0x05 /* timing sequencer data */
#define PIXMASK IO_VGA+0x06 /* pixel write mask */
#define PALRADR IO_VGA+0x07 /* palette read address */
#define PALWADR IO_VGA+0x08 /* palette write address */
#define PALDATA IO_VGA+0x09 /* palette data register */
#define GDCIDX IO_VGA+0x0E /* graph data controller idx */
#define GDCREG IO_VGA+0x0F /* graph data controller data */
/* special characters */
#define cntlc 0x03
#define cntld 0x04
@ -141,6 +128,7 @@ typedef struct term_stat {
} term_stat;
typedef struct scr_stat {
int adp; /* video adapter index */
u_short *scr_buf; /* buffer when off screen */
int xpos; /* current X position */
int ypos; /* current Y position */
@ -150,6 +138,8 @@ typedef struct scr_stat {
int ysize; /* Y text size */
int xpixel; /* X graphics size */
int ypixel; /* Y graphics size */
int xoff; /* X offset in pixel mode */
int yoff; /* Y offset in pixel mode */
int font_size; /* fontsize in Y direction */
int start; /* modified area start */
int end; /* modified area end */
@ -186,7 +176,8 @@ typedef struct scr_stat {
int history_size; /* size of history buffer */
struct apmhook r_hook; /* reconfiguration support */
#ifdef SC_SPLASH_SCREEN
u_char splash_save_mode; /* saved mode for splash screen */
int splash_save_mode; /* saved mode for splash screen */
int splash_save_status; /* saved status for splash screen */
#endif
} scr_stat;
@ -195,18 +186,59 @@ typedef struct default_attr {
int rev_color; /* reverse hardware color */
} default_attr;
#define ISTEXTSC(scp) (!((scp)->status \
& (UNKNOWN_MODE | GRAPHICS_MODE | PIXEL_MODE)))
#define ISGRAPHSC(scp) (((scp)->status \
& (UNKNOWN_MODE | GRAPHICS_MODE)))
#define ISPIXELSC(scp) (((scp)->status \
& (UNKNOWN_MODE | GRAPHICS_MODE | PIXEL_MODE))\
== PIXEL_MODE)
#define ISUNKNOWNSC(scp) ((scp)->status & UNKNOWN_MODE)
#define ISFONTAVAIL(af) ((af) & V_ADP_FONT)
#define ISMOUSEAVAIL(af) ((af) & V_ADP_FONT)
#define ISPALAVAIL(af) ((af) & V_ADP_PALETTE)
/* misc prototypes used by different syscons related LKM's */
void set_border(u_char color);
void set_mode(scr_stat *scp);
void copy_font(int operation, int font_type, char* font_image);
void load_palette(char *palette);
/* syscons.c */
extern int (*sc_user_ioctl)(dev_t dev, int cmd, caddr_t data, int flag,
struct proc *p);
int set_mode(scr_stat *scp);
scr_stat *sc_get_scr_stat(dev_t dev);
void copy_font(scr_stat *scp, int operation, int font_size, u_char *font_image);
#define save_palette(scp, pal) (*biosvidsw.save_palette)((scp)->adp, pal)
#define load_palette(scp, pal) (*biosvidsw.load_palette)((scp)->adp, pal)
#define set_border(scp, col) (*biosvidsw.set_border)((scp)->adp, col)
#define get_adapter(scp) (*biosvidsw.adapter)((scp)->adp)
int add_scrn_saver(void (*this)(int));
int remove_scrn_saver(void (*this)(int));
void sc_clear_screen(scr_stat *scp);
void sc_move_mouse(scr_stat *scp, int x, int y);
int sc_clean_up(scr_stat *scp);
void sc_alloc_scr_buffer(scr_stat *scp, int wait, int clear);
void sc_alloc_cut_buffer(scr_stat *scp, int wait);
void sc_alloc_history_buffer(scr_stat *scp, int lines, int extra, int wait);
/* scvidctl.c */
int sc_set_text_mode(scr_stat *scp, struct tty *tp, int mode,
int xsize, int ysize, int fontsize);
int sc_set_graphics_mode(scr_stat *scp, struct tty *tp, int mode);
int sc_set_pixel_mode(scr_stat *scp, struct tty *tp,
int xsize, int ysize, int fontsize);
int sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag,
struct proc *p);
#ifdef SC_SPLASH_SCREEN
void splash(int);
int splash_load(void);
int splash_unload(void);
/* splash.c */
void scsplash(int);
int scsplash_load(scr_stat *scp);
int scsplash_unload(scr_stat *scp);
#endif
#endif /* !_I386_ISA_SYSCONS_H_ */

868
sys/i386/isa/vesa.c Normal file
View File

@ -0,0 +1,868 @@
/*-
* Copyright (c) 1998 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.
* 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. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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$
*/
#include "sc.h"
#include "opt_vesa.h"
#include "opt_vm86.h"
#if (NSC > 0 && defined(VESA) && defined(VM86)) || defined(VESA_MODULE)
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <machine/console.h>
#include <machine/md_var.h>
#include <machine/vm86.h>
#include <machine/pc/bios.h>
#include <machine/pc/vesa.h>
#include <i386/isa/videoio.h>
#ifdef VESA_MODULE
#include <sys/exec.h>
#include <sys/sysent.h>
#include <sys/lkm.h>
MOD_MISC(vesa);
#endif
/* VESA video adapter state buffer stub */
struct adp_state {
int sig;
#define V_STATE_SIG 0x61736576
u_char regs[1];
};
typedef struct adp_state adp_state_t;
/* VESA video adapter */
static video_adapter_t *vesa_adp = NULL;
static int vesa_state_buf_size = 0;
static void *vesa_state_buf = NULL;
/* VESA functions */
static vi_init_t vesa_init;
static vi_adapter_t vesa_adapter;
static vi_get_info_t vesa_get_info;
static vi_query_mode_t vesa_query_mode;
static vi_set_mode_t vesa_set_mode;
static vi_save_font_t vesa_save_font;
static vi_load_font_t vesa_load_font;
static vi_show_font_t vesa_show_font;
static vi_save_palette_t vesa_save_palette;
static vi_load_palette_t vesa_load_palette;
static vi_set_border_t vesa_set_border;
static vi_save_state_t vesa_save_state;
static vi_load_state_t vesa_load_state;
static vi_set_win_org_t vesa_set_origin;
static vi_read_hw_cursor_t vesa_read_hw_cursor;
static vi_set_hw_cursor_t vesa_set_hw_cursor;
static vi_diag_t vesa_diag;
static struct vidsw vesavidsw = {
vesa_init, vesa_adapter, vesa_get_info, vesa_query_mode,
vesa_set_mode, vesa_save_font, vesa_load_font, vesa_show_font,
vesa_save_palette,vesa_load_palette,vesa_set_border,vesa_save_state,
vesa_load_state,vesa_set_origin,vesa_read_hw_cursor,vesa_set_hw_cursor,
vesa_diag,
};
static struct vidsw prevvidsw;
/* VESA BIOS video modes */
#define VESA_MAXMODES 64
#define EOT (-1)
#define NA (-2)
static video_info_t vesa_vmode[VESA_MAXMODES + 1] = {
{ EOT, },
};
static int vesa_init_done = FALSE;
static int has_vesa_bios = FALSE;
static struct vesa_info *vesa_adp_info = NULL;
static u_int16_t *vesa_vmodetab = NULL;
/* local macros and functions */
#define BIOS_SADDRTOLADDR(p) ((((p) & 0xffff0000) >> 12) + ((p) & 0x0000ffff))
static int vesa_bios_get_mode(int mode, struct vesa_mode *vmode);
static int vesa_bios_set_mode(int mode);
static int vesa_bios_set_dac(int bits);
static int vesa_bios_save_palette(int start, int colors, u_char *palette);
static int vesa_bios_load_palette(int start, int colors, u_char *palette);
#define STATE_SIZE 0
#define STATE_SAVE 1
#define STATE_LOAD 2
#define STATE_HW (1<<0)
#define STATE_DATA (1<<1)
#define STATE_DAC (1<<2)
#define STATE_REG (1<<3)
#define STATE_MOST (STATE_HW | STATE_DATA | STATE_REG)
#define STATE_ALL (STATE_HW | STATE_DATA | STATE_DAC | STATE_REG)
static int vesa_bios_state_buf_size(void);
static int vesa_bios_save_restore(int code, void *p, size_t size);
static int translate_flags(u_int16_t vflags);
static int vesa_bios_init(void);
static void clear_modes(video_info_t *info, int color);
static void
dump_buffer(u_char *buf, size_t len)
{
int i;
for(i = 0; i < len;) {
printf("%02x ", buf[i]);
if ((++i % 16) == 0)
printf("\n");
}
}
/* VESA BIOS calls */
static int
vesa_bios_get_mode(int mode, struct vesa_mode *vmode)
{
struct vm86frame vmf;
u_char buf[256];
int err;
bzero(&vmf, sizeof(vmf));
bzero(buf, sizeof(buf));
vmf.vmf_eax = 0x4f01;
vmf.vmf_ecx = mode;
err = vm86_datacall(0x10, &vmf, (char *)buf, sizeof(buf),
&vmf.vmf_es, &vmf.vmf_di);
if ((err != 0) || (vmf.vmf_eax != 0x4f))
return 1;
bcopy(buf, vmode, sizeof(*vmode));
return 0;
}
static int
vesa_bios_set_mode(int mode)
{
struct vm86frame vmf;
int err;
bzero(&vmf, sizeof(vmf));
vmf.vmf_eax = 0x4f02;
vmf.vmf_ebx = mode;
err = vm86_intcall(0x10, &vmf);
return ((err != 0) || (vmf.vmf_eax != 0x4f));
}
static int
vesa_bios_set_dac(int bits)
{
struct vm86frame vmf;
int err;
bzero(&vmf, sizeof(vmf));
vmf.vmf_eax = 0x4f08;
vmf.vmf_ebx = (bits << 8);
err = vm86_intcall(0x10, &vmf);
return ((err != 0) || (vmf.vmf_eax != 0x4f));
}
static int
vesa_bios_save_palette(int start, int colors, u_char *palette)
{
struct vm86frame vmf;
u_char *p;
int err;
int i;
p = malloc(colors*4, M_DEVBUF, M_WAITOK);
bzero(&vmf, sizeof(vmf));
vmf.vmf_eax = 0x4f09;
vmf.vmf_ebx = 1; /* get primary palette data */
vmf.vmf_ecx = colors;
vmf.vmf_edx = start;
err = vm86_datacall(0x10, &vmf, p, colors*4, &vmf.vmf_es, &vmf.vmf_di);
if ((err != 0) || (vmf.vmf_eax != 0x4f)) {
free(p, M_DEVBUF);
return 1;
}
for (i = 0; i < colors; ++i) {
palette[i*3] = p[i*4 + 1];
palette[i*3 + 1] = p[i*4 + 2];
palette[i*3 + 2] = p[i*4 + 3];
}
free(p, M_DEVBUF);
return 0;
}
static int
vesa_bios_load_palette(int start, int colors, u_char *palette)
{
struct vm86frame vmf;
u_char *p;
int err;
int i;
p = malloc(colors*4, M_DEVBUF, M_WAITOK);
for (i = 0; i < colors; ++i) {
p[i*4] = 0;
p[i*4 + 1] = palette[i*3];
p[i*4 + 2] = palette[i*3 + 1];
p[i*4 + 3] = palette[i*3 + 2];
}
bzero(&vmf, sizeof(vmf));
vmf.vmf_eax = 0x4f09;
vmf.vmf_ebx = 0; /* set primary palette data */
vmf.vmf_ecx = colors;
vmf.vmf_edx = start;
err = vm86_datacall(0x10, &vmf, p, colors*4, &vmf.vmf_es, &vmf.vmf_di);
free(p, M_DEVBUF);
return ((err != 0) || (vmf.vmf_eax != 0x4f));
}
static int
vesa_bios_state_buf_size(void)
{
struct vm86frame vmf;
int err;
bzero(&vmf, sizeof(vmf));
vmf.vmf_eax = 0x4f04;
vmf.vmf_ecx = STATE_MOST;
vmf.vmf_edx = STATE_SIZE;
err = vm86_intcall(0x10, &vmf);
if ((err != 0) || (vmf.vmf_eax != 0x4f))
return 0;
return vmf.vmf_ebx*64;
}
static int
vesa_bios_save_restore(int code, void *p, size_t size)
{
struct vm86frame vmf;
int err;
bzero(&vmf, sizeof(vmf));
vmf.vmf_eax = 0x4f04;
vmf.vmf_ecx = STATE_MOST;
vmf.vmf_edx = code; /* STATE_SAVE/STATE_LOAD */
err = vm86_datacall(0x10, &vmf, (char *)p, size,
&vmf.vmf_es, &vmf.vmf_bx);
return ((err != 0) || (vmf.vmf_eax != 0x4f));
}
static int
translate_flags(u_int16_t vflags)
{
static struct {
u_int16_t mask;
int set;
int reset;
} ftable[] = {
{ V_MODECOLOR, V_INFO_COLOR, 0 },
{ V_MODEGRAPHICS, V_INFO_GRAPHICS, 0 },
{ V_MODELFB, V_INFO_LENEAR, 0 },
};
int flags;
int i;
for (flags = 0, i = 0; i < sizeof(ftable)/sizeof(ftable[0]); ++i) {
flags |= (vflags & ftable[i].mask) ?
ftable[i].set : ftable[i].reset;
}
return flags;
}
static int
vesa_bios_init(void)
{
static u_char buf[512];
struct vm86frame vmf;
struct vesa_mode vmode;
u_int32_t p;
int modes;
int err;
int i;
if (vesa_init_done)
return 0;
has_vesa_bios = FALSE;
vesa_adp_info = NULL;
vesa_vmode[0].vi_mode = EOT;
bzero(&vmf, sizeof(vmf)); /* paranoia */
bzero(buf, sizeof(buf));
bcopy("VBE2", buf, 4); /* try for VBE2 data */
vmf.vmf_eax = 0x4f00;
err = vm86_datacall(0x10, &vmf, (char *)buf, sizeof(buf),
&vmf.vmf_es, &vmf.vmf_di);
if ((err != 0) || (vmf.vmf_eax != 0x4f) || bcmp("VESA", buf, 4))
return 1;
vesa_adp_info = (struct vesa_info *)buf;
if (bootverbose)
dump_buffer(buf, 64);
if (vesa_adp_info->v_flags & V_NONVGA)
return 1;
/* obtain video mode information */
p = BIOS_SADDRTOLADDR(vesa_adp_info->v_modetable);
vesa_vmodetab = (u_int16_t *)BIOS_PADDRTOVADDR(p);
for (i = 0, modes = 0; vesa_vmodetab[i] != 0xffff; ++i) {
if (modes >= VESA_MAXMODES)
break;
if (vesa_bios_get_mode(vesa_vmodetab[i], &vmode))
continue;
/* reject unsupported modes */
#if 0
if ((vmode.v_modeattr & (V_MODESUPP | V_MODEOPTINFO
| V_MODENONVGA))
!= (V_MODESUPP | V_MODEOPTINFO))
continue;
#else
if ((vmode.v_modeattr & (V_MODEOPTINFO | V_MODENONVGA))
!= (V_MODEOPTINFO))
continue;
#endif
/* copy some fields */
bzero(&vesa_vmode[modes], sizeof(vesa_vmode[modes]));
vesa_vmode[modes].vi_mode = vesa_vmodetab[i];
vesa_vmode[modes].vi_width = vmode.v_width;
vesa_vmode[modes].vi_height = vmode.v_height;
vesa_vmode[modes].vi_depth = vmode.v_bpp;
vesa_vmode[modes].vi_planes = vmode.v_planes;
vesa_vmode[modes].vi_cwidth = vmode.v_cwidth;
vesa_vmode[modes].vi_cheight = vmode.v_cheight;
vesa_vmode[modes].vi_window = (u_int)vmode.v_waseg << 4;
/* XXX window B */
vesa_vmode[modes].vi_window_size = vmode.v_wsize;
vesa_vmode[modes].vi_window_gran = vmode.v_wgran;
vesa_vmode[modes].vi_buffer = vmode.v_lfb;
vesa_vmode[modes].vi_buffer_size = vmode.v_offscreen;
/* pixel format, memory model... */
vesa_vmode[modes].vi_flags = translate_flags(vmode.v_modeattr)
| V_INFO_VESA;
++modes;
}
vesa_vmode[modes].vi_mode = EOT;
if (bootverbose)
printf("VESA: %d mode(s) found\n", modes);
has_vesa_bios = TRUE;
return 0;
}
static void
clear_modes(video_info_t *info, int color)
{
while (info->vi_mode != EOT) {
if ((info->vi_flags & V_INFO_COLOR) != color)
info->vi_mode = NA;
++info;
}
}
/* exported functions */
static int
vesa_init(void)
{
int adapters;
int i;
adapters = (*prevvidsw.init)();
for (i = 0; i < adapters; ++i) {
if ((vesa_adp = (*prevvidsw.adapter)(i)) == NULL)
continue;
if (vesa_adp->va_type == KD_VGA) {
vesa_adp->va_flags |= V_ADP_VESA;
return adapters;
}
}
vesa_adp = NULL;
return adapters;
}
static video_adapter_t
*vesa_adapter(int ad)
{
return (*prevvidsw.adapter)(ad);
}
static int
vesa_get_info(int ad, int mode, video_info_t *info)
{
int i;
if ((*prevvidsw.get_info)(ad, mode, info) == 0)
return 0;
if (ad != vesa_adp->va_index)
return 1;
for (i = 0; vesa_vmode[i].vi_mode != EOT; ++i) {
if (vesa_vmode[i].vi_mode == NA)
continue;
if (vesa_vmode[i].vi_mode == mode) {
*info = vesa_vmode[i];
return 0;
}
}
return 1;
}
static int
vesa_query_mode(int ad, video_info_t *info)
{
int i;
if ((i = (*prevvidsw.query_mode)(ad, info)) != -1)
return i;
if (ad != vesa_adp->va_index)
return -1;
for (i = 0; vesa_vmode[i].vi_mode != EOT; ++i) {
if ((info->vi_width != 0)
&& (info->vi_width != vesa_vmode[i].vi_width))
continue;
if ((info->vi_height != 0)
&& (info->vi_height != vesa_vmode[i].vi_height))
continue;
if ((info->vi_cwidth != 0)
&& (info->vi_cwidth != vesa_vmode[i].vi_cwidth))
continue;
if ((info->vi_cheight != 0)
&& (info->vi_cheight != vesa_vmode[i].vi_cheight))
continue;
if ((info->vi_depth != 0)
&& (info->vi_depth != vesa_vmode[i].vi_depth))
continue;
if ((info->vi_planes != 0)
&& (info->vi_planes != vesa_vmode[i].vi_planes))
continue;
/* pixel format, memory model */
if ((info->vi_flags != 0)
&& (info->vi_flags != vesa_vmode[i].vi_flags))
continue;
return vesa_vmode[i].vi_mode;
}
return -1;
}
static int
vesa_set_mode(int ad, int mode)
{
video_info_t info;
size_t len;
if (ad != vesa_adp->va_index)
return (*prevvidsw.set_mode)(ad, mode);
#ifdef SC_VIDEO_DEBUG
printf("VESA: set_mode(): %d(%x) -> %d(%x)\n",
vesa_adp->va_mode, vesa_adp->va_mode, mode, mode);
#endif
/*
* If the current mode is a VESA mode and the new mode is not,
* restore the state of the adapter first, so that non-standard,
* extended SVGA registers are set to the state compatible with
* the standard VGA modes. Otherwise (*prevvidsw.set_mode)()
* may not be able to set up the new mode correctly.
*/
if (VESA_MODE(vesa_adp->va_mode)) {
if ((*prevvidsw.get_info)(ad, mode, &info) == 0) {
/* assert(vesa_state_buf != NULL); */
if ((vesa_state_buf == NULL)
|| vesa_load_state(ad, vesa_state_buf))
return 1;
free(vesa_state_buf, M_DEVBUF);
vesa_state_buf = NULL;
#ifdef SC_VIDEO_DEBUG
printf("VESA: restored\n");
#endif
}
/*
* once (*prevvidsw.get_info)() succeeded,
* (*prevvidsw.set_mode)() below won't fail...
*/
}
/* we may not need to handle this mode after all... */
if ((*prevvidsw.set_mode)(ad, mode) == 0)
return 0;
/* is the new mode supported? */
if (vesa_get_info(ad, mode, &info))
return 1;
/* assert(VESA_MODE(mode)); */
#ifdef SC_VIDEO_DEBUG
printf("VESA: about to set a VESA mode...\n");
#endif
/*
* If the current mode is not a VESA mode, save the current state
* so that the adapter state can be restored later when a non-VESA
* mode is to be set up. See above.
*/
if (!VESA_MODE(vesa_adp->va_mode) && (vesa_state_buf == NULL)) {
len = vesa_save_state(ad, NULL, 0);
vesa_state_buf = malloc(len, M_DEVBUF, M_WAITOK);
if (vesa_save_state(ad, vesa_state_buf, len)) {
#ifdef SC_VIDEO_DEBUG
printf("VESA: state save failed! (len=%d)\n", len);
#endif
free(vesa_state_buf, M_DEVBUF);
vesa_state_buf = NULL;
return 1;
}
#ifdef SC_VIDEO_DEBUG
printf("VESA: saved (len=%d)\n", len);
dump_buffer(vesa_state_buf, len);
#endif
}
if (vesa_bios_set_mode(mode))
return 1;
#ifdef SC_VIDEO_DEBUG
printf("VESA: mode set!\n");
#endif
vesa_adp->va_mode = mode;
vesa_adp->va_flags &= ~V_ADP_COLOR;
vesa_adp->va_flags |=
(info.vi_flags & V_INFO_COLOR) ? V_ADP_COLOR : 0;
vesa_adp->va_crtc_addr =
(vesa_adp->va_flags & V_ADP_COLOR) ? COLOR_BASE : MONO_BASE;
vesa_adp->va_window = BIOS_PADDRTOVADDR(info.vi_window);
vesa_adp->va_window_size = info.vi_window_size;
vesa_adp->va_window_gran = info.vi_window_gran;
if (info.vi_buffer_size == 0) {
vesa_adp->va_buffer = 0;
vesa_adp->va_buffer_size = 0;
} else {
vesa_adp->va_buffer = BIOS_PADDRTOVADDR(info.vi_buffer);
vesa_adp->va_buffer_size = info.vi_buffer_size;
}
return 0;
}
static int
vesa_save_font(int ad, int page, int fontsize, u_char *data, int ch, int count)
{
return (*prevvidsw.save_font)(ad, page, fontsize, data, ch, count);
}
static int
vesa_load_font(int ad, int page, int fontsize, u_char *data, int ch, int count)
{
return (*prevvidsw.load_font)(ad, page, fontsize, data, ch, count);
}
static int
vesa_show_font(int ad, int page)
{
return (*prevvidsw.show_font)(ad, page);
}
static int
vesa_save_palette(int ad, u_char *palette)
{
if ((ad != vesa_adp->va_index) || !(vesa_adp_info->v_flags & V_DAC8)
|| vesa_bios_set_dac(8))
return (*prevvidsw.save_palette)(ad, palette);
return vesa_bios_save_palette(0, 256, palette);
}
static int
vesa_load_palette(int ad, u_char *palette)
{
if ((ad != vesa_adp->va_index) || !(vesa_adp_info->v_flags & V_DAC8)
|| vesa_bios_set_dac(8))
return (*prevvidsw.load_palette)(ad, palette);
return vesa_bios_load_palette(0, 256, palette);
}
static int
vesa_set_border(int ad, int color)
{
return (*prevvidsw.set_border)(ad, color);
}
static int
vesa_save_state(int ad, void *p, size_t size)
{
if (ad != vesa_adp->va_index)
return (*prevvidsw.save_state)(ad, p, size);
if (vesa_state_buf_size == 0)
vesa_state_buf_size = vesa_bios_state_buf_size();
if (size == 0)
return (sizeof(int) + vesa_state_buf_size);
else if (size < (sizeof(int) + vesa_state_buf_size))
return 1;
((adp_state_t *)p)->sig = V_STATE_SIG;
bzero(((adp_state_t *)p)->regs, vesa_state_buf_size);
return vesa_bios_save_restore(STATE_SAVE, ((adp_state_t *)p)->regs,
vesa_state_buf_size);
}
static int
vesa_load_state(int ad, void *p)
{
if ((ad != vesa_adp->va_index)
|| (((adp_state_t *)p)->sig != V_STATE_SIG))
return (*prevvidsw.load_state)(ad, p);
return vesa_bios_save_restore(STATE_LOAD, ((adp_state_t *)p)->regs,
vesa_state_buf_size);
}
static int
vesa_set_origin(int ad, off_t offset)
{
struct vm86frame vmf;
int err;
/*
* This function should return as quickly as possible to
* maintain good performance of the system. For this reason,
* error checking is kept minimal and let the VESA BIOS to
* detect error.
*/
if (ad != vesa_adp->va_index)
return (*prevvidsw.set_win_org)(ad, offset);
if (vesa_adp->va_window_gran == 0)
return 1;
bzero(&vmf, sizeof(vmf));
vmf.vmf_eax = 0x4f05;
vmf.vmf_ebx = 0; /* WINDOW_A, XXX */
vmf.vmf_edx = offset/vesa_adp->va_window_gran;
err = vm86_intcall(0x10, &vmf);
return ((err != 0) || (vmf.vmf_eax != 0x4f));
}
static int
vesa_read_hw_cursor(int ad, int *col, int *row)
{
return (*prevvidsw.read_hw_cursor)(ad, col, row);
}
static int
vesa_set_hw_cursor(int ad, int col, int row)
{
return (*prevvidsw.set_hw_cursor)(ad, col, row);
}
static int
vesa_diag(int level)
{
struct vesa_mode vmode;
u_int32_t p;
int i;
/* general adapter information */
printf("VESA: v%d.%d, %dk memory, flags:0x%x, mode table:%p (%x)\n",
((vesa_adp_info->v_version & 0xf000) >> 12) * 10
+ ((vesa_adp_info->v_version & 0x0f00) >> 8),
((vesa_adp_info->v_version & 0x00f0) >> 4) * 10
+ (vesa_adp_info->v_version & 0x000f),
vesa_adp_info->v_memsize * 64, vesa_adp_info->v_flags,
vesa_vmodetab, vesa_adp_info->v_modetable);
/* OEM string */
p = BIOS_SADDRTOLADDR(vesa_adp_info->v_oemstr);
if (p != 0)
printf("VESA: %s\n", (char *)BIOS_PADDRTOVADDR(p));
if (level <= 0)
return 0;
if (vesa_adp_info->v_version >= 0x0200) {
/* vendor name */
p = BIOS_SADDRTOLADDR(vesa_adp_info->v_venderstr);
if (p != 0)
printf("VESA: %s, ", (char *)BIOS_PADDRTOVADDR(p));
/* product name */
p = BIOS_SADDRTOLADDR(vesa_adp_info->v_prodstr);
if (p != 0)
printf("%s, ", (char *)BIOS_PADDRTOVADDR(p));
/* product revision */
p = BIOS_SADDRTOLADDR(vesa_adp_info->v_revstr);
if (p != 0)
printf("%s\n", (char *)BIOS_PADDRTOVADDR(p));
}
/* mode information */
for (i = 0; vesa_vmodetab[i] != 0xffff; ++i) {
if (vesa_bios_get_mode(vesa_vmodetab[i], &vmode))
continue;
/* print something for diagnostic purpose */
printf("VESA: mode:0x%03x, flags:0x%04x",
vesa_vmodetab[i], vmode.v_modeattr);
if (vmode.v_modeattr & V_MODEOPTINFO) {
if (vmode.v_modeattr & V_MODEGRAPHICS) {
printf(", G %dx%dx%d %d, ",
vmode.v_width, vmode.v_height,
vmode.v_bpp, vmode.v_planes);
} else {
printf(", T %dx%d, ",
vmode.v_width, vmode.v_height);
}
printf("font:%dx%d",
vmode.v_cwidth, vmode.v_cheight);
}
if (vmode.v_modeattr & V_MODELFB) {
printf(", mem:%d, LFB:0x%x, off:0x%x",
vmode.v_memmodel, vmode.v_lfb,
vmode.v_offscreen);
}
printf("\n");
printf("VESA: window A:0x%x (%x), window B:0x%x (%x), ",
vmode.v_waseg, vmode.v_waattr,
vmode.v_wbseg, vmode.v_wbattr);
printf("size:%dk, gran:%dk\n",
vmode.v_wsize, vmode.v_wgran);
}
return 0;
}
/* module loading */
#ifdef VESA_MODULE
static int
vesa_load(struct lkm_table *lkmtp, int cmd)
#else
int
vesa_load(void)
#endif
{
int adapters;
int error;
int s;
int i;
if (vesa_init_done)
return 0;
/*
* If the VESA module is statically linked to the kernel, or
* it has already been loaded, abort loading this module this time.
*/
vesa_adp = NULL;
adapters = (*biosvidsw.init)();
for (i = 0; i < adapters; ++i) {
if ((vesa_adp = (*biosvidsw.adapter)(i)) == NULL)
continue;
if (vesa_adp->va_flags & V_ADP_VESA)
return ENXIO;
if (vesa_adp->va_type == KD_VGA)
break;
}
/* if a VGA adapter is not found, abort */
if (i >= adapters)
return ENXIO;
if (vesa_bios_init())
return ENXIO;
vesa_adp->va_flags |= V_ADP_VESA;
/* remove conflicting modes if we have more than one adapter */
if (adapters > 1) {
clear_modes(vesa_vmode,
(vesa_adp->va_flags & V_ADP_COLOR) ?
V_INFO_COLOR : 0);
}
#ifdef VESA_MODULE
s = spltty();
#endif
if ((error = vesa_load_ioctl()) == 0) {
bcopy(&biosvidsw, &prevvidsw, sizeof(prevvidsw));
bcopy(&vesavidsw, &biosvidsw, sizeof(vesavidsw));
vesa_init_done = TRUE;
}
#ifdef VESA_MODULE
splx(s);
if (error == 0)
vesa_diag(bootverbose);
#endif
return error;
}
#ifdef VESA_MODULE
static int
vesa_unload(struct lkm_table *lkmtp, int cmd)
{
int error;
int s;
/* if the adapter is currently in a VESA mode, don't unload */
if ((vesa_adp != NULL) && VESA_MODE(vesa_adp->va_mode))
return EBUSY;
/*
* FIXME: if there is at least one vty which is in a VESA mode,
* we shouldn't be unloading! XXX
*/
s = spltty();
if ((error = vesa_unload_ioctl()) == 0) {
if (vesa_adp)
vesa_adp->va_flags &= ~V_ADP_VESA;
bcopy(&prevvidsw, &biosvidsw, sizeof(biosvidsw));
}
splx(s);
return error;
}
int
vesa_mod(struct lkm_table *lkmtp, int cmd, int ver)
{
MOD_DISPATCH(vesa, lkmtp, cmd, ver,
vesa_load, vesa_unload, lkm_nullcmd);
}
#endif /* VESA_MODULE */
#endif /* (NSC > 0 && VESA && VM86) || VESA_MODULE */

1612
sys/i386/isa/videoio.c Normal file

File diff suppressed because it is too large Load Diff

107
sys/i386/isa/videoio.h Normal file
View File

@ -0,0 +1,107 @@
/*-
* Copyright (c) 1998 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.
* 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. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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$
*/
#ifndef _I386_ISA_VIDEOIO_H_
#define _I386_ISA_VIDEOIO_H_
#ifdef KERNEL
#define V_MAX_ADAPTERS 2
#define V_MODE_MAP_SIZE (M_VGA_CG320 + 1)
#define V_MODE_PARAM_SIZE 64
/* physical addresses */
#define MONO_BUF BIOS_PADDRTOVADDR(0xb0000)
#define CGA_BUF BIOS_PADDRTOVADDR(0xb8000)
#define GRAPHICS_BUF BIOS_PADDRTOVADDR(0xa0000)
#define VIDEOMEM 0x000A0000
/* I/O port addresses */
#define MONO_BASE 0x3B4 /* crt controller base mono */
#define COLOR_BASE 0x3D4 /* crt controller base color */
#define MISC 0x3C2 /* misc output register */
#define ATC IO_VGA+0x00 /* attribute controller */
#define TSIDX IO_VGA+0x04 /* timing sequencer idx */
#define TSREG IO_VGA+0x05 /* timing sequencer data */
#define PIXMASK IO_VGA+0x06 /* pixel write mask */
#define PALRADR IO_VGA+0x07 /* palette read address */
#define PALWADR IO_VGA+0x08 /* palette write address */
#define PALDATA IO_VGA+0x09 /* palette data register */
#define GDCIDX IO_VGA+0x0E /* graph data controller idx */
#define GDCREG IO_VGA+0x0F /* graph data controller data */
/* video function table */
typedef int vi_init_t(void);
typedef video_adapter_t *vi_adapter_t(int ad);
typedef int vi_get_info_t(int ad, int mode, video_info_t *info);
typedef int vi_query_mode_t(int ad, video_info_t *info);
typedef int vi_set_mode_t(int ad, int mode);
typedef int vi_save_font_t(int ad, int page, int size, u_char *data,
int c, int count);
typedef int vi_load_font_t(int ad, int page, int size, u_char *data,
int c, int count);
typedef int vi_show_font_t(int ad, int page);
typedef int vi_save_palette_t(int ad, u_char *palette);
typedef int vi_load_palette_t(int ad, u_char *palette);
typedef int vi_set_border_t(int ad, int border);
typedef int vi_save_state_t(int ad, void *p, size_t size);
typedef int vi_load_state_t(int ad, void *p);
typedef int vi_set_win_org_t(int ad, off_t offset);
typedef int vi_read_hw_cursor_t(int ad, int *col, int *row);
typedef int vi_set_hw_cursor_t(int ad, int col, int row);
typedef int vi_diag_t(int level);
struct vidsw {
vi_init_t *init; /* all */
vi_adapter_t *adapter; /* all */
vi_get_info_t *get_info; /* all */
vi_query_mode_t *query_mode; /* all */
vi_set_mode_t *set_mode; /* EGA/VGA */
vi_save_font_t *save_font; /* EGA/VGA */
vi_load_font_t *load_font; /* EGA/VGA */
vi_show_font_t *show_font; /* EGA/VGA */
vi_save_palette_t *save_palette; /* VGA */
vi_load_palette_t *load_palette; /* VGA */
vi_set_border_t *set_border; /* CGA/EGA/VGA */
vi_save_state_t *save_state; /* VGA */
vi_load_state_t *load_state; /* EGA/VGA */
vi_set_win_org_t *set_win_org; /* all */
vi_read_hw_cursor_t *read_hw_cursor; /* all */
vi_set_hw_cursor_t *set_hw_cursor; /* all */
vi_diag_t *diag; /* all */
};
extern struct vidsw biosvidsw;
#endif /* KERNEL */
#endif /* !_I386_ISA_VIDEOIO_H_ */

View File

@ -6,13 +6,13 @@
* 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
* in this position and unchanged.
* notice, this list of conditions and the following disclaimer,
* without modification, immediately at the beginning of the file.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@ -25,7 +25,7 @@
* (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: wst.c,v 1.10 1998/08/24 02:28:16 bde Exp $
* $Id$
*/
#include "wdc.h"

View File

@ -1,18 +1,18 @@
/*-
* Copyright (c) 1995 Søren Schmidt
* Copyright (c) 1995-1998 Søren Schmidt
* 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
* in this position and unchanged.
* notice, this list of conditions and the following disclaimer,
* without modification, immediately at the beginning of the file.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software withough specific prior written permission
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@ -25,7 +25,7 @@
* (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: blank_saver.c,v 1.10 1997/07/15 14:49:09 yokota Exp $
* $Id$
*/
#include <sys/param.h>

View File

@ -25,7 +25,7 @@
* (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: daemon_saver.c,v 1.8 1998/01/16 17:58:43 bde Exp $
* $Id: daemon_saver.c,v 1.9 1998/08/06 09:14:20 yokota Exp $
*/
#include <sys/param.h>
@ -205,7 +205,7 @@ daemon_saver(int blank)
/* clear the screen and set the border color */
fillw(((FG_LIGHTGREY|BG_BLACK) << 8) | scr_map[0x20],
Crtat, scp->xsize * scp->ysize);
set_border(0);
set_border(scp, 0);
xlen = ylen = tlen = 0;
}
if (scrn_blanked++ < 2)
@ -322,7 +322,7 @@ daemon_saver(int blank)
draw_string(txpos, typos, toff, (char *)message, tlen);
} else {
if (scrn_blanked > 0) {
set_border(scp->border);
set_border(scp, scp->border);
scrn_blanked = 0;
}
}

View File

@ -1,18 +1,18 @@
/*-
* Copyright (c) 1995-1997 Søren Schmidt
* Copyright (c) 1995-1998 Søren Schmidt
* 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
* in this position and unchanged.
* notice, this list of conditions and the following disclaimer,
* without modification, immediately at the beginning of the file.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software withough specific prior written permission
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@ -25,7 +25,7 @@
* (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: fade_saver.c,v 1.11 1997/07/15 14:49:25 yokota Exp $
* $Id$
*/
#include <sys/param.h>
@ -84,7 +84,7 @@ fade_saver(int blank)
else {
switch (crtc_type) {
case KD_VGA:
load_palette(palette);
load_palette(cur_console, palette);
count = 0;
break;
case KD_EGA:

View File

@ -1,18 +1,18 @@
/*-
* Copyright (c) 1995 Søren Schmidt
* Copyright (c) 1995-1998 Søren Schmidt
* 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
* in this position and unchanged.
* notice, this list of conditions and the following disclaimer,
* without modification, immediately at the beginning of the file.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software withough specific prior written permission
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@ -25,7 +25,7 @@
* (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: green_saver.c,v 1.10 1997/07/15 14:49:29 yokota Exp $
* $Id$
*/
#include <sys/param.h>

View File

@ -1,18 +1,18 @@
/*-
* Copyright (c) 1995-1997 Søren Schmidt
* Copyright (c) 1995-1998 Søren Schmidt
* 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
* in this position and unchanged.
* notice, this list of conditions and the following disclaimer,
* without modification, immediately at the beginning of the file.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software withough specific prior written permission
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@ -25,12 +25,12 @@
* (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: saver.h,v 1.9 1997/07/15 14:48:11 yokota Exp $
* $Id$
*/
#include <machine/apm_bios.h>
#include <machine/console.h>
#include <i386/isa/videoio.h>
#include <i386/isa/syscons.h>
extern scr_stat *cur_console;

View File

@ -1,18 +1,18 @@
/*-
* Copyright (c) 1995 Søren Schmidt
* Copyright (c) 1995-1998 Søren Schmidt
* 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
* in this position and unchanged.
* notice, this list of conditions and the following disclaimer,
* without modification, immediately at the beginning of the file.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software withough specific prior written permission
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@ -25,7 +25,7 @@
* (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: snake_saver.c,v 1.16 1998/01/16 17:58:50 bde Exp $
* $Id$
*/
#include <sys/param.h>
@ -63,7 +63,7 @@ snake_saver(int blank)
if (scrn_blanked <= 0) {
fillw((FG_LIGHTGREY|BG_BLACK)<<8 | scr_map[0x20],
Crtat, scp->xsize * scp->ysize);
set_border(0);
set_border(scp, 0);
dirx = (scp->xpos ? 1 : -1);
diry = (scp->ypos ?
scp->xsize : -scp->xsize);
@ -99,7 +99,7 @@ snake_saver(int blank)
}
else {
if (scrn_blanked > 0) {
set_border(scp->border);
set_border(scp, scp->border);
scrn_blanked = 0;
}
}

View File

@ -1,18 +1,18 @@
/*-
* Copyright (c) 1995 Søren Schmidt
* Copyright (c) 1995-1998 Søren Schmidt
* 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
* in this position and unchanged.
* notice, this list of conditions and the following disclaimer,
* without modification, immediately at the beginning of the file.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software withough specific prior written permission
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@ -25,7 +25,7 @@
* (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: star_saver.c,v 1.13 1998/01/16 17:58:55 bde Exp $
* $Id$
*/
#include <sys/param.h>
@ -62,7 +62,7 @@ star_saver(int blank)
scrn_blanked = 1;
fillw((FG_LIGHTGREY|BG_BLACK)<<8|scr_map[0x20], Crtat,
scp->xsize * scp->ysize);
set_border(0);
set_border(scp, 0);
for(i=0; i<NUM_STARS; i++) {
stars[i][0] =
random() % (scp->xsize*scp->ysize);
@ -80,7 +80,7 @@ star_saver(int blank)
}
else {
if (scrn_blanked > 0) {
set_border(scp->border);
set_border(scp, scp->border);
scrn_blanked = 0;
}
}

View File

@ -6,13 +6,13 @@
* 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
* in this position and unchanged.
* notice, this list of conditions and the following disclaimer,
* without modification, immediately at the beginning of the file.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@ -25,7 +25,7 @@
* (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: wst.c,v 1.10 1998/08/24 02:28:16 bde Exp $
* $Id$
*/
#include "wdc.h"

View File

@ -11,7 +11,7 @@
.\" documentation and/or other materials provided with the distribution.
.\"
.\" @(#)vidcontrol.1
.\" $Id: vidcontrol.1,v 1.11 1997/07/24 23:46:35 wosch Exp $
.\" $Id: vidcontrol.1,v 1.12 1997/10/27 07:52:08 charnier Exp $
.\"
.Dd May 22, 1994
.Dt VIDCONTROL 1
@ -25,6 +25,7 @@
.Op Fl b Ar color
.Op Fl c Ar appearance
.Op Fl d
.Op Fl i Ar adapter|mode
.Op Fl l Ar scrmap
.Op Fl L
.Op Fl m Ar on|off
@ -84,6 +85,10 @@ Install screen output map file from
.Ar scrmap
.It Fl L
Install default screen output map.
.It Fl i Ar adapter
Shows info about the current videoadapter.
.It Fl i Ar mode
Shows the possible videomodes with the current video hardware.
.It Fl m Ar on|off
Switch the mousepointer
.Ar on

View File

@ -28,7 +28,7 @@
#ifndef lint
static const char rcsid[] =
"$Id: vidcontrol.c,v 1.18 1997/10/27 07:52:10 charnier Exp $";
"$Id: vidcontrol.c,v 1.19 1998/07/14 10:32:27 bde Exp $";
#endif /* not lint */
#include <ctype.h>
@ -259,6 +259,7 @@ void
video_mode(int argc, char **argv, int *index)
{
unsigned long mode;
int size[3];
if (*index < argc) {
if (!strcmp(argv[*index], "VGA_40x25"))
@ -277,10 +278,27 @@ video_mode(int argc, char **argv, int *index)
mode = SW_ENH_C80x25;
else if (!strcmp(argv[*index], "EGA_80x43"))
mode = SW_ENH_C80x43;
else if (!strcmp(argv[*index], "VESA_132x25"))
mode = SW_VESA_C132x25;
else if (!strcmp(argv[*index], "VESA_132x43"))
mode = SW_VESA_C132x43;
else if (!strcmp(argv[*index], "VESA_132x50"))
mode = SW_VESA_C132x50;
else if (!strcmp(argv[*index], "VESA_132x60"))
mode = SW_VESA_C132x60;
else if (!strcmp(argv[*index], "VESA_800x600"))
mode = SW_VESA_800x600;
else
return;
if (ioctl(0, mode, NULL) < 0)
warn("cannot set videomode");
if (mode == SW_VESA_800x600) {
size[0] = 80; /* columns */
size[1] = 25; /* rows */
size[2] = 16; /* font size */
if (ioctl(0, KDRASTER, size))
warn("cannot activate raster display");
}
(*index)++;
}
return;
@ -375,6 +393,103 @@ set_mouse(char *arg)
ioctl(0, CONS_MOUSECTL, &mouse);
}
static char
*adapter_name(int type)
{
static struct {
int type;
char *name;
} names[] = {
{ KD_MONO, "MDA" },
{ KD_HERCULES, "Hercules" },
{ KD_CGA, "CGA" },
{ KD_EGA, "EGA" },
{ KD_VGA, "VGA" },
{ KD_PC98, "PC-98xx" },
{ -1, "Unknown" },
};
int i;
for (i = 0; names[i].type != -1; ++i)
if (names[i].type == type)
break;
return names[i].name;
}
void
show_adapter_info(void)
{
struct video_adapter ad;
ad.va_index = 0;
if (ioctl(0, CONS_ADPINFO, &ad)) {
warn("failed to obtain adapter information");
return;
}
printf("adapter %d:\n", ad.va_index);
printf(" type:%s%s (%d), flags:0x%08x, CRTC:0x%x\n",
(ad.va_flags & V_ADP_VESA) ? "VESA " : "",
adapter_name(ad.va_type), ad.va_type,
ad.va_flags, ad.va_crtc_addr);
printf(" initial mode:%d, current mode:%d, BIOS mode:%d\n",
ad.va_initial_mode, ad.va_mode, ad.va_initial_bios_mode);
}
void
show_mode_info(void)
{
struct video_info info;
char buf[80];
int mode;
int c;
printf(" mode# flags type size "
"font window linear buffer\n");
printf("---------------------------------------"
"---------------------------------------\n");
for (mode = 0; mode < M_VESA_MODE_MAX; ++mode) {
info.vi_mode = mode;
if (ioctl(0, CONS_MODEINFO, &info))
continue;
printf("%3d (0x%03x)", mode, mode);
printf(" 0x%08x", info.vi_flags);
if (info.vi_flags & V_INFO_GRAPHICS) {
c = 'G';
snprintf(buf, sizeof(buf), "%dx%dx%d %d",
info.vi_width, info.vi_height,
info.vi_depth, info.vi_planes);
} else {
c = 'T';
snprintf(buf, sizeof(buf), "%dx%d",
info.vi_width, info.vi_height);
}
printf(" %c %-15s", c, buf);
snprintf(buf, sizeof(buf), "%dx%d",
info.vi_cwidth, info.vi_cheight);
printf(" %-5s", buf);
printf(" 0x%05x %2dk %2dk",
info.vi_window, info.vi_window_size,
info.vi_window_gran);
printf(" 0x%08x %2dk\n",
info.vi_buffer, info.vi_buffer_size);
}
}
void
show_info(char *arg)
{
if (!strcmp(arg, "adapter"))
show_adapter_info();
else if (!strcmp(arg, "mode"))
show_mode_info();
else {
warnx("argument to -i must either adapter or mode");
return;
}
}
void
test_frame()
{
@ -402,7 +517,7 @@ main(int argc, char **argv)
info.size = sizeof(info);
if (ioctl(0, CONS_GETINFO, &info) < 0)
err(1, "must be on a virtual console");
while((opt = getopt(argc, argv, "b:c:df:l:Lm:r:s:t:x")) != -1)
while((opt = getopt(argc, argv, "b:c:df:i:l:Lm:r:s:t:x")) != -1)
switch(opt) {
case 'b':
set_border_color(optarg);
@ -417,6 +532,9 @@ main(int argc, char **argv)
load_font(optarg,
nextarg(argc, argv, &optind, 'f'));
break;
case 'i':
show_info(optarg);
break;
case 'l':
load_scrnmap(optarg);
break;