blob: cbec8bd0841fa7f35b4a8514496ad83ac1c0473b [file] [log] [blame]
Thomas Gleixner97873a32019-06-04 10:11:30 +02001/* SPDX-License-Identifier: GPL-2.0-only */
H. Peter Anvin7052fdd2007-07-11 12:18:53 -07002/* ----------------------------------------------------------------------- *
3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 * Copyright 2007 rPath, Inc. - All Rights Reserved
6 *
H. Peter Anvin7052fdd2007-07-11 12:18:53 -07007 * ----------------------------------------------------------------------- */
8
9/*
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070010 * The actual transition into protected mode
11 */
12
13#include <asm/boot.h>
H. Peter Anvin02a7b422008-01-30 13:33:02 +010014#include <asm/processor-flags.h>
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070015#include <asm/segment.h>
Cyrill Gorcunov324bda9e42009-02-14 00:50:21 +030016#include <linux/linkage.h>
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070017
18 .text
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070019 .code16
20
21/*
22 * void protected_mode_jump(u32 entrypoint, u32 bootparams);
23 */
Jiri Slaby37818af2019-10-11 13:50:56 +020024SYM_FUNC_START_NOALIGN(protected_mode_jump)
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070025 movl %edx, %esi # Pointer to boot_params table
H. Peter Anvinc4d9ba62008-01-30 13:33:01 +010026
27 xorl %ebx, %ebx
28 movw %cs, %bx
29 shll $4, %ebx
30 addl %ebx, 2f
H. Peter Anvin2ee23942008-06-30 15:42:47 -070031 jmp 1f # Short jump to serialize on 386/486
321:
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070033
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070034 movw $__BOOT_DS, %cx
H. Peter Anvin88089512008-01-30 13:33:02 +010035 movw $__BOOT_TSS, %di
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070036
37 movl %cr0, %edx
H. Peter Anvin02a7b422008-01-30 13:33:02 +010038 orb $X86_CR0_PE, %dl # Protected mode
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070039 movl %edx, %cr0
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070040
H. Peter Anvinc4d9ba62008-01-30 13:33:01 +010041 # Transition to 32-bit mode
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070042 .byte 0x66, 0xea # ljmpl opcode
Jiri Slaby30a24412019-10-11 11:22:13 +0200432: .long .Lin_pm32 # offset
H. Peter Anvin7052fdd2007-07-11 12:18:53 -070044 .word __BOOT_CS # segment
Jiri Slaby37818af2019-10-11 13:50:56 +020045SYM_FUNC_END(protected_mode_jump)
H. Peter Anvinc4d9ba62008-01-30 13:33:01 +010046
47 .code32
H. Peter Anvinbe721692009-03-17 15:26:06 -070048 .section ".text32","ax"
Jiri Slabydeff8a22019-10-11 13:50:47 +020049SYM_FUNC_START_LOCAL_NOALIGN(.Lin_pm32)
H. Peter Anvinc4d9ba62008-01-30 13:33:01 +010050 # Set up data segments for flat 32-bit mode
51 movl %ecx, %ds
52 movl %ecx, %es
53 movl %ecx, %fs
54 movl %ecx, %gs
55 movl %ecx, %ss
56 # The 32-bit code sets up its own stack, but this way we do have
57 # a valid stack if some debugging hack wants to use it.
58 addl %ebx, %esp
59
H. Peter Anvin88089512008-01-30 13:33:02 +010060 # Set up TR to make Intel VT happy
61 ltr %di
62
H. Peter Anvinc4d9ba62008-01-30 13:33:01 +010063 # Clear registers to allow for future extensions to the
64 # 32-bit boot protocol
65 xorl %ecx, %ecx
66 xorl %edx, %edx
67 xorl %ebx, %ebx
68 xorl %ebp, %ebp
69 xorl %edi, %edi
70
H. Peter Anvin88089512008-01-30 13:33:02 +010071 # Set up LDTR to make Intel VT happy
72 lldt %cx
73
H. Peter Anvinc4d9ba62008-01-30 13:33:01 +010074 jmpl *%eax # Jump to the 32-bit entrypoint
Jiri Slabydeff8a22019-10-11 13:50:47 +020075SYM_FUNC_END(.Lin_pm32)