pmjump.S 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* ----------------------------------------------------------------------- *
  3. *
  4. * Copyright (C) 1991, 1992 Linus Torvalds
  5. * Copyright 2007 rPath, Inc. - All Rights Reserved
  6. *
  7. * ----------------------------------------------------------------------- */
  8. /*
  9. * The actual transition into protected mode
  10. */
  11. #include <asm/boot.h>
  12. #include <asm/processor-flags.h>
  13. #include <asm/segment.h>
  14. #include <linux/linkage.h>
  15. .text
  16. .code16
  17. /*
  18. * void protected_mode_jump(u32 entrypoint, u32 bootparams);
  19. */
  20. SYM_FUNC_START_NOALIGN(protected_mode_jump)
  21. movl %edx, %esi # Pointer to boot_params table
  22. xorl %ebx, %ebx
  23. movw %cs, %bx
  24. shll $4, %ebx
  25. addl %ebx, 2f
  26. jmp 1f # Short jump to serialize on 386/486
  27. 1:
  28. movw $__BOOT_DS, %cx
  29. movw $__BOOT_TSS, %di
  30. movl %cr0, %edx
  31. orb $X86_CR0_PE, %dl # Protected mode
  32. movl %edx, %cr0
  33. # Transition to 32-bit mode
  34. .byte 0x66, 0xea # ljmpl opcode
  35. 2: .long .Lin_pm32 # offset
  36. .word __BOOT_CS # segment
  37. SYM_FUNC_END(protected_mode_jump)
  38. .code32
  39. .section ".text32","ax"
  40. SYM_FUNC_START_LOCAL_NOALIGN(.Lin_pm32)
  41. # Set up data segments for flat 32-bit mode
  42. movl %ecx, %ds
  43. movl %ecx, %es
  44. movl %ecx, %fs
  45. movl %ecx, %gs
  46. movl %ecx, %ss
  47. # The 32-bit code sets up its own stack, but this way we do have
  48. # a valid stack if some debugging hack wants to use it.
  49. addl %ebx, %esp
  50. # Set up TR to make Intel VT happy
  51. ltr %di
  52. # Clear registers to allow for future extensions to the
  53. # 32-bit boot protocol
  54. xorl %ecx, %ecx
  55. xorl %edx, %edx
  56. xorl %ebx, %ebx
  57. xorl %ebp, %ebp
  58. xorl %edi, %edi
  59. # Set up LDTR to make Intel VT happy
  60. lldt %cx
  61. jmpl *%eax # Jump to the 32-bit entrypoint
  62. SYM_FUNC_END(.Lin_pm32)