blob: 019c17a7585115a7cfdb0c27696544b8127599b5 [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
Cyrill Gorcunov324bda9e2009-02-14 00:50:21 +030050GLOBAL(in_pm32)
H. Peter Anvinc4d9ba62008-01-30 13:33:01 +010051 # 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
H. Peter Anvin88089512008-01-30 13:33:02 +010061 # Set up TR to make Intel VT happy
62 ltr %di
63
H. Peter Anvinc4d9ba62008-01-30 13:33:01 +010064 # 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
H. Peter Anvin88089512008-01-30 13:33:02 +010072 # Set up LDTR to make Intel VT happy
73 lldt %cx
74
H. Peter Anvinc4d9ba62008-01-30 13:33:01 +010075 jmpl *%eax # Jump to the 32-bit entrypoint
Cyrill Gorcunov324bda9e2009-02-14 00:50:21 +030076ENDPROC(in_pm32)