blob: 3e0edc6d2a2079892e1a655ef2e7a35a013c4ef3 [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/*
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070012 * The actual transition into protected mode
13 */
14
15#include <asm/boot.h>
H. Peter Anvin02a7b422008-01-30 13:33:02 +010016#include <asm/processor-flags.h>
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070017#include <asm/segment.h>
Cyrill Gorcunov324bda9e2009-02-14 00:50:21 +030018#include <linux/linkage.h>
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070019
20 .text
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070021 .code16
22
23/*
24 * void protected_mode_jump(u32 entrypoint, u32 bootparams);
25 */
Cyrill Gorcunov324bda9e2009-02-14 00:50:21 +030026GLOBAL(protected_mode_jump)
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070027 movl %edx, %esi # Pointer to boot_params table
H. Peter Anvinc4d9ba62008-01-30 13:33:01 +010028
29 xorl %ebx, %ebx
30 movw %cs, %bx
31 shll $4, %ebx
32 addl %ebx, 2f
H. Peter Anvin2ee23942008-06-30 15:42:47 -070033 jmp 1f # Short jump to serialize on 386/486
341:
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070035
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070036 movw $__BOOT_DS, %cx
H. Peter Anvin88089512008-01-30 13:33:02 +010037 movw $__BOOT_TSS, %di
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070038
39 movl %cr0, %edx
H. Peter Anvin02a7b422008-01-30 13:33:02 +010040 orb $X86_CR0_PE, %dl # Protected mode
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070041 movl %edx, %cr0
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070042
H. Peter Anvinc4d9ba62008-01-30 13:33:01 +010043 # Transition to 32-bit mode
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070044 .byte 0x66, 0xea # ljmpl opcode
H. Peter Anvinc4d9ba62008-01-30 13:33:01 +0100452: .long in_pm32 # offset
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070046 .word __BOOT_CS # segment
Cyrill Gorcunov324bda9e2009-02-14 00:50:21 +030047ENDPROC(protected_mode_jump)
H. Peter Anvinc4d9ba62008-01-30 13:33:01 +010048
49 .code32
H. Peter Anvinbe721692009-03-17 15:26:06 -070050 .section ".text32","ax"
Cyrill Gorcunov324bda9e2009-02-14 00:50:21 +030051GLOBAL(in_pm32)
H. Peter Anvinc4d9ba62008-01-30 13:33:01 +010052 # Set up data segments for flat 32-bit mode
53 movl %ecx, %ds
54 movl %ecx, %es
55 movl %ecx, %fs
56 movl %ecx, %gs
57 movl %ecx, %ss
58 # The 32-bit code sets up its own stack, but this way we do have
59 # a valid stack if some debugging hack wants to use it.
60 addl %ebx, %esp
61
H. Peter Anvin88089512008-01-30 13:33:02 +010062 # Set up TR to make Intel VT happy
63 ltr %di
64
H. Peter Anvinc4d9ba62008-01-30 13:33:01 +010065 # Clear registers to allow for future extensions to the
66 # 32-bit boot protocol
67 xorl %ecx, %ecx
68 xorl %edx, %edx
69 xorl %ebx, %ebx
70 xorl %ebp, %ebp
71 xorl %edi, %edi
72
H. Peter Anvin88089512008-01-30 13:33:02 +010073 # Set up LDTR to make Intel VT happy
74 lldt %cx
75
H. Peter Anvinc4d9ba62008-01-30 13:33:01 +010076 jmpl *%eax # Jump to the 32-bit entrypoint
Cyrill Gorcunov324bda9e2009-02-14 00:50:21 +030077ENDPROC(in_pm32)