2 * Code shared between SPL and U-Boot proper
4 * Copyright (c) 2015 Google, Inc
5 * Written by Simon Glass <sjg@chromium.org>
7 * SPDX-License-Identifier: GPL-2.0+
12 DECLARE_GLOBAL_DATA_PTR;
15 * It isn't trivial to figure out whether memcpy() exists. The arch-specific
16 * memcpy() is not normally available in SPL due to code size.
18 #if !defined(CONFIG_SPL_BUILD) || \
19 (defined(CONFIG_SPL_LIBGENERIC_SUPPORT) && \
20 !defined(CONFIG_USE_ARCH_MEMSET))
24 /* Unfortunately x86 can't compile this code as gd cannot be assigned */
26 __weak void arch_setup_gd(struct global_data *gd_ptr)
30 #endif /* !CONFIG_X86 */
32 ulong board_init_f_mem(ulong top)
34 struct global_data *gd_ptr;
39 /* Leave space for the stack we are running with now */
42 top -= sizeof(struct global_data);
44 gd_ptr = (struct global_data *)top;
46 memset(gd_ptr, '\0', sizeof(*gd));
48 for (ptr = (int *)gd_ptr; ptr < (int *)(gd_ptr + 1); )
51 arch_setup_gd(gd_ptr);
53 #if defined(CONFIG_SYS_MALLOC_F)
54 top -= CONFIG_SYS_MALLOC_F_LEN;
55 gd->malloc_base = top;