These two patches enable qemu to use the recently added SeaBIOS bootsplash code. The first patch is for SeaBIOS - it enables finding the "bootsplash.jpg" file from either CBFS (on coreboot) or fw_cfg (on QEMU). The second patch is for qemu - it enables loading a "bootsplash.jpg" file into fw_cfg from the bios roms directory if the file is present.
Some notes:
This uses the qemu "rom" interface for loading the jpeg file. It seems to work, but I'm not sure if this is strictly correct.
The jpeg viewer in SeaBIOS will look at the image size and try to find a vesa graphics mode that supports that size. So, choose images that are exactly 640x480, 1024x768, etc. Also, the SeaBIOS viewer has stripped down support for jpegs - not all valid jpegs will work. Some quick tests with the netpbm tools worked okay for me.
SeaBIOS only shows the bootsplash during the interval between vgabios init and OS execution. This is generally too short a time to be seen. Add "-menu boot=on" to the qemu command line to have it shown longer.
Unfortunately, the vgabios doesn't support writing text to the screen while in a vesa video mode. So, this means that if a user selects F12 for the boot menu, they can't actually see the boot menu. This will need to be fixed in SeaBIOS in a follow up patch.
-Kevin
Load the "bootsplash.jpg" file into fw_cfg if it is found in the roms directory.
--- a/hw/fw_cfg.c +++ b/hw/fw_cfg.c @@ -304,8 +304,12 @@ int fw_cfg_add_file(FWCfgState *s, const char *dir, const char *filename, basename = filename; }
- snprintf(s->files->f[index].name, sizeof(s->files->f[index].name), - "%s/%s", dir, basename); + if (dir && dir[0]) + snprintf(s->files->f[index].name, sizeof(s->files->f[index].name), + "%s/%s", dir, basename); + else + strncpy(s->files->f[index].name, basename, + sizeof(s->files->f[index].name)); for (i = 0; i < index; i++) { if (strcmp(s->files->f[index].name, s->files->f[i].name) == 0) { FW_CFG_DPRINTF("%s: skip duplicate: %s\n", __FUNCTION__, diff --git a/hw/pc.c b/hw/pc.c index 58dea57..6893799 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -54,6 +54,7 @@ #endif
#define BIOS_FILENAME "bios.bin" +#define BOOTSPLASH_FILENAME "bootsplash.jpg"
#define PC_MAX_BIOS_SIZE (4 * 1024 * 1024)
@@ -963,6 +964,13 @@ void pc_memory_init(ram_addr_t ram_size, fw_cfg = bochs_bios_init(); rom_set_fw(fw_cfg);
+ /* Optional bootsplash file */ + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, BOOTSPLASH_FILENAME); + if (filename) { + qemu_free(filename); + rom_add_file(BOOTSPLASH_FILENAME, "", 0); + } + if (linux_boot) { load_linux(fw_cfg, kernel_filename, initrd_filename, kernel_cmdline, below_4g_mem_size); }
Allow the bootsplash code to pull the jpeg file from either cbfs (on coreboot) or fwcfg (on qemu).
diff --git a/src/bootsplash.c b/src/bootsplash.c index 676ece3..1dcd402 100644 --- a/src/bootsplash.c +++ b/src/bootsplash.c @@ -11,14 +11,14 @@ #include "util.h" // dprintf #include "jpeg.h" // splash #include "biosvar.h" // SET_EBDA +#include "paravirt.h" // romfile_find
/**************************************************************** * VESA structures ****************************************************************/
-struct vesa_info -{ +struct vesa_info { u32 vesa_signature; u16 vesa_version; struct segoff_s oem_string_ptr; @@ -36,8 +36,7 @@ struct vesa_info #define VESA_SIGNATURE 0x41534556 // VESA #define VBE2_SIGNATURE 0x32454256 // VBE2
-struct vesa_mode_info -{ +struct vesa_mode_info { u16 mode_attributes; u8 win_a_attributes; u8 win_b_attributes; @@ -73,6 +72,7 @@ struct vesa_mode_info u8 reserved[206]; } PACKED;
+ /**************************************************************** * Helper functions ****************************************************************/ @@ -92,7 +92,8 @@ call16_int10(struct bregs *br) * VGA text / graphics console ****************************************************************/
-static void enable_vga_text_console(void) +static void +enable_vga_text_console(void) { dprintf(1, "Turning on vga text mode console\n"); struct bregs br; @@ -140,20 +141,20 @@ find_videomode(struct vesa_info *vesa_info, struct vesa_mode_info *mode_info } }
-void enable_vga_console(void) +void +enable_vga_console(void) { struct vesa_info *vesa_info = NULL; struct vesa_mode_info *mode_info = NULL; struct jpeg_decdata *jpeg = NULL; u8 *filedata = NULL, *picture = NULL;
- /* Needs coreboot support for CBFS */ - if (!CONFIG_BOOTSPLASH || !CONFIG_COREBOOT) + if (!CONFIG_BOOTSPLASH) goto gotext; - struct cbfs_file *file = cbfs_finddatafile("bootsplash.jpg"); + u32 file = romfile_find("bootsplash.jpg"); if (!file) goto gotext; - int filesize = cbfs_datasize(file); + int filesize = romfile_size(file);
filedata = malloc_tmphigh(filesize); vesa_info = malloc_tmplow(sizeof(*vesa_info)); @@ -186,7 +187,7 @@ void enable_vga_console(void) vendor, product);
// Parse jpeg and get image size. - cbfs_copyfile(file, filedata, filesize); + romfile_copy(file, filedata, filesize); int ret = jpeg_decode(jpeg, filedata); if (ret) { dprintf(1, "jpeg_decode failed with return code %d...\n", ret); @@ -248,7 +249,7 @@ gotext: void disable_bootsplash(void) { - if (!CONFIG_BOOTSPLASH || !CONFIG_COREBOOT || !GET_EBDA(bootsplash_active)) + if (!CONFIG_BOOTSPLASH || !GET_EBDA(bootsplash_active)) return; SET_EBDA(bootsplash_active, 0); enable_vga_text_console();
On Sun, Aug 01, 2010 at 03:45:34PM -0400, Kevin O'Connor wrote:
Allow the bootsplash code to pull the jpeg file from either cbfs (on coreboot) or fwcfg (on qemu).
FYI, I've pushed this patch (and the previous series) into SeaBIOS git.
-Kevin