From 257aaee9e3aeeffe50ed54de7342dd2bc9baae76 Mon Sep 17 00:00:00 2001 From: Julius Werner Date: Tue, 25 Nov 2014 12:55:20 -0800 Subject: [PATCH] arm: Redesign mainboard and SoC hooks for bootblock This patch makes some slight changes to the way bootblock_cpu_init() and bootblock_mainboard_init() are used on ARM. Experience has shown that nearly every board needs either one or both of these hooks, so having explicit Kconfigs for them has become unwieldy. Instead, this patch implements them as a weak symbol that can be overridden by mainboard/SoC code, as the more recent arm64_soc_init() is also doing. Since the whole concept of a single "CPU" on ARM systems has kinda died out, rename bootblock_cpu_init() to bootblock_soc_init(). (This had already been done on Storm/ipq806x, which is now adjusted to directly use the generic hook.) Also add a proper license header to bootblock_common.h that was somehow missing. Leaving non-ARM32 architectures out for now, since they are still using the really old and weird x86 model of directly including a file. These architectures should also eventually be aligned with the cleaner ARM32 model as they mature. BRANCH=None BUG=chrome-os-partner:32123 TEST=Booted on Pinky. Compiled for Storm and confirmed in the disassembly that bootblock_soc_init() is still compiled in and called right before the (now no-op) bootblock_mainboard_init(). Change-Id: I57013b99c3af455cc3d7e78f344888d27ffb8d79 Signed-off-by: Julius Werner Reviewed-on: https://chromium-review.googlesource.com/231940 Reviewed-by: Aaron Durbin --- src/Kconfig | 8 ------ src/arch/arm/armv4/bootblock_simple.c | 5 +++- src/arch/arm/armv7/bootblock_simple.c | 5 +++- src/arch/arm/include/bootblock_common.h | 38 ++++++++++++++++--------- src/cpu/armltd/armv8/Kconfig | 5 ---- src/cpu/armltd/armv8/bootblock.c | 17 ----------- src/cpu/armltd/cortex-a9/Kconfig | 6 ---- src/cpu/armltd/cortex-a9/bootblock.c | 17 ----------- src/mainboard/google/storm/Makefile.inc | 1 - src/mainboard/google/storm/bootblock.c | 25 ---------------- src/soc/marvell/bg4cd/bootblock.c | 3 +- src/soc/rockchip/rk3288/bootblock.c | 2 +- src/soc/samsung/exynos5250/bootblock.c | 2 +- src/soc/samsung/exynos5420/bootblock.c | 2 +- 14 files changed, 37 insertions(+), 99 deletions(-) delete mode 100644 src/cpu/armltd/armv8/bootblock.c delete mode 100644 src/cpu/armltd/cortex-a9/bootblock.c delete mode 100644 src/mainboard/google/storm/bootblock.c diff --git a/src/Kconfig b/src/Kconfig index f926f2e266..8d3d831df9 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -281,14 +281,6 @@ source src/soc/Kconfig endmenu -config CPU_HAS_BOOTBLOCK_INIT - bool - default n - -config MAINBOARD_HAS_BOOTBLOCK_INIT - bool - default n - source src/device/Kconfig menu "Generic Drivers" diff --git a/src/arch/arm/armv4/bootblock_simple.c b/src/arch/arm/armv4/bootblock_simple.c index 80401b3951..517e4d1bb0 100644 --- a/src/arch/arm/armv4/bootblock_simple.c +++ b/src/arch/arm/armv4/bootblock_simple.c @@ -26,12 +26,15 @@ #include #include +__attribute__((weak)) void bootblock_soc_init(void) { /* do nothing */ } +__attribute__((weak)) void bootblock_mainboard_init(void) { /* do nothing */ } + void main(void) { const char *stage_name = "fallback/romstage"; void *entry; - bootblock_cpu_init(); + bootblock_soc_init(); bootblock_mainboard_init(); if (CONFIG_BOOTBLOCK_CONSOLE) { diff --git a/src/arch/arm/armv7/bootblock_simple.c b/src/arch/arm/armv7/bootblock_simple.c index 27261df98d..5e7ba2035a 100644 --- a/src/arch/arm/armv7/bootblock_simple.c +++ b/src/arch/arm/armv7/bootblock_simple.c @@ -27,11 +27,14 @@ #include #include +__attribute__((weak)) void bootblock_soc_init(void) { /* do nothing */ } +__attribute__((weak)) void bootblock_mainboard_init(void) { /* do nothing */ } + void main(void) { void *entry = (void *)-1; - bootblock_cpu_init(); + bootblock_soc_init(); bootblock_mainboard_init(); if (CONFIG_BOOTBLOCK_CONSOLE) { diff --git a/src/arch/arm/include/bootblock_common.h b/src/arch/arm/include/bootblock_common.h index 72a4ba9fce..413a206177 100644 --- a/src/arch/arm/include/bootblock_common.h +++ b/src/arch/arm/include/bootblock_common.h @@ -1,17 +1,27 @@ -#if CONFIG_CPU_HAS_BOOTBLOCK_INIT -void bootblock_cpu_init(void); -#else -static void __attribute__((unused)) bootblock_cpu_init(void) -{ -} -#endif +/* + * This file is part of the coreboot project. + * + * Copyright 2014 Google Inc. + * + * 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 + */ -#if CONFIG_MAINBOARD_HAS_BOOTBLOCK_INIT +#ifndef __ARCH_BOOTBLOCK_COMMON_H +#define __ARCH_BOOTBLOCK_COMMON_H + +/* These are defined as weak no-ops that can be overridden by mainboard/SoC. */ void bootblock_mainboard_init(void); -#else -static void __attribute__((unused)) bootblock_mainboard_init(void) -{ -} -#endif - void bootblock_soc_init(void); + +#endif /* __ARCH_BOOTBLOCK_COMMON_H */ diff --git a/src/cpu/armltd/armv8/Kconfig b/src/cpu/armltd/armv8/Kconfig index 19575671d4..13a712c18f 100644 --- a/src/cpu/armltd/armv8/Kconfig +++ b/src/cpu/armltd/armv8/Kconfig @@ -6,10 +6,5 @@ config CPU_ARMLTD_ARMV8 if CPU_ARMLTD_ARMV8 -config BOOTBLOCK_CPU_INIT - string - default "cpu/armltd/armv8/bootblock.c" - help - CPU/SoC-specific bootblock code. endif diff --git a/src/cpu/armltd/armv8/bootblock.c b/src/cpu/armltd/armv8/bootblock.c deleted file mode 100644 index 8925439d2a..0000000000 --- a/src/cpu/armltd/armv8/bootblock.c +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (C) 2013 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - */ - -void bootblock_cpu_init(void); -void bootblock_cpu_init(void) -{ -} diff --git a/src/cpu/armltd/cortex-a9/Kconfig b/src/cpu/armltd/cortex-a9/Kconfig index 7b4231bfc7..91dbdb9211 100644 --- a/src/cpu/armltd/cortex-a9/Kconfig +++ b/src/cpu/armltd/cortex-a9/Kconfig @@ -8,10 +8,4 @@ config CPU_ARMLTD_CORTEX_A9 if CPU_ARMLTD_CORTEX_A9 -config BOOTBLOCK_CPU_INIT - string - default "cpu/armltd/cortex-a9/bootblock.c" - help - CPU/SoC-specific bootblock code. - endif diff --git a/src/cpu/armltd/cortex-a9/bootblock.c b/src/cpu/armltd/cortex-a9/bootblock.c deleted file mode 100644 index 8925439d2a..0000000000 --- a/src/cpu/armltd/cortex-a9/bootblock.c +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (C) 2013 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - */ - -void bootblock_cpu_init(void); -void bootblock_cpu_init(void) -{ -} diff --git a/src/mainboard/google/storm/Makefile.inc b/src/mainboard/google/storm/Makefile.inc index 80727b6adb..6ee0841dc3 100644 --- a/src/mainboard/google/storm/Makefile.inc +++ b/src/mainboard/google/storm/Makefile.inc @@ -17,7 +17,6 @@ ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ## -bootblock-y += bootblock.c bootblock-y += cdp.c romstage-y += romstage.c diff --git a/src/mainboard/google/storm/bootblock.c b/src/mainboard/google/storm/bootblock.c deleted file mode 100644 index 03f214a5cb..0000000000 --- a/src/mainboard/google/storm/bootblock.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - * This file is part of the coreboot project. - * - * Copyright 2014 Google Inc. - * - * 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 - */ - -#include - -void bootblock_mainboard_init(void) -{ - bootblock_soc_init(); -} diff --git a/src/soc/marvell/bg4cd/bootblock.c b/src/soc/marvell/bg4cd/bootblock.c index e7ce203d46..236a71810a 100644 --- a/src/soc/marvell/bg4cd/bootblock.c +++ b/src/soc/marvell/bg4cd/bootblock.c @@ -19,6 +19,7 @@ #include -void bootblock_cpu_init(void) +void bootblock_soc_init(void) { +/* TODO: I assume this is a placeholder. If it's not really needed delete it. */ } diff --git a/src/soc/rockchip/rk3288/bootblock.c b/src/soc/rockchip/rk3288/bootblock.c index 8f6c92d0dc..006af727d1 100644 --- a/src/soc/rockchip/rk3288/bootblock.c +++ b/src/soc/rockchip/rk3288/bootblock.c @@ -28,7 +28,7 @@ #include #include -void bootblock_cpu_init(void) +void bootblock_soc_init(void) { rk3288_init_timer(); diff --git a/src/soc/samsung/exynos5250/bootblock.c b/src/soc/samsung/exynos5250/bootblock.c index d4655e3557..dd0e01c87c 100644 --- a/src/soc/samsung/exynos5250/bootblock.c +++ b/src/soc/samsung/exynos5250/bootblock.c @@ -21,7 +21,7 @@ #include #include -void bootblock_cpu_init(void) +void bootblock_soc_init(void) { /* kick off the multi-core timer. * We want to do this as early as we can. diff --git a/src/soc/samsung/exynos5420/bootblock.c b/src/soc/samsung/exynos5420/bootblock.c index 26877dd36c..f347677b94 100644 --- a/src/soc/samsung/exynos5420/bootblock.c +++ b/src/soc/samsung/exynos5420/bootblock.c @@ -28,7 +28,7 @@ #define SRAM_SIZE 1 #define SRAM_END (SRAM_START + SRAM_SIZE) /* plus one... */ -void bootblock_cpu_init(void) +void bootblock_soc_init(void) { /* kick off the multi-core timer. * We want to do this as early as we can.