git: 65c10f12df1c - stable/13 - vt: use TERMINAL_DECLARE_EARLY() macro

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Mon, 16 May 2022 13:51:25 UTC
The branch stable/13 has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=65c10f12df1caeb22bc06c258c1bc45b38a80518

commit 65c10f12df1caeb22bc06c258c1bc45b38a80518
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2021-09-20 19:50:04 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2022-05-16 13:34:04 +0000

    vt: use TERMINAL_DECLARE_EARLY() macro
    
    It simplifies the declaration of the driver structures a little. There
    are no current consumers of this macro, in fact it looks like it was
    added for exactly this purpose.
    
    This decreases the scope of some variables, so rework the initialization
    in vt_init_logos() such that it doesn't require them.
    
    No functional change intended.
    
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D34820
    
    (cherry picked from commit ff1c8af8c34965cc13e53f8290adc5a2fe09501b)
---
 sys/dev/vt/vt.h          |  2 --
 sys/dev/vt/vt_core.c     | 16 +++-------------
 sys/dev/vt/vt_cpulogos.c | 10 ++++++----
 3 files changed, 9 insertions(+), 19 deletions(-)

diff --git a/sys/dev/vt/vt.h b/sys/dev/vt/vt.h
index 5ba64388bd27..b4361f77317c 100644
--- a/sys/dev/vt/vt.h
+++ b/sys/dev/vt/vt.h
@@ -386,8 +386,6 @@ struct vt_driver {
  */
 
 extern struct vt_device vt_consdev;
-extern struct terminal vt_consterm;
-extern const struct terminal_class vt_termclass;
 void vt_upgrade(struct vt_device *vd);
 
 #define	PIXEL_WIDTH(w)	((w) / 8)
diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c
index 83bfda1cb876..2357b377f1e5 100644
--- a/sys/dev/vt/vt_core.c
+++ b/sys/dev/vt/vt_core.c
@@ -87,7 +87,7 @@ static tc_opened_t	vtterm_opened;
 static tc_ioctl_t	vtterm_ioctl;
 static tc_mmap_t	vtterm_mmap;
 
-const struct terminal_class vt_termclass = {
+static const struct terminal_class vt_termclass = {
 	.tc_bell	= vtterm_bell,
 	.tc_cursor	= vtterm_cursor,
 	.tc_putchar	= vtterm_putchar,
@@ -202,7 +202,7 @@ SET_DECLARE(vt_drv_set, struct vt_driver);
 #define	_VTDEFH	MAX(100, PIXEL_HEIGHT(VT_FB_MAX_HEIGHT))
 #define	_VTDEFW	MAX(200, PIXEL_WIDTH(VT_FB_MAX_WIDTH))
 
-struct terminal	vt_consterm;
+static struct terminal	vt_consterm;
 static struct vt_window	vt_conswindow;
 #ifndef SC_NO_CONSDRAWN
 static term_char_t vt_consdrawn[PIXEL_HEIGHT(VT_FB_MAX_HEIGHT) * PIXEL_WIDTH(VT_FB_MAX_WIDTH)];
@@ -262,19 +262,9 @@ static struct vt_window	vt_conswindow = {
 	.vw_bell_pitch = VT_BELLPITCH,
 	.vw_bell_duration = VT_BELLDURATION,
 };
-struct terminal vt_consterm = {
-	.tm_class = &vt_termclass,
-	.tm_softc = &vt_conswindow,
-	.tm_flags = TF_CONS,
-};
-static struct consdev vt_consterm_consdev = {
-	.cn_ops = &termcn_cnops,
-	.cn_arg = &vt_consterm,
-	.cn_name = "ttyv0",
-};
 
 /* Add to set of consoles. */
-DATA_SET(cons_set, vt_consterm_consdev);
+TERMINAL_DECLARE_EARLY(vt_consterm, vt_termclass, &vt_conswindow);
 
 /*
  * Right after kmem is done to allow early drivers to use locking and allocate
diff --git a/sys/dev/vt/vt_cpulogos.c b/sys/dev/vt/vt_cpulogos.c
index 6450c89ead6d..7e0be12b3adb 100644
--- a/sys/dev/vt/vt_cpulogos.c
+++ b/sys/dev/vt/vt_cpulogos.c
@@ -221,12 +221,14 @@ vt_init_logos(void *dummy)
 	if (!vt_splash_cpu)
 		return;
 
-	tm = &vt_consterm;
-	vw = tm->tm_softc;
+	vd = &vt_consdev;
+	if (vd == NULL)
+		return;
+	vw = vd->vd_curwindow;
 	if (vw == NULL)
 		return;
-	vd = vw->vw_device;
-	if (vd == NULL)
+	tm = vw->vw_terminal;
+	if (tm == NULL)
 		return;
 	vf = vw->vw_font;
 	if (vf == NULL)