init_helpers.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * (C) Copyright 2011
  3. * Graeme Russ, <graeme.russ@gmail.com>
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <command.h>
  25. #include <stdio_dev.h>
  26. #include <version.h>
  27. #include <malloc.h>
  28. #include <net.h>
  29. #include <ide.h>
  30. #include <serial.h>
  31. #include <spi.h>
  32. #include <status_led.h>
  33. #include <asm/processor.h>
  34. #include <asm/u-boot-x86.h>
  35. #include <asm/init_helpers.h>
  36. DECLARE_GLOBAL_DATA_PTR;
  37. /************************************************************************
  38. * Init Utilities *
  39. ************************************************************************
  40. * Some of this code should be moved into the core functions,
  41. * or dropped completely,
  42. * but let's get it working (again) first...
  43. */
  44. int display_banner(void)
  45. {
  46. printf("\n\n%s\n\n", version_string);
  47. return 0;
  48. }
  49. int display_dram_config(void)
  50. {
  51. int i;
  52. puts("DRAM Configuration:\n");
  53. for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
  54. printf("Bank #%d: %08lx ", i, gd->bd->bi_dram[i].start);
  55. print_size(gd->bd->bi_dram[i].size, "\n");
  56. }
  57. return 0;
  58. }
  59. int init_baudrate_f(void)
  60. {
  61. gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE);
  62. return 0;
  63. }
  64. int calculate_relocation_address(void)
  65. {
  66. ulong text_start = (ulong)&__text_start;
  67. ulong bss_end = (ulong)&__bss_end;
  68. ulong dest_addr;
  69. /*
  70. * NOTE: All destination address are rounded down to 16-byte
  71. * boundary to satisfy various worst-case alignment
  72. * requirements
  73. */
  74. /* Stack is at top of available memory */
  75. dest_addr = gd->ram_size;
  76. gd->start_addr_sp = dest_addr;
  77. /* U-Boot is below the stack */
  78. dest_addr -= CONFIG_SYS_STACK_SIZE;
  79. dest_addr -= (bss_end - text_start);
  80. dest_addr &= ~15;
  81. gd->relocaddr = dest_addr;
  82. gd->reloc_off = (dest_addr - text_start);
  83. return 0;
  84. }
  85. int init_cache_f_r(void)
  86. {
  87. /* Initialise the CPU cache(s) */
  88. return init_cache();
  89. }
  90. int set_reloc_flag_r(void)
  91. {
  92. gd->flags = GD_FLG_RELOC;
  93. return 0;
  94. }
  95. int mem_malloc_init_r(void)
  96. {
  97. mem_malloc_init(((gd->relocaddr - CONFIG_SYS_MALLOC_LEN)+3)&~3,
  98. CONFIG_SYS_MALLOC_LEN);
  99. return 0;
  100. }
  101. bd_t bd_data;
  102. int init_bd_struct_r(void)
  103. {
  104. gd->bd = &bd_data;
  105. memset(gd->bd, 0, sizeof(bd_t));
  106. return 0;
  107. }
  108. #ifndef CONFIG_SYS_NO_FLASH
  109. int flash_init_r(void)
  110. {
  111. ulong size;
  112. puts("Flash: ");
  113. /* configure available FLASH banks */
  114. size = flash_init();
  115. print_size(size, "\n");
  116. return 0;
  117. }
  118. #endif
  119. #ifdef CONFIG_STATUS_LED
  120. int status_led_set_r(void)
  121. {
  122. status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING);
  123. return 0;
  124. }
  125. #endif
  126. int set_load_addr_r(void)
  127. {
  128. /* Initialize from environment */
  129. load_addr = getenv_ulong("loadaddr", 16, load_addr);
  130. return 0;
  131. }
  132. int init_func_spi(void)
  133. {
  134. puts("SPI: ");
  135. spi_init();
  136. puts("ready\n");
  137. return 0;
  138. }