lib/cbfs: Use linker symbols over .c include in cbfs.c

Change-Id: Ieb7f383c84401aab87adc833deebf289cd0c9a0f
Signed-off-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Reviewed-on: http://review.coreboot.org/7426
Tested-by: build bot (Jenkins)
Reviewed-by: Marc Jones <marc.jones@se-eng.com>
This commit is contained in:
Edward O'Callaghan 2014-11-11 12:22:04 +11:00
parent 129462da1b
commit cdabc880e1
4 changed files with 60 additions and 50 deletions

View File

@ -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

View File

@ -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;

View File

@ -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)

52
src/lib/cbfs_core.h Normal file
View File

@ -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 */