1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2011 The Chromium OS Authors.
4 * (C) Copyright 2002-2006
5 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
8 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
9 * Marius Groeger <mgroeger@sysgo.de>
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)
53 #include <asm/sections.h>
55 #include <linux/errno.h>
58 * Pointer to initial global data area
60 * Here we initialize it if needed.
62 #ifdef XTRN_DECLARE_GLOBAL_DATA_PTR
63 #undef XTRN_DECLARE_GLOBAL_DATA_PTR
64 #define XTRN_DECLARE_GLOBAL_DATA_PTR /* empty = allocate here */
65 DECLARE_GLOBAL_DATA_PTR = (gd_t *)(CONFIG_SYS_INIT_GD_ADDR);
67 DECLARE_GLOBAL_DATA_PTR;
71 * TODO(sjg@chromium.org): IMO this code should be
72 * refactored to a single function, something like:
74 * void led_set_state(enum led_colour_t colour, int on);
76 /************************************************************************
77 * Coloured LED functionality
78 ************************************************************************
79 * May be supplied by boards if desired
81 __weak void coloured_LED_init(void) {}
82 __weak void red_led_on(void) {}
83 __weak void red_led_off(void) {}
84 __weak void green_led_on(void) {}
85 __weak void green_led_off(void) {}
86 __weak void yellow_led_on(void) {}
87 __weak void yellow_led_off(void) {}
88 __weak void blue_led_on(void) {}
89 __weak void blue_led_off(void) {}
92 * Why is gd allocated a register? Prior to reloc it might be better to
93 * just pass it around to each function in this file?
95 * After reloc one could argue that it is hardly used and doesn't need
96 * to be in a register. Or if it is it should perhaps hold pointers to all
97 * global data for all modules, so that post-reloc we can avoid the massive
98 * literal pool we get on ARM. Or perhaps just encourage each module to use
102 #if defined(CONFIG_WATCHDOG) || defined(CONFIG_HW_WATCHDOG)
103 static int init_func_watchdog_init(void)
105 # if defined(CONFIG_HW_WATCHDOG) && \
106 (defined(CONFIG_M68K) || defined(CONFIG_MICROBLAZE) || \
107 defined(CONFIG_SH) || \
108 defined(CONFIG_DESIGNWARE_WATCHDOG) || \
109 defined(CONFIG_IMX_WATCHDOG))
111 puts(" Watchdog enabled\n");
118 int init_func_watchdog_reset(void)
124 #endif /* CONFIG_WATCHDOG */
126 __weak void board_add_ram_info(int use_default)
128 /* please define platform specific board_add_ram_info() */
131 static int init_baud_rate(void)
133 gd->baudrate = env_get_ulong("baudrate", 10, CONFIG_BAUDRATE);
137 static int display_text_info(void)
139 #if !defined(CONFIG_SANDBOX) && !defined(CONFIG_EFI_APP)
140 ulong bss_start, bss_end, text_base;
142 bss_start = (ulong)&__bss_start;
143 bss_end = (ulong)&__bss_end;
145 #ifdef CONFIG_SYS_TEXT_BASE
146 text_base = CONFIG_SYS_TEXT_BASE;
148 text_base = CONFIG_SYS_MONITOR_BASE;
151 debug("U-Boot code: %08lX -> %08lX BSS: -> %08lX\n",
152 text_base, bss_start, bss_end);
158 #ifdef CONFIG_SYSRESET
159 static int print_resetinfo(void)
165 ret = uclass_first_device_err(UCLASS_SYSRESET, &dev);
167 debug("%s: No sysreset device found (error: %d)\n",
169 /* Not all boards have sysreset drivers available during early
170 * boot, so don't fail if one can't be found.
175 if (!sysreset_get_status(dev, status, sizeof(status)))
176 printf("%s", status);
182 #if defined(CONFIG_DISPLAY_CPUINFO) && CONFIG_IS_ENABLED(CPU)
183 static int print_cpuinfo(void)
189 dev = cpu_get_current_dev();
191 debug("%s: Could not get CPU device\n",
196 ret = cpu_get_desc(dev, desc, sizeof(desc));
198 debug("%s: Could not get CPU description (err = %d)\n",
203 printf("CPU: %s\n", desc);
209 static int announce_dram_init(void)
215 static int show_dram_config(void)
217 unsigned long long size;
219 #ifdef CONFIG_NR_DRAM_BANKS
222 debug("\nRAM Configuration:\n");
223 for (i = size = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
224 size += gd->bd->bi_dram[i].size;
225 debug("Bank #%d: %llx ", i,
226 (unsigned long long)(gd->bd->bi_dram[i].start));
228 print_size(gd->bd->bi_dram[i].size, "\n");
236 print_size(size, "");
237 board_add_ram_info(0);
243 __weak int dram_init_banksize(void)
245 #if defined(CONFIG_NR_DRAM_BANKS) && defined(CONFIG_SYS_SDRAM_BASE)
246 gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
247 gd->bd->bi_dram[0].size = get_effective_memsize();
253 #if defined(CONFIG_SYS_I2C)
254 static int init_func_i2c(void)
263 #if defined(CONFIG_VID)
264 __weak int init_func_vid(void)
270 static int setup_mon_len(void)
272 #if defined(__ARM__) || defined(__MICROBLAZE__)
273 gd->mon_len = (ulong)&__bss_end - (ulong)_start;
274 #elif defined(CONFIG_SANDBOX) || defined(CONFIG_EFI_APP)
275 gd->mon_len = (ulong)&_end - (ulong)_init;
276 #elif defined(CONFIG_NIOS2) || defined(CONFIG_XTENSA)
277 gd->mon_len = CONFIG_SYS_MONITOR_LEN;
278 #elif defined(CONFIG_NDS32) || defined(CONFIG_SH) || defined(CONFIG_RISCV)
279 gd->mon_len = (ulong)(&__bss_end) - (ulong)(&_start);
280 #elif defined(CONFIG_SYS_MONITOR_BASE)
281 /* TODO: use (ulong)&__bss_end - (ulong)&__text_start; ? */
282 gd->mon_len = (ulong)&__bss_end - CONFIG_SYS_MONITOR_BASE;
287 static int setup_spl_handoff(void)
289 #if CONFIG_IS_ENABLED(HANDOFF)
290 gd->spl_handoff = bloblist_find(BLOBLISTT_SPL_HANDOFF,
291 sizeof(struct spl_handoff));
292 debug("Found SPL hand-off info %p\n", gd->spl_handoff);
298 __weak int arch_cpu_init(void)
303 __weak int mach_cpu_init(void)
308 /* Get the top of usable RAM */
309 __weak ulong board_get_usable_ram_top(ulong total_size)
311 #if defined(CONFIG_SYS_SDRAM_BASE) && CONFIG_SYS_SDRAM_BASE > 0
313 * Detect whether we have so much RAM that it goes past the end of our
314 * 32-bit address space. If so, clip the usable RAM so it doesn't.
316 if (gd->ram_top < CONFIG_SYS_SDRAM_BASE)
318 * Will wrap back to top of 32-bit space when reservations
326 static int setup_dest_addr(void)
328 debug("Monitor len: %08lX\n", gd->mon_len);
330 * Ram is setup, size stored in gd !!
332 debug("Ram size: %08lX\n", (ulong)gd->ram_size);
333 #if defined(CONFIG_SYS_MEM_TOP_HIDE)
335 * Subtract specified amount of memory to hide so that it won't
336 * get "touched" at all by U-Boot. By fixing up gd->ram_size
337 * the Linux kernel should now get passed the now "corrected"
338 * memory size and won't touch it either. This should work
339 * for arch/ppc and arch/powerpc. Only Linux board ports in
340 * arch/powerpc with bootwrapper support, that recalculate the
341 * memory size from the SDRAM controller setup will have to
344 gd->ram_size -= CONFIG_SYS_MEM_TOP_HIDE;
346 #ifdef CONFIG_SYS_SDRAM_BASE
347 gd->ram_base = CONFIG_SYS_SDRAM_BASE;
349 gd->ram_top = gd->ram_base + get_effective_memsize();
350 gd->ram_top = board_get_usable_ram_top(gd->mon_len);
351 gd->relocaddr = gd->ram_top;
352 debug("Ram top: %08lX\n", (ulong)gd->ram_top);
353 #if defined(CONFIG_MP) && (defined(CONFIG_MPC86xx) || defined(CONFIG_E500))
355 * We need to make sure the location we intend to put secondary core
356 * boot code is reserved and not used by any part of u-boot
358 if (gd->relocaddr > determine_mp_bootpg(NULL)) {
359 gd->relocaddr = determine_mp_bootpg(NULL);
360 debug("Reserving MP boot page to %08lx\n", gd->relocaddr);
367 /* reserve protected RAM */
368 static int reserve_pram(void)
372 reg = env_get_ulong("pram", 10, CONFIG_PRAM);
373 gd->relocaddr -= (reg << 10); /* size is in kB */
374 debug("Reserving %ldk for protected RAM at %08lx\n", reg,
378 #endif /* CONFIG_PRAM */
380 /* Round memory pointer down to next 4 kB limit */
381 static int reserve_round_4k(void)
383 gd->relocaddr &= ~(4096 - 1);
387 __weak int arch_reserve_mmu(void)
392 static int reserve_video(void)
394 #ifdef CONFIG_DM_VIDEO
398 addr = gd->relocaddr;
399 ret = video_reserve(&addr);
402 gd->relocaddr = addr;
403 #elif defined(CONFIG_LCD)
404 # ifdef CONFIG_FB_ADDR
405 gd->fb_base = CONFIG_FB_ADDR;
407 /* reserve memory for LCD display (always full pages) */
408 gd->relocaddr = lcd_setmem(gd->relocaddr);
409 gd->fb_base = gd->relocaddr;
410 # endif /* CONFIG_FB_ADDR */
416 static int reserve_trace(void)
419 gd->relocaddr -= CONFIG_TRACE_BUFFER_SIZE;
420 gd->trace_buff = map_sysmem(gd->relocaddr, CONFIG_TRACE_BUFFER_SIZE);
421 debug("Reserving %luk for trace data at: %08lx\n",
422 (unsigned long)CONFIG_TRACE_BUFFER_SIZE >> 10, gd->relocaddr);
428 static int reserve_uboot(void)
430 if (!(gd->flags & GD_FLG_SKIP_RELOC)) {
432 * reserve memory for U-Boot code, data & bss
433 * round down to next 4 kB limit
435 gd->relocaddr -= gd->mon_len;
436 gd->relocaddr &= ~(4096 - 1);
437 #if defined(CONFIG_E500) || defined(CONFIG_MIPS)
438 /* round down to next 64 kB limit so that IVPR stays aligned */
439 gd->relocaddr &= ~(65536 - 1);
442 debug("Reserving %ldk for U-Boot at: %08lx\n",
443 gd->mon_len >> 10, gd->relocaddr);
446 gd->start_addr_sp = gd->relocaddr;
452 * reserve after start_addr_sp the requested size and make the stack pointer
453 * 16-byte aligned, this alignment is needed for cast on the reserved memory
454 * ref = x86_64 ABI: https://reviews.llvm.org/D30049: 16 bytes
455 * = ARMv8 Instruction Set Overview: quad word, 16 bytes
457 static unsigned long reserve_stack_aligned(size_t size)
459 return ALIGN_DOWN(gd->start_addr_sp - size, 16);
462 #ifdef CONFIG_SYS_NONCACHED_MEMORY
463 static int reserve_noncached(void)
466 * The value of gd->start_addr_sp must match the value of malloc_start
467 * calculated in boatrd_f.c:initr_malloc(), which is passed to
468 * board_r.c:mem_malloc_init() and then used by
469 * cache.c:noncached_init()
471 * These calculations must match the code in cache.c:noncached_init()
473 gd->start_addr_sp = ALIGN(gd->start_addr_sp, MMU_SECTION_SIZE) -
475 gd->start_addr_sp -= ALIGN(CONFIG_SYS_NONCACHED_MEMORY,
477 debug("Reserving %dM for noncached_alloc() at: %08lx\n",
478 CONFIG_SYS_NONCACHED_MEMORY >> 20, gd->start_addr_sp);
484 /* reserve memory for malloc() area */
485 static int reserve_malloc(void)
487 gd->start_addr_sp = reserve_stack_aligned(TOTAL_MALLOC_LEN);
488 debug("Reserving %dk for malloc() at: %08lx\n",
489 TOTAL_MALLOC_LEN >> 10, gd->start_addr_sp);
490 #ifdef CONFIG_SYS_NONCACHED_MEMORY
497 /* (permanently) allocate a Board Info struct */
498 static int reserve_board(void)
501 gd->start_addr_sp = reserve_stack_aligned(sizeof(struct bd_info));
502 gd->bd = (struct bd_info *)map_sysmem(gd->start_addr_sp,
503 sizeof(struct bd_info));
504 memset(gd->bd, '\0', sizeof(struct bd_info));
505 debug("Reserving %zu Bytes for Board Info at: %08lx\n",
506 sizeof(struct bd_info), gd->start_addr_sp);
511 static int setup_machine(void)
513 #ifdef CONFIG_MACH_TYPE
514 gd->bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
519 static int reserve_global_data(void)
521 gd->start_addr_sp = reserve_stack_aligned(sizeof(gd_t));
522 gd->new_gd = (gd_t *)map_sysmem(gd->start_addr_sp, sizeof(gd_t));
523 debug("Reserving %zu Bytes for Global Data at: %08lx\n",
524 sizeof(gd_t), gd->start_addr_sp);
528 static int reserve_fdt(void)
530 #ifndef CONFIG_OF_EMBED
532 * If the device tree is sitting immediately above our image then we
533 * must relocate it. If it is embedded in the data section, then it
534 * will be relocated with other data.
537 gd->fdt_size = ALIGN(fdt_totalsize(gd->fdt_blob), 32);
539 gd->start_addr_sp = reserve_stack_aligned(gd->fdt_size);
540 gd->new_fdt = map_sysmem(gd->start_addr_sp, gd->fdt_size);
541 debug("Reserving %lu Bytes for FDT at: %08lx\n",
542 gd->fdt_size, gd->start_addr_sp);
549 static int reserve_bootstage(void)
551 #ifdef CONFIG_BOOTSTAGE
552 int size = bootstage_get_size();
554 gd->start_addr_sp = reserve_stack_aligned(size);
555 gd->new_bootstage = map_sysmem(gd->start_addr_sp, size);
556 debug("Reserving %#x Bytes for bootstage at: %08lx\n", size,
563 __weak int arch_reserve_stacks(void)
568 static int reserve_stacks(void)
570 /* make stack pointer 16-byte aligned */
571 gd->start_addr_sp = reserve_stack_aligned(16);
574 * let the architecture-specific code tailor gd->start_addr_sp and
577 return arch_reserve_stacks();
580 static int reserve_bloblist(void)
582 #ifdef CONFIG_BLOBLIST
583 gd->start_addr_sp = reserve_stack_aligned(CONFIG_BLOBLIST_SIZE);
584 gd->new_bloblist = map_sysmem(gd->start_addr_sp, CONFIG_BLOBLIST_SIZE);
590 static int display_new_sp(void)
592 debug("New Stack Pointer is: %08lx\n", gd->start_addr_sp);
597 __weak int arch_setup_bdinfo(void)
602 int setup_bdinfo(void)
604 struct bd_info *bd = gd->bd;
606 bd->bi_memstart = gd->ram_base; /* start of memory */
607 bd->bi_memsize = gd->ram_size; /* size in bytes */
609 if (IS_ENABLED(CONFIG_SYS_HAS_SRAM)) {
610 bd->bi_sramstart = CONFIG_SYS_SRAM_BASE; /* start of SRAM */
611 bd->bi_sramsize = CONFIG_SYS_SRAM_SIZE; /* size of SRAM */
614 return arch_setup_bdinfo();
618 static int init_post(void)
620 post_bootmode_init();
621 post_run(NULL, POST_ROM | post_bootmode_get(0));
627 static int reloc_fdt(void)
629 #ifndef CONFIG_OF_EMBED
630 if (gd->flags & GD_FLG_SKIP_RELOC)
633 memcpy(gd->new_fdt, gd->fdt_blob, fdt_totalsize(gd->fdt_blob));
634 gd->fdt_blob = gd->new_fdt;
641 static int reloc_bootstage(void)
643 #ifdef CONFIG_BOOTSTAGE
644 if (gd->flags & GD_FLG_SKIP_RELOC)
646 if (gd->new_bootstage) {
647 int size = bootstage_get_size();
649 debug("Copying bootstage from %p to %p, size %x\n",
650 gd->bootstage, gd->new_bootstage, size);
651 memcpy(gd->new_bootstage, gd->bootstage, size);
652 gd->bootstage = gd->new_bootstage;
653 bootstage_relocate();
660 static int reloc_bloblist(void)
662 #ifdef CONFIG_BLOBLIST
663 if (gd->flags & GD_FLG_SKIP_RELOC)
665 if (gd->new_bloblist) {
666 int size = CONFIG_BLOBLIST_SIZE;
668 debug("Copying bloblist from %p to %p, size %x\n",
669 gd->bloblist, gd->new_bloblist, size);
670 memcpy(gd->new_bloblist, gd->bloblist, size);
671 gd->bloblist = gd->new_bloblist;
678 static int setup_reloc(void)
680 if (gd->flags & GD_FLG_SKIP_RELOC) {
681 debug("Skipping relocation due to flag\n");
685 #ifdef CONFIG_SYS_TEXT_BASE
687 gd->reloc_off = gd->relocaddr - (unsigned long)__image_copy_start;
688 #elif defined(CONFIG_M68K)
690 * On all ColdFire arch cpu, monitor code starts always
691 * just after the default vector table location, so at 0x400
693 gd->reloc_off = gd->relocaddr - (CONFIG_SYS_TEXT_BASE + 0x400);
694 #elif !defined(CONFIG_SANDBOX)
695 gd->reloc_off = gd->relocaddr - CONFIG_SYS_TEXT_BASE;
698 memcpy(gd->new_gd, (char *)gd, sizeof(gd_t));
700 debug("Relocation Offset is: %08lx\n", gd->reloc_off);
701 debug("Relocating to %08lx, new gd at %08lx, sp at %08lx\n",
702 gd->relocaddr, (ulong)map_to_sysmem(gd->new_gd),
708 #ifdef CONFIG_OF_BOARD_FIXUP
709 static int fix_fdt(void)
711 return board_fix_fdt((void *)gd->fdt_blob);
715 /* ARM calls relocate_code from its crt0.S */
716 #if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) && \
717 !CONFIG_IS_ENABLED(X86_64)
719 static int jump_to_copy(void)
721 if (gd->flags & GD_FLG_SKIP_RELOC)
724 * x86 is special, but in a nice way. It uses a trampoline which
725 * enables the dcache if possible.
727 * For now, other archs use relocate_code(), which is implemented
728 * similarly for all archs. When we do generic relocation, hopefully
729 * we can make all archs enable the dcache prior to relocation.
731 #if defined(CONFIG_X86) || defined(CONFIG_ARC)
733 * SDRAM and console are now initialised. The final stack can now
734 * be setup in SDRAM. Code execution will continue in Flash, but
735 * with the stack in SDRAM and Global Data in temporary memory
738 arch_setup_gd(gd->new_gd);
739 board_init_f_r_trampoline(gd->start_addr_sp);
741 relocate_code(gd->start_addr_sp, gd->new_gd, gd->relocaddr);
748 /* Record the board_init_f() bootstage (after arch_cpu_init()) */
749 static int initf_bootstage(void)
751 bool from_spl = IS_ENABLED(CONFIG_SPL_BOOTSTAGE) &&
752 IS_ENABLED(CONFIG_BOOTSTAGE_STASH);
755 ret = bootstage_init(!from_spl);
759 const void *stash = map_sysmem(CONFIG_BOOTSTAGE_STASH_ADDR,
760 CONFIG_BOOTSTAGE_STASH_SIZE);
762 ret = bootstage_unstash(stash, CONFIG_BOOTSTAGE_STASH_SIZE);
763 if (ret && ret != -ENOENT) {
764 debug("Failed to unstash bootstage: err=%d\n", ret);
769 bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_F, "board_init_f");
774 static int initf_console_record(void)
776 #if defined(CONFIG_CONSOLE_RECORD) && CONFIG_VAL(SYS_MALLOC_F_LEN)
777 return console_record_init();
783 static int initf_dm(void)
785 #if defined(CONFIG_DM) && CONFIG_VAL(SYS_MALLOC_F_LEN)
788 bootstage_start(BOOTSTAGE_ID_ACCUM_DM_F, "dm_f");
789 ret = dm_init_and_scan(true);
790 bootstage_accum(BOOTSTAGE_ID_ACCUM_DM_F);
794 #ifdef CONFIG_TIMER_EARLY
795 ret = dm_timer_init();
803 /* Architecture-specific memory reservation */
804 __weak int reserve_arch(void)
809 __weak int arch_cpu_init_dm(void)
814 __weak int checkcpu(void)
819 __weak int clear_bss(void)
824 static const init_fnc_t init_sequence_f[] = {
826 #ifdef CONFIG_OF_CONTROL
829 #ifdef CONFIG_TRACE_EARLY
834 initf_bootstage, /* uses its own timer, so does not need DM */
835 #ifdef CONFIG_BLOBLIST
839 initf_console_record,
840 #if defined(CONFIG_HAVE_FSP)
843 arch_cpu_init, /* basic arch cpu dependent setup */
844 mach_cpu_init, /* SoC/machine dependent CPU setup */
847 #if defined(CONFIG_BOARD_EARLY_INIT_F)
850 #if defined(CONFIG_PPC) || defined(CONFIG_SYS_FSL_CLK) || defined(CONFIG_M68K)
851 /* get CPU and bus clocks according to the environment variable */
852 get_clocks, /* get CPU and bus clocks (etc.) */
854 #if !defined(CONFIG_M68K)
855 timer_init, /* initialize timer */
857 #if defined(CONFIG_BOARD_POSTCLK_INIT)
860 env_init, /* initialize environment */
861 init_baud_rate, /* initialze baudrate settings */
862 serial_init, /* serial communications setup */
863 console_init_f, /* stage 1 init of console */
864 display_options, /* say that we are here */
865 display_text_info, /* show debugging info if required */
867 #if defined(CONFIG_SYSRESET)
870 #if defined(CONFIG_DISPLAY_CPUINFO)
871 print_cpuinfo, /* display cpu info (and speed) */
873 #if defined(CONFIG_DTB_RESELECT)
876 #if defined(CONFIG_DISPLAY_BOARDINFO)
879 INIT_FUNC_WATCHDOG_INIT
880 #if defined(CONFIG_MISC_INIT_F)
883 INIT_FUNC_WATCHDOG_RESET
884 #if defined(CONFIG_SYS_I2C)
887 #if defined(CONFIG_VID) && !defined(CONFIG_SPL)
891 dram_init, /* configure available RAM banks */
895 INIT_FUNC_WATCHDOG_RESET
896 #if defined(CONFIG_SYS_DRAM_TEST)
898 #endif /* CONFIG_SYS_DRAM_TEST */
899 INIT_FUNC_WATCHDOG_RESET
904 INIT_FUNC_WATCHDOG_RESET
906 * Now that we have DRAM mapped and working, we can
907 * relocate the code and continue running from DRAM.
909 * Reserve memory at end of RAM for (top down in that order):
910 * - area that won't get touched by U-Boot and Linux (optional)
911 * - kernel log buffer
915 * - board info struct
918 #ifdef CONFIG_OF_BOARD_FIXUP
940 INIT_FUNC_WATCHDOG_RESET
943 INIT_FUNC_WATCHDOG_RESET
948 #if defined(CONFIG_X86) || defined(CONFIG_ARC)
953 #if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) && \
954 !CONFIG_IS_ENABLED(X86_64)
960 void board_init_f(ulong boot_flags)
962 gd->flags = boot_flags;
963 gd->have_console = 0;
965 if (initcall_run_list(init_sequence_f))
968 #if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) && \
969 !defined(CONFIG_EFI_APP) && !CONFIG_IS_ENABLED(X86_64) && \
971 /* NOTREACHED - jump_to_copy() does not return */
976 #if defined(CONFIG_X86) || defined(CONFIG_ARC)
978 * For now this code is only used on x86.
980 * init_sequence_f_r is the list of init functions which are run when
981 * U-Boot is executing from Flash with a semi-limited 'C' environment.
982 * The following limitations must be considered when implementing an
984 * - 'static' variables are read-only
985 * - Global Data (gd->xxx) is read/write
987 * The '_f_r' sequence must, as a minimum, copy U-Boot to RAM (if
988 * supported). It _should_, if possible, copy global data to RAM and
989 * initialise the CPU caches (to speed up the relocation process)
991 * NOTE: At present only x86 uses this route, but it is intended that
992 * all archs will move to this when generic relocation is implemented.
994 static const init_fnc_t init_sequence_f_r[] = {
995 #if !CONFIG_IS_ENABLED(X86_64)
1002 void board_init_f_r(void)
1004 if (initcall_run_list(init_sequence_f_r))
1008 * The pre-relocation drivers may be using memory that has now gone
1009 * away. Mark serial as unavailable - this will fall back to the debug
1010 * UART if available.
1012 * Do the same with log drivers since the memory may not be available.
1014 gd->flags &= ~(GD_FLG_SERIAL_READY | GD_FLG_LOG_READY);
1020 * U-Boot has been copied into SDRAM, the BSS has been cleared etc.
1021 * Transfer execution from Flash to RAM by calculating the address
1022 * of the in-RAM copy of board_init_r() and calling it
1024 (board_init_r + gd->reloc_off)((gd_t *)gd, gd->relocaddr);
1026 /* NOTREACHED - board_init_r() does not return */
1029 #endif /* CONFIG_X86 */