1
0

start_gcc.S 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2006-09-15 QiuYi The first version.
  9. * 2012-02-15 aozima update.
  10. */
  11. /* the magic number for the multiboot header. */
  12. #define MULTIBOOT_HEADER_MAGIC 0x1BADB002
  13. /* the flags for the multiboot header. */
  14. #define MULTIBOOT_HEADER_FLAGS 0x00000003
  15. #define CONFIG_STACKSIZE 8192
  16. /**
  17. * @addtogroup I386
  18. */
  19. /*@{*/
  20. .section .init, "ax"
  21. /* the system entry */
  22. .globl _start
  23. _start:
  24. jmp multiboot_entry
  25. /* Align 32 bits boundary. */
  26. .align 4
  27. /* multiboot header. */
  28. multiboot_header:
  29. /* magic */
  30. .long MULTIBOOT_HEADER_MAGIC
  31. /* flags */
  32. .long MULTIBOOT_HEADER_FLAGS
  33. /* checksum */
  34. .long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
  35. multiboot_entry:
  36. movl $(_end + 0x1000),%esp
  37. /* reset eflags. */
  38. pushl $0
  39. popf
  40. /* rebuild globe describe table */
  41. lgdt __gdtdesc
  42. movl $0x10,%eax
  43. movw %ax,%ds
  44. movw %ax,%es
  45. movw %ax,%ss
  46. ljmp $0x08, $relocated
  47. relocated:
  48. /* push the pointer to the multiboot information structure. */
  49. pushl %ebx
  50. /* push the magic value. */
  51. pushl %eax
  52. call rtthread_startup
  53. /* never get here */
  54. spin:
  55. hlt
  56. jmp spin
  57. .data
  58. .p2align 2
  59. __gdt:
  60. .word 0,0,0,0
  61. .word 0x07FF /* 8Mb - limit=2047 */
  62. .word 0x0000
  63. .word 0x9A00 /* code read/exec */
  64. .word 0x00C0
  65. .word 0x07FF /* 8Mb - limit=2047 */
  66. .word 0x0000
  67. .word 0x9200 /* data read/write */
  68. .word 0x00C0
  69. __gdtdesc:
  70. .word 0x17
  71. .long __gdt
  72. /*@}*/