[coreboot-gerrit] Patch set updated for coreboot: 55640b2 lib/cbfs: Use linker symbols over .c include in cbfs.c

Edward O'Callaghan (eocallaghan@alterapraxis.com) gerrit at coreboot.org
Tue Nov 18 15:52:55 CET 2014


Edward O'Callaghan (eocallaghan at alterapraxis.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/7426

-gerrit

commit 55640b2a6a7a29144bb34afda7a97351eca56dde
Author: Edward O'Callaghan <eocallaghan at alterapraxis.com>
Date:   Tue Nov 11 12:22:04 2014 +1100

    lib/cbfs: Use linker symbols over .c include in cbfs.c
    
    Change-Id: Ieb7f383c84401aab87adc833deebf289cd0c9a0f
    Signed-off-by: Edward O'Callaghan <eocallaghan at alterapraxis.com>
---
 src/lib/Makefile.inc |  8 ++++----
 src/lib/cbfs.c       | 48 ++----------------------------------------------
 src/lib/cbfs_core.c  |  2 ++
 src/lib/cbfs_core.h  | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 60 insertions(+), 50 deletions(-)

diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc
index 98292a8..6286cab 100644
--- a/src/lib/Makefile.inc
+++ b/src/lib/Makefile.inc
@@ -18,7 +18,7 @@
 #
 subdirs-y += loaders
 
-bootblock-y += cbfs.c
+bootblock-y += cbfs.c cbfs_core.c
 bootblock-y += memchr.c
 bootblock-y += memcmp.c
 
@@ -28,7 +28,7 @@ $(foreach arch,$(ARCH_SUPPORTED),\
 	    $(eval rmodules_$(arch)-y += memcmp.c))
 
 romstage-$(CONFIG_I2C_TPM) += delay.c
-romstage-y += cbfs.c
+romstage-y += cbfs.c cbfs_core.c
 romstage-$(CONFIG_COMPRESS_RAMSTAGE) += lzma.c
 #romstage-y += lzmadecode.c
 romstage-$(CONFIG_CACHE_AS_RAM) += ramtest.c
@@ -56,7 +56,7 @@ ramstage-y += delay.c
 ramstage-y += fallback_boot.c
 ramstage-y += compute_ip_checksum.c
 ramstage-y += version.c
-ramstage-y += cbfs.c
+ramstage-y += cbfs.c cbfs_core.c
 ramstage-y += lzma.c
 #ramstage-y += lzmadecode.c
 ramstage-y += stack.c
@@ -91,7 +91,7 @@ ramstage-$(CONFIG_REG_SCRIPT) += reg_script.c
 
 romstage-$(CONFIG_CACHE_RELOCATED_RAMSTAGE_OUTSIDE_CBMEM) += ramstage_cache.c
 
-smm-y += cbfs.c memcmp.c
+smm-y += cbfs.c cbfs_core.c memcmp.c
 smm-$(CONFIG_COMPILER_GCC) += gcc.c
 
 $(obj)/lib/version.ramstage.o : $(obj)/build.h
diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c
index de25736..9ee2b46 100644
--- a/src/lib/cbfs.c
+++ b/src/lib/cbfs.c
@@ -18,52 +18,8 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
  */
 
-#ifdef LIBPAYLOAD
-# include <libpayload-config.h>
-# ifdef CONFIG_LZMA
-#  include <lzma.h>
-#  define CBFS_CORE_WITH_LZMA
-# endif
-# define CBFS_MINI_BUILD
-#elif defined(__SMM__)
-# define CBFS_MINI_BUILD
-#elif defined(__BOOT_BLOCK__)
-  /* No LZMA in boot block. */
-#elif defined(__PRE_RAM__) && !CONFIG_COMPRESS_RAMSTAGE
-  /* No LZMA in romstage if ramstage is not compressed. */
-#else
-# define CBFS_CORE_WITH_LZMA
-# include <lib.h>
-#endif
-
-#include <cbfs.h>
-#include <string.h>
-#include <cbmem.h>
-
-#ifdef LIBPAYLOAD
-# include <stdio.h>
-# define DEBUG(x...)
-# define LOG(x...) printf(x)
-# define ERROR(x...) printf(x)
-#else
-# include <console/console.h>
-# define ERROR(x...) printk(BIOS_ERR, "CBFS: " x)
-# define LOG(x...) printk(BIOS_INFO, "CBFS: " x)
-# if CONFIG_DEBUG_CBFS
-#  define DEBUG(x...) printk(BIOS_SPEW, "CBFS: " x)
-# else
-#  define DEBUG(x...)
-# endif
-#endif
-
-#if defined(CONFIG_CBFS_HEADER_ROM_OFFSET) && (CONFIG_CBFS_HEADER_ROM_OFFSET)
-# define CBFS_HEADER_ROM_ADDRESS (CONFIG_CBFS_HEADER_ROM_OFFSET)
-#else
-// Indirect address: only works on 32bit top-aligned systems.
-# define CBFS_HEADER_ROM_ADDRESS (*(uint32_t *)0xfffffffc)
-#endif
 
