start.S 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * File : start.S
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://openlab.rt-thread.com/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2006-09-15 QiuYi The first version
  13. */
  14. #define __ASM__
  15. #include <grub.h>
  16. #define CONFIG_STACKSIZE 8192
  17. /**
  18. * @addtogroup I386
  19. */
  20. /*@{*/
  21. .section .init, "ax"
  22. .text
  23. /* the system entry */
  24. .globl _start
  25. _start:
  26. jmp multiboot_entry
  27. /* Align 32 bits boundary. */
  28. .align 4
  29. /* multiboot header. */
  30. multiboot_header:
  31. /* magic */
  32. .long MULTIBOOT_HEADER_MAGIC
  33. /* flags */
  34. .long MULTIBOOT_HEADER_FLAGS
  35. /* checksum */
  36. .long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
  37. multiboot_entry:
  38. movl $(_end + 0x1000),%esp
  39. /* reset eflags. */
  40. pushl $0
  41. popf
  42. /*rebuild globe describe table*/
  43. lgdt mygdtdesc
  44. movl $0x10,%eax
  45. movw %ax,%ds
  46. movw %ax,%es
  47. movw %ax,%ss
  48. ljmp $0x08, $relocated
  49. relocated:
  50. /* push the pointer to the multiboot information structure. */
  51. pushl %ebx
  52. /* push the magic value. */
  53. pushl %eax
  54. call rtthread_startup
  55. /* never get here */
  56. spin:
  57. hlt
  58. jmp spin
  59. .data
  60. .p2align 2
  61. mygdt:
  62. .word 0,0,0,0
  63. .word 0x07FF /* 8Mb - limit=2047 */
  64. .word 0x0000
  65. .word 0x9A00 /* code read/exec */
  66. .word 0x00C0
  67. .word 0x07FF /* 8Mb - limit=2047 */
  68. .word 0x0000
  69. .word 0x9200 /* data read/write */
  70. .word 0x00C0
  71. mygdtdesc:
  72. .word 0x17
  73. .long mygdt
  74. /*@}*/