trampoline.S 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. *
  3. * Trampoline.S Derived from Setup.S by Linus Torvalds
  4. *
  5. * 4 Jan 1997 Michael Chastain: changed to gnu as.
  6. *
  7. * Entry: CS:IP point to the start of our code, we are
  8. * in real mode with no stack, but the rest of the
  9. * trampoline page to make our stack and everything else
  10. * is a mystery.
  11. *
  12. * In fact we don't actually need a stack so we don't
  13. * set one up.
  14. *
  15. * On entry to trampoline_data, the processor is in real mode
  16. * with 16-bit addressing and 16-bit data. CS has some value
  17. * and IP is zero. Thus, data addresses need to be absolute
  18. * (no relocation) and are taken with regard to r_base.
  19. *
  20. * If you work on this file, check the object module with objdump
  21. * --full-contents --reloc to make sure there are no relocation
  22. * entries. For the GDT entry we do hand relocation in smpboot.c
  23. * because of 64bit linker limitations.
  24. */
  25. #include <linux/linkage.h>
  26. #include <asm/segment.h>
  27. #include <asm/page.h>
  28. .data
  29. .code16
  30. ENTRY(trampoline_data)
  31. r_base = .
  32. wbinvd
  33. mov %cs, %ax # Code and data in the same place
  34. mov %ax, %ds
  35. cli # We should be safe anyway
  36. movl $0xA5A5A5A5, trampoline_data - r_base
  37. # write marker for master knows we're running
  38. /*
  39. * GDT tables in non default location kernel can be beyond 16MB and
  40. * lgdt will not be able to load the address as in real mode default
  41. * operand size is 16bit. Use lgdtl instead to force operand size
  42. * to 32 bit.
  43. */
  44. lidtl idt_48 - r_base # load idt with 0, 0
  45. lgdtl gdt_48 - r_base # load gdt with whatever is appropriate
  46. xor %ax, %ax
  47. inc %ax # protected mode (PE) bit
  48. lmsw %ax # into protected mode
  49. # flaush prefetch and jump to startup_32 in arch/x86_64/kernel/head.S
  50. ljmpl $__KERNEL32_CS, $(startup_32-__START_KERNEL_map)
  51. # Careful these need to be in the same 64K segment as the above;
  52. idt_48:
  53. .word 0 # idt limit = 0
  54. .word 0, 0 # idt base = 0L
  55. gdt_48:
  56. .short GDT_ENTRIES*8 - 1 # gdt limit
  57. .long cpu_gdt_table-__START_KERNEL_map
  58. .globl trampoline_end
  59. trampoline_end: