]>
git.ipfire.org Git - people/ms/u-boot.git/blob - arch/x86/lib/init_helpers.c
582c0ffe245ca6739d40347408a89bc80c728744
3 * Graeme Russ, <graeme.russ@gmail.com>
5 * SPDX-License-Identifier: GPL-2.0+
10 #include <asm/sections.h>
12 DECLARE_GLOBAL_DATA_PTR
;
14 /* Get the top of usable RAM */
15 __weak ulong
board_get_usable_ram_top(ulong total_size
)
20 int calculate_relocation_address(void)
22 const ulong uboot_size
= (uintptr_t)&__bss_end
-
23 (uintptr_t)&__text_start
;
28 #if defined(CONFIG_OF_SEPARATE) && defined(CONFIG_OF_CONTROL)
30 fdt_size
= ALIGN(fdt_totalsize(gd
->fdt_blob
) + 0x1000, 32);
32 total_size
= ALIGN(uboot_size
, 1 << 12) + CONFIG_SYS_MALLOC_LEN
+
33 CONFIG_SYS_STACK_SIZE
+ fdt_size
;
35 dest_addr
= board_get_usable_ram_top(total_size
);
37 * NOTE: All destination address are rounded down to 16-byte
38 * boundary to satisfy various worst-case alignment
43 #if defined(CONFIG_OF_SEPARATE) && defined(CONFIG_OF_CONTROL)
45 * If the device tree is sitting immediate above our image then we
46 * must relocate it. If it is embedded in the data section, then it
47 * will be relocated with other data.
50 dest_addr
-= fdt_size
;
51 gd
->new_fdt
= (void *)dest_addr
;
55 /* U-Boot is below the FDT */
56 dest_addr
-= uboot_size
;
57 dest_addr
&= ~((1 << 12) - 1);
58 gd
->relocaddr
= dest_addr
;
59 gd
->reloc_off
= dest_addr
- (uintptr_t)&__text_start
;
61 /* Stack is at the bottom, so it can grow down */
62 gd
->start_addr_sp
= dest_addr
- CONFIG_SYS_MALLOC_LEN
;
67 int init_cache_f_r(void)
69 /* Initialise the CPU cache(s) */
75 int init_bd_struct_r(void)
78 memset(gd
->bd
, 0, sizeof(bd_t
));
83 int init_func_spi(void)
93 #ifdef CONFIG_OF_EMBED
94 /* Get a pointer to the FDT */
95 gd
->fdt_blob
= _binary_dt_dtb_start
;
96 #elif defined CONFIG_OF_SEPARATE
97 /* FDT is at end of image */
98 gd
->fdt_blob
= (ulong
*)&_end
;
100 /* Allow the early environment to override the fdt address */
101 gd
->fdt_blob
= (void *)getenv_ulong("fdtcontroladdr", 16,
102 (uintptr_t)gd
->fdt_blob
);
107 int prepare_fdt(void)
109 /* For now, put this check after the console is ready */
110 if (fdtdec_prepare_fdt()) {
111 panic("** CONFIG_OF_CONTROL defined but no FDT - please see "
112 "doc/README.fdt-control");