Skip to content

Commit

Permalink
loader: Load a splash screen if "splash" variable is defined
Browse files Browse the repository at this point in the history
Load a splash screen that vt(4) can use if the "splash" env variable is defined.
For now only png is supported and decoding is done in loader and not in kernel
compared to splash screen support in sc(4).

For using this add:
boot_mute="YES"
splash="/boot/images/freebsd-logo-rev.png"
in loader.conf

Differential Revision:	https://reviews.freebsd.org/D45932
Reviewed by:		imp, tsoome
Sponsored by:		Beckhoff Automation GmbH & Co. KG
  • Loading branch information
evadot committed Jul 11, 2024
1 parent f6e8b0e commit 00460cc
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions stand/common/bootstrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ int tslog_init(void);
int tslog_publish(void);

vm_offset_t build_font_module(vm_offset_t);
vm_offset_t build_splash_module(vm_offset_t);

/* MI module loaders */
#ifdef __elfN
Expand Down
48 changes: 48 additions & 0 deletions stand/common/gfx_fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
#include <teken.h>
#include <gfx_fb.h>
#include <sys/font.h>
#include <sys/splash.h>
#include <sys/linker.h>
#include <sys/module.h>
#include <sys/stdint.h>
Expand Down Expand Up @@ -3007,3 +3008,50 @@ build_font_module(vm_offset_t addr)
file_addmetadata(fp, MODINFOMD_FONT, sizeof(fontp), &fontp);
return (addr);
}

vm_offset_t
build_splash_module(vm_offset_t addr)
{
struct preloaded_file *fp;
struct splash_info si;
const char *splash;
png_t png;
uint64_t splashp;
int error;

/* We can't load first */
if ((file_findfile(NULL, NULL)) == NULL) {
printf("Can not load splash module: %s\n",
"the kernel is not loaded");
return (addr);
}

fp = file_findfile(NULL, "elf kernel");
if (fp == NULL)
fp = file_findfile(NULL, "elf64 kernel");
if (fp == NULL)
panic("can't find kernel file");

splash = getenv("splash");
if (splash == NULL)
return (addr);

/* Parse png */
if ((error = png_open(&png, splash)) != PNG_NO_ERROR) {
return (addr);
}

si.si_width = png.width;
si.si_height = png.height;
si.si_depth = png.bpp;
splashp = addr;
addr += archsw.arch_copyin(&si, addr, sizeof (struct splash_info));
addr = roundup2(addr, 8);

/* Copy the bitmap. */
addr += archsw.arch_copyin(png.image, addr, png.png_datalen);

printf("Loading splash ok\n");
file_addmetadata(fp, MODINFOMD_SPLASH, sizeof(splashp), &splashp);
return (addr);
}
5 changes: 5 additions & 0 deletions stand/efi/loader/bootinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,11 @@ bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, bool exit_bs)

/* Pad to a page boundary. */
addr = roundup(addr, PAGE_SIZE);

addr = build_splash_module(addr);

/* Pad to a page boundary. */
addr = roundup(addr, PAGE_SIZE);
#endif

/* Copy our environment. */
Expand Down

0 comments on commit 00460cc

Please sign in to comment.