Module Name:    src
Committed By:   jmcneill
Date:           Mon Sep 14 11:56:28 UTC 2009

Modified Files:
        src/sys/arch/i386/stand/lib: exec.c vbe.c vbe.h
        src/sys/arch/i386/stand/pxeboot: main.c

Log Message:
Don't commit the selected VBE mode until the loader is past the point of
no return; need to stick in text mode as long as possible since libsa does
not include a rasops library. While here, add the 'vesa' command to pxeboot
to mirror biosboot behaviour.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/i386/stand/lib/exec.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/i386/stand/lib/vbe.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/lib/vbe.h
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/i386/stand/pxeboot/main.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/i386/stand/lib/exec.c
diff -u src/sys/arch/i386/stand/lib/exec.c:1.41 src/sys/arch/i386/stand/lib/exec.c:1.42
--- src/sys/arch/i386/stand/lib/exec.c:1.41	Sun Sep 13 18:13:37 2009
+++ src/sys/arch/i386/stand/lib/exec.c	Mon Sep 14 11:56:27 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.41 2009/09/13 18:13:37 jmcneill Exp $	 */
+/*	$NetBSD: exec.c,v 1.42 2009/09/14 11:56:27 jmcneill Exp $	 */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -114,6 +114,7 @@
 #include "libi386.h"
 #include "bootinfo.h"
 #include "bootmod.h"
+#include "vbe.h"
 #ifdef SUPPORT_PS2
 #include "biosmca.h"
 #endif
@@ -289,8 +290,6 @@
 	BI_ALLOC(32); /* ??? */
 
 	BI_ADD(&btinfo_console, BTINFO_CONSOLE, sizeof(struct btinfo_console));
-	BI_ADD(&btinfo_framebuffer, BTINFO_FRAMEBUFFER,
-	    sizeof(struct btinfo_framebuffer));
 
 	howto = boothowto;
 
@@ -323,6 +322,11 @@
 	btinfo_symtab.esym = marks[MARK_END];
 	BI_ADD(&btinfo_symtab, BTINFO_SYMTAB, sizeof(struct btinfo_symtab));
 
+	/* set new video mode if necessary */
+	vbe_commit();
+	BI_ADD(&btinfo_framebuffer, BTINFO_FRAMEBUFFER,
+	    sizeof(struct btinfo_framebuffer));
+
 	if (callback != NULL)
 		(*callback)();
 	startprog(marks[MARK_ENTRY], BOOT_NARGS, boot_argv,

Index: src/sys/arch/i386/stand/lib/vbe.c
diff -u src/sys/arch/i386/stand/lib/vbe.c:1.3 src/sys/arch/i386/stand/lib/vbe.c:1.4
--- src/sys/arch/i386/stand/lib/vbe.c:1.3	Mon Aug 24 02:15:46 2009
+++ src/sys/arch/i386/stand/lib/vbe.c	Mon Sep 14 11:56:27 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: vbe.c,v 1.3 2009/08/24 02:15:46 jmcneill Exp $ */
+/* $NetBSD: vbe.c,v 1.4 2009/09/14 11:56:27 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2009 Jared D. McNeill <jmcne...@invisible.ca>
@@ -42,6 +42,7 @@
 
 static struct _vbestate {
 	int		available;
+	int		modenum;
 } vbestate;
 
 static void
@@ -91,6 +92,7 @@
 
 	vbe_dump(&vbe);
 	vbestate.available = 1;
+	vbestate.modenum = 0;
 }
 
 int
@@ -173,6 +175,22 @@
 	return 0;
 }
 
+int
+vbe_commit(void)
+{
+	int ret = 1;
+
+	if (vbestate.modenum > 0) {
+		ret = vbe_set_mode(vbestate.modenum);
+		if (ret) {
+			printf("WARNING: failed to set VESA VBE mode 0x%x\n",
+			    vbestate.modenum);
+			delay(5000000);
+		}
+	}
+	return ret;
+}
+
 static void *
 vbe_farptr(uint32_t farptr)
 {
@@ -330,8 +348,7 @@
 	}
 
 	if (strcmp(arg, "disabled") == 0 || strcmp(arg, "off") == 0) {
-		framebuffer_configure(NULL);
-		biosvideomode();
+		vbestate.modenum = 0;
 		return;
 	}
 
@@ -341,13 +358,15 @@
 		modenum = strtoul(arg, NULL, 0);
 	else if (strchr(arg, 'x') != NULL) {
 		modenum = vbe_find_mode(arg);
-		if (modenum == 0)
+		if (modenum == 0) {
+			printf("mode %s not supported by firmware\n", arg);
 			return;
+		}
 	} else
 		modenum = 0;
 
 	if (modenum >= 0x100) {
-		vbe_set_mode(modenum);
+		vbestate.modenum = modenum;
 		return;
 	}
 

Index: src/sys/arch/i386/stand/lib/vbe.h
diff -u src/sys/arch/i386/stand/lib/vbe.h:1.1 src/sys/arch/i386/stand/lib/vbe.h:1.2
--- src/sys/arch/i386/stand/lib/vbe.h:1.1	Mon Feb 16 22:39:31 2009
+++ src/sys/arch/i386/stand/lib/vbe.h	Mon Sep 14 11:56:27 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: vbe.h,v 1.1 2009/02/16 22:39:31 jmcneill Exp $ */
+/* $NetBSD: vbe.h,v 1.2 2009/09/14 11:56:27 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2009 Jared D. McNeill <jmcne...@invisible.ca>
@@ -94,6 +94,7 @@
 
 /* high-level VBE helpers, from vbe.c */
 void vbe_init(void);
+int vbe_commit(void);
 int vbe_available(void);
 int vbe_set_mode(int);
 int vbe_set_palette(const uint8_t *, int);

Index: src/sys/arch/i386/stand/pxeboot/main.c
diff -u src/sys/arch/i386/stand/pxeboot/main.c:1.20 src/sys/arch/i386/stand/pxeboot/main.c:1.21
--- src/sys/arch/i386/stand/pxeboot/main.c:1.20	Sat Mar 21 15:01:56 2009
+++ src/sys/arch/i386/stand/pxeboot/main.c	Mon Sep 14 11:56:27 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.20 2009/03/21 15:01:56 ad Exp $	*/
+/*	$NetBSD: main.c,v 1.21 2009/09/14 11:56:27 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 1996
@@ -48,6 +48,7 @@
 #include <bootmenu.h>
 #include <bootmod.h>
 #include "pxeboot.h"
+#include "vbe.h"
 
 extern struct x86_boot_params boot_params;
 
@@ -72,6 +73,7 @@
 	{ "consdev",	command_consdev },
 	{ "modules",    command_modules },
 	{ "load",	module_add },
+	{ "vesa",	command_vesa },
 	{ NULL,		NULL },
 };
 
@@ -180,6 +182,7 @@
 	       "boot [filename] [-adsqv]\n"
 	       "     (ex. \"netbsd.old -s\"\n"
 	       "consdev {pc|com[0123]|com[0123]kbd|auto}\n"
+	       "vesa {enabled|disabled|list|modenum}\n"
 	       "modules {enabled|disabled}\n"
 	       "load {path_to_module}\n"
 	       "help|?\n"

Reply via email to