pmjump.S 1.8 KB

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