Patchwork cbfs, smaller api, more types

login
register
about
Submitter Stefan Reinauer
Date 2010-02-28 00:51:09
Message ID <4B89BDFD.8000605@coresystems.de>
Download mbox | patch
Permalink /patch/990/
State Accepted
Headers show

Comments

Stefan Reinauer - 2010-02-28 00:51:09
new version
New version:

- support for adding Intel "Modular BIOS Interface" binaries used
  by some intel option roms (up to and including i945)
- Move bootsplash to top level menu and allow to specify filename,
  add file if filename is specified
- clean up CBFS, make static what's not called externally
- add CBFS types: bootsplash, raw, vsa, mbi, microcode

Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Patrick Georgi - 2010-03-01 17:24:26
Am 28.02.2010 01:51, schrieb Stefan Reinauer:
> 
> new version
> 
I'm not sure what to do with the CBFS type numbers, but I guess we still
have them, so we can as well put them to use. This doesn't add any
headers or anything similarily controversial, so it won't be in the way
should type numbers be removed at some point.

Acked-by: Patrick Georgi <patrick.georgi@coresystems.de>

Patch

Index: src/Kconfig
===================================================================
--- src/Kconfig	(revision 5169)
+++ src/Kconfig	(working copy)
@@ -432,8 +432,68 @@ 
 	  the "0x" prefix) and 3230 specifies the PCI device ID of the
 	  video card (also in hex, without "0x" prefix).
 
+config INTEL_MBI
+	bool "Add an MBI image"
+	depends on NORTHBRIDGE_INTEL_I82830
+	help
+	  Select this option if you have an Intel MBI image that you would
+	  like to add to your ROM.
+
+	  You will be able to specify the location and file name of the
+	  image later.
+
+config FALLBACK_MBI_FILE
+	string "Intel MBI path and filename"
+	depends on INTEL_MBI
+	default "mbi.bin"
+	help
+	  The path and filename of the file to use as VGA BIOS.
+
 endmenu
 
+menu "Bootsplash"
+	depends on PCI_OPTION_ROM_RUN_YABEL
+
+config BOOTSPLASH
+	prompt "Show graphical bootsplash"
+	bool
+	depends on PCI_OPTION_ROM_RUN_YABEL
+	help
+	  This option shows a graphical bootsplash screen. The grapics are
+	  loaded from the CBFS file bootsplash.jpg.
+
+config FALLBACK_BOOTSPLASH_FILE
+	string "Bootsplash path and filename"
+	depends on BOOTSPLASH
+	default "bootsplash.jpg"
+	help
+	  The path and filename of the file to use as graphical bootsplash 
+	  screen. The file format has to be jpg. 
+
+# TODO: Turn this into a "choice".
+config FRAMEBUFFER_VESA_MODE
+	prompt "VESA framebuffer video mode"
+	hex
+	default 0x117
+	depends on BOOTSPLASH
+	help
+	  This option sets the resolution used for the coreboot framebuffer and
+	  bootsplash screen. Set to 0x117 for 1024x768x16. A diligent soul will
+	  some day make this a "choice".
+
+config COREBOOT_KEEP_FRAMEBUFFER
+	prompt "Keep VESA framebuffer"
+	bool
+	depends on BOOTSPLASH
+	help
+	  This option keeps the framebuffer mode set after coreboot finishes
+	  execution. If this option is enabled, coreboot will pass a
+	  framebuffer entry in its coreboot table and the payload will need a
+	  framebuffer driver. If this option is disabled, coreboot will switch
+	  back to text mode before handing control to a payload.
+
+endmenu
+
 menu "Debugging"
 
 # TODO: Better help text and detailed instructions.
Index: src/devices/Kconfig
===================================================================
--- src/devices/Kconfig	(revision 5169)
+++ src/devices/Kconfig	(working copy)
@@ -167,36 +167,6 @@ 
 	  they can still access all devices in the system.
 	  Enable this option for a good compromise between security and speed.
 
