Module Name:    src
Committed By:   bouyer
Date:           Mon Oct 16 17:31:18 UTC 2023

Modified Files:
        src/sys/arch/xen/include: hypervisor.h
        src/sys/arch/xen/x86: pvh_consinit.c
        src/sys/arch/xen/xen: xen_machdep.c

Log Message:
Move the pvh_xencons so xen_machdep.c as early_xencons, so it can be
used in the future as early ouput for plain PV guests too.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/xen/include/hypervisor.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/xen/x86/pvh_consinit.c
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/xen/xen/xen_machdep.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/xen/include/hypervisor.h
diff -u src/sys/arch/xen/include/hypervisor.h:1.58 src/sys/arch/xen/include/hypervisor.h:1.59
--- src/sys/arch/xen/include/hypervisor.h:1.58	Mon Oct 16 17:29:31 2023
+++ src/sys/arch/xen/include/hypervisor.h	Mon Oct 16 17:31:17 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: hypervisor.h,v 1.58 2023/10/16 17:29:31 bouyer Exp $	*/
+/*	$NetBSD: hypervisor.h,v 1.59 2023/10/16 17:31:17 bouyer Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -214,4 +214,6 @@ hypervisor_notify_via_evtchn(unsigned in
 void xen_init_ksyms(void);
 void xen_map_vcpu(struct cpu_info *);
 
+void xen_early_console(void);
+
 #endif /* _XEN_HYPERVISOR_H_ */

Index: src/sys/arch/xen/x86/pvh_consinit.c
diff -u src/sys/arch/xen/x86/pvh_consinit.c:1.4 src/sys/arch/xen/x86/pvh_consinit.c:1.5
--- src/sys/arch/xen/x86/pvh_consinit.c:1.4	Sat Jul 22 19:13:17 2023
+++ src/sys/arch/xen/x86/pvh_consinit.c	Mon Oct 16 17:31:18 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: pvh_consinit.c,v 1.4 2023/07/22 19:13:17 mrg Exp $ */
+/* $NetBSD: pvh_consinit.c,v 1.5 2023/10/16 17:31:18 bouyer Exp $ */
 
 /*
  * Copyright (c) 2020 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pvh_consinit.c,v 1.4 2023/07/22 19:13:17 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pvh_consinit.c,v 1.5 2023/10/16 17:31:18 bouyer Exp $");
 
 #include "xencons.h"
 #include <sys/param.h>
@@ -43,16 +43,6 @@ __KERNEL_RCSID(0, "$NetBSD: pvh_consinit
 
 #include "xen_def_cons.h"
 
-static int pvh_xenconscn_getc(dev_t);
-static void pvh_xenconscn_putc(dev_t, int);
-static void pvh_xenconscn_pollc(dev_t, int);
-
-static struct consdev pvh_xencons = {
-        NULL, NULL, pvh_xenconscn_getc, pvh_xenconscn_putc, pvh_xenconscn_pollc,
-	NULL, NULL, NULL, NODEV, CN_NORMAL
-};
-
-
 int
 xen_pvh_consinit(void)
 {
@@ -76,7 +66,7 @@ xen_pvh_consinit(void)
 	}
 	if (initted == 0 && !xendomain_is_dom0()) {
 		/* pmap not up yet, fall back to printk() */
-		cn_tab = &pvh_xencons;
+		xen_early_console();
 		initted++;
 		return 1;
 	} else if (initted > 1) {
@@ -116,23 +106,3 @@ xen_pvh_consinit(void)
 #endif
 	return 1;
 }
-
-static int
-pvh_xenconscn_getc(dev_t dev)
-{
-	while(1)
-		;
-	return -1;
-}
-
-static void
-pvh_xenconscn_putc(dev_t dev, int c)
-{
-	printk("%c", c);
-}
-
-static void
-pvh_xenconscn_pollc(dev_t dev, int on)
-{
-	return;
-}

Index: src/sys/arch/xen/xen/xen_machdep.c
diff -u src/sys/arch/xen/xen/xen_machdep.c:1.27 src/sys/arch/xen/xen/xen_machdep.c:1.28
--- src/sys/arch/xen/xen/xen_machdep.c:1.27	Sat Aug 20 23:48:51 2022
+++ src/sys/arch/xen/xen/xen_machdep.c	Mon Oct 16 17:31:18 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: xen_machdep.c,v 1.27 2022/08/20 23:48:51 riastradh Exp $	*/
+/*	$NetBSD: xen_machdep.c,v 1.28 2023/10/16 17:31:18 bouyer Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -53,7 +53,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xen_machdep.c,v 1.27 2022/08/20 23:48:51 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_machdep.c,v 1.28 2023/10/16 17:31:18 bouyer Exp $");
 
 #include "opt_xen.h"
 
@@ -70,6 +70,8 @@ __KERNEL_RCSID(0, "$NetBSD: xen_machdep.
 #include <sys/pmf.h>
 #include <sys/xcall.h>
 
+#include <dev/cons.h>
+
 #include <xen/intr.h>
 #include <xen/hypervisor.h>
 #include <xen/shutdown_xenbus.h>
@@ -440,6 +442,41 @@ printk(const char *fmt, ...)
 	(void)HYPERVISOR_console_io(CONSOLEIO_write, ret, buf);
 }
 
+static int early_xenconscn_getc(dev_t);
+static void early_xenconscn_putc(dev_t, int);
+static void early_xenconscn_pollc(dev_t, int);
+
+static struct consdev early_xencons = {
+	NULL, NULL,
+	early_xenconscn_getc, early_xenconscn_putc, early_xenconscn_pollc,
+	NULL, NULL, NULL, NODEV, CN_NORMAL
+};
+
+void
+xen_early_console(void)
+{
+	cn_tab = &early_xencons; /* fallback console */
+}
+
+static int
+early_xenconscn_getc(dev_t dev)
+{
+	while(1)
+		;
+	return -1;
+}
+
+static void 
+early_xenconscn_putc(dev_t dev, int c)
+{
+	printk("%c", c);
+}
+
+static void
+early_xenconscn_pollc(dev_t dev, int on)
+{
+	return;
+}
 bool xen_feature_tables[XENFEAT_NR_SUBMAPS * 32];
 
 void

Reply via email to