efi_thunk_64.S 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (C) 2014 Intel Corporation; author Matt Fleming
  3. */
  4. #include <linux/linkage.h>
  5. #include <asm/page_types.h>
  6. .text
  7. .code64
  8. ENTRY(efi64_thunk)
  9. push %rbp
  10. push %rbx
  11. /*
  12. * Switch to 1:1 mapped 32-bit stack pointer.
  13. */
  14. movq %rsp, efi_saved_sp(%rip)
  15. movq efi_scratch+25(%rip), %rsp
  16. /*
  17. * Calculate the physical address of the kernel text.
  18. */
  19. movq $__START_KERNEL_map, %rax
  20. subq phys_base(%rip), %rax
  21. /*
  22. * Push some physical addresses onto the stack. This is easier
  23. * to do now in a code64 section while the assembler can address
  24. * 64-bit values. Note that all the addresses on the stack are
  25. * 32-bit.
  26. */
  27. subq $16, %rsp
  28. leaq efi_exit32(%rip), %rbx
  29. subq %rax, %rbx
  30. movl %ebx, 8(%rsp)
  31. leaq efi_gdt64(%rip), %rbx
  32. subq %rax, %rbx
  33. movl %ebx, 2(%ebx)
  34. movl %ebx, 4(%rsp)
  35. leaq efi_gdt32(%rip), %rbx
  36. subq %rax, %rbx
  37. movl %ebx, 2(%ebx)
  38. movl %ebx, (%rsp)
  39. leaq __efi64_thunk(%rip), %rbx
  40. subq %rax, %rbx
  41. call *%rbx
  42. movq efi_saved_sp(%rip), %rsp
  43. pop %rbx
  44. pop %rbp
  45. retq
  46. ENDPROC(efi64_thunk)
  47. .data
  48. efi_gdt32:
  49. .word efi_gdt32_end - efi_gdt32
  50. .long 0 /* Filled out above */
  51. .word 0
  52. .quad 0x0000000000000000 /* NULL descriptor */
  53. .quad 0x00cf9a000000ffff /* __KERNEL_CS */
  54. .quad 0x00cf93000000ffff /* __KERNEL_DS */
  55. efi_gdt32_end:
  56. efi_saved_sp: .quad 0