-config BOOTSPLASH
-	prompt "Show graphical bootsplash"
-	bool
-	depends on PCI_OPTION_ROM_RUN_YABEL
-	help
-	  This option shows a graphical bootsplash screen. The grapics are
-	  loaded from the CBFS file bootsplash.jpg.
-
-# TODO: Turn this into a "choice".
-config FRAMEBUFFER_VESA_MODE
-	prompt "VESA framebuffer video mode"
-	hex
-	default 0x117
-	depends on BOOTSPLASH
-	help
-	  This option sets the resolution used for the coreboot framebuffer and
-	  bootsplash screen. Set to 0x117 for 1024x768x16. A diligent soul will
-	  some day make this a "choice".
-
-config COREBOOT_KEEP_FRAMEBUFFER
-	prompt "Keep VESA framebuffer"
-	bool
-	depends on BOOTSPLASH
-	help
-	  This option keeps the framebuffer mode set after coreboot finishes
-	  execution. If this option is enabled, coreboot will pass a
-	  framebuffer entry in its coreboot table and the payload will need a
-	  framebuffer driver. If this option is disabled, coreboot will switch
-	  back to text mode before handing control to a payload.
-
 config CONSOLE_VGA_MULTI
 	bool
 	default n
Index: src/include/cbfs.h
===================================================================
--- src/include/cbfs.h	(revision 5169)
+++ src/include/cbfs.h	(working copy)
@@ -63,9 +63,14 @@ 
     Users are welcome to use any other value for their
     components */
 
-#define CBFS_TYPE_STAGE     0x10
-#define CBFS_TYPE_PAYLOAD   0x20
-#define CBFS_TYPE_OPTIONROM 0x30
+#define CBFS_TYPE_STAGE      0x10
+#define CBFS_TYPE_PAYLOAD    0x20
+#define CBFS_TYPE_OPTIONROM  0x30
+#define CBFS_TYPE_BOOTSPLASH 0x40
+#define CBFS_TYPE_RAW        0x50
+#define CBFS_TYPE_VSA        0x51
+#define CBFS_TYPE_MBI        0x52
+#define CBFS_TYPE_MICROCODE  0x53
 
 /** this is the master cbfs header - it need to be
     located somewhere in the bootblock.  Where it
@@ -164,11 +169,8 @@ 
 void * cbfs_get_file(const char *name);
 void *cbfs_load_optionrom(u16 vendor, u16 device, void * dest);
 int run_address(void *f);
-int cbfs_decompress(int algo, void *src, void *dst, int len);
-struct cbfs_stage *cbfs_find_file(const char *name, int type);
-int cbfs_check_magic(struct cbfs_file *file);
-struct cbfs_header *cbfs_master_header(void);
 struct cbfs_file *cbfs_find(const char *name);
+void *cbfs_find_file(const char *name, int type);
 void cbfs_and_run_core(const char *filename, unsigned int ebp);
 
 #endif
Index: src/lib/cbfs.c
===================================================================
--- src/lib/cbfs.c	(revision 5169)
+++ src/lib/cbfs.c	(working copy)
@@ -24,7 +24,16 @@ 
 #include <lib.h>
 #include <arch/byteorder.h>
 
-int cbfs_decompress(int algo, void *src, void *dst, int len)
+
+/**
+ * Decompression wrapper for CBFS
+ * @param algo
+ * @param src
+ * @param dst
+ * @param len
+ * @return 0 on success, -1 on failure
+ */
+static int cbfs_decompress(int algo, void *src, void *dst, int len)
 {
 	switch(algo) {
 	case CBFS_COMPRESS_NONE:
@@ -44,12 +53,12 @@ 
 	}
 }
 
-int cbfs_check_magic(struct cbfs_file *file)
+static int cbfs_check_magic(struct cbfs_file *file)
 {
 	return !strcmp(file->magic, CBFS_FILE_MAGIC) ? 1 : 0;
 }
 
-struct cbfs_header *cbfs_master_header(void)
+static struct cbfs_header *cbfs_master_header(void)
 {
 	struct cbfs_header *header;
 
@@ -103,7 +112,7 @@ 
 	}
 }
 
-struct cbfs_stage *cbfs_find_file(const char *name, int type)
+void *cbfs_find_file(const char *name, int type)
 {
 	struct cbfs_file *file = cbfs_find(name);
 
@@ -123,7 +132,7 @@ 
 	return (void *) CBFS_SUBHEADER(file);
 }
 
-static int tohex4(unsigned int c)
+static inline int tohex4(unsigned int c)
 {
 	return (c<=9)?(c+'0'):(c-10+'a');
 }
@@ -205,11 +214,6 @@ 
 	return (void *) entry;
 }
 
