From cdabc880e1273076ff0786fbbe0ffdc2ea87eca4 Mon Sep 17 00:00:00 2001 From: Edward O'Callaghan Date: Tue, 11 Nov 2014 12:22:04 +1100 Subject: lib/cbfs: Use linker symbols over .c include in cbfs.c Change-Id: Ieb7f383c84401aab87adc833deebf289cd0c9a0f Signed-off-by: Edward O'Callaghan Reviewed-on: http://review.coreboot.org/7426 Tested-by: build bot (Jenkins) Reviewed-by: Marc Jones --- 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(-) create mode 100644 src/lib/cbfs_core.h diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc index 98292a8e75..6286cabf13 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 de25736fc3..9ee2b468a8 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 -# ifdef CONFIG_LZMA -# include -# 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 -#endif - -#include -#include -#include - -#ifdef LIBPAYLOAD -# include -# define DEBUG(x...) -# define LOG(x...) printf(x) -# define ERROR(x...) printf(x) -#else -# include -# 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 5e83a4e4ff..0f97755314 100644 --- a/src/lib/cbfs_core.c +++ b/src/lib/cbfs_core.c @@ -52,6 +52,8 @@ #include #include +#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 0000000000..c1eecd25a3 --- /dev/null +++ b/src/lib/cbfs_core.h @@ -0,0 +1,52 @@ +#ifndef __LIB_CBFS_CORE +#define __LIB_CBFS_CORE + +#include +#include + +#ifdef LIBPAYLOAD +# include +# ifdef CONFIG_LZMA +# include +# 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 +#endif + +#include +#include +#include + +#ifdef LIBPAYLOAD +# include +# define DEBUG(x...) +# define LOG(x...) printf(x) +# define ERROR(x...) printf(x) +#else +# include +# 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 */ -- cgit v1.2.3