head32.S 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* arch/x86/init/head32.S
  2. *
  3. * This file is part of evx.
  4. *
  5. * evx is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * evx is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with evx. If not, see <https://www.gnu.org/licenses/>
  17. */
  18. .code32
  19. .globl _start
  20. _start:
  21. /* we are now in the protected-mode, just
  22. * do some initializes, and call main */
  23. lgdt gdt_descr
  24. movl $0xc0000000, %eax
  25. leal 1f, %ecx
  26. orl %ecx, %eax
  27. pushl %eax
  28. movl $0xc0000000, %eax
  29. leal init, %ecx
  30. orl %ecx, %eax
  31. pushl %eax
  32. retl
  33. 1: hlt
  34. jmp 1b
  35. .globl __stack_chk_fail
  36. __stack_chk_fail:
  37. hlt
  38. jmp __stack_chk_fail
  39. .data
  40. .align 16
  41. .globl gdt
  42. gdt: .long 0x00000000, 0x00000000
  43. .long 0x0000ffff, 0x00cf9a00
  44. .long 0x0000ffff, 0x00cf9200
  45. .globl gdt_descr
  46. gdt_descr:
  47. .word . - gdt
  48. .long gdt