spl.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * (C) Copyright 2010-2012
  3. * Texas Instruments, <www.ti.com>
  4. *
  5. * Aneesh V <aneesh@ti.com>
  6. * Tom Rini <trini@ti.com>
  7. *
  8. * See file CREDITS for list of people who contributed to this
  9. * project.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 of
  14. * the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  24. * MA 02111-1307 USA
  25. */
  26. #include <common.h>
  27. #include <config.h>
  28. #include <spl.h>
  29. #include <image.h>
  30. #include <linux/compiler.h>
  31. /* Pointer to as well as the global data structure for SPL */
  32. DECLARE_GLOBAL_DATA_PTR;
  33. gd_t gdata __attribute__ ((section(".data")));
  34. /*
  35. * In the context of SPL, board_init_f must ensure that any clocks/etc for
  36. * DDR are enabled, ensure that the stack pointer is valid, clear the BSS
  37. * and call board_init_f. We provide this version by default but mark it
  38. * as __weak to allow for platforms to do this in their own way if needed.
  39. */
  40. void __weak board_init_f(ulong dummy)
  41. {
  42. /* Set the stack pointer. */
  43. asm volatile("mov sp, %0\n" : : "r"(CONFIG_SPL_STACK));
  44. /* Clear the BSS. */
  45. memset(__bss_start, 0, __bss_end__ - __bss_start);
  46. /* Set global data pointer. */
  47. gd = &gdata;
  48. board_init_r(NULL, 0);
  49. }
  50. /*
  51. * This function jumps to an image with argument. Normally an FDT or ATAGS
  52. * image.
  53. * arg: Pointer to paramter image in RAM
  54. */
  55. #ifdef CONFIG_SPL_OS_BOOT
  56. void __noreturn jump_to_image_linux(void *arg)
  57. {
  58. debug("Entering kernel arg pointer: 0x%p\n", arg);
  59. typedef void (*image_entry_arg_t)(int, int, void *)
  60. __attribute__ ((noreturn));
  61. image_entry_arg_t image_entry =
  62. (image_entry_arg_t) spl_image.entry_point;
  63. cleanup_before_linux();
  64. image_entry(0, CONFIG_MACH_TYPE, arg);
  65. }
  66. #endif