Committer: Michael Beasley <mike@snafu.setup>
[mikesnafu-overlay.git] / arch / x86 / boot / pmjump.S
blobf5402d51f7c3d1ff534a009d54d438a3cfa54ec8
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  * ----------------------------------------------------------------------- */
12  * arch/i386/boot/pmjump.S
13  *
14  * The actual transition into protected mode
15  */
17 #include <asm/boot.h>
18 #include <asm/processor-flags.h>
19 #include <asm/segment.h>
21         .text
23         .globl  protected_mode_jump
24         .type   protected_mode_jump, @function
26         .code16
29  * void protected_mode_jump(u32 entrypoint, u32 bootparams);
30  */
31 protected_mode_jump:
32         movl    %edx, %esi              # Pointer to boot_params table
34         xorl    %ebx, %ebx
35         movw    %cs, %bx
36         shll    $4, %ebx
37         addl    %ebx, 2f
39         movw    $__BOOT_DS, %cx
40         movw    $__BOOT_TSS, %di
42         movl    %cr0, %edx
43         orb     $X86_CR0_PE, %dl        # Protected mode
44         movl    %edx, %cr0
45         jmp     1f                      # Short jump to serialize on 386/486
48         # Transition to 32-bit mode
49         .byte   0x66, 0xea              # ljmpl opcode
50 2:      .long   in_pm32                 # offset
51         .word   __BOOT_CS               # segment
53         .size   protected_mode_jump, .-protected_mode_jump
55         .code32
56         .type   in_pm32, @function
57 in_pm32:
58         # Set up data segments for flat 32-bit mode
59         movl    %ecx, %ds
60         movl    %ecx, %es
61         movl    %ecx, %fs
62         movl    %ecx, %gs
63         movl    %ecx, %ss
64         # The 32-bit code sets up its own stack, but this way we do have
65         # a valid stack if some debugging hack wants to use it.
66         addl    %ebx, %esp
68         # Set up TR to make Intel VT happy
69         ltr     %di
71         # Clear registers to allow for future extensions to the
72         # 32-bit boot protocol
73         xorl    %ecx, %ecx
74         xorl    %edx, %edx
75         xorl    %ebx, %ebx
76         xorl    %ebp, %ebp
77         xorl    %edi, %edi
79         # Set up LDTR to make Intel VT happy
80         lldt    %cx
82         jmpl    *%eax                   # Jump to the 32-bit entrypoint
84         .size   in_pm32, .-in_pm32