From 488ff14b4ee58f58852f181b0322fbd5a1621858 Mon Sep 17 00:00:00 2001 From: Goldenkrew3000 Date: Tue, 17 Feb 2026 09:32:07 +1000 Subject: [PATCH] Added optional boot slowdown, and removed bootsplash ability Added an option to allow waiting x milliseconds until clearing the framebuffer to allow time to the Coreboot bootsplash. Also removed SeaBIOS's bootsplash ability completely. --- src/boot.c | 2 - src/bootsplash.c | 206 +---------------------------------------------- src/rf_config.h | 6 ++ src/util.h | 2 - 4 files changed, 10 insertions(+), 206 deletions(-) create mode 100644 src/rf_config.h diff --git a/src/boot.c b/src/boot.c index 5c37daf..33a0001 100644 --- a/src/boot.c +++ b/src/boot.c @@ -719,9 +719,7 @@ interactive_bootmenu(void) printf("%s", bootmsg ?: "\nPress ESC for boot menu.\n\n"); free(bootmsg); - enable_bootsplash(); scan_code = get_keystroke(menutime); - disable_bootsplash(); if (scan_code != menukey) return; } diff --git a/src/bootsplash.c b/src/bootsplash.c index 538b316..a657195 100644 --- a/src/bootsplash.c +++ b/src/bootsplash.c @@ -15,6 +15,7 @@ #include "std/vbe.h" // struct vbe_info #include "string.h" // memset #include "util.h" // enable_bootsplash +#include "rf_config.h" /**************************************************************** @@ -39,6 +40,9 @@ call16_int10(struct bregs *br) void enable_vga_console(void) { + /* Wait x ms until clearing framebuffer to leave time for Coreboot's bootsplash */ + msleep(RF_CONF_COREBOOT_BOOTSPLASH); + dprintf(1, "Turning on vga text mode console\n"); struct bregs br; @@ -51,205 +55,3 @@ enable_vga_console(void) printf("SeaBIOS (version %s)\n", VERSION); display_uuid(); } - -static int -find_videomode(struct vbe_info *vesa_info, struct vbe_mode_info *mode_info - , int width, int height, int bpp_req) -{ - dprintf(3, "Finding vesa mode with dimensions %d/%d\n", width, height); - u16 *videomodes = SEGOFF_TO_FLATPTR(vesa_info->video_mode); - for (;; videomodes++) { - u16 videomode = *videomodes; - if (videomode == 0xffff) { - dprintf(1, "Unable to find vesa video mode dimensions %d/%d\n" - , width, height); - return -1; - } - struct bregs br; - memset(&br, 0, sizeof(br)); - br.ax = 0x4f01; - br.cx = videomode; - br.di = FLATPTR_TO_OFFSET(mode_info); - br.es = FLATPTR_TO_SEG(mode_info); - call16_int10(&br); - if (br.ax != 0x4f) { - dprintf(1, "get_mode failed.\n"); - continue; - } - if (mode_info->xres != width - || mode_info->yres != height) - continue; - u8 depth = mode_info->bits_per_pixel; - if (bpp_req == 0) { - if ((depth != 16 && depth != 24 && depth != 32) - || mode_info->green_size == 5) - continue; - } else { - if (depth != bpp_req) - continue; - } - return videomode; - } -} - -static int BootsplashActive; - -void -enable_bootsplash(void) -{ - if (!CONFIG_BOOTSPLASH) - return; - /* splash picture can be bmp or jpeg file */ - dprintf(3, "Checking for bootsplash\n"); - u8 type = 0; /* 0 means jpg, 1 means bmp, default is 0=jpg */ - int filesize; - u8 *filedata = romfile_loadfile("bootsplash.jpg", &filesize); - if (!filedata) { - filedata = romfile_loadfile("bootsplash.bmp", &filesize); - if (!filedata) - return; - type = 1; - } - dprintf(3, "start showing bootsplash\n"); - - u8 *picture = NULL; /* data buff used to be flushed to the video buf */ - struct jpeg_decdata *jpeg = NULL; - struct bmp_decdata *bmp = NULL; - struct vbe_info *vesa_info = malloc_tmplow(sizeof(*vesa_info)); - struct vbe_mode_info *mode_info = malloc_tmplow(sizeof(*mode_info)); - if (!vesa_info || !mode_info) { - warn_noalloc(); - goto done; - } - - /* Check whether we have a VESA 2.0 compliant BIOS */ - memset(vesa_info, 0, sizeof(struct vbe_info)); - vesa_info->signature = VBE2_SIGNATURE; - struct bregs br; - memset(&br, 0, sizeof(br)); - br.ax = 0x4f00; - br.di = FLATPTR_TO_OFFSET(vesa_info); - br.es = FLATPTR_TO_SEG(vesa_info); - call16_int10(&br); - if (vesa_info->signature != VESA_SIGNATURE) { - dprintf(1,"No VBE2 found.\n"); - goto done; - } - - /* Print some debugging information about our card. */ - char *vendor = SEGOFF_TO_FLATPTR(vesa_info->oem_vendor_string); - char *product = SEGOFF_TO_FLATPTR(vesa_info->oem_product_string); - dprintf(3, "VESA %d.%d\nVENDOR: %s\nPRODUCT: %s\n", - vesa_info->version>>8, vesa_info->version&0xff, - vendor, product); - - int ret, width, height; - int bpp_require = 0; - if (type == 0) { - jpeg = jpeg_alloc(); - if (!jpeg) { - warn_noalloc(); - goto done; - } - /* Parse jpeg and get image size. */ - dprintf(5, "Decoding bootsplash.jpg\n"); - ret = jpeg_decode(jpeg, filedata); - if (ret) { - dprintf(1, "jpeg_decode failed with return code %d...\n", ret); - goto done; - } - jpeg_get_size(jpeg, &width, &height); - } else { - bmp = bmp_alloc(); - if (!bmp) { - warn_noalloc(); - goto done; - } - /* Parse bmp and get image size. */ - dprintf(5, "Decoding bootsplash.bmp\n"); - ret = bmp_decode(bmp, filedata, filesize); - if (ret) { - dprintf(1, "bmp_decode failed with return code %d...\n", ret); - goto done; - } - bmp_get_info(bmp, &width, &height, &bpp_require); - } - - // jpeg would use 16 or 24 bpp video mode, BMP uses 16/24/32 bpp mode. - - // Try to find a graphics mode with the corresponding dimensions. - int videomode = find_videomode(vesa_info, mode_info, width, height, - bpp_require); - if (videomode < 0) { - dprintf(1, "failed to find a videomode with %dx%d %dbpp (0=any).\n", - width, height, bpp_require); - goto done; - } - void *framebuffer = (void *)mode_info->phys_base; - int depth = mode_info->bits_per_pixel; - dprintf(3, "mode: %04x\n", videomode); - dprintf(3, "framebuffer: %p\n", framebuffer); - dprintf(3, "bytes per scanline: %d\n", mode_info->bytes_per_scanline); - dprintf(3, "bits per pixel: %d\n", depth); - - // Allocate space for image and decompress it. - int imagesize = height * mode_info->bytes_per_scanline; - picture = malloc_tmphigh(imagesize); - if (!picture) { - warn_noalloc(); - goto done; - } - - if (type == 0) { - dprintf(5, "Decompressing bootsplash.jpg\n"); - ret = jpeg_show(jpeg, picture, width, height, depth, - mode_info->bytes_per_scanline); - if (ret) { - dprintf(1, "jpeg_show failed with return code %d...\n", ret); - goto done; - } - } else { - dprintf(5, "Decompressing bootsplash.bmp\n"); - ret = bmp_show(bmp, picture, width, height, depth, - mode_info->bytes_per_scanline); - if (ret) { - dprintf(1, "bmp_show failed with return code %d...\n", ret); - goto done; - } - } - - /* Switch to graphics mode */ - dprintf(5, "Switching to graphics mode\n"); - memset(&br, 0, sizeof(br)); - br.ax = 0x4f02; - br.bx = videomode | VBE_MODE_LINEAR_FRAME_BUFFER; - call16_int10(&br); - if (br.ax != 0x4f) { - dprintf(1, "set_mode failed.\n"); - goto done; - } - - /* Show the picture */ - dprintf(5, "Showing bootsplash picture\n"); - iomemcpy(framebuffer, picture, imagesize); - dprintf(5, "Bootsplash copy complete\n"); - BootsplashActive = 1; - -done: - free(filedata); - free(picture); - free(vesa_info); - free(mode_info); - free(jpeg); - free(bmp); - return; -} - -void -disable_bootsplash(void) -{ - if (!CONFIG_BOOTSPLASH || !BootsplashActive) - return; - BootsplashActive = 0; - enable_vga_console(); -} diff --git a/src/rf_config.h b/src/rf_config.h new file mode 100644 index 0000000..0171751 --- /dev/null +++ b/src/rf_config.h @@ -0,0 +1,6 @@ +#ifndef _RF_CONFIG_H +#define _RF_CONFIG_H + +#define RF_CONF_COREBOOT_BOOTSPLASH 500 // 500 ms before clearing Coreboot bootsplash + +#endif diff --git a/src/util.h b/src/util.h index aff8e88..acac468 100644 --- a/src/util.h +++ b/src/util.h @@ -50,8 +50,6 @@ int boot_lchs_find_ata_device(struct pci_device *pci, int chanid, int slave, // bootsplash.c void enable_vga_console(void); -void enable_bootsplash(void); -void disable_bootsplash(void); // cdrom.c extern struct eltorito_s CDEmu;