git: 82829e49e627 - stable/14 - vt: splash: Use splash screen passed from loader

From: Emmanuel Vadot <manu_at_FreeBSD.org>
Date: Mon, 29 Jul 2024 16:38:35 UTC
The branch stable/14 has been updated by manu:

URL: https://cgit.FreeBSD.org/src/commit/?id=82829e49e627c17041c7c0dddde58f1f3481e982

commit 82829e49e627c17041c7c0dddde58f1f3481e982
Author:     Emmanuel Vadot <manu@FreeBSD.org>
AuthorDate: 2024-07-09 12:38:41 +0000
Commit:     Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2024-07-29 16:37:44 +0000

    vt: splash: Use splash screen passed from loader
    
    If loader(8) gives use a splash screen to use using the MODINFOMD_SPLASH
    type, use it if RB_MUTE is set to "YES".
    By design only argb data will be displayed.
    
    Differential Revision:  https://reviews.freebsd.org/D45931
    Reviewed by:            imp, tsoome
    Sponsored by:           Beckhoff Automation GmbH & Co. KG
    
    (cherry picked from commit f6e8b0e85081681100bf9cd74423be02233204bc)
---
 sys/dev/vt/vt_core.c | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c
index 797af56e5e1d..e27f74b03a0f 100644
--- a/sys/dev/vt/vt_core.c
+++ b/sys/dev/vt/vt_core.c
@@ -45,6 +45,7 @@
 #include <sys/lock.h>
 #include <sys/malloc.h>
 #include <sys/mutex.h>
+#include <sys/splash.h>
 #include <sys/power.h>
 #include <sys/priv.h>
 #include <sys/proc.h>
@@ -1658,18 +1659,33 @@ vtterm_done(struct terminal *tm)
 static void
 vtterm_splash(struct vt_device *vd)
 {
+	caddr_t kmdp;
+	struct splash_info *si;
+	uintptr_t image;
 	vt_axis_t top, left;
 
-	/* Display a nice boot splash. */
+	kmdp = preload_search_by_type("elf kernel");
+	if (kmdp == NULL)
+		kmdp = preload_search_by_type("elf64 kernel");
+	si = MD_FETCH(kmdp, MODINFOMD_SPLASH, struct splash_info *);
 	if (!(vd->vd_flags & VDF_TEXTMODE) && (boothowto & RB_MUTE)) {
-		top = (vd->vd_height - vt_logo_height) / 2;
-		left = (vd->vd_width - vt_logo_width) / 2;
-		switch (vt_logo_depth) {
-		case 1:
-			/* XXX: Unhardcode colors! */
+		if (si == NULL) {
+			top = (vd->vd_height - vt_logo_height) / 2;
+			left = (vd->vd_width - vt_logo_width) / 2;
 			vd->vd_driver->vd_bitblt_bmp(vd, vd->vd_curwindow,
 			    vt_logo_image, NULL, vt_logo_width, vt_logo_height,
 			    left, top, TC_WHITE, TC_BLACK);
+		} else {
+			if (si->si_depth != 4)
+				return;
+			printf("SPLASH: width: %d height: %d depth: %d\n", si->si_width, si->si_height, si->si_depth);
+			image = (uintptr_t)si + sizeof(struct splash_info);
+			image = roundup2(image, 8);
+			top = (vd->vd_height - si->si_height) / 2;
+			left = (vd->vd_width - si->si_width) / 2;
+			vd->vd_driver->vd_bitblt_argb(vd, vd->vd_curwindow,
+			    (unsigned char *)image, si->si_width, si->si_height,
+			    left, top);
 		}
 		vd->vd_flags |= VDF_SPLASH;
 	}