From owner-freebsd-bugs Sat Jan 16 02:30:07 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id CAA28619 for freebsd-bugs-outgoing; Sat, 16 Jan 1999 02:30:07 -0800 (PST) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id CAA28597 for ; Sat, 16 Jan 1999 02:30:02 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id CAA25291; Sat, 16 Jan 1999 02:30:02 -0800 (PST) Date: Sat, 16 Jan 1999 02:30:02 -0800 (PST) Message-Id: <199901161030.CAA25291@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.ORG From: Kazutaka YOKOTA Subject: Re: kern/9520: VESA Console Lock-ups Reply-To: Kazutaka YOKOTA Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org The following reply was made to PR kern/9520; it has been noted by GNATS. From: Kazutaka YOKOTA To: aa8vb@pagesz.net Cc: FreeBSD-gnats-submit@freebsd.org, yokota@zodiac.mech.utsunomiya-u.ac.jp Subject: Re: kern/9520: VESA Console Lock-ups Date: Sat, 16 Jan 1999 19:27:39 +0900 In my previous mail to you, I wrote: >>>Number: 9520 >>>Category: kern >>>Synopsis: VESA Console Lock-ups >[...] >>>Release: FreeBSD 3.0-RELEASE i386 >>>Organization: >>self >>>Environment: >> >> Stock 3.0-RELEASE. VESA and VM86 options in compiled into kernel. [...] >> I like the new VESA support! However, if I'm not careful I can >> lock my system pretty easily. For example, switch ttyv0 to >> 132x43, then Alt-F2 over to ttyv1. Instant lock. If I switch >> all the ttys over to the same mode before a tty switch (via >> vidcontrol < /dev/ttyv1 132x40, etc.) then tty switches seem >> to work OK. However if I try to switch ttyv0 back to 80x60 while >> ttyv0 is active, I hit another lock up. > >Is it actually lockup? Does the system beeps when you type anything >after switching to ttyv0? > >I wonder if it is possible to type Alt-F1 to get back to ttyv0... > >I have some theory and will send you a patch shortly. Ok, here is the patch. It is relative to 3.0-RELEASE. However, I have not tested this patch as I don't have a 3.0-RELEASE box around me at the moment. Apply the patch to /sys/i386/isa/vesa.c and rebuild the kernel. Please report if it works. Kazu yokota@FreeBSD.ORG --- vesa.c-1.8 Sat Jan 16 18:55:46 1999 +++ vesa.c Sat Jan 16 19:15:31 1999 @@ -118,11 +118,14 @@ /* local macros and functions */ #define BIOS_SADDRTOLADDR(p) ((((p) & 0xffff0000) >> 12) + ((p) & 0x0000ffff)) +static int int10_set_mode(int mode); 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); +static int vesa_bios_save_palette(int start, int colors, u_char *palette, + int bits); +static int vesa_bios_load_palette(int start, int colors, u_char *palette, + int bits); #define STATE_SIZE 0 #define STATE_SAVE 1 #define STATE_LOAD 2 @@ -153,6 +156,18 @@ } } +/* INT 10 BIOS calls */ +static int +int10_set_mode(int mode) +{ + struct vm86frame vmf; + + bzero(&vmf, sizeof(vmf)); + vmf.vmf_eax = 0x0000 | mode; + vm86_intcall(0x10, &vmf); + return 0; +} + /* VESA BIOS calls */ static int vesa_bios_get_mode(int mode, struct vesa_mode *vmode) @@ -196,11 +211,13 @@ vmf.vmf_eax = 0x4f08; vmf.vmf_ebx = (bits << 8); err = vm86_intcall(0x10, &vmf); - return ((err != 0) || (vmf.vmf_eax != 0x4f)); + if ((err != 0) || (vmf.vmf_eax != 0x4f)) + return 6; /* XXX */ + return ((vmf.vmf_ebx >> 8) & 0x00ff); } static int -vesa_bios_save_palette(int start, int colors, u_char *palette) +vesa_bios_save_palette(int start, int colors, u_char *palette, int bits) { struct vm86frame vmf; u_char *p; @@ -220,17 +237,18 @@ return 1; } + bits = 8 - bits; 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]; + palette[i*3] = p[i*4 + 2] << bits; + palette[i*3 + 1] = p[i*4 + 1] << bits; + palette[i*3 + 2] = p[i*4] << bits; } free(p, M_DEVBUF); return 0; } static int -vesa_bios_load_palette(int start, int colors, u_char *palette) +vesa_bios_load_palette(int start, int colors, u_char *palette, int bits) { struct vm86frame vmf; u_char *p; @@ -238,11 +256,12 @@ int i; p = malloc(colors*4, M_DEVBUF, M_WAITOK); + bits = 8 - bits; 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]; + p[i*4] = palette[i*3 + 2] >> bits; + p[i*4 + 1] = palette[i*3 + 1] >> bits; + p[i*4 + 2] = palette[i*3] >> bits; + p[i*4 + 3] = 0; } bzero(&vmf, sizeof(vmf)); @@ -664,21 +683,35 @@ 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); + int bits; + int error; - return vesa_bios_save_palette(0, 256, palette); + if ((ad == vesa_adp->va_index) && (vesa_adp_info->v_flags & V_DAC8) + && ((bits = vesa_bios_set_dac(8)) > 6)) { + error = vesa_bios_save_palette(0, 256, palette, bits); + if (error == 0) + return 0 + vesa_bios_set_dac(6); + } + + return (*prevvidsw->save_palette)(ad, palette); } static int -vesa_load_palette(int ad, u_char *palette) +vesa_load_palette(video_adapter_t *adp, 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); + int bits; + int error; + + if ((ad == vesa_adp->va_index) && (vesa_adp_info->v_flags & V_DAC8) + && ((bits = vesa_bios_set_dac(8)) > 6)) { + error = vesa_bios_load_palette(0, 256, palette, bits); + if (error == 0) + return 0 + vesa_bios_set_dac(6); + } - return vesa_bios_load_palette(0, 256, palette); + return (*prevvidsw->load_palette)(ad, palette); } static int To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message