start.S 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. /* Check we have enough memory for stack */
  58. movl $CONFIG_SYS_STACK_SIZE, %ecx
  59. cmpl %ecx, %eax
  60. jae mem_ok
  61. /* indicate (lack of) progress */
  62. movw $0x81, %ax
  63. movl $.progress0a, %ebp
  64. jmp show_boot_progress_asm
  65. .progress0a:
  66. jmp die
  67. mem_ok:
  68. /* Set stack pointer to upper memory limit*/
  69. movl %eax, %esp
  70. /* indicate progress */
  71. movw $0x02, %ax
  72. movl $.progress1, %ebp
  73. jmp show_boot_progress_asm
  74. .progress1:
  75. /* Test the stack */
  76. pushl $0
  77. popl %eax
  78. cmpl $0, %eax
  79. jne no_stack
  80. push $0x55aa55aa
  81. popl %ebx
  82. cmpl $0x55aa55aa, %ebx
  83. je stack_ok
  84. no_stack:
  85. /* indicate (lack of) progress */
  86. movw $0x82, %ax
  87. movl $.progress1a, %ebp
  88. jmp show_boot_progress_asm
  89. .progress1a:
  90. jmp die
  91. stack_ok:
  92. /* indicate progress */
  93. movw $0x03, %ax
  94. movl $.progress2, %ebp
  95. jmp show_boot_progress_asm
  96. .progress2:
  97. wbinvd
  98. /* Get upper memory limit */
  99. movl %esp, %ecx
  100. subl $CONFIG_SYS_STACK_SIZE, %ecx
  101. /* Create a Stack Frame */
  102. pushl %ebp
  103. movl %esp, %ebp
  104. /* stack_limit parameter */
  105. pushl %ecx
  106. call board_init_f /* Enter, U-boot! */
  107. /* indicate (lack of) progress */
  108. movw $0x85, %ax
  109. movl $.progress4a, %ebp
  110. jmp show_boot_progress_asm
  111. .progress4a:
  112. die: hlt
  113. jmp die
  114. hlt