start.S 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * U-boot - i386 Startup Code
  3. *
  4. * Copyright (c) 2002 Omicron Ceti AB, Daniel Engström <denaiel@omicron.se>
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. #include <config.h>
  25. #include <version.h>
  26. .section .text
  27. .code32
  28. .globl _start
  29. .type _start, @function
  30. .globl _i386boot_start
  31. _i386boot_start:
  32. _start:
  33. movl $0x18,%eax /* Load our segement registes, the
  34. * gdt have already been loaded by start16.S */
  35. movw %ax,%fs
  36. movw %ax,%ds
  37. movw %ax,%gs
  38. movw %ax,%es
  39. movw %ax,%ss
  40. /* We call a few functions in the board support package
  41. * since we have no stack yet we'll have to use %ebp
  42. * to store the return address */
  43. /* Early platform init (setup gpio, etc ) */
  44. mov $early_board_init_ret, %ebp
  45. jmp early_board_init
  46. early_board_init_ret:
  47. /* The __port80 entry-point should be usabe by now */
  48. /* so we try to indicate progress */
  49. movw $0x01, %ax
  50. movl $.progress0, %ebp
  51. jmp show_boot_progress_asm
  52. .progress0:
  53. /* size memory */
  54. mov $mem_init_ret, %ebp
  55. jmp mem_init
  56. mem_init_ret:
  57. /* fetch memory size (into %eax) */
  58. mov $get_mem_size_ret, %ebp
  59. jmp get_mem_size
  60. get_mem_size_ret:
  61. /* Check we have enough memory for stack */
  62. movl $CONFIG_SYS_STACK_SIZE, %ecx
  63. cmpl %ecx, %eax
  64. jae mem_ok
  65. /* indicate (lack of) progress */
  66. movw $0x81, %ax
  67. movl $.progress0a, %ebp
  68. jmp show_boot_progress_asm
  69. .progress0a:
  70. jmp die
  71. mem_ok:
  72. /* Set stack pointer to upper memory limit*/
  73. movl %eax, %esp
  74. /* indicate progress */
  75. movw $0x02, %ax
  76. movl $.progress1, %ebp
  77. jmp show_boot_progress_asm
  78. .progress1:
  79. /* Test the stack */
  80. pushl $0
  81. popl %eax
  82. cmpl $0, %eax
  83. jne no_stack
  84. push $0x55aa55aa
  85. popl %ebx
  86. cmpl $0x55aa55aa, %ebx
  87. je stack_ok
  88. no_stack:
  89. /* indicate (lack of) progress */
  90. movw $0x82, %ax
  91. movl $.progress1a, %ebp
  92. jmp show_boot_progress_asm
  93. .progress1a:
  94. jmp die
  95. stack_ok:
  96. /* indicate progress */
  97. movw $0x03, %ax
  98. movl $.progress2, %ebp
  99. jmp show_boot_progress_asm
  100. .progress2:
  101. wbinvd
  102. /* Get upper memory limit */
  103. movl %esp, %ecx
  104. subl $CONFIG_SYS_STACK_SIZE, %ecx
  105. /* Create a Stack Frame */
  106. pushl %ebp
  107. movl %esp, %ebp
  108. /* stack_limit parameter */
  109. pushl %ecx
  110. call board_init_f /* Enter, U-boot! */
  111. /* indicate (lack of) progress */
  112. movw $0x85, %ax
  113. movl $.progress4a, %ebp
  114. jmp show_boot_progress_asm
  115. .progress4a:
  116. die: hlt
  117. jmp die
  118. hlt