scvesactl.c revision 39668
139287Ssos/*- 239643Syokota * Copyright (c) 1998 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp> 339287Ssos * All rights reserved. 439287Ssos * 539287Ssos * Redistribution and use in source and binary forms, with or without 639287Ssos * modification, are permitted provided that the following conditions 739287Ssos * are met: 839287Ssos * 1. Redistributions of source code must retain the above copyright 939643Syokota * notice, this list of conditions and the following disclaimer as 1039643Syokota * the first lines of this file unmodified. 1139287Ssos * 2. Redistributions in binary form must reproduce the above copyright 1239287Ssos * notice, this list of conditions and the following disclaimer in the 1339287Ssos * documentation and/or other materials provided with the distribution. 1439287Ssos * 1539643Syokota * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1639643Syokota * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1739643Syokota * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1839643Syokota * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 1939643Syokota * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2039643Syokota * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2139643Syokota * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2239643Syokota * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2339643Syokota * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2439643Syokota * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2539287Ssos * 2639668Syokota * $Id: scvesactl.c,v 1.4 1998/09/26 03:34:10 yokota Exp $ 2739287Ssos */ 2839287Ssos 2939287Ssos#include "sc.h" 3039287Ssos#include "opt_vesa.h" 3139287Ssos#include "opt_vm86.h" 3239287Ssos 3339287Ssos#if (NSC > 0 && defined(VESA) && defined(VM86)) || defined(VESA_MODULE) 3439287Ssos 3539287Ssos#include <sys/param.h> 3639287Ssos#include <sys/systm.h> 3739668Syokota#include <sys/conf.h> 3839287Ssos#include <sys/tty.h> 3939287Ssos#include <sys/kernel.h> 4039287Ssos 4139287Ssos#include <machine/apm_bios.h> 4239287Ssos#include <machine/console.h> 4339287Ssos#include <machine/pc/vesa.h> 4439287Ssos 4539287Ssos#include <i386/isa/videoio.h> 4639287Ssos#include <i386/isa/syscons.h> 4739287Ssos 4839667Syokotastatic d_ioctl_t *prev_user_ioctl; 4939287Ssos 5039667Syokotastatic int 5139667Syokotavesa_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) 5239287Ssos{ 5339287Ssos scr_stat *scp; 5439287Ssos struct tty *tp; 5539287Ssos video_info_t info; 5639287Ssos video_adapter_t *adp; 5739287Ssos int mode; 5839287Ssos int error; 5939287Ssos int s; 6039287Ssos 6139287Ssos tp = scdevtotty(dev); 6239287Ssos if (!tp) 6339287Ssos return ENXIO; 6439287Ssos scp = sc_get_scr_stat(tp->t_dev); 6539287Ssos 6639287Ssos switch (cmd) { 6739287Ssos case SW_VESA_USER: 6839287Ssos 6939287Ssos mode = (int)data; 7039287Ssos if ((*biosvidsw.get_info)(scp->adp, mode, &info)) 7139287Ssos return ENODEV; 7239287Ssos if (info.vi_flags & V_INFO_GRAPHICS) 7339287Ssos goto vesa_graphics; 7439287Ssos else 7539287Ssos goto vesa_text; 7639287Ssos 7739591Syokota /* generic text modes */ 7839591Syokota case SW_TEXT_132x25: case SW_TEXT_132x30: 7939591Syokota case SW_TEXT_132x43: case SW_TEXT_132x50: 8039591Syokota case SW_TEXT_132x60: 8139591Syokota adp = get_adapter(scp); 8239591Syokota if (!(adp->va_flags & V_ADP_MODECHANGE)) 8339591Syokota return ENODEV; 8439591Syokota return sc_set_text_mode(scp, tp, cmd & 0xff, 0, 0, 0); 8539591Syokota 8639287Ssos /* text modes */ 8739287Ssos case SW_VESA_C80x60: 8839287Ssos case SW_VESA_C132x25: 8939287Ssos case SW_VESA_C132x43: 9039287Ssos case SW_VESA_C132x50: 9139287Ssos case SW_VESA_C132x60: 9239287Ssos adp = get_adapter(scp); 9339287Ssos if (!(adp->va_flags & V_ADP_MODECHANGE)) 9439287Ssos return ENODEV; 9539287Ssos mode = (cmd & 0xff) + M_VESA_BASE; 9639287Ssosvesa_text: 9739287Ssos return sc_set_text_mode(scp, tp, mode, 0, 0, 0); 9839287Ssos 9939287Ssos /* graphics modes */ 10039287Ssos case SW_VESA_32K_320: case SW_VESA_64K_320: 10139287Ssos case SW_VESA_FULL_320: 10239287Ssos 10339287Ssos case SW_VESA_CG640x400: 10439287Ssos 10539287Ssos case SW_VESA_CG640x480: 10639287Ssos case SW_VESA_32K_640: case SW_VESA_64K_640: 10739287Ssos case SW_VESA_FULL_640: 10839287Ssos 10939287Ssos case SW_VESA_800x600: case SW_VESA_CG800x600: 11039287Ssos case SW_VESA_32K_800: case SW_VESA_64K_800: 11139287Ssos case SW_VESA_FULL_800: 11239287Ssos 11339287Ssos case SW_VESA_1024x768: case SW_VESA_CG1024x768: 11439287Ssos case SW_VESA_32K_1024: case SW_VESA_64K_1024: 11539287Ssos case SW_VESA_FULL_1024: 11639287Ssos 11739287Ssos case SW_VESA_1280x1024: case SW_VESA_CG1280x1024: 11839287Ssos case SW_VESA_32K_1280: case SW_VESA_64K_1280: 11939287Ssos case SW_VESA_FULL_1280: 12039287Ssos adp = get_adapter(scp); 12139287Ssos if (!(adp->va_flags & V_ADP_MODECHANGE)) 12239287Ssos return ENODEV; 12339287Ssos mode = (cmd & 0xff) + M_VESA_BASE; 12439287Ssosvesa_graphics: 12539287Ssos return sc_set_graphics_mode(scp, tp, mode); 12639287Ssos } 12739287Ssos 12839287Ssos if (prev_user_ioctl) 12939287Ssos return (*prev_user_ioctl)(dev, cmd, data, flag, p); 13039287Ssos else 13139287Ssos return ENOIOCTL; 13239287Ssos} 13339287Ssos 13439287Ssosint 13539287Ssosvesa_load_ioctl(void) 13639287Ssos{ 13739287Ssos if (prev_user_ioctl) 13839287Ssos return EBUSY; 13939287Ssos prev_user_ioctl = sc_user_ioctl; 14039287Ssos sc_user_ioctl = vesa_ioctl; 14139287Ssos return 0; 14239287Ssos} 14339287Ssos 14439287Ssosint 14539287Ssosvesa_unload_ioctl(void) 14639287Ssos{ 14739287Ssos if (sc_user_ioctl != vesa_ioctl) 14839287Ssos return EBUSY; 14939287Ssos sc_user_ioctl = prev_user_ioctl; 15039287Ssos prev_user_ioctl = NULL; 15139287Ssos return 0; 15239287Ssos} 15339287Ssos 15439287Ssos#endif /* (NSC > 0 && VESA && VM86) || VESA_MODULE */ 155