start.S 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * U-boot - x86 Startup Code
  3. *
  4. * (C) Copyright 2008-2011
  5. * Graeme Russ, <graeme.russ@gmail.com>
  6. *
  7. * (C) Copyright 2002
  8. * Daniel Engström, Omicron Ceti AB, <daniel@omicron.se>
  9. *
  10. * See file CREDITS for list of people who contributed to this
  11. * project.
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License as
  15. * published by the Free Software Foundation; either version 2 of
  16. * the License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  26. * MA 02111-1307 USA
  27. */
  28. #include <config.h>
  29. #include <version.h>
  30. #include <asm/global_data.h>
  31. #include <asm/processor-flags.h>
  32. .section .text
  33. .code32
  34. .globl _start
  35. .type _start, @function
  36. .globl _x86boot_start
  37. _x86boot_start:
  38. /*
  39. * This is the fail safe 32-bit bootstrap entry point. The
  40. * following code is not executed from a cold-reset (actually, a
  41. * lot of it is, but from real-mode after cold reset. It is
  42. * repeated here to put the board into a state as close to cold
  43. * reset as necessary)
  44. */
  45. cli
  46. cld
  47. /* Turn of cache (this might require a 486-class CPU) */
  48. movl %cr0, %eax
  49. orl $(X86_CR0_NW | X86_CR0_CD), %eax
  50. movl %eax, %cr0
  51. wbinvd
  52. _start:
  53. /* This is the 32-bit cold-reset entry point */
  54. /* Load the segement registes to match the gdt loaded in start16.S */
  55. movl $0x18, %eax
  56. movw %ax, %fs
  57. movw %ax, %ds
  58. movw %ax, %gs
  59. movw %ax, %es
  60. movw %ax, %ss
  61. /* Clear the interrupt vectors */
  62. lidt blank_idt_ptr
  63. /* Early platform init (setup gpio, etc ) */
  64. jmp early_board_init
  65. .globl early_board_init_ret
  66. early_board_init_ret:
  67. /* Initialise Cache-As-RAM */
  68. jmp car_init
  69. .globl car_init_ret
  70. car_init_ret:
  71. /*
  72. * We now have CONFIG_SYS_CAR_SIZE bytes of Cache-As-RAM (or SRAM,
  73. * or fully initialised SDRAM - we really don't care which)
  74. * starting at CONFIG_SYS_CAR_ADDR to be used as a temporary stack
  75. */
  76. movl $CONFIG_SYS_INIT_SP_ADDR, %esp
  77. /* Set parameter to board_init_f() to boot flags */
  78. xorl %eax, %eax
  79. movw %bx, %ax
  80. /* Enter, U-boot! */
  81. call board_init_f
  82. /* indicate (lack of) progress */
  83. movw $0x85, %ax
  84. jmp die
  85. .globl relocate_code
  86. .type relocate_code, @function
  87. relocate_code:
  88. /*
  89. * SDRAM has been initialised, U-Boot code has been copied into
  90. * RAM, BSS has been cleared and relocation adjustments have been
  91. * made. It is now time to jump into the in-RAM copy of U-Boot
  92. *
  93. * %eax = Address of top of stack
  94. * %edx = Address of Global Data
  95. * %ecx = Base address of in-RAM copy of U-Boot
  96. */
  97. /* Setup stack in RAM */
  98. movl %eax, %esp
  99. /* Setup call address of in-RAM copy of board_init_r() */
  100. movl $board_init_r, %ebp
  101. addl (GD_RELOC_OFF * 4)(%edx), %ebp
  102. /* Setup parameters to board_init_r() */
  103. movl %edx, %eax
  104. movl %ecx, %edx
  105. /* Jump to in-RAM copy of board_init_r() */
  106. call *%ebp
  107. die: hlt
  108. jmp die
  109. hlt
  110. blank_idt_ptr:
  111. .word 0 /* limit */
  112. .long 0 /* base */