Module Name: src
Committed By: martin
Date: Sun Dec 8 13:09:28 UTC 2019
Modified Files:
src/sys/arch/x86/include [netbsd-9]: genfb_machdep.h
src/sys/arch/x86/x86 [netbsd-9]: genfb_machdep.c hyperv.c
Log Message:
Pull up following revision(s) (requested by nonaka in ticket #502):
sys/arch/x86/x86/hyperv.c: revision 1.5
sys/arch/x86/include/genfb_machdep.h: revision 1.4
sys/arch/x86/x86/genfb_machdep.c: revision 1.15
Prevent panic when attaching genfb if using a serial console with Hyper-V Gen.2.
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.3.60.1 src/sys/arch/x86/include/genfb_machdep.h
cvs rdiff -u -r1.13 -r1.13.2.1 src/sys/arch/x86/x86/genfb_machdep.c
cvs rdiff -u -r1.4 -r1.4.4.1 src/sys/arch/x86/x86/hyperv.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/x86/include/genfb_machdep.h
diff -u src/sys/arch/x86/include/genfb_machdep.h:1.3 src/sys/arch/x86/include/genfb_machdep.h:1.3.60.1
--- src/sys/arch/x86/include/genfb_machdep.h:1.3 Wed Feb 9 13:24:23 2011
+++ src/sys/arch/x86/include/genfb_machdep.h Sun Dec 8 13:09:28 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: genfb_machdep.h,v 1.3 2011/02/09 13:24:23 jmcneill Exp $ */
+/* $NetBSD: genfb_machdep.h,v 1.3.60.1 2019/12/08 13:09:28 martin Exp $ */
/*-
* Copyright (c) 2009 Jared D. McNeill <[email protected]>
@@ -29,6 +29,7 @@
#ifndef _X86_GENFB_MACHDEP_H
#define _X86_GENFB_MACHDEP_H
+int x86_genfb_init(void);
int x86_genfb_cnattach(void);
void x86_genfb_mtrr_init(uint64_t, uint32_t);
void x86_genfb_set_console_dev(device_t);
Index: src/sys/arch/x86/x86/genfb_machdep.c
diff -u src/sys/arch/x86/x86/genfb_machdep.c:1.13 src/sys/arch/x86/x86/genfb_machdep.c:1.13.2.1
--- src/sys/arch/x86/x86/genfb_machdep.c:1.13 Sun May 19 07:43:17 2019
+++ src/sys/arch/x86/x86/genfb_machdep.c Sun Dec 8 13:09:28 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: genfb_machdep.c,v 1.13 2019/05/19 07:43:17 mlelstv Exp $ */
+/* $NetBSD: genfb_machdep.c,v 1.13.2.1 2019/12/08 13:09:28 martin Exp $ */
/*-
* Copyright (c) 2009 Jared D. McNeill <[email protected]>
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: genfb_machdep.c,v 1.13 2019/05/19 07:43:17 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfb_machdep.c,v 1.13.2.1 2019/12/08 13:09:28 martin Exp $");
#include "opt_mtrr.h"
@@ -136,23 +136,19 @@ x86_genfb_mtrr_init(uint64_t physaddr, u
}
int
-x86_genfb_cnattach(void)
+x86_genfb_init(void)
{
- static int ncalls = 0;
+ static int inited, attached;
struct rasops_info *ri = &x86_genfb_console_screen.scr_ri;
const struct btinfo_framebuffer *fbinfo;
bus_space_tag_t t = x86_bus_space_mem;
bus_space_handle_t h;
void *bits;
- long defattr;
int err;
- /* XXX jmcneill
- * Defer console initialization until UVM is initialized
- */
- ++ncalls;
- if (ncalls < 3)
- return -1;
+ if (inited)
+ return attached;
+ inited = 1;
memset(&x86_genfb_console_screen, 0, sizeof(x86_genfb_console_screen));
@@ -206,6 +202,27 @@ x86_genfb_cnattach(void)
x86_genfb_stdscreen.textops = &ri->ri_ops;
x86_genfb_stdscreen.capabilities = ri->ri_caps;
+ attached = 1;
+ return 1;
+}
+
+int
+x86_genfb_cnattach(void)
+{
+ static int ncalls = 0;
+ struct rasops_info *ri = &x86_genfb_console_screen.scr_ri;
+ long defattr;
+
+ /* XXX jmcneill
+ * Defer console initialization until UVM is initialized
+ */
+ ++ncalls;
+ if (ncalls < 3)
+ return -1;
+
+ if (!x86_genfb_init())
+ return 0;
+
ri->ri_ops.allocattr(ri, 0, 0, 0, &defattr);
wsdisplay_preattach(&x86_genfb_stdscreen, ri, 0, 0, defattr);
@@ -213,6 +230,12 @@ x86_genfb_cnattach(void)
}
#else /* NWSDISPLAY > 0 && NGENFB > 0 */
int
+x86_genfb_init(void)
+{
+ return 0;
+}
+
+int
x86_genfb_cnattach(void)
{
return 0;
Index: src/sys/arch/x86/x86/hyperv.c
diff -u src/sys/arch/x86/x86/hyperv.c:1.4 src/sys/arch/x86/x86/hyperv.c:1.4.4.1
--- src/sys/arch/x86/x86/hyperv.c:1.4 Mon Jun 3 09:51:04 2019
+++ src/sys/arch/x86/x86/hyperv.c Sun Dec 8 13:09:28 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: hyperv.c,v 1.4 2019/06/03 09:51:04 nonaka Exp $ */
+/* $NetBSD: hyperv.c,v 1.4.4.1 2019/12/08 13:09:28 martin Exp $ */
/*-
* Copyright (c) 2009-2012,2016-2017 Microsoft Corp.
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
#ifdef __KERNEL_RCSID
-__KERNEL_RCSID(0, "$NetBSD: hyperv.c,v 1.4 2019/06/03 09:51:04 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hyperv.c,v 1.4.4.1 2019/12/08 13:09:28 martin Exp $");
#endif
#ifdef __FBSDID
__FBSDID("$FreeBSD: head/sys/dev/hyperv/vmbus/hyperv.c 331757 2018-03-30 02:25:12Z emaste $");
@@ -70,7 +70,7 @@ __FBSDID("$FreeBSD: head/sys/dev/hyperv/
#include <x86/efi.h>
#include <dev/wsfb/genfbvar.h>
-#include <arch/x86/include/genfb_machdep.h>
+#include <x86/genfb_machdep.h>
#include <x86/x86/hypervreg.h>
#include <x86/x86/hypervvar.h>
@@ -1103,6 +1103,9 @@ device_hyperv_register(device_t dev, voi
sizeof(*aa->aa_type)) == 0) {
prop_dictionary_t dict = device_properties(dev);
+ /* Initialize genfb for serial console */
+ x86_genfb_init();
+
/*
* framebuffer drivers other than genfb can work
* without the address property