blob: f7153d0d476e8beb8d38c1a8bfe3d0088968a5b0 [file] [log] [blame]
H. Peter Anvin7052fdd2007-07-11 12:18:53 -07001/* ----------------------------------------------------------------------- *
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 * arch/i386/boot/pmjump.S
13 *
14 * The actual transition into protected mode
15 */
16
17#include <asm/boot.h>
18#include <asm/segment.h>
19
20 .text
21
22 .globl protected_mode_jump
23 .type protected_mode_jump, @function
24
25 .code16
26
27/*
28 * void protected_mode_jump(u32 entrypoint, u32 bootparams);
29 */
30protected_mode_jump:
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070031 movl %edx, %esi # Pointer to boot_params table
H. Peter Anvinc4d9ba62008-01-30 13:33:01 +010032
33 xorl %ebx, %ebx
34 movw %cs, %bx
35 shll $4, %ebx
36 addl %ebx, 2f
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070037
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070038 movw $__BOOT_DS, %cx
H. Peter Anvin88089512008-01-30 13:33:02 +010039 movw $__BOOT_TSS, %di
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070040
41 movl %cr0, %edx
42 orb $1, %dl # Protected mode (PE) bit
43 movl %edx, %cr0
H. Peter Anvin7ed19292007-11-04 17:50:12 -080044 jmp 1f # Short jump to serialize on 386/486
451:
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070046
H. Peter Anvinc4d9ba62008-01-30 13:33:01 +010047 # Transition to 32-bit mode
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070048 .byte 0x66, 0xea # ljmpl opcode
H. Peter Anvinc4d9ba62008-01-30 13:33:01 +0100492: .long in_pm32 # offset
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070050 .word __BOOT_CS # segment
51
52 .size protected_mode_jump, .-protected_mode_jump
H. Peter Anvinc4d9ba62008-01-30 13:33:01 +010053
54 .code32
55 .type in_pm32, @function
56in_pm32:
57 # Set up data segments for flat 32-bit mode
58 movl %ecx, %ds
59 movl %ecx, %es
60 movl %ecx, %fs
61 movl %ecx, %gs
62 movl %ecx, %ss
63 # The 32-bit code sets up its own stack, but this way we do have
64 # a valid stack if some debugging hack wants to use it.
65 addl %ebx, %esp
66
H. Peter Anvin88089512008-01-30 13:33:02 +010067 # Set up TR to make Intel VT happy
68 ltr %di
69
H. Peter Anvinc4d9ba62008-01-30 13:33:01 +010070 # Clear registers to allow for future extensions to the
71 # 32-bit boot protocol
72 xorl %ecx, %ecx
73 xorl %edx, %edx
74 xorl %ebx, %ebx
75 xorl %ebp, %ebp
76 xorl %edi, %edi
77
H. Peter Anvin88089512008-01-30 13:33:02 +010078 # Set up LDTR to make Intel VT happy
79 lldt %cx
80
H. Peter Anvinc4d9ba62008-01-30 13:33:01 +010081 jmpl *%eax # Jump to the 32-bit entrypoint
82
83 .size in_pm32, .-in_pm32