blob: f5402d51f7c3d1ff534a009d54d438a3cfa54ec8 [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>
H. Peter Anvin02a7b422008-01-30 13:33:02 +010018#include <asm/processor-flags.h>
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070019#include <asm/segment.h>
20
21 .text
22
23 .globl protected_mode_jump
24 .type protected_mode_jump, @function
25
26 .code16
27
28/*
29 * void protected_mode_jump(u32 entrypoint, u32 bootparams);
30 */
31protected_mode_jump:
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070032 movl %edx, %esi # Pointer to boot_params table
H. Peter Anvinc4d9ba62008-01-30 13:33:01 +010033
34 xorl %ebx, %ebx
35 movw %cs, %bx
36 shll $4, %ebx
37 addl %ebx, 2f
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070038
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070039 movw $__BOOT_DS, %cx
H. Peter Anvin88089512008-01-30 13:33:02 +010040 movw $__BOOT_TSS, %di
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070041
42 movl %cr0, %edx
H. Peter Anvin02a7b422008-01-30 13:33:02 +010043 orb $X86_CR0_PE, %dl # Protected mode
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070044 movl %edx, %cr0
H. Peter Anvin7ed19292007-11-04 17:50:12 -080045 jmp 1f # Short jump to serialize on 386/486
461:
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070047
H. Peter Anvinc4d9ba62008-01-30 13:33:01 +010048 # Transition to 32-bit mode
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070049 .byte 0x66, 0xea # ljmpl opcode
H. Peter Anvinc4d9ba62008-01-30 13:33:01 +0100502: .long in_pm32 # offset
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070051 .word __BOOT_CS # segment
52
53 .size protected_mode_jump, .-protected_mode_jump
H. Peter Anvinc4d9ba62008-01-30 13:33:01 +010054
55 .code32
56 .type in_pm32, @function
57in_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
67
H. Peter Anvin88089512008-01-30 13:33:02 +010068 # Set up TR to make Intel VT happy
69 ltr %di
70
H. Peter Anvinc4d9ba62008-01-30 13:33:01 +010071 # 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
78
H. Peter Anvin88089512008-01-30 13:33:02 +010079 # Set up LDTR to make Intel VT happy
80 lldt %cx
81
H. Peter Anvinc4d9ba62008-01-30 13:33:01 +010082 jmpl *%eax # Jump to the 32-bit entrypoint
83
84 .size in_pm32, .-in_pm32