trampoline_32.S 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. * This is only used for booting secondary CPUs in SMP machine
  8. *
  9. * Entry: CS:IP point to the start of our code, we are
  10. * in real mode with no stack, but the rest of the
  11. * trampoline page to make our stack and everything else
  12. * is a mystery.
  13. *
  14. * We jump into arch/x86/kernel/head_32.S.
  15. *
  16. * On entry to trampoline_data, the processor is in real mode
  17. * with 16-bit addressing and 16-bit data. CS has some value
  18. * and IP is zero. Thus, we load CS to the physical segment
  19. * of the real mode code before doing anything further.
  20. *
  21. * The structure real_mode_header includes entries that need
  22. * to be set up before executing this code:
  23. *
  24. * startup_32_smp
  25. * boot_gdt
  26. */
  27. #include <linux/linkage.h>
  28. #include <linux/init.h>
  29. #include <asm/segment.h>
  30. #include <asm/page_types.h>
  31. .text
  32. .code16
  33. .globl trampoline_data
  34. .balign PAGE_SIZE
  35. trampoline_data:
  36. wbinvd # Needed for NUMA-Q should be harmless for others
  37. .byte 0xea # ljmpw
  38. .word 1f # Offset
  39. .word real_mode_seg # Segment
  40. 1:
  41. mov %cs, %ax # Code and data in the same place
  42. mov %ax, %ds
  43. cli # We should be safe anyway
  44. movl startup_32_smp, %eax # where we need to go
  45. movl $0xA5A5A5A5, trampoline_status
  46. # write marker for master knows we're running
  47. /*
  48. * GDT tables in non default location kernel can be beyond 16MB and
  49. * lgdt will not be able to load the address as in real mode default
  50. * operand size is 16bit. Use lgdtl instead to force operand size
  51. * to 32 bit.
  52. */
  53. lidtl boot_idt_descr # load idt with 0, 0
  54. lgdtl boot_gdt_descr # load gdt with whatever is appropriate
  55. movw $1, %dx # protected mode (PE) bit
  56. lmsw %dx # into protected mode
  57. ljmpl $__BOOT_CS, $pa_startup_32
  58. .section ".text32","ax"
  59. .code32
  60. ENTRY(startup_32) # note: also used from wakeup_asm.S
  61. jmp *%eax
  62. .data
  63. .globl startup_32_smp, boot_gdt, trampoline_status
  64. .balign 4
  65. boot_gdt_descr:
  66. .word __BOOT_DS + 7 # gdt limit
  67. boot_gdt:
  68. .long 0 # gdt base
  69. boot_idt_descr:
  70. .word 0 # idt limit = 0
  71. .long 0 # idt base = 0L
  72. trampoline_status:
  73. .long 0
  74. startup_32_smp:
  75. .long 0