Subject: setting video mode in biosboot..
To: None <port-i386@netbsd.org>
From: Andrew Gillham <gillhaa@ghost.whirlpool.com>
List: port-i386
Date: 04/16/2000 01:39:34
Hi,

I just filed a PR on this, but thought I would send the code here
as well for some feedback.
Basically, my Netpliance I-Opener boots up and shows a graphical
logo while the BIOS does the POST and during the actual disk boot.
As a result, biosboot is loaded with the video still in graphics
mode.  This is ok for biosboot since it makes BIOS calls for output,
but as soon as it loads the kernel, all output stops.  It seems
like the kernel doesn't keep going,  but I'm not sure about this.

So I added a 'biosvideomode' function and call it just before
the 'print_banner' in biosboot.  This has the effect of switching
back to 80x25 and clearing the screen.  Combine this with printing
the text logo from Greywolf's .sig (hope you don't mind!) and it
looks pretty nice on my I-Opener.  And it will reboot cleanly without
manual intervention. (e.g. operator pressing TAB during boot)

Potentially wrapping the new stuff in a check for SUPPORT_SERIAL
might be appropriate to avoid calling a video function with no
video?  Or should biosvideomode() check for a video card signature?

Anyway, feedback, suggestions, complaints welcomed. :)

--- 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);

-Andrew
-----------------------------------------------------------------
Andrew Gillham                            | NetBSD ist Affengeil.
gillham@whirlpool.com                     | Nachts ist es kaelter
I speak for myself, not for my employer.  | als draussen.