-void * cbfs_get_file(const char *name)
-{
-	return (void *) cbfs_find(name);
-}
-
 int cbfs_execute_stage(const char *name)
 {
 	struct cbfs_stage *stage = (struct cbfs_stage *)
@@ -233,7 +237,7 @@ 
  * run_address is passed the address of a function taking no parameters and
  * jumps to it, returning the result. 
  * @param f the address to call as a function. 
- * returns value returned by the function. 
+ * @return value returned by the function. 
  */
 
 int run_address(void *f)
Index: src/arch/i386/Makefile.inc
===================================================================
--- src/arch/i386/Makefile.inc	(revision 5169)
+++ src/arch/i386/Makefile.inc	(working copy)
@@ -28,6 +28,14 @@ 
 	@printf "    VGABIOS    $(CONFIG_FALLBACK_VGA_BIOS_FILE) $(CONFIG_FALLBACK_VGA_BIOS_ID)\n"
 	$(CBFSTOOL) $(obj)/coreboot.rom add $(CONFIG_FALLBACK_VGA_BIOS_FILE) "pci$(CONFIG_FALLBACK_VGA_BIOS_ID).rom" optionrom
 endif
+ifeq ($(CONFIG_INTEL_MBI),y)
+	@printf "    MBI        $(CONFIG_FALLBACK_MBI_FILE)\n"
+	$(CBFSTOOL) $(obj)/coreboot.rom add $(CONFIG_FALLBACK_MBI_FILE) mbi.bin mbi
+endif
+ifeq ($(CONFIG_BOOTSPLASH),y)
+	@printf "    BOOTSPLASH $(CONFIG_FALLBACK_BOOTSPLASH_FILE)\n"
+	$(CBFSTOOL) $(obj)/coreboot.rom add $(CONFIG_FALLBACK_BOOTSPLASH_FILE) bootsplash.jpg bootsplash
+endif
 	@printf "    CBFSPRINT  $(subst $(obj)/,,$(@))\n\n"
 	$(CBFSTOOL) $(obj)/coreboot.rom print
 
Index: util/x86emu/yabel/vbe.c
===================================================================
--- util/x86emu/yabel/vbe.c	(revision 5169)
+++ util/x86emu/yabel/vbe.c	(working copy)
@@ -795,12 +795,11 @@ 
 	 * cares. */
 	int imagesize = 1024*768*2;
 	
-	struct cbfs_file *file = cbfs_find("bootsplash.jpg");
-	if (!file) { 
+	unsigned char *jpeg = cbfs_find_file("bootsplash.jpg", CBFS_TYPE_BOOTSPLASH);
+	if (!jpeg) { 
 		DEBUG_PRINTF_VBE("Could not find bootsplash.jpg\n");
 		return;
 	}
-	unsigned char *jpeg = ((unsigned char *)file) + ntohl(file->offset);
 	DEBUG_PRINTF_VBE("Splash at %08x ...\n", jpeg);
 	dump(jpeg, 64);
 
Index: util/cbfstool/cbfs.h
===================================================================
--- util/cbfstool/cbfs.h	(revision 5169)
+++ util/cbfstool/cbfs.h	(working copy)
@@ -68,9 +68,14 @@ 
     Users are welcome to use any other value for their
     components */
 
-#define CBFS_COMPONENT_STAGE     0x10
-#define CBFS_COMPONENT_PAYLOAD   0x20
-#define CBFS_COMPONENT_OPTIONROM 0x30
+#define CBFS_COMPONENT_STAGE      0x10
+#define CBFS_COMPONENT_PAYLOAD    0x20
+#define CBFS_COMPONENT_OPTIONROM  0x30
+#define CBFS_COMPONENT_BOOTSPLASH 0x40
+#define CBFS_COMPONENT_RAW        0x50
+#define CBFS_COMPONENT_VSA        0x51
+#define CBFS_COMPONENT_MBI        0x52
+#define CBFS_COMPONENT_MICROCODE  0x53
 
 /* The deleted type is chosen to be a value
  * that can be written in a FLASH from all other
Index: util/cbfstool/common.c
===================================================================
--- util/cbfstool/common.c	(revision 5169)
+++ util/cbfstool/common.c	(working copy)
@@ -128,6 +128,11 @@ 
 	{CBFS_COMPONENT_STAGE, "stage"},
 	{CBFS_COMPONENT_PAYLOAD, "payload"},
 	{CBFS_COMPONENT_OPTIONROM, "optionrom"},
+	{CBFS_COMPONENT_BOOTSPLASH, "bootsplash"},
+	{CBFS_COMPONENT_RAW, "raw"},
+	{CBFS_COMPONENT_VSA, "vsa"},
+	{CBFS_COMPONENT_MBI, "mbi"},
+	{CBFS_COMPONENT_MICROCODE, "microcode"},
 	{CBFS_COMPONENT_DELETED, "deleted"},
 	{CBFS_COMPONENT_NULL, "null"}
 };