diff --git a/stand/common/bootstrap.h b/stand/common/bootstrap.h index 79ce0b023b7a..09c4832f5855 100644 --- a/stand/common/bootstrap.h +++ b/stand/common/bootstrap.h @@ -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 diff --git a/stand/common/gfx_fb.c b/stand/common/gfx_fb.c index 0a88a166089b..9942c629d124 100644 --- a/stand/common/gfx_fb.c +++ b/stand/common/gfx_fb.c @@ -87,6 +87,7 @@ #include #include #include +#include #include #include #include @@ -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); +} diff --git a/stand/efi/loader/bootinfo.c b/stand/efi/loader/bootinfo.c index b55c2184d9fe..0a53422142e2 100644 --- a/stand/efi/loader/bootinfo.c +++ b/stand/efi/loader/bootinfo.c @@ -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. */