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.diff -r1.3 -r1.3.60.1 src/sys/arch/x86/include/genfb_machdep.h
(martin)
--- src/sys/arch/x86/include/genfb_machdep.h 2011/02/09 13:24:23 1.3
+++ src/sys/arch/x86/include/genfb_machdep.h 2019/12/08 13:09:28 1.3.60.1
@@ -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 <jmcneill@invisible.ca>
@@ -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);
--- src/sys/arch/x86/x86/genfb_machdep.c 2019/05/19 07:43:17 1.13
+++ src/sys/arch/x86/x86/genfb_machdep.c 2019/12/08 13:09:28 1.13.2.1
@@ -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 <jmcneill@invisible.ca>
@@ -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 @@
}
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,12 +202,39 @@
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);
return 1;
}
#else /* NWSDISPLAY > 0 && NGENFB > 0 */
+int
+x86_genfb_init(void)
+{
+ return 0;
+}
+
int
x86_genfb_cnattach(void)
{
--- src/sys/arch/x86/x86/hyperv.c 2019/06/03 09:51:04 1.4
+++ src/sys/arch/x86/x86/hyperv.c 2019/12/08 13:09:28 1.4.4.1
@@ -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 @@
#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>
@@ -1102,6 +1102,9 @@
if (memcmp(aa->aa_type, &hyperv_guid_video,
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