pmjump.S 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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)