pmjump.S 1.7 KB

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