trampoline_32.S 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 $0xA5A5A5A5, trampoline_status
  45. # write marker for master knows we're running
  46. /* GDT tables in non default location kernel can be beyond 16MB and
  47. * lgdt will not be able to load the address as in real mode default
  48. * operand size is 16bit. Use lgdtl instead to force operand size
  49. * to 32 bit.
  50. */
  51. lidtl boot_idt_descr # load idt with 0, 0
  52. lgdtl boot_gdt_descr # load gdt with whatever is appropriate
  53. xor %ax, %ax
  54. inc %ax # protected mode (PE) bit
  55. lmsw %ax # into protected mode
  56. # flush prefetch and jump to startup_32_smp in arch/i386/kernel/head.S
  57. ljmpl *(startup_32_smp)
  58. .data
  59. .globl startup_32_smp, boot_gdt, trampoline_status
  60. .balign 4
  61. boot_gdt_descr:
  62. .word __BOOT_DS + 7 # gdt limit
  63. boot_gdt:
  64. .long 0 # gdt base
  65. boot_idt_descr:
  66. .word 0 # idt limit = 0
  67. .long 0 # idt base = 0L
  68. trampoline_status:
  69. .long 0
  70. startup_32_smp:
  71. .long 0x00000000
  72. .word __BOOT_CS, 0