summaryrefslogtreecommitdiff
path: root/common/board_f.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2013-03-05 14:39:52 +0000
committerTom Rini <trini@ti.com>2013-03-15 16:14:00 -0400
commit48a3380675f4759fd63609d03f5cffc33274f96b (patch)
treec511e31f65720a58fbe50883b8f6f111b391e013 /common/board_f.c
parent660c60c4e70c1f8369e7fc4e23b3bc10e01f1199 (diff)
downloadu-boot-imx-48a3380675f4759fd63609d03f5cffc33274f96b.zip
u-boot-imx-48a3380675f4759fd63609d03f5cffc33274f96b.tar.gz
u-boot-imx-48a3380675f4759fd63609d03f5cffc33274f96b.tar.bz2
x86: Adjust board_f.c for x86
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@chromium.org>
Diffstat (limited to 'common/board_f.c')
-rw-r--r--common/board_f.c83
1 files changed, 81 insertions, 2 deletions
diff --git a/common/board_f.c b/common/board_f.c
index 1721eed..29b49c3 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) */
@@ -716,7 +720,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;
}
@@ -743,6 +765,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@chromium.org): remove */
+# ifdef CONFIG_OF_CONTROL
+ find_fdt, /* TODO(sjg@chromium.org): remove */
+# endif
+#endif
mark_bootstage,
#ifdef CONFIG_OF_CONTROL
fdtdec_check_fdt,
@@ -791,6 +819,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@chromium.org): remove */
+#endif
display_options, /* say that we are here */
display_text_info, /* show debugging info if required */
#if defined(CONFIG_8260)
@@ -828,6 +859,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? */
@@ -879,7 +912,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,
@@ -914,9 +947,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;
@@ -929,6 +964,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");