board_init.c 820 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Code shared between SPL and U-Boot proper
  3. *
  4. * Copyright (c) 2015 Google, Inc
  5. * Written by Simon Glass <sjg@chromium.org>
  6. *
  7. * SPDX-License-Identifier: GPL-2.0+
  8. */
  9. #include <common.h>
  10. DECLARE_GLOBAL_DATA_PTR;
  11. /* Unfortunately x86 can't compile this code as gd cannot be assigned */
  12. #ifndef CONFIG_X86
  13. __weak void arch_setup_gd(struct global_data *gd_ptr)
  14. {
  15. gd = gd_ptr;
  16. }
  17. #endif /* !CONFIG_X86 */
  18. ulong board_init_f_mem(ulong top)
  19. {
  20. struct global_data *gd_ptr;
  21. /* Leave space for the stack we are running with now */
  22. top -= 0x40;
  23. top -= sizeof(struct global_data);
  24. top = ALIGN(top, 16);
  25. gd_ptr = (struct global_data *)top;
  26. memset(gd_ptr, '\0', sizeof(*gd));
  27. arch_setup_gd(gd_ptr);
  28. #if defined(CONFIG_SYS_MALLOC_F)
  29. top -= CONFIG_SYS_MALLOC_F_LEN;
  30. gd->malloc_base = top;
  31. #endif
  32. return top;
  33. }