1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2011 The Chromium OS Authors.
4 * (C) Copyright 2002-2006
8 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
14 #include <bootstage.h>
15 #include <clock_legacy.h>
21 #include <env_internal.h>
39 #include <status_led.h>
45 #include <asm/cache.h>
46 #ifdef CONFIG_MACH_TYPE
47 #include <asm/mach-types.h>
49 #if defined(CONFIG_MP) && defined(CONFIG_PPC)
52 #include <asm/global_data.h>
54 #include <asm/sections.h>
56 #include <linux/errno.h>
59 * Pointer to initial global data area
61 * Here we initialize it if needed.
63 #ifdef XTRN_DECLARE_GLOBAL_DATA_PTR
64 #undef XTRN_DECLARE_GLOBAL_DATA_PTR
65 #define XTRN_DECLARE_GLOBAL_DATA_PTR /* empty = allocate here */
66 DECLARE_GLOBAL_DATA_PTR = (gd_t *)(CONFIG_SYS_INIT_GD_ADDR);
68 DECLARE_GLOBAL_DATA_PTR;
73 * refactored to a single function, something like:
75 * void led_set_state(enum led_colour_t colour, int on);
77 /************************************************************************
78 * Coloured LED functionality
79 ************************************************************************
80 * May be supplied by boards if desired
82 __weak void coloured_LED_init(void) {}
83 __weak void red_led_on(void) {}
84 __weak void red_led_off(void) {}
85 __weak void green_led_on(void) {}
86 __weak void green_led_off(void) {}
87 __weak void yellow_led_on(void) {}
88 __weak void yellow_led_off(void) {}
89 __weak void blue_led_on(void) {}
90 __weak void blue_led_off(void) {}
93 * Why is gd allocated a register? Prior to reloc it might be better to
94 * just pass it around to each function in this file?
96 * After reloc one could argue that it is hardly used and doesn't need
97 * to be in a register. Or if it is it should perhaps hold pointers to all
98 * global data for all modules, so that post-reloc we can avoid the massive
99 * literal pool we get on ARM. Or perhaps just encourage each module to use
103 #if defined(CONFIG_WATCHDOG) || defined(CONFIG_HW_WATCHDOG)
104 static int init_func_watchdog_init(void)
106 # if defined(CONFIG_HW_WATCHDOG) && \
107 (defined(CONFIG_M68K) || defined(CONFIG_MICROBLAZE) || \
108 defined(CONFIG_SH) || \
109 defined(CONFIG_DESIGNWARE_WATCHDOG) || \
110 defined(CONFIG_IMX_WATCHDOG))
112 puts(" Watchdog enabled\n");
119 int init_func_watchdog_reset(void)
125 #endif /* CONFIG_WATCHDOG */
127 __weak void board_add_ram_info(int use_default)
129 /* please define platform specific board_add_ram_info() */
132 static int init_baud_rate(void)
134 gd->baudrate = env_get_ulong("baudrate", 10, CONFIG_BAUDRATE);
138 static int display_text_info(void)
140 #if !defined(CONFIG_SANDBOX) && !defined(CONFIG_EFI_APP)
141 ulong bss_start, bss_end, text_base;
143 bss_start = (ulong)&__bss_start;
144 bss_end = (ulong)&__bss_end;
146 #ifdef CONFIG_SYS_TEXT_BASE
147 text_base = CONFIG_SYS_TEXT_BASE;
149 text_base = CONFIG_SYS_MONITOR_BASE;
152 debug("U-Boot code: %08lX -> %08lX BSS: -> %08lX\n",
153 text_base, bss_start, bss_end);
159 #ifdef CONFIG_SYSRESET
160 static int print_resetinfo(void)
166 ret = uclass_first_device_err(UCLASS_SYSRESET, &dev);
168 debug("%s: No sysreset device found (error: %d)\n",
170 /* Not all boards have sysreset drivers available during early
171 * boot, so don't fail if one can't be found.
176 if (!sysreset_get_status(dev, status, sizeof(status)))
177 printf("%s", status);
183 #if defined(CONFIG_DISPLAY_CPUINFO) && CONFIG_IS_ENABLED(CPU)
184 static int print_cpuinfo(void)
190 dev = cpu_get_current_dev();
192 debug("%s: Could not get CPU device\n",
197 ret = cpu_get_desc(dev, desc, sizeof(desc));
199 debug("%s: Could not get CPU description (err = %d)\n",
204 printf("CPU: %s\n", desc);
210 static int announce_dram_init(void)
216 static int show_dram_config(void)
218 unsigned long long size;
221 debug("\nRAM Configuration:\n");
222 for (i = size = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
223 size += gd->bd->bi_dram[i].size;
224 debug("Bank #%d: %llx ", i,
225 (unsigned long long)(gd->bd->bi_dram[i].start));
227 print_size(gd->bd->bi_dram[i].size, "\n");
232 print_size(size, "");
233 board_add_ram_info(0);
239 __weak int dram_init_banksize(void)
241 gd->bd->bi_dram[0].start = gd->ram_base;
242 gd->bd->bi_dram[0].size = get_effective_memsize();
247 #if defined(CONFIG_SYS_I2C)
248 static int init_func_i2c(void)
257 #if defined(CONFIG_VID)
258 __weak int init_func_vid(void)
264 static int setup_mon_len(void)
266 #if defined(__ARM__) || defined(__MICROBLAZE__)
267 gd->mon_len = (ulong)&__bss_end - (ulong)_start;
268 #elif defined(CONFIG_SANDBOX) || defined(CONFIG_EFI_APP)
269 gd->mon_len = (ulong)&_end - (ulong)_init;
270 #elif defined(CONFIG_NIOS2) || defined(CONFIG_XTENSA)
271 gd->mon_len = CONFIG_SYS_MONITOR_LEN;
272 #elif defined(CONFIG_NDS32) || defined(CONFIG_SH) || defined(CONFIG_RISCV)
273 gd->mon_len = (ulong)(&__bss_end) - (ulong)(&_start);
274 #elif defined(CONFIG_SYS_MONITOR_BASE)
275 /* TODO: use (ulong)&__bss_end - (ulong)&__text_start; ? */
276 gd->mon_len = (ulong)&__bss_end - CONFIG_SYS_MONITOR_BASE;
281 static int setup_spl_handoff(void)
283 #if CONFIG_IS_ENABLED(HANDOFF)
284 gd->spl_handoff = bloblist_find(BLOBLISTT_SPL_HANDOFF,
285 sizeof(struct spl_handoff));
286 debug("Found SPL hand-off info %p\n", gd->spl_handoff);
292 __weak int arch_cpu_init(void)
297 __weak int mach_cpu_init(void)
302 /* Get the top of usable RAM */
303 __weak ulong board_get_usable_ram_top(ulong total_size)
305 #if defined(CONFIG_SYS_SDRAM_BASE) && CONFIG_SYS_SDRAM_BASE > 0
307 * Detect whether we have so much RAM that it goes past the end of our
308 * 32-bit address space. If so, clip the usable RAM so it doesn't.
310 if (gd->ram_top < CONFIG_SYS_SDRAM_BASE)
312 * Will wrap back to top of 32-bit space when reservations
320 static int setup_dest_addr(void)
322 debug("Monitor len: %08lX\n", gd->mon_len);
324 * Ram is setup, size stored in gd !!
326 debug("Ram size: %08lX\n", (ulong)gd->ram_size);
327 #if defined(CONFIG_SYS_MEM_TOP_HIDE)
329 * Subtract specified amount of memory to hide so that it won't
330 * get "touched" at all by U-Boot. By fixing up gd->ram_size
331 * the Linux kernel should now get passed the now "corrected"
332 * memory size and won't touch it either. This should work
333 * for arch/ppc and arch/powerpc. Only Linux board ports in
334 * arch/powerpc with bootwrapper support, that recalculate the
335 * memory size from the SDRAM controller setup will have to
338 gd->ram_size -= CONFIG_SYS_MEM_TOP_HIDE;
340 #ifdef CONFIG_SYS_SDRAM_BASE
341 gd->ram_base = CONFIG_SYS_SDRAM_BASE;
343 gd->ram_top = gd->ram_base + get_effective_memsize();
344 gd->ram_top = board_get_usable_ram_top(gd->mon_len);
345 gd->relocaddr = gd->ram_top;
346 debug("Ram top: %08lX\n", (ulong)gd->ram_top);
347 #if defined(CONFIG_MP) && (defined(CONFIG_MPC86xx) || defined(CONFIG_E500))
349 * We need to make sure the location we intend to put secondary core
350 * boot code is reserved and not used by any part of u-boot
352 if (gd->relocaddr > determine_mp_bootpg(NULL)) {
353 gd->relocaddr = determine_mp_bootpg(NULL);
354 debug("Reserving MP boot page to %08lx\n", gd->relocaddr);
361 /* reserve protected RAM */
362 static int reserve_pram(void)
366 reg = env_get_ulong("pram", 10, CONFIG_PRAM);
367 gd->relocaddr -= (reg << 10); /* size is in kB */
368 debug("Reserving %ldk for protected RAM at %08lx\n", reg,
372 #endif /* CONFIG_PRAM */
374 /* Round memory pointer down to next 4 kB limit */
375 static int reserve_round_4k(void)
377 gd->relocaddr &= ~(4096 - 1);
381 __weak int arch_reserve_mmu(void)
386 static int reserve_video(void)
388 #ifdef CONFIG_DM_VIDEO
392 addr = gd->relocaddr;
393 ret = video_reserve(&addr);
396 debug("Reserving %luk for video at: %08lx\n",
397 (unsigned long)gd->relocaddr - addr, addr);
398 gd->relocaddr = addr;
399 #elif defined(CONFIG_LCD)
400 # ifdef CONFIG_FB_ADDR
401 gd->fb_base = CONFIG_FB_ADDR;
403 /* reserve memory for LCD display (always full pages) */
404 gd->relocaddr = lcd_setmem(gd->relocaddr);
405 gd->fb_base = gd->relocaddr;
406 # endif /* CONFIG_FB_ADDR */
412 static int reserve_trace(void)
415 gd->relocaddr -= CONFIG_TRACE_BUFFER_SIZE;
416 gd->trace_buff = map_sysmem(gd->relocaddr, CONFIG_TRACE_BUFFER_SIZE);
417 debug("Reserving %luk for trace data at: %08lx\n",
418 (unsigned long)CONFIG_TRACE_BUFFER_SIZE >> 10, gd->relocaddr);
424 static int reserve_uboot(void)
426 if (!(gd->flags & GD_FLG_SKIP_RELOC)) {
428 * reserve memory for U-Boot code, data & bss
429 * round down to next 4 kB limit
431 gd->relocaddr -= gd->mon_len;
432 gd->relocaddr &= ~(4096 - 1);
433 #if defined(CONFIG_E500) || defined(CONFIG_MIPS)
434 /* round down to next 64 kB limit so that IVPR stays aligned */
435 gd->relocaddr &= ~(65536 - 1);
438 debug("Reserving %ldk for U-Boot at: %08lx\n",
439 gd->mon_len >> 10, gd->relocaddr);
442 gd->start_addr_sp = gd->relocaddr;
448 * reserve after start_addr_sp the requested size and make the stack pointer
449 * 16-byte aligned, this alignment is needed for cast on the reserved memory
450 * ref = x86_64 ABI: https://reviews.llvm.org/D30049: 16 bytes
451 * = ARMv8 Instruction Set Overview: quad word, 16 bytes
453 static unsigned long reserve_stack_aligned(size_t size)
455 return ALIGN_DOWN(gd->start_addr_sp - size, 16);
458 #ifdef CONFIG_SYS_NONCACHED_MEMORY
459 static int reserve_noncached(void)
462 * The value of gd->start_addr_sp must match the value of malloc_start
463 * calculated in boatrd_f.c:initr_malloc(), which is passed to
464 * board_r.c:mem_malloc_init() and then used by
465 * cache.c:noncached_init()
467 * These calculations must match the code in cache.c:noncached_init()
469 gd->start_addr_sp = ALIGN(gd->start_addr_sp, MMU_SECTION_SIZE) -
471 gd->start_addr_sp -= ALIGN(CONFIG_SYS_NONCACHED_MEMORY,
473 debug("Reserving %dM for noncached_alloc() at: %08lx\n",
474 CONFIG_SYS_NONCACHED_MEMORY >> 20, gd->start_addr_sp);
480 /* reserve memory for malloc() area */
481 static int reserve_malloc(void)
483 gd->start_addr_sp = reserve_stack_aligned(TOTAL_MALLOC_LEN);
484 debug("Reserving %dk for malloc() at: %08lx\n",
485 TOTAL_MALLOC_LEN >> 10, gd->start_addr_sp);
486 #ifdef CONFIG_SYS_NONCACHED_MEMORY
493 /* (permanently) allocate a Board Info struct */
494 static int reserve_board(void)
497 gd->start_addr_sp = reserve_stack_aligned(sizeof(struct bd_info));
498 gd->bd = (struct bd_info *)map_sysmem(gd->start_addr_sp,
499 sizeof(struct bd_info));
500 memset(gd->bd, '\0', sizeof(struct bd_info));
501 debug("Reserving %zu Bytes for Board Info at: %08lx\n",
502 sizeof(struct bd_info), gd->start_addr_sp);
507 static int reserve_global_data(void)
509 gd->start_addr_sp = reserve_stack_aligned(sizeof(gd_t));
510 gd->new_gd = (gd_t *)map_sysmem(gd->start_addr_sp, sizeof(gd_t));
511 debug("Reserving %zu Bytes for Global Data at: %08lx\n",
512 sizeof(gd_t), gd->start_addr_sp);
516 static int reserve_fdt(void)
518 if (!IS_ENABLED(CONFIG_OF_EMBED)) {
520 * If the device tree is sitting immediately above our image
521 * then we must relocate it. If it is embedded in the data
522 * section, then it will be relocated with other data.
525 gd->fdt_size = ALIGN(fdt_totalsize(gd->fdt_blob), 32);
527 gd->start_addr_sp = reserve_stack_aligned(gd->fdt_size);
528 gd->new_fdt = map_sysmem(gd->start_addr_sp, gd->fdt_size);
529 debug("Reserving %lu Bytes for FDT at: %08lx\n",
530 gd->fdt_size, gd->start_addr_sp);
537 static int reserve_bootstage(void)
539 #ifdef CONFIG_BOOTSTAGE
540 int size = bootstage_get_size();
542 gd->start_addr_sp = reserve_stack_aligned(size);
543 gd->new_bootstage = map_sysmem(gd->start_addr_sp, size);
544 debug("Reserving %#x Bytes for bootstage at: %08lx\n", size,
551 __weak int arch_reserve_stacks(void)
556 static int reserve_stacks(void)
558 /* make stack pointer 16-byte aligned */
559 gd->start_addr_sp = reserve_stack_aligned(16);
562 * let the architecture-specific code tailor gd->start_addr_sp and
565 return arch_reserve_stacks();
568 static int reserve_bloblist(void)
570 #ifdef CONFIG_BLOBLIST
571 /* Align to a 4KB boundary for easier reading of addresses */
572 gd->start_addr_sp = ALIGN_DOWN(gd->start_addr_sp -
573 CONFIG_BLOBLIST_SIZE_RELOC, 0x1000);
574 gd->new_bloblist = map_sysmem(gd->start_addr_sp,
575 CONFIG_BLOBLIST_SIZE_RELOC);
581 static int display_new_sp(void)
583 debug("New Stack Pointer is: %08lx\n", gd->start_addr_sp);
588 __weak int arch_setup_bdinfo(void)
593 int setup_bdinfo(void)
595 struct bd_info *bd = gd->bd;
597 if (IS_ENABLED(CONFIG_SYS_HAS_SRAM)) {
598 bd->bi_sramstart = CONFIG_SYS_SRAM_BASE; /* start of SRAM */
599 bd->bi_sramsize = CONFIG_SYS_SRAM_SIZE; /* size of SRAM */
602 #ifdef CONFIG_MACH_TYPE
603 bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
606 return arch_setup_bdinfo();
610 static int init_post(void)
612 post_bootmode_init();
613 post_run(NULL, POST_ROM | post_bootmode_get(0));
619 static int reloc_fdt(void)
621 if (!IS_ENABLED(CONFIG_OF_EMBED)) {
622 if (gd->flags & GD_FLG_SKIP_RELOC)
625 memcpy(gd->new_fdt, gd->fdt_blob,
626 fdt_totalsize(gd->fdt_blob));
627 gd->fdt_blob = gd->new_fdt;
634 static int reloc_bootstage(void)
636 #ifdef CONFIG_BOOTSTAGE
637 if (gd->flags & GD_FLG_SKIP_RELOC)
639 if (gd->new_bootstage) {
640 int size = bootstage_get_size();
642 debug("Copying bootstage from %p to %p, size %x\n",
643 gd->bootstage, gd->new_bootstage, size);
644 memcpy(gd->new_bootstage, gd->bootstage, size);
645 gd->bootstage = gd->new_bootstage;
646 bootstage_relocate();
653 static int reloc_bloblist(void)
655 #ifdef CONFIG_BLOBLIST
656 if (gd->flags & GD_FLG_SKIP_RELOC)
658 if (gd->new_bloblist) {
659 int size = CONFIG_BLOBLIST_SIZE;
661 debug("Copying bloblist from %p to %p, size %x\n",
662 gd->bloblist, gd->new_bloblist, size);
663 bloblist_reloc(gd->new_bloblist, CONFIG_BLOBLIST_SIZE_RELOC,
665 gd->bloblist = gd->new_bloblist;
672 static int setup_reloc(void)
674 if (gd->flags & GD_FLG_SKIP_RELOC) {
675 debug("Skipping relocation due to flag\n");
679 #ifdef CONFIG_SYS_TEXT_BASE
681 gd->reloc_off = gd->relocaddr - (unsigned long)__image_copy_start;
682 #elif defined(CONFIG_M68K)
684 * On all ColdFire arch cpu, monitor code starts always
685 * just after the default vector table location, so at 0x400
687 gd->reloc_off = gd->relocaddr - (CONFIG_SYS_TEXT_BASE + 0x400);
688 #elif !defined(CONFIG_SANDBOX)
689 gd->reloc_off = gd->relocaddr - CONFIG_SYS_TEXT_BASE;
692 memcpy(gd->new_gd, (char *)gd, sizeof(gd_t));
694 debug("Relocation Offset is: %08lx\n", gd->reloc_off);
695 debug("Relocating to %08lx, new gd at %08lx, sp at %08lx\n",
696 gd->relocaddr, (ulong)map_to_sysmem(gd->new_gd),
702 #ifdef CONFIG_OF_BOARD_FIXUP
703 static int fix_fdt(void)
705 return board_fix_fdt((void *)gd->fdt_blob);
709 /* ARM calls relocate_code from its crt0.S */
710 #if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) && \
711 !CONFIG_IS_ENABLED(X86_64)
713 static int jump_to_copy(void)
715 if (gd->flags & GD_FLG_SKIP_RELOC)
718 * x86 is special, but in a nice way. It uses a trampoline which
719 * enables the dcache if possible.
721 * For now, other archs use relocate_code(), which is implemented
722 * similarly for all archs. When we do generic relocation, hopefully
723 * we can make all archs enable the dcache prior to relocation.
725 #if defined(CONFIG_X86) || defined(CONFIG_ARC)
727 * SDRAM and console are now initialised. The final stack can now
728 * be setup in SDRAM. Code execution will continue in Flash, but
729 * with the stack in SDRAM and Global Data in temporary memory
732 arch_setup_gd(gd->new_gd);
733 board_init_f_r_trampoline(gd->start_addr_sp);
735 relocate_code(gd->start_addr_sp, gd->new_gd, gd->relocaddr);
742 /* Record the board_init_f() bootstage (after arch_cpu_init()) */
743 static int initf_bootstage(void)
745 bool from_spl = IS_ENABLED(CONFIG_SPL_BOOTSTAGE) &&
746 IS_ENABLED(CONFIG_BOOTSTAGE_STASH);
749 ret = bootstage_init(!from_spl);
753 const void *stash = map_sysmem(CONFIG_BOOTSTAGE_STASH_ADDR,
754 CONFIG_BOOTSTAGE_STASH_SIZE);
756 ret = bootstage_unstash(stash, CONFIG_BOOTSTAGE_STASH_SIZE);
757 if (ret && ret != -ENOENT) {
758 debug("Failed to unstash bootstage: err=%d\n", ret);
763 bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_F, "board_init_f");
768 static int initf_dm(void)
770 #if defined(CONFIG_DM) && CONFIG_VAL(SYS_MALLOC_F_LEN)
773 bootstage_start(BOOTSTAGE_ID_ACCUM_DM_F, "dm_f");
774 ret = dm_init_and_scan(true);
775 bootstage_accum(BOOTSTAGE_ID_ACCUM_DM_F);
779 if (IS_ENABLED(CONFIG_TIMER_EARLY)) {
780 ret = dm_timer_init();
789 /* Architecture-specific memory reservation */
790 __weak int reserve_arch(void)
795 __weak int arch_cpu_init_dm(void)
800 __weak int checkcpu(void)
805 __weak int clear_bss(void)
810 static const init_fnc_t init_sequence_f[] = {
812 #ifdef CONFIG_OF_CONTROL
815 #ifdef CONFIG_TRACE_EARLY
820 initf_bootstage, /* uses its own timer, so does not need DM */
821 #ifdef CONFIG_BLOBLIST
825 #if defined(CONFIG_CONSOLE_RECORD_INIT_F)
828 #if defined(CONFIG_HAVE_FSP)
831 arch_cpu_init, /* basic arch cpu dependent setup */
832 mach_cpu_init, /* SoC/machine dependent CPU setup */
835 #if defined(CONFIG_BOARD_EARLY_INIT_F)
838 #if defined(CONFIG_PPC) || defined(CONFIG_SYS_FSL_CLK) || defined(CONFIG_M68K)
839 /* get CPU and bus clocks according to the environment variable */
840 get_clocks, /* get CPU and bus clocks (etc.) */
842 #if !defined(CONFIG_M68K)
843 timer_init, /* initialize timer */
845 #if defined(CONFIG_BOARD_POSTCLK_INIT)
848 env_init, /* initialize environment */
849 init_baud_rate, /* initialze baudrate settings */
850 serial_init, /* serial communications setup */
851 console_init_f, /* stage 1 init of console */
852 display_options, /* say that we are here */
853 display_text_info, /* show debugging info if required */
855 #if defined(CONFIG_SYSRESET)
858 #if defined(CONFIG_DISPLAY_CPUINFO)
859 print_cpuinfo, /* display cpu info (and speed) */
861 #if defined(CONFIG_DTB_RESELECT)
864 #if defined(CONFIG_DISPLAY_BOARDINFO)
867 INIT_FUNC_WATCHDOG_INIT
868 #if defined(CONFIG_MISC_INIT_F)
871 INIT_FUNC_WATCHDOG_RESET
872 #if defined(CONFIG_SYS_I2C)
875 #if defined(CONFIG_VID) && !defined(CONFIG_SPL)
879 dram_init, /* configure available RAM banks */
883 INIT_FUNC_WATCHDOG_RESET
884 #if defined(CONFIG_SYS_DRAM_TEST)
886 #endif /* CONFIG_SYS_DRAM_TEST */
887 INIT_FUNC_WATCHDOG_RESET
892 INIT_FUNC_WATCHDOG_RESET
894 * Now that we have DRAM mapped and working, we can
895 * relocate the code and continue running from DRAM.
897 * Reserve memory at end of RAM for (top down in that order):
898 * - area that won't get touched by U-Boot and Linux (optional)
899 * - kernel log buffer
903 * - board info struct
906 #ifdef CONFIG_OF_BOARD_FIXUP
927 INIT_FUNC_WATCHDOG_RESET
930 INIT_FUNC_WATCHDOG_RESET
935 #if defined(CONFIG_X86) || defined(CONFIG_ARC)
940 #if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) && \
941 !CONFIG_IS_ENABLED(X86_64)
947 void board_init_f(ulong boot_flags)
949 gd->flags = boot_flags;
950 gd->have_console = 0;
952 if (initcall_run_list(init_sequence_f))
955 #if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) && \
956 !defined(CONFIG_EFI_APP) && !CONFIG_IS_ENABLED(X86_64) && \
958 /* NOTREACHED - jump_to_copy() does not return */
963 #if defined(CONFIG_X86) || defined(CONFIG_ARC)
965 * For now this code is only used on x86.
967 * init_sequence_f_r is the list of init functions which are run when
968 * U-Boot is executing from Flash with a semi-limited 'C' environment.
969 * The following limitations must be considered when implementing an
971 * - 'static' variables are read-only
972 * - Global Data (gd->xxx) is read/write
974 * The '_f_r' sequence must, as a minimum, copy U-Boot to RAM (if
975 * supported). It _should_, if possible, copy global data to RAM and
976 * initialise the CPU caches (to speed up the relocation process)
978 * NOTE: At present only x86 uses this route, but it is intended that
979 * all archs will move to this when generic relocation is implemented.
981 static const init_fnc_t init_sequence_f_r[] = {
982 #if !CONFIG_IS_ENABLED(X86_64)
989 void board_init_f_r(void)
991 if (initcall_run_list(init_sequence_f_r))
995 * The pre-relocation drivers may be using memory that has now gone
996 * away. Mark serial as unavailable - this will fall back to the debug
999 * Do the same with log drivers since the memory may not be available.
1001 gd->flags &= ~(GD_FLG_SERIAL_READY | GD_FLG_LOG_READY);
1007 * U-Boot has been copied into SDRAM, the BSS has been cleared etc.
1008 * Transfer execution from Flash to RAM by calculating the address
1009 * of the in-RAM copy of board_init_r() and calling it
1011 (board_init_r + gd->reloc_off)((gd_t *)gd, gd->relocaddr);
1013 /* NOTREACHED - board_init_r() does not return */
1016 #endif /* CONFIG_X86 */