- make some functions static because they're only used within cbfs.c
- add new types for bootsplash, RAW, VSA, MBI
- drop unused cbfs_get_file()

Signed-off-by: Stefan Reinauer <stepan@coresystems.de>


Index: src/include/cbfs.h
===================================================================
--- src/include/cbfs.h	(revision 5166)
+++ src/include/cbfs.h	(working copy)
@@ -63,9 +63,13 @@
     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
 
 /** this is the master cbfs header - it need to be
     located somewhere in the bootblock.  Where it
@@ -164,11 +168,7 @@
 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 5166)
+++ 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;
 
@@ -71,7 +80,7 @@
 	return header;
 }
 
-struct cbfs_file *cbfs_find(const char *name)
+static struct cbfs_file *cbfs_find(const char *name)
 {
 	struct cbfs_header *header = cbfs_master_header();
 	unsigned long offset;
@@ -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: util/x86emu/yabel/vbe.c
===================================================================
--- util/x86emu/yabel/vbe.c	(revision 5166)
+++ 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 5166)
+++ util/cbfstool/cbfs.h	(working copy)
@@ -68,9 +68,13 @@
     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
 
 /* 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 5166)
+++ util/cbfstool/common.c	(working copy)
@@ -128,6 +128,10 @@
 	{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_DELETED, "deleted"},
 	{CBFS_COMPONENT_NULL, "null"}
 };
