Subject: port-i386/9897: i386 boot doesn't reset video mode
To: None <gnats-bugs@gnats.netbsd.org>
From: None <gillham@vaultron.com>
List: netbsd-bugs
Date: 04/15/2000 22:26:12
>Number:         9897
>Category:       port-i386
>Synopsis:       i386 boot doesn't reset video mode
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    port-i386-maintainer
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat Apr 15 22:27:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Andrew Gillham
>Release:        2000/04/13
>Organization:
	
>Environment:
System: NetBSD flash.vaultron.com 1.4X NetBSD 1.4X (FLASH) #2: Thu Apr 13 22:04:31 EDT 2000 root@flash.vaultron.com:/usr/src/sys/arch/i386/compile/FLASH i386


>Description:
	The code in src/sys/arch/i386/stand uses the video card in the
	state the BIOS left it.  On some systems, this means graphics mode.
	(e.g. Netpliance I-Opener)  On other systems there may be various
	"artifacts" on the screen that the boot code overwrites.
	This code provides a 'biosvideomode' call that resets the current
	video mode to 80x25 (this will be selectable in the future perhaps.)
	Also, a text logo was added based on Greywolf's .sig.

	Without this code, an I-opener will not boot successfully without
	user intervention.  The BIOS leaves a logo on the screen, leaving
	the screen in a graphics mode.  The biosboot code is able to output
	charaters, but when the kernel is loaded and initialized it is
	unable to use the console. (and the machine "hangs" though it might
	be continuing it's boot, but it is hard to tell)

	This code call INT 10 to set the video mode which has the side effect
	(benefit) of clearing the screen.  Combined with the text logo, this
	looks nice to me.

>How-To-Repeat:
	Boot NetBSD/i386 on an I-Opener.
>Fix:

--- biosboot/main.c.orig	Thu Mar 30 07:21:47 2000
+++ biosboot/main.c	Sun Apr 16 01:45:34 2000
@@ -236,6 +236,13 @@
 #endif
 	gateA20();
 
+	biosvideomode();
+	printf("    ______ _   __     __  ____ _____ ____  \n");
+	printf("   ______ / |_/ /__  / /_/ __ ) ___// __ \\ \n");
+	printf("  ______ /  |/ / _ \\/ __/ __  \\__ \\/ / / / \n");
+	printf(" ______ / /|  /  __/ /_/ /_/ /__/ / /_/ /  \n");
+	printf("______ /_/ |_/\\___/\\__/_____/____/_____/   \n");
+
 	print_banner();
 
 	/* try to set default device to what BIOS tells us */
--- dosboot/main.c.orig	Mon Mar 13 07:36:33 2000
+++ dosboot/main.c	Sun Apr 16 01:52:53 2000
@@ -262,6 +262,13 @@
 #endif
 	gateA20();
 
+	biosvideomode();
+	printf("    ______ _   __     __  ____ _____ ____  \n");
+	printf("   ______ / |_/ /__  / /_/ __ ) ___// __ \\ \n");
+	printf("  ______ /  |/ / _ \\/ __/ __  \\__ \\/ / / / \n");
+	printf(" ______ / /|  /  __/ /_/ /_/ /__/ / /_/ /  \n");
+	printf("______ /_/ |_/\\___/\\__/_____/____/_____/   \n");
+
 	print_banner();
 
 	current_fsmode = "dos";
--- lib/Makefile.orig	Sun Apr 16 01:50:41 2000
+++ lib/Makefile	Sun Apr 16 02:02:22 2000
@@ -15,7 +15,7 @@
 #CPPFLAGS+= -DNO_DISKLABEL
 #CPPFLAGS+= -DSAVE_MEMORY
 
-SRCS= pcio.c conio.S comio.S comio_direct.c
+SRCS= pcio.c conio.S comio.S comio_direct.c biosvideomode.S
 SRCS+= getsecs.c biosgetrtc.S biosdelay.S biosreboot.S gatea20.c
 SRCS+= biosmem.S getextmemx.c biosmemx.S printmemlist.c
 SRCS+= pread.c menuutils.c parseutils.c
--- /dev/null	Sun Apr 16 02:06:57 2000
+++ lib/biosvideomode.S	Sun Apr 16 01:49:59 2000
@@ -0,0 +1,67 @@
+
+/*
+ * Copyright (c) 1996
+ * 	Perry E. Metzger.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgements:
+ *	This product includes software developed for the NetBSD Project
+ *	by Perry E. Metzger.
+ * 4. The names of the authors may not be used to endorse or promote products
+ *    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
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR 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.
+ *
+ */
+	
+
+#include <machine/asm.h>
+
+#define	data32	.byte 0x66
+
+	.text
+
+ENTRY(biosvideomode)
+	pushl	%ebp
+	movl	%esp,%ebp
+	pushl	%ebx
+	push	%esi
+	push	%edi
+
+	call	_C_LABEL(prot_to_real)
+
+	movb	$0, %ah
+	movb	$2, %al
+	int	$0x10
+	# zero-extend 16-bit result to 32 bits.
+	data32
+	movl	$0, %ebx
+	mov	%eax,%ebx		# !!! at run time, it is mov %ax,%bx
+
+	data32
+	call	_C_LABEL(real_to_prot)
+
+	movl	%ebx, %eax
+
+	pop	%edi
+	pop	%esi
+	popl	%ebx
+	popl	%ebp
+	ret
--- lib/libi386.h.orig	Wed Dec 22 17:33:50 1999
+++ lib/libi386.h	Sun Apr 16 01:01:56 2000
@@ -50,6 +50,7 @@
 int getbasemem __P((void));
 int getextmemx __P((void));
 int getextmem1 __P((void));
+int biosvideomode __P((void));
 #ifdef CONSERVATIVE_MEMDETECT
 #define getextmem() getextmem1()
 #else
--- netboot/main.c.orig	Thu Sep 18 07:54:18 1997
+++ netboot/main.c	Sun Apr 16 01:54:13 2000
@@ -117,6 +117,13 @@
 	initio(CONSDEV_AUTO);
 	gateA20();
 
+	biosvideomode();
+	printf("    ______ _   __     __  ____ _____ ____  \n");
+	printf("   ______ / |_/ /__  / /_/ __ ) ___// __ \\ \n");
+	printf("  ______ /  |/ / _ \\/ __/ __  \\__ \\/ / / / \n");
+	printf(" ______ / /|  /  __/ /_/ /_/ /__/ / /_/ /  \n");
+	printf("______ /_/ |_/\\___/\\__/_____/____/_____/   \n");
+
 	print_banner();
 
 	c = awaitkey(TIMEOUT, 1);
>Release-Note:
>Audit-Trail:
>Unformatted: