diff options
Diffstat (limited to 'arch/x86/boot/pmjump.S')
-rw-r--r-- | arch/x86/boot/pmjump.S | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/arch/x86/boot/pmjump.S b/arch/x86/boot/pmjump.S index fa6bed1fac14..ef0da1f2c7fd 100644 --- a/arch/x86/boot/pmjump.S +++ b/arch/x86/boot/pmjump.S | |||
@@ -29,12 +29,13 @@ | |||
29 | */ | 29 | */ |
30 | protected_mode_jump: | 30 | protected_mode_jump: |
31 | movl %edx, %esi # Pointer to boot_params table | 31 | movl %edx, %esi # Pointer to boot_params table |
32 | movl %eax, 2f # Patch ljmpl instruction | 32 | |
33 | xorl %ebx, %ebx | ||
34 | movw %cs, %bx | ||
35 | shll $4, %ebx | ||
36 | addl %ebx, 2f | ||
33 | 37 | ||
34 | movw $__BOOT_DS, %cx | 38 | movw $__BOOT_DS, %cx |
35 | xorl %ebx, %ebx # Per the 32-bit boot protocol | ||
36 | xorl %ebp, %ebp # Per the 32-bit boot protocol | ||
37 | xorl %edi, %edi # Per the 32-bit boot protocol | ||
38 | 39 | ||
39 | movl %cr0, %edx | 40 | movl %cr0, %edx |
40 | orb $1, %dl # Protected mode (PE) bit | 41 | orb $1, %dl # Protected mode (PE) bit |
@@ -42,15 +43,34 @@ protected_mode_jump: | |||
42 | jmp 1f # Short jump to serialize on 386/486 | 43 | jmp 1f # Short jump to serialize on 386/486 |
43 | 1: | 44 | 1: |
44 | 45 | ||
45 | movw %cx, %ds | 46 | # Transition to 32-bit mode |
46 | movw %cx, %es | ||
47 | movw %cx, %fs | ||
48 | movw %cx, %gs | ||
49 | movw %cx, %ss | ||
50 | |||
51 | # Jump to the 32-bit entrypoint | ||
52 | .byte 0x66, 0xea # ljmpl opcode | 47 | .byte 0x66, 0xea # ljmpl opcode |
53 | 2: .long 0 # offset | 48 | 2: .long in_pm32 # offset |
54 | .word __BOOT_CS # segment | 49 | .word __BOOT_CS # segment |
55 | 50 | ||
56 | .size protected_mode_jump, .-protected_mode_jump | 51 | .size protected_mode_jump, .-protected_mode_jump |
52 | |||
53 | .code32 | ||
54 | .type in_pm32, @function | ||
55 | in_pm32: | ||
56 | # Set up data segments for flat 32-bit mode | ||
57 | movl %ecx, %ds | ||
58 | movl %ecx, %es | ||
59 | movl %ecx, %fs | ||
60 | movl %ecx, %gs | ||
61 | movl %ecx, %ss | ||
62 | # The 32-bit code sets up its own stack, but this way we do have | ||
63 | # a valid stack if some debugging hack wants to use it. | ||
64 | addl %ebx, %esp | ||
65 | |||
66 | # Clear registers to allow for future extensions to the | ||
67 | # 32-bit boot protocol | ||
68 | xorl %ecx, %ecx | ||
69 | xorl %edx, %edx | ||
70 | xorl %ebx, %ebx | ||
71 | xorl %ebp, %ebp | ||
72 | xorl %edi, %edi | ||
73 | |||
74 | jmpl *%eax # Jump to the 32-bit entrypoint | ||
75 | |||
76 | .size in_pm32, .-in_pm32 | ||