trampoline_32.S 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. #include "realmode.h"
  32. .text
  33. .code16
  34. .globl trampoline_data
  35. .balign PAGE_SIZE
  36. trampoline_data:
  37. wbinvd # Needed for NUMA-Q should be harmless for others
  38. LJMPW_RM(1f)
  39. 1:
  40. mov %cs, %ax # Code and data in the same place
  41. mov %ax, %ds
  42. cli # We should be safe anyway
  43. movl startup_32_smp, %eax # where we need to go
  44. movl $0xA5A5A5A5, trampoline_status
  45. # write marker for master knows we're running
  46. /*
  47. * GDT tables in non default location kernel can be beyond 16MB and
  48. * lgdt will not be able to load the address as in real mode default
  49. * operand size is 16bit. Use lgdtl instead to force operand size
  50. * to 32 bit.
  51. */
  52. lidtl boot_idt_descr # load idt with 0, 0
  53. lgdtl boot_gdt_descr # load gdt with whatever is appropriate
  54. movw $1, %dx # protected mode (PE) bit
  55. lmsw %dx # into protected mode
  56. ljmpl $__BOOT_CS, $pa_startup_32
  57. .section ".text32","ax"
  58. .code32
  59. ENTRY(startup_32) # note: also used from wakeup_asm.S
  60. jmp *%eax
  61. .data
  62. .globl startup_32_smp, boot_gdt, trampoline_status
  63. .balign 4
  64. boot_gdt_descr:
  65. .word __BOOT_DS + 7 # gdt limit
  66. boot_gdt:
  67. .long 0 # gdt base
  68. boot_idt_descr:
  69. .word 0 # idt limit = 0
  70. .long 0 # idt base = 0L
  71. trampoline_status:
  72. .long 0
  73. startup_32_smp:
  74. .long 0