Merge branch 'master' of /home/davem/src/GIT/linux-2.6/
[sfrench/cifs-2.6.git] / arch / x86 / boot / pmjump.S
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 /*
12  * The actual transition into protected mode
13  */
14
15 #include <asm/boot.h>
16 #include <asm/processor-flags.h>
17 #include <asm/segment.h>
18 #include <linux/linkage.h>
19
20         .text
21         .code16
22
23 /*
24  * void protected_mode_jump(u32 entrypoint, u32 bootparams);
25  */
26 GLOBAL(protected_mode_jump)
27         movl    %edx, %esi              # Pointer to boot_params table
28
29         xorl    %ebx, %ebx
30         movw    %cs, %bx
31         shll    $4, %ebx
32         addl    %ebx, 2f
33         jmp     1f                      # Short jump to serialize on 386/486
34 1:
35
36         movw    $__BOOT_DS, %cx
37         movw    $__BOOT_TSS, %di
38
39         movl    %cr0, %edx
40         orb     $X86_CR0_PE, %dl        # Protected mode
41         movl    %edx, %cr0
42
43         # Transition to 32-bit mode
44         .byte   0x66, 0xea              # ljmpl opcode
45 2:      .long   in_pm32                 # offset
46         .word   __BOOT_CS               # segment
47 ENDPROC(protected_mode_jump)
48
49         .code32
50 GLOBAL(in_pm32)
51         # Set up data segments for flat 32-bit mode
52         movl    %ecx, %ds
53         movl    %ecx, %es
54         movl    %ecx, %fs
55         movl    %ecx, %gs
56         movl    %ecx, %ss
57         # The 32-bit code sets up its own stack, but this way we do have
58         # a valid stack if some debugging hack wants to use it.
59         addl    %ebx, %esp
60
61         # Set up TR to make Intel VT happy
62         ltr     %di
63
64         # Clear registers to allow for future extensions to the
65         # 32-bit boot protocol
66         xorl    %ecx, %ecx
67         xorl    %edx, %edx
68         xorl    %ebx, %ebx
69         xorl    %ebp, %ebp
70         xorl    %edi, %edi
71
72         # Set up LDTR to make Intel VT happy
73         lldt    %cx
74
75         jmpl    *%eax                   # Jump to the 32-bit entrypoint
76 ENDPROC(in_pm32)