[U-Boot] [PATCH v6 18/31] x86: Adjust board_f.c for x86
Simon Glass
sjg at chromium.org
Wed Mar 6 01:39:52 CET 2013
For x86, things have adjusted somewhat since this series was originally
written. It has its own way of running through initcalls which is actually
nicer than others archs.
Unfortunately this does introduce exceptions. We will soon require use of
generic board on x86, but until then we need to fit in with what is there,
and treat x86 as a special case.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
Changes in v6: None
Changes in v5:
- Add new patch to adjust board_f.c for x86
Changes in v4: None
Changes in v3: None
Changes in v2: None
common/board_f.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 81 insertions(+), 2 deletions(-)
diff --git a/common/board_f.c b/common/board_f.c
index c73677b..0d88a96 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -57,6 +57,10 @@
#include <asm/mp.h>
#endif
#include <asm/sections.h>
+#ifdef CONFIG_X86
+#include <asm/init_helpers.h>
+#include <asm/relocate.h>
+#endif
#include <linux/compiler.h>
/*
@@ -423,7 +427,7 @@ static int reserve_lcd(void)
#endif /* CONFIG_LCD */
#if defined(CONFIG_VIDEO) && (!defined(CONFIG_PPC) || defined(CONFIG_8xx)) \
- && !defined(CONFIG_ARM)
+ && !defined(CONFIG_ARM) && !defined(CONFIG_X86)
static int reserve_video(void)
{
/* reserve memory for video display (always full pages) */
@@ -717,7 +721,25 @@ static int setup_reloc(void)
static int jump_to_copy(void)
{
+ /*
+ * x86 is special, but in a nice way. It uses a trampoline which
+ * enables the dcache if possible.
+ *
+ * For now, other archs use relocate_code(), which is implemented
+ * similarly for all archs. When we do generic relocation, hopefully
+ * we can make all archs enable the dcache prior to relocation.
+ */
+#ifdef CONFIG_X86
+ /*
+ * SDRAM and console are now initialised. The final stack can now
+ * be setup in SDRAM. Code execution will continue in Flash, but
+ * with the stack in SDRAM and Global Data in temporary memory
+ * (CPU cache)
+ */
+ board_init_f_r_trampoline(gd->start_addr_sp);
+#else
relocate_code(gd->dest_addr_sp, gd->new_gd, gd->dest_addr);
+#endif
return 0;
}
@@ -744,6 +766,12 @@ static init_fnc_t init_sequence_f[] = {
probecpu,
#endif
arch_cpu_init, /* basic arch cpu dependent setup */
+#ifdef CONFIG_X86
+ cpu_init_f, /* TODO(sjg at chromium.org): remove */
+# ifdef CONFIG_OF_CONTROL
+ find_fdt, /* TODO(sjg at chromium.org): remove */
+# endif
+#endif
mark_bootstage,
#ifdef CONFIG_OF_CONTROL
fdtdec_check_fdt,
@@ -792,6 +820,9 @@ static init_fnc_t init_sequence_f[] = {
init_baud_rate, /* initialze baudrate settings */
serial_init, /* serial communications setup */
console_init_f, /* stage 1 init of console */
+#if defined(CONFIG_X86) && defined(CONFIG_OF_CONTROL)
+ prepare_fdt, /* TODO(sjg at chromium.org): remove */
+#endif
display_options, /* say that we are here */
display_text_info, /* show debugging info if required */
#if defined(CONFIG_8260)
@@ -829,6 +860,8 @@ static init_fnc_t init_sequence_f[] = {
#endif
#ifdef CONFIG_X86
dram_init_f, /* configure available RAM banks */
+ /* x86 would prefer that this happens after relocation */
+ dram_init,
#endif
announce_dram_init,
/* TODO: unify all these dram functions? */
@@ -880,7 +913,7 @@ static init_fnc_t init_sequence_f[] = {
#endif
/* TODO: Why the dependency on CONFIG_8xx? */
#if defined(CONFIG_VIDEO) && (!defined(CONFIG_PPC) || defined(CONFIG_8xx)) \
- && !defined(CONFIG_ARM)
+ && !defined(CONFIG_ARM) && !defined(CONFIG_X86)
reserve_video,
#endif
reserve_uboot,
@@ -915,9 +948,11 @@ static init_fnc_t init_sequence_f[] = {
void board_init_f(ulong boot_flags)
{
+#ifndef CONFIG_X86
gd_t data;
gd = &data;
+#endif
gd->flags = boot_flags;
@@ -930,6 +965,50 @@ void board_init_f(ulong boot_flags)
#endif
}
+#ifdef CONFIG_X86
+/*
+ * For now this code is only used on x86.
+ *
+ * init_sequence_f_r is the list of init functions which are run when
+ * U-Boot is executing from Flash with a semi-limited 'C' environment.
+ * The following limitations must be considered when implementing an
+ * '_f_r' function:
+ * - 'static' variables are read-only
+ * - Global Data (gd->xxx) is read/write
+ *
+ * The '_f_r' sequence must, as a minimum, copy U-Boot to RAM (if
+ * supported). It _should_, if possible, copy global data to RAM and
+ * initialise the CPU caches (to speed up the relocation process)
+ *
+ * NOTE: At present only x86 uses this route, but it is intended that
+ * all archs will move to this when generic relocation is implemented.
+ */
+static init_fnc_t init_sequence_f_r[] = {
+ init_cache_f_r,
+ copy_uboot_to_ram,
+ clear_bss,
+ do_elf_reloc_fixups,
+
+ NULL,
+};
+
+void board_init_f_r(void)
+{
+ if (initcall_run_list(init_sequence_f_r))
+ hang();
+
+ /*
+ * U-Boot has been copied into SDRAM, the BSS has been cleared etc.
+ * Transfer execution from Flash to RAM by calculating the address
+ * of the in-RAM copy of board_init_r() and calling it
+ */
+ (board_init_r + gd->reloc_off)(gd, gd->relocaddr);
+
+ /* NOTREACHED - board_init_r() does not return */
+ hang();
+}
+#endif /* CONFIG_X86 */
+
void hang(void)
{
puts("### ERROR ### Please RESET the board ###\n");
--
1.8.1.3
More information about the U-Boot
mailing list