setup-x86_64.S 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * purgatory: setup code
  4. *
  5. * Copyright (C) 2003,2004 Eric Biederman ([email protected])
  6. * Copyright (C) 2014 Red Hat Inc.
  7. *
  8. * This code has been taken from kexec-tools.
  9. */
  10. #include <linux/linkage.h>
  11. #include <asm/purgatory.h>
  12. .text
  13. .balign 16
  14. .code64
  15. SYM_CODE_START(purgatory_start)
  16. /* Load a gdt so I know what the segment registers are */
  17. lgdt gdt(%rip)
  18. /* load the data segments */
  19. movl $0x18, %eax /* data segment */
  20. movl %eax, %ds
  21. movl %eax, %es
  22. movl %eax, %ss
  23. movl %eax, %fs
  24. movl %eax, %gs
  25. /* Setup a stack */
  26. leaq lstack_end(%rip), %rsp
  27. /* Call the C code */
  28. call purgatory
  29. jmp entry64
  30. SYM_CODE_END(purgatory_start)
  31. .section ".rodata"
  32. .balign 16
  33. SYM_DATA_START_LOCAL(gdt)
  34. /* 0x00 unusable segment
  35. * 0x08 unused
  36. * so use them as the gdt ptr
  37. */
  38. .word gdt_end - gdt - 1
  39. .quad gdt
  40. .word 0, 0, 0
  41. /* 0x10 4GB flat code segment */
  42. .word 0xFFFF, 0x0000, 0x9A00, 0x00AF
  43. /* 0x18 4GB flat data segment */
  44. .word 0xFFFF, 0x0000, 0x9200, 0x00CF
  45. SYM_DATA_END_LABEL(gdt, SYM_L_LOCAL, gdt_end)
  46. .bss
  47. .balign 4096
  48. SYM_DATA_START_LOCAL(lstack)
  49. .skip 4096
  50. SYM_DATA_END_LABEL(lstack, SYM_L_LOCAL, lstack_end)