pmjump.S 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. .text
  17. .globl protected_mode_jump
  18. .type protected_mode_jump, @function
  19. .code16
  20. /*
  21. * void protected_mode_jump(u32 entrypoint, u32 bootparams);
  22. */
  23. protected_mode_jump:
  24. movl %edx, %esi # Pointer to boot_params table
  25. xorl %ebx, %ebx
  26. movw %cs, %bx
  27. shll $4, %ebx
  28. addl %ebx, 2f
  29. jmp 1f # Short jump to serialize on 386/486
  30. 1:
  31. movw $__BOOT_DS, %cx
  32. movw $__BOOT_TSS, %di
  33. movl %cr0, %edx
  34. orb $X86_CR0_PE, %dl # Protected mode
  35. movl %edx, %cr0
  36. # Transition to 32-bit mode
  37. .byte 0x66, 0xea # ljmpl opcode
  38. 2: .long in_pm32 # offset
  39. .word __BOOT_CS # segment
  40. .size protected_mode_jump, .-protected_mode_jump
  41. .code32
  42. .type in_pm32, @function
  43. in_pm32:
  44. # Set up data segments for flat 32-bit mode
  45. movl %ecx, %ds
  46. movl %ecx, %es
  47. movl %ecx, %fs
  48. movl %ecx, %gs
  49. movl %ecx, %ss
  50. # The 32-bit code sets up its own stack, but this way we do have
  51. # a valid stack if some debugging hack wants to use it.
  52. addl %ebx, %esp
  53. # Set up TR to make Intel VT happy
  54. ltr %di
  55. # Clear registers to allow for future extensions to the
  56. # 32-bit boot protocol
  57. xorl %ecx, %ecx
  58. xorl %edx, %edx
  59. xorl %ebx, %ebx
  60. xorl %ebp, %ebp
  61. xorl %edi, %edi
  62. # Set up LDTR to make Intel VT happy
  63. lldt %cx
  64. jmpl *%eax # Jump to the 32-bit entrypoint
  65. .size in_pm32, .-in_pm32