2 * Copyright (c) 2011 The Chromium OS Authors.
3 * (C) Copyright 2002-2006
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
7 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
8 * Marius Groeger <mgroeger@sysgo.de>
10 * SPDX-License-Identifier: GPL-2.0+
15 #include <environment.h>
21 #include <init_helpers.h>
26 /* TODO: Can we move these into arch/ headers? */
36 #if defined(CONFIG_MP) && (defined(CONFIG_MPC86xx) || defined(CONFIG_E500))
44 #include <status_led.h>
50 #include <asm/sections.h>
52 #include <linux/errno.h>
55 * Pointer to initial global data area
57 * Here we initialize it if needed.
59 #ifdef XTRN_DECLARE_GLOBAL_DATA_PTR
60 #undef XTRN_DECLARE_GLOBAL_DATA_PTR
61 #define XTRN_DECLARE_GLOBAL_DATA_PTR /* empty = allocate here */
62 DECLARE_GLOBAL_DATA_PTR = (gd_t *) (CONFIG_SYS_INIT_GD_ADDR);
64 DECLARE_GLOBAL_DATA_PTR;
68 * TODO(sjg@chromium.org): IMO this code should be
69 * refactored to a single function, something like:
71 * void led_set_state(enum led_colour_t colour, int on);
73 /************************************************************************
74 * Coloured LED functionality
75 ************************************************************************
76 * May be supplied by boards if desired
78 __weak void coloured_LED_init(void) {}
79 __weak void red_led_on(void) {}
80 __weak void red_led_off(void) {}
81 __weak void green_led_on(void) {}
82 __weak void green_led_off(void) {}
83 __weak void yellow_led_on(void) {}
84 __weak void yellow_led_off(void) {}
85 __weak void blue_led_on(void) {}
86 __weak void blue_led_off(void) {}
89 * Why is gd allocated a register? Prior to reloc it might be better to
90 * just pass it around to each function in this file?
92 * After reloc one could argue that it is hardly used and doesn't need
93 * to be in a register. Or if it is it should perhaps hold pointers to all
94 * global data for all modules, so that post-reloc we can avoid the massive
95 * literal pool we get on ARM. Or perhaps just encourage each module to use
99 #if defined(CONFIG_WATCHDOG) || defined(CONFIG_HW_WATCHDOG)
100 static int init_func_watchdog_init(void)
102 # if defined(CONFIG_HW_WATCHDOG) && \
103 (defined(CONFIG_M68K) || defined(CONFIG_MICROBLAZE) || \
104 defined(CONFIG_SH) || defined(CONFIG_AT91SAM9_WATCHDOG) || \
105 defined(CONFIG_DESIGNWARE_WATCHDOG) || \
106 defined(CONFIG_IMX_WATCHDOG))
108 puts(" Watchdog enabled\n");
115 int init_func_watchdog_reset(void)
121 #endif /* CONFIG_WATCHDOG */
123 __weak void board_add_ram_info(int use_default)
125 /* please define platform specific board_add_ram_info() */
128 static int init_baud_rate(void)
130 gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE);
134 static int display_text_info(void)
136 #if !defined(CONFIG_SANDBOX) && !defined(CONFIG_EFI_APP)
137 ulong bss_start, bss_end, text_base;
139 bss_start = (ulong)&__bss_start;
140 bss_end = (ulong)&__bss_end;
142 #ifdef CONFIG_SYS_TEXT_BASE
143 text_base = CONFIG_SYS_TEXT_BASE;
145 text_base = CONFIG_SYS_MONITOR_BASE;
148 debug("U-Boot code: %08lX -> %08lX BSS: -> %08lX\n",
149 text_base, bss_start, bss_end);
152 #ifdef CONFIG_USE_IRQ
153 debug("IRQ Stack: %08lx\n", IRQ_STACK_START);
154 debug("FIQ Stack: %08lx\n", FIQ_STACK_START);
160 static int announce_dram_init(void)
166 #if defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(CONFIG_M68K)
167 static int init_func_ram(void)
173 static int show_dram_config(void)
175 unsigned long long size;
177 #ifdef CONFIG_NR_DRAM_BANKS
180 debug("\nRAM Configuration:\n");
181 for (i = size = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
182 size += gd->bd->bi_dram[i].size;
183 debug("Bank #%d: %llx ", i,
184 (unsigned long long)(gd->bd->bi_dram[i].start));
186 print_size(gd->bd->bi_dram[i].size, "\n");
194 print_size(size, "");
195 board_add_ram_info(0);
201 __weak int dram_init_banksize(void)
203 #if defined(CONFIG_NR_DRAM_BANKS) && defined(CONFIG_SYS_SDRAM_BASE)
204 gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
205 gd->bd->bi_dram[0].size = get_effective_memsize();
211 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C)
212 static int init_func_i2c(void)
215 #ifdef CONFIG_SYS_I2C
218 i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
225 #if defined(CONFIG_HARD_SPI)
226 static int init_func_spi(void)
236 static int zero_global_data(void)
238 memset((void *)gd, '\0', sizeof(gd_t));
243 static int setup_mon_len(void)
245 #if defined(__ARM__) || defined(__MICROBLAZE__)
246 gd->mon_len = (ulong)&__bss_end - (ulong)_start;
247 #elif defined(CONFIG_SANDBOX) || defined(CONFIG_EFI_APP)
248 gd->mon_len = (ulong)&_end - (ulong)_init;
249 #elif defined(CONFIG_NIOS2) || defined(CONFIG_XTENSA)
250 gd->mon_len = CONFIG_SYS_MONITOR_LEN;
251 #elif defined(CONFIG_NDS32) || defined(CONFIG_SH)
252 gd->mon_len = (ulong)(&__bss_end) - (ulong)(&_start);
253 #elif defined(CONFIG_SYS_MONITOR_BASE)
254 /* TODO: use (ulong)&__bss_end - (ulong)&__text_start; ? */
255 gd->mon_len = (ulong)&__bss_end - CONFIG_SYS_MONITOR_BASE;
260 __weak int arch_cpu_init(void)
265 __weak int mach_cpu_init(void)
270 /* Get the top of usable RAM */
271 __weak ulong board_get_usable_ram_top(ulong total_size)
273 #ifdef CONFIG_SYS_SDRAM_BASE
275 * Detect whether we have so much RAM that it goes past the end of our
276 * 32-bit address space. If so, clip the usable RAM so it doesn't.
278 if (gd->ram_top < CONFIG_SYS_SDRAM_BASE)
280 * Will wrap back to top of 32-bit space when reservations
288 static int setup_dest_addr(void)
290 debug("Monitor len: %08lX\n", gd->mon_len);
292 * Ram is setup, size stored in gd !!
294 debug("Ram size: %08lX\n", (ulong)gd->ram_size);
295 #if defined(CONFIG_SYS_MEM_TOP_HIDE)
297 * Subtract specified amount of memory to hide so that it won't
298 * get "touched" at all by U-Boot. By fixing up gd->ram_size
299 * the Linux kernel should now get passed the now "corrected"
300 * memory size and won't touch it either. This should work
301 * for arch/ppc and arch/powerpc. Only Linux board ports in
302 * arch/powerpc with bootwrapper support, that recalculate the
303 * memory size from the SDRAM controller setup will have to
306 gd->ram_size -= CONFIG_SYS_MEM_TOP_HIDE;
308 #ifdef CONFIG_SYS_SDRAM_BASE
309 gd->ram_top = CONFIG_SYS_SDRAM_BASE;
311 gd->ram_top += get_effective_memsize();
312 gd->ram_top = board_get_usable_ram_top(gd->mon_len);
313 gd->relocaddr = gd->ram_top;
314 debug("Ram top: %08lX\n", (ulong)gd->ram_top);
315 #if defined(CONFIG_MP) && (defined(CONFIG_MPC86xx) || defined(CONFIG_E500))
317 * We need to make sure the location we intend to put secondary core
318 * boot code is reserved and not used by any part of u-boot
320 if (gd->relocaddr > determine_mp_bootpg(NULL)) {
321 gd->relocaddr = determine_mp_bootpg(NULL);
322 debug("Reserving MP boot page to %08lx\n", gd->relocaddr);
328 #if defined(CONFIG_LOGBUFFER)
329 static int reserve_logbuffer(void)
331 #ifndef CONFIG_ALT_LB_ADDR
332 /* reserve kernel log buffer */
333 gd->relocaddr -= LOGBUFF_RESERVE;
334 debug("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN,
343 /* reserve protected RAM */
344 static int reserve_pram(void)
348 reg = getenv_ulong("pram", 10, CONFIG_PRAM);
349 gd->relocaddr -= (reg << 10); /* size is in kB */
350 debug("Reserving %ldk for protected RAM at %08lx\n", reg,
354 #endif /* CONFIG_PRAM */
356 /* Round memory pointer down to next 4 kB limit */
357 static int reserve_round_4k(void)
359 gd->relocaddr &= ~(4096 - 1);
364 static int reserve_mmu(void)
366 #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
367 /* reserve TLB table */
368 gd->arch.tlb_size = PGTABLE_SIZE;
369 gd->relocaddr -= gd->arch.tlb_size;
371 /* round down to next 64 kB limit */
372 gd->relocaddr &= ~(0x10000 - 1);
374 gd->arch.tlb_addr = gd->relocaddr;
375 debug("TLB table from %08lx to %08lx\n", gd->arch.tlb_addr,
376 gd->arch.tlb_addr + gd->arch.tlb_size);
378 #ifdef CONFIG_SYS_MEM_RESERVE_SECURE
380 * Record allocated tlb_addr in case gd->tlb_addr to be overwritten
381 * with location within secure ram.
383 gd->arch.tlb_allocated = gd->arch.tlb_addr;
391 static int reserve_video(void)
393 #ifdef CONFIG_DM_VIDEO
397 addr = gd->relocaddr;
398 ret = video_reserve(&addr);
401 gd->relocaddr = addr;
402 #elif defined(CONFIG_LCD)
403 # ifdef CONFIG_FB_ADDR
404 gd->fb_base = CONFIG_FB_ADDR;
406 /* reserve memory for LCD display (always full pages) */
407 gd->relocaddr = lcd_setmem(gd->relocaddr);
408 gd->fb_base = gd->relocaddr;
409 # endif /* CONFIG_FB_ADDR */
410 #elif defined(CONFIG_VIDEO) && \
411 (!defined(CONFIG_PPC) || defined(CONFIG_8xx)) && \
412 !defined(CONFIG_ARM) && !defined(CONFIG_X86) && \
413 !defined(CONFIG_M68K)
414 /* reserve memory for video display (always full pages) */
415 gd->relocaddr = video_setmem(gd->relocaddr);
416 gd->fb_base = gd->relocaddr;
422 static int reserve_trace(void)
425 gd->relocaddr -= CONFIG_TRACE_BUFFER_SIZE;
426 gd->trace_buff = map_sysmem(gd->relocaddr, CONFIG_TRACE_BUFFER_SIZE);
427 debug("Reserving %dk for trace data at: %08lx\n",
428 CONFIG_TRACE_BUFFER_SIZE >> 10, gd->relocaddr);
434 static int reserve_uboot(void)
437 * reserve memory for U-Boot code, data & bss
438 * round down to next 4 kB limit
440 gd->relocaddr -= gd->mon_len;
441 gd->relocaddr &= ~(4096 - 1);
443 /* round down to next 64 kB limit so that IVPR stays aligned */
444 gd->relocaddr &= ~(65536 - 1);
447 debug("Reserving %ldk for U-Boot at: %08lx\n", gd->mon_len >> 10,
450 gd->start_addr_sp = gd->relocaddr;
455 /* reserve memory for malloc() area */
456 static int reserve_malloc(void)
458 gd->start_addr_sp = gd->start_addr_sp - TOTAL_MALLOC_LEN;
459 debug("Reserving %dk for malloc() at: %08lx\n",
460 TOTAL_MALLOC_LEN >> 10, gd->start_addr_sp);
464 /* (permanently) allocate a Board Info struct */
465 static int reserve_board(void)
468 gd->start_addr_sp -= sizeof(bd_t);
469 gd->bd = (bd_t *)map_sysmem(gd->start_addr_sp, sizeof(bd_t));
470 memset(gd->bd, '\0', sizeof(bd_t));
471 debug("Reserving %zu Bytes for Board Info at: %08lx\n",
472 sizeof(bd_t), gd->start_addr_sp);
477 static int setup_machine(void)
479 #ifdef CONFIG_MACH_TYPE
480 gd->bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
485 static int reserve_global_data(void)
487 gd->start_addr_sp -= sizeof(gd_t);
488 gd->new_gd = (gd_t *)map_sysmem(gd->start_addr_sp, sizeof(gd_t));
489 debug("Reserving %zu Bytes for Global Data at: %08lx\n",
490 sizeof(gd_t), gd->start_addr_sp);
494 static int reserve_fdt(void)
496 #ifndef CONFIG_OF_EMBED
498 * If the device tree is sitting immediately above our image then we
499 * must relocate it. If it is embedded in the data section, then it
500 * will be relocated with other data.
503 gd->fdt_size = ALIGN(fdt_totalsize(gd->fdt_blob) + 0x1000, 32);
505 gd->start_addr_sp -= gd->fdt_size;
506 gd->new_fdt = map_sysmem(gd->start_addr_sp, gd->fdt_size);
507 debug("Reserving %lu Bytes for FDT at: %08lx\n",
508 gd->fdt_size, gd->start_addr_sp);
515 int arch_reserve_stacks(void)
520 static int reserve_stacks(void)
522 /* make stack pointer 16-byte aligned */
523 gd->start_addr_sp -= 16;
524 gd->start_addr_sp &= ~0xf;
527 * let the architecture-specific code tailor gd->start_addr_sp and
530 return arch_reserve_stacks();
533 static int display_new_sp(void)
535 debug("New Stack Pointer is: %08lx\n", gd->start_addr_sp);
540 #if defined(CONFIG_M68K) || defined(CONFIG_MIPS) || defined(CONFIG_PPC) || \
542 static int setup_board_part1(void)
547 * Save local variables to board info struct
549 bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; /* start of memory */
550 bd->bi_memsize = gd->ram_size; /* size in bytes */
552 #ifdef CONFIG_SYS_SRAM_BASE
553 bd->bi_sramstart = CONFIG_SYS_SRAM_BASE; /* start of SRAM */
554 bd->bi_sramsize = CONFIG_SYS_SRAM_SIZE; /* size of SRAM */
557 #if defined(CONFIG_8xx) || defined(CONFIG_MPC8260) || defined(CONFIG_5xx) || \
558 defined(CONFIG_E500) || defined(CONFIG_MPC86xx)
559 bd->bi_immr_base = CONFIG_SYS_IMMR; /* base of IMMR register */
561 #if defined(CONFIG_MPC5xxx) || defined(CONFIG_M68K)
562 bd->bi_mbar_base = CONFIG_SYS_MBAR; /* base of internal registers */
564 #if defined(CONFIG_MPC83xx)
565 bd->bi_immrbar = CONFIG_SYS_IMMR;
572 #if defined(CONFIG_PPC) || defined(CONFIG_M68K)
573 static int setup_board_part2(void)
577 bd->bi_intfreq = gd->cpu_clk; /* Internal Freq, in Hz */
578 bd->bi_busfreq = gd->bus_clk; /* Bus Freq, in Hz */
579 #if defined(CONFIG_CPM2)
580 bd->bi_cpmfreq = gd->arch.cpm_clk;
581 bd->bi_brgfreq = gd->arch.brg_clk;
582 bd->bi_sccfreq = gd->arch.scc_clk;
583 bd->bi_vco = gd->arch.vco_out;
584 #endif /* CONFIG_CPM2 */
585 #if defined(CONFIG_MPC512X)
586 bd->bi_ipsfreq = gd->arch.ips_clk;
587 #endif /* CONFIG_MPC512X */
588 #if defined(CONFIG_MPC5xxx)
589 bd->bi_ipbfreq = gd->arch.ipb_clk;
590 bd->bi_pcifreq = gd->pci_clk;
591 #endif /* CONFIG_MPC5xxx */
592 #if defined(CONFIG_M68K) && defined(CONFIG_PCI)
593 bd->bi_pcifreq = gd->pci_clk;
595 #if defined(CONFIG_EXTRA_CLOCK)
596 bd->bi_inpfreq = gd->arch.inp_clk; /* input Freq in Hz */
597 bd->bi_vcofreq = gd->arch.vco_clk; /* vco Freq in Hz */
598 bd->bi_flbfreq = gd->arch.flb_clk; /* flexbus Freq in Hz */
606 static int init_post(void)
608 post_bootmode_init();
609 post_run(NULL, POST_ROM | post_bootmode_get(0));
615 static int reloc_fdt(void)
617 #ifndef CONFIG_OF_EMBED
618 if (gd->flags & GD_FLG_SKIP_RELOC)
621 memcpy(gd->new_fdt, gd->fdt_blob, gd->fdt_size);
622 gd->fdt_blob = gd->new_fdt;
629 static int setup_reloc(void)
631 if (gd->flags & GD_FLG_SKIP_RELOC) {
632 debug("Skipping relocation due to flag\n");
636 #ifdef CONFIG_SYS_TEXT_BASE
637 gd->reloc_off = gd->relocaddr - CONFIG_SYS_TEXT_BASE;
640 * On all ColdFire arch cpu, monitor code starts always
641 * just after the default vector table location, so at 0x400
643 gd->reloc_off = gd->relocaddr - (CONFIG_SYS_TEXT_BASE + 0x400);
646 memcpy(gd->new_gd, (char *)gd, sizeof(gd_t));
648 debug("Relocation Offset is: %08lx\n", gd->reloc_off);
649 debug("Relocating to %08lx, new gd at %08lx, sp at %08lx\n",
650 gd->relocaddr, (ulong)map_to_sysmem(gd->new_gd),
656 #ifdef CONFIG_OF_BOARD_FIXUP
657 static int fix_fdt(void)
659 return board_fix_fdt((void *)gd->fdt_blob);
663 /* ARM calls relocate_code from its crt0.S */
664 #if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) && \
665 !CONFIG_IS_ENABLED(X86_64)
667 static int jump_to_copy(void)
669 if (gd->flags & GD_FLG_SKIP_RELOC)
672 * x86 is special, but in a nice way. It uses a trampoline which
673 * enables the dcache if possible.
675 * For now, other archs use relocate_code(), which is implemented
676 * similarly for all archs. When we do generic relocation, hopefully
677 * we can make all archs enable the dcache prior to relocation.
679 #if defined(CONFIG_X86) || defined(CONFIG_ARC)
681 * SDRAM and console are now initialised. The final stack can now
682 * be setup in SDRAM. Code execution will continue in Flash, but
683 * with the stack in SDRAM and Global Data in temporary memory
686 arch_setup_gd(gd->new_gd);
687 board_init_f_r_trampoline(gd->start_addr_sp);
689 relocate_code(gd->start_addr_sp, gd->new_gd, gd->relocaddr);
696 /* Record the board_init_f() bootstage (after arch_cpu_init()) */
697 static int mark_bootstage(void)
699 bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_F, "board_init_f");
704 static int initf_console_record(void)
706 #if defined(CONFIG_CONSOLE_RECORD) && defined(CONFIG_SYS_MALLOC_F_LEN)
707 return console_record_init();
713 static int initf_dm(void)
715 #if defined(CONFIG_DM) && defined(CONFIG_SYS_MALLOC_F_LEN)
718 ret = dm_init_and_scan(true);
722 #ifdef CONFIG_TIMER_EARLY
723 ret = dm_timer_init();
731 /* Architecture-specific memory reservation */
732 __weak int reserve_arch(void)
737 __weak int arch_cpu_init_dm(void)
742 static const init_fnc_t init_sequence_f[] = {
744 #ifdef CONFIG_OF_CONTROL
751 initf_console_record,
752 #if defined(CONFIG_HAVE_FSP)
755 arch_cpu_init, /* basic arch cpu dependent setup */
756 mach_cpu_init, /* SoC/machine dependent CPU setup */
759 mark_bootstage, /* need timer, go after init dm */
760 #if defined(CONFIG_BOARD_EARLY_INIT_F)
763 #if defined(CONFIG_PPC) || defined(CONFIG_SYS_FSL_CLK) || defined(CONFIG_M68K)
764 /* get CPU and bus clocks according to the environment variable */
765 get_clocks, /* get CPU and bus clocks (etc.) */
767 timer_init, /* initialize timer */
768 #if defined(CONFIG_BOARD_POSTCLK_INIT)
771 env_init, /* initialize environment */
772 init_baud_rate, /* initialze baudrate settings */
773 serial_init, /* serial communications setup */
774 console_init_f, /* stage 1 init of console */
775 display_options, /* say that we are here */
776 display_text_info, /* show debugging info if required */
777 #if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_SH) || \
781 #if defined(CONFIG_DISPLAY_CPUINFO)
782 print_cpuinfo, /* display cpu info (and speed) */
784 #if defined(CONFIG_DISPLAY_BOARDINFO)
787 INIT_FUNC_WATCHDOG_INIT
788 #if defined(CONFIG_MISC_INIT_F)
791 INIT_FUNC_WATCHDOG_RESET
792 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C)
795 #if defined(CONFIG_HARD_SPI)
799 /* TODO: unify all these dram functions? */
800 #if defined(CONFIG_ARM) || defined(CONFIG_X86) || defined(CONFIG_NDS32) || \
801 defined(CONFIG_MICROBLAZE) || defined(CONFIG_AVR32) || \
803 dram_init, /* configure available RAM banks */
805 #if defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(CONFIG_M68K)
811 INIT_FUNC_WATCHDOG_RESET
812 #if defined(CONFIG_SYS_DRAM_TEST)
814 #endif /* CONFIG_SYS_DRAM_TEST */
815 INIT_FUNC_WATCHDOG_RESET
820 INIT_FUNC_WATCHDOG_RESET
822 * Now that we have DRAM mapped and working, we can
823 * relocate the code and continue running from DRAM.
825 * Reserve memory at end of RAM for (top down in that order):
826 * - area that won't get touched by U-Boot and Linux (optional)
827 * - kernel log buffer
831 * - board info struct
834 #if defined(CONFIG_LOGBUFFER)
856 #if defined(CONFIG_M68K) || defined(CONFIG_MIPS) || defined(CONFIG_PPC) || \
860 #if defined(CONFIG_PPC) || defined(CONFIG_M68K)
861 INIT_FUNC_WATCHDOG_RESET
865 #ifdef CONFIG_SYS_EXTBDINFO
868 #ifdef CONFIG_OF_BOARD_FIXUP
871 INIT_FUNC_WATCHDOG_RESET
874 #if defined(CONFIG_X86) || defined(CONFIG_ARC)
879 #if defined(CONFIG_XTENSA)
882 #if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) && \
883 !CONFIG_IS_ENABLED(X86_64)
889 void board_init_f(ulong boot_flags)
891 #ifdef CONFIG_SYS_GENERIC_GLOBAL_DATA
893 * For some architectures, global data is initialized and used before
894 * calling this function. The data should be preserved. For others,
895 * CONFIG_SYS_GENERIC_GLOBAL_DATA should be defined and use the stack
896 * here to host global data until relocation.
903 * Clear global data before it is accessed at debug print
904 * in initcall_run_list. Otherwise the debug print probably
905 * get the wrong value of gd->have_console.
910 gd->flags = boot_flags;
911 gd->have_console = 0;
913 if (initcall_run_list(init_sequence_f))
916 #if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) && \
917 !defined(CONFIG_EFI_APP) && !CONFIG_IS_ENABLED(X86_64)
918 /* NOTREACHED - jump_to_copy() does not return */
923 #if defined(CONFIG_X86) || defined(CONFIG_ARC)
925 * For now this code is only used on x86.
927 * init_sequence_f_r is the list of init functions which are run when
928 * U-Boot is executing from Flash with a semi-limited 'C' environment.
929 * The following limitations must be considered when implementing an
931 * - 'static' variables are read-only
932 * - Global Data (gd->xxx) is read/write
934 * The '_f_r' sequence must, as a minimum, copy U-Boot to RAM (if
935 * supported). It _should_, if possible, copy global data to RAM and
936 * initialise the CPU caches (to speed up the relocation process)
938 * NOTE: At present only x86 uses this route, but it is intended that
939 * all archs will move to this when generic relocation is implemented.
941 static const init_fnc_t init_sequence_f_r[] = {
942 #if !CONFIG_IS_ENABLED(X86_64)
949 void board_init_f_r(void)
951 if (initcall_run_list(init_sequence_f_r))
955 * The pre-relocation drivers may be using memory that has now gone
956 * away. Mark serial as unavailable - this will fall back to the debug
959 gd->flags &= ~GD_FLG_SERIAL_READY;
962 * U-Boot has been copied into SDRAM, the BSS has been cleared etc.
963 * Transfer execution from Flash to RAM by calculating the address
964 * of the in-RAM copy of board_init_r() and calling it
966 (board_init_r + gd->reloc_off)((gd_t *)gd, gd->relocaddr);
968 /* NOTREACHED - board_init_r() does not return */
971 #endif /* CONFIG_X86 */