Fork of the vendor (Boundary Devices) u-boot for Reform 2, with minor tweaks. The goal is to migrate to mainstream u-boot or barebox ASAP. The main impediment so far is the 4GB RAM config.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 
 
 

119 lines
2.5 KiB

  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
  4. */
  5. #include <asm/cache.h>
  6. #include <common.h>
  7. DECLARE_GLOBAL_DATA_PTR;
  8. static ulong get_sp(void)
  9. {
  10. ulong ret;
  11. asm("mov %0, sp" : "=r"(ret) : );
  12. return ret;
  13. }
  14. void arch_lmb_reserve(struct lmb *lmb)
  15. {
  16. ulong sp;
  17. /*
  18. * Booting a (Linux) kernel image
  19. *
  20. * Allocate space for command line and board info - the
  21. * address should be as high as possible within the reach of
  22. * the kernel (see CONFIG_SYS_BOOTMAPSZ settings), but in unused
  23. * memory, which means far enough below the current stack
  24. * pointer.
  25. */
  26. sp = get_sp();
  27. debug("## Current stack ends at 0x%08lx ", sp);
  28. /* adjust sp by 4K to be safe */
  29. sp -= 4096;
  30. lmb_reserve(lmb, sp, (CONFIG_SYS_SDRAM_BASE + gd->ram_size - sp));
  31. }
  32. static int cleanup_before_linux(void)
  33. {
  34. disable_interrupts();
  35. sync_n_cleanup_cache_all();
  36. return 0;
  37. }
  38. __weak int board_prep_linux(bootm_headers_t *images) { return 0; }
  39. /* Subcommand: PREP */
  40. static int boot_prep_linux(bootm_headers_t *images)
  41. {
  42. int ret;
  43. ret = image_setup_linux(images);
  44. if (ret)
  45. return ret;
  46. return board_prep_linux(images);
  47. }
  48. /* Generic implementation for single core CPU */
  49. __weak void board_jump_and_run(ulong entry, int zero, int arch, uint params)
  50. {
  51. void (*kernel_entry)(int zero, int arch, uint params);
  52. kernel_entry = (void (*)(int, int, uint))entry;
  53. kernel_entry(zero, arch, params);
  54. }
  55. /* Subcommand: GO */
  56. static void boot_jump_linux(bootm_headers_t *images, int flag)
  57. {
  58. ulong kernel_entry;
  59. unsigned int r0, r2;
  60. int fake = (flag & BOOTM_STATE_OS_FAKE_GO);
  61. kernel_entry = images->ep;
  62. debug("## Transferring control to Linux (at address %08lx)...\n",
  63. kernel_entry);
  64. bootstage_mark(BOOTSTAGE_ID_RUN_OS);
  65. printf("\nStarting kernel ...%s\n\n", fake ?
  66. "(fake run for tracing)" : "");
  67. bootstage_mark_name(BOOTSTAGE_ID_BOOTM_HANDOFF, "start_kernel");
  68. if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) {
  69. r0 = 2;
  70. r2 = (unsigned int)images->ft_addr;
  71. } else {
  72. r0 = 1;
  73. r2 = (unsigned int)env_get("bootargs");
  74. }
  75. cleanup_before_linux();
  76. if (!fake)
  77. board_jump_and_run(kernel_entry, r0, 0, r2);
  78. }
  79. int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
  80. {
  81. /* No need for those on ARC */
  82. if ((flag & BOOTM_STATE_OS_BD_T) || (flag & BOOTM_STATE_OS_CMDLINE))
  83. return -1;
  84. if (flag & BOOTM_STATE_OS_PREP)
  85. return boot_prep_linux(images);
  86. if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) {
  87. boot_jump_linux(images, flag);
  88. return 0;
  89. }
  90. return -1;
  91. }