David Hendricks (dhendrix@chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2252
-gerrit
commit d8c5961da96cb75069cd373018e4713e82257879 Author: Hung-Te Lin hungte@chromium.org Date: Fri Feb 1 01:09:24 2013 +0800
armv7: Add 'bootblock' build class.
For ARM platform, the bootblock may need more C source files to initialize UART / SPI for loading romstage. To preventing making complex and implicit dependency by using #include inside bootblock.c, we should add a new build class "bootblock".
Also #ifdef __BOOT_BLOCK__ can be used to detect if the source is being compiled for boot block.
For x86, the bootblock is limited to fewer assembly files so it's not using this class. (Some files shared by x86 and arm in top level or lib are also changed but nothing should be changed in x86 build process.)
Change-Id: Ia81bccc366d2082397d133d9245f7ecb33b8bc8b Signed-off-by: Hung-Te Lin hungte@chromium.org --- Makefile.inc | 10 ++++- src/arch/armv7/Makefile.inc | 9 +++-- src/arch/armv7/bootblock_simple.c | 2 +- src/arch/armv7/include/arch/cbfs.h | 60 ----------------------------- src/arch/armv7/lib/Makefile.inc | 1 + src/cpu/samsung/exynos5-common/Makefile.inc | 1 + src/lib/Makefile.inc | 10 +++++ src/lib/cbfs.c | 2 + src/mainboard/google/snow/bootblock.c | 3 -- 9 files changed, 30 insertions(+), 68 deletions(-)
diff --git a/Makefile.inc b/Makefile.inc index 3731797..0b473e4 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -58,7 +58,7 @@ subdirs-y += site-local
####################################################################### # Add source classes and their build options -classes-y := ramstage romstage smm cpu_microcode +classes-y := ramstage romstage bootblock smm cpu_microcode
####################################################################### # Helper functions for ramstage postprocess @@ -111,6 +111,9 @@ $(error Your current configuration requires binary-only components, but you did endif endif
+bootblock-c-ccopts:=-D__BOOT_BLOCK__ +bootblock-S-ccopts:=-D__BOOT_BLOCK__ + smm-c-ccopts:=-D__SMM__ smm-S-ccopts:=-D__SMM__
@@ -121,6 +124,7 @@ endif
ramstage-c-deps:=$$(OPTION_TABLE_H) romstage-c-deps:=$$(OPTION_TABLE_H) +bootblock-c-deps:=$$(OPTION_TABLE_H)
####################################################################### # Add handler to compile ACPI's ASL @@ -286,6 +290,10 @@ $(obj)/%.romstage.o $(abspath $(obj))/%.romstage.o: $(obj)/%.c $(obj)/config.h $ @printf " CC $(subst $(obj)/,,$(@))\n" $(CC) -MMD -D__PRE_RAM__ $(CFLAGS) -c -o $@ $<
+$(obj)/%.bootblock.o $(abspath $(obj))/%.bootblock.o: $(obj)/%.c $(obj)/config.h $(OPTION_TABLE_H) + @printf " CC $(subst $(obj)/,,$(@))\n" + $(CC) -MMD -D__BOOT_BLOCK__ $(CFLAGS) -c -o $@ $< + ####################################################################### # Clean up rules clean-abuild: diff --git a/src/arch/armv7/Makefile.inc b/src/arch/armv7/Makefile.inc index e55f477..715ce1e 100644 --- a/src/arch/armv7/Makefile.inc +++ b/src/arch/armv7/Makefile.inc @@ -207,6 +207,9 @@ bootblock_inc += $(src)/arch/armv7/lib/id.inc bootblock_inc += $(chipset_bootblock_inc) bootblock_inc += $(objgenerated)/bootblock.inc
+bootblock_custom = $(src)/$(call strip_quotes,$(CONFIG_BOOTBLOCK_CPU_INIT)) +bootblock_custom += $(src)/$(call strip_quotes,$(CONFIG_BOOTBLOCK_MAINBOARD_INIT)) + $(objgenerated)/bootblock.ld: $$(bootblock_lds) $(obj)/ldoptions @printf " GEN $(subst $(obj)/,,$(@))\n" printf '$(foreach ldscript,ldoptions $(bootblock_lds),INCLUDE "$(ldscript)"\n)' > $@ @@ -223,18 +226,18 @@ $(objgenerated)/bootblock.s: $(objgenerated)/bootblock_inc.S $(obj)/config.h $(o @printf " CC $(subst $(obj)/,,$(@))\n" $(CC) -MMD -x assembler-with-cpp -E -I$(src)/include -I$(src)/arch/armv7/include -I$(obj) -include $(obj)/build.h -include $(obj)/config.h -I. -I$(src) $< -o $@
-$(objgenerated)/bootblock.inc: $(src)/arch/armv7/$(subst ",,$(CONFIG_BOOTBLOCK_SOURCE)) $(OPTION_TABLE_H) +$(objgenerated)/bootblock.inc: $(src)/arch/armv7/$(subst ",,$(CONFIG_BOOTBLOCK_SOURCE)) $(bootblock_custom) $(OPTION_TABLE_H) @printf " CC $(subst $(obj)/,,$(@))\n" $(CC) $(INCLUDES) -MM -MT$(objgenerated)/bootblock.inc \ $< > $(objgenerated)/bootblock.inc.d $(CC) -c -S $(CFLAGS) -I. $(INCLUDES) $< -o $@
-$(objcbfs)/bootblock.debug: $(objgenerated)/bootblock.o $(objgenerated)/bootblock.ld +$(objcbfs)/bootblock.debug: $(objgenerated)/bootblock.o $(objgenerated)/bootblock.ld $$(bootblock-objs) $(stages) @printf " LINK $(subst $(obj)/,,$(@))\n" ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y) $(LD) -m armelf_linux_eabi -static -o $@.tmp -L$(obj) $< -T $(objgenerated)/bootblock.ld else - $(CC) -nostdlib -nostartfiles -static -o $@ -L$(obj) -T $(objgenerated)/bootblock.ld -Wl,--start-group $(objgenerated)/bootblock.o $(stages) $(LIBGCC_FILE_NAME) -Wl,--end-group + $(CC) -nostdlib -nostartfiles -static -o $@ -L$(obj) -T $(objgenerated)/bootblock.ld -Wl,--start-group $(objgenerated)/bootblock.o $(bootblock-objs) $(stages) $(LIBGCC_FILE_NAME) -Wl,--end-group endif
################################################################################ diff --git a/src/arch/armv7/bootblock_simple.c b/src/arch/armv7/bootblock_simple.c index 8df7e6a..e808edc 100644 --- a/src/arch/armv7/bootblock_simple.c +++ b/src/arch/armv7/bootblock_simple.c @@ -20,9 +20,9 @@ */
#include <bootblock_common.h> -#include <arch/cbfs.h> #include <arch/hlt.h> #include <arch/stages.h> +#include <cbfs.h>
#include "stages.c"
diff --git a/src/arch/armv7/include/arch/cbfs.h b/src/arch/armv7/include/arch/cbfs.h deleted file mode 100644 index e34a0d2..0000000 --- a/src/arch/armv7/include/arch/cbfs.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This file is part of the coreboot project. - * - * Copyright (C) 2012 The ChromiumOS Authors. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __INCLUDE_ARCH_CBFS__ -#define __INCLUDE_ARCH_CBFS__ - -#include <cbfs_core.h> -#include <arch/byteorder.h> - -// TODO FIXME This file is only for providing CBFS function in bootblock. -// Should be removed once bootblock can link lib/* files. -#include "lib/cbfs.c" - -// mem* and ulzma are now workarounds for bootblock compilation. -void *memcpy(void *dest, const void *src, size_t n) { - char *d = (char *)dest; - const char *s = (const char*)src; - while (n-- > 0) - *d++ = *s++; - return dest; -} - -void *memset(void *dest, int c, size_t n) { - char *d = (char*)dest; - while (n-- > 0) - *d++ = c; - return dest; -} - -int memcmp(const void *ptr1, const void *ptr2, size_t n) { - const char *s1 = (const char*)ptr1, *s2 = (const char*)ptr2; - int c; - while (n-- > 0) - if ((c = *s1++ - *s2++)) - return c; - return 0; -} - -unsigned long ulzma(unsigned char *src, unsigned char *dest) { - // TODO remove this. - return -1; -} - -#endif // __INCLUDE_ARCH_CBFS__ diff --git a/src/arch/armv7/lib/Makefile.inc b/src/arch/armv7/lib/Makefile.inc index e52bc54..2470db2 100644 --- a/src/arch/armv7/lib/Makefile.inc +++ b/src/arch/armv7/lib/Makefile.inc @@ -21,3 +21,4 @@ ramstage-y += syslib.c #FIXME(dhendrix): should this be a config option? romstage-y += eabi_compat.c ramstage-y += eabi_compat.c +bootblock-y += eabi_compat.c diff --git a/src/cpu/samsung/exynos5-common/Makefile.inc b/src/cpu/samsung/exynos5-common/Makefile.inc index d919347..ff86fbd 100644 --- a/src/cpu/samsung/exynos5-common/Makefile.inc +++ b/src/cpu/samsung/exynos5-common/Makefile.inc @@ -1,2 +1,3 @@ romstage-y += spi.c ramstage-y += spi.c +bootblock-y += spi.c diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc index 6796448..8ff0a44 100644 --- a/src/lib/Makefile.inc +++ b/src/lib/Makefile.inc @@ -17,6 +17,16 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #
+bootblock-y += cbfs.c +ifneq ($(CONFIG_HAVE_ARCH_MEMSET),y) +bootblock-y += memset.c +endif +bootblock-y += memchr.c +ifneq ($(CONFIG_HAVE_ARCH_MEMCPY),y) +bootblock-y += memcpy.c +endif +bootblock-y += memcmp.c + ifneq ($(CONFIG_HAVE_ARCH_MEMSET),y) romstage-y += memset.c endif diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c index 3e44582..4702f1e 100644 --- a/src/lib/cbfs.c +++ b/src/lib/cbfs.c @@ -27,6 +27,8 @@ # define CBFS_MINI_BUILD #elif defined(__SMM__) # define CBFS_MINI_BUILD +#elif defined(__BOOT_BLOCK__) + /* No LZMA in boot block. */ #else # define CBFS_CORE_WITH_LZMA # include <lib.h> diff --git a/src/mainboard/google/snow/bootblock.c b/src/mainboard/google/snow/bootblock.c index 3887e7e..7609410 100644 --- a/src/mainboard/google/snow/bootblock.c +++ b/src/mainboard/google/snow/bootblock.c @@ -42,9 +42,6 @@
#define EXYNOS5_CLOCK_BASE 0x10010000
-/* TODO Move to Makefile.inc once we support adding bootblock stage files. */ -#include "cpu/samsung/exynos5-common/spi.c" - void clock_ll_set_pre_ratio(enum periph_id periph_id, unsigned divisor) { struct exynos5_clock *clk =