[coreboot-gerrit] Patch set updated for coreboot: 0d68a3f lib/cbfs: Use linker symbols over .c include in cbfs.c
Edward O'Callaghan (eocallaghan@alterapraxis.com)
gerrit at coreboot.org
Tue Nov 11 06:04:57 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 0d68a3fe0b1dfe9d709f9c1b35ac444d9056eb11
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 | 46 +--------------------------------------
src/lib/cbfs_core.c | 2 ++
src/lib/cbfs_core.h | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 68 insertions(+), 49 deletions(-)
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc
index c104ce3..20b0957 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..9dd94fe 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)
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..43e5024
--- /dev/null
+++ b/src/lib/cbfs_core.h
@@ -0,0 +1,61 @@
+#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
+
+const struct cbfs_header *cbfs_get_header(struct cbfs_media *media);
+
+struct cbfs_file *cbfs_get_file(struct cbfs_media *media, const char *name);
+
+void *cbfs_get_file_content(struct cbfs_media *media, const char *name,
+ int type, size_t *sz);
+
+int cbfs_decompress(int algo, void *src, void *dst, int len);
+
+#endif /* __LIB_CBFS_CORE */
More information about the coreboot-gerrit
mailing list