-#include "cbfs_core.c"
+#include "cbfs_core.h"
 
 #ifndef __SMM__
 static inline int tohex4(unsigned int c)
@@ -120,7 +76,7 @@ void *cbfs_load_optionrom(struct cbfs_media *media, uint16_t vendor,
 void * cbfs_load_stage(struct cbfs_media *media, const char *name)
 {
 	struct cbfs_stage *stage = (struct cbfs_stage *)
-		cbfs_get_file_content(media, name, CBFS_TYPE_STAGE, NULL);
+	cbfs_get_file_content(media, name, CBFS_TYPE_STAGE, NULL);
 	/* this is a mess. There is no ntohll. */
 	/* for now, assume compatible byte order until we solve this. */
 	uintptr_t entry;
diff --git a/src/lib/cbfs_core.c b/src/lib/cbfs_core.c
index 5e83a4e..0f97755 100644
--- a/src/lib/cbfs_core.c
+++ b/src/lib/cbfs_core.c
@@ -52,6 +52,8 @@
 #include <cbfs.h>
 #include <string.h>
 
+#include "cbfs_core.h"
+
 /* returns a pointer to CBFS master header, or CBFS_HEADER_INVALID_ADDRESS
  *  on failure */
 const struct cbfs_header *cbfs_get_header(struct cbfs_media *media)
diff --git a/src/lib/cbfs_core.h b/src/lib/cbfs_core.h
new file mode 100644
index 0000000..c1eecd2
--- /dev/null
+++ b/src/lib/cbfs_core.h
@@ -0,0 +1,52 @@
+#ifndef __LIB_CBFS_CORE
+#define __LIB_CBFS_CORE
+
+#include <cbfs.h>
+#include <string.h>
+
+#ifdef LIBPAYLOAD
+# include <libpayload-config.h>
+# ifdef CONFIG_LZMA
+#  include <lzma.h>
+#  define CBFS_CORE_WITH_LZMA
+# endif
+# define CBFS_MINI_BUILD
+#elif defined(__SMM__)
+# define CBFS_MINI_BUILD
+#elif defined(__BOOT_BLOCK__)
+  /* No LZMA in boot block. */
+#elif defined(__PRE_RAM__) && !CONFIG_COMPRESS_RAMSTAGE
+  /* No LZMA in romstage if ramstage is not compressed. */
+#else
+# define CBFS_CORE_WITH_LZMA
+# include <lib.h>
+#endif
+
+#include <cbfs.h>
+#include <string.h>
+#include <cbmem.h>
+
+#ifdef LIBPAYLOAD
+# include <stdio.h>
+# define DEBUG(x...)
+# define LOG(x...) printf(x)
+# define ERROR(x...) printf(x)
+#else
+# include <console/console.h>
+# define ERROR(x...) printk(BIOS_ERR, "CBFS: " x)
+# define LOG(x...) printk(BIOS_INFO, "CBFS: " x)
+# if CONFIG_DEBUG_CBFS
+#  define DEBUG(x...) printk(BIOS_SPEW, "CBFS: " x)
+# else
+#  define DEBUG(x...)
+# endif
+#endif
+
+#if defined(CONFIG_CBFS_HEADER_ROM_OFFSET) && (CONFIG_CBFS_HEADER_ROM_OFFSET)
+# define CBFS_HEADER_ROM_ADDRESS (CONFIG_CBFS_HEADER_ROM_OFFSET)
+#else
+// Indirect address: only works on 32bit top-aligned systems.
+# define CBFS_HEADER_ROM_ADDRESS (*(uint32_t *)0xfffffffc)
+#endif
+
+#endif /* __LIB_CBFS_CORE */



More information about the coreboot-gerrit mailing list