Merge tag 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm
[linux-2.6-block.git] / arch / x86 / boot / pmjump.S
CommitLineData
97873a3d 1/* SPDX-License-Identifier: GPL-2.0-only */
7052fdd8
PA
2/* ----------------------------------------------------------------------- *
3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 * Copyright 2007 rPath, Inc. - All Rights Reserved
6 *
7052fdd8
PA
7 * ----------------------------------------------------------------------- */
8
9/*
7052fdd8
PA
10 * The actual transition into protected mode
11 */
12
13#include <asm/boot.h>
02a7b425 14#include <asm/processor-flags.h>
7052fdd8 15#include <asm/segment.h>
324bda9e 16#include <linux/linkage.h>
7052fdd8
PA
17
18 .text
7052fdd8
PA
19 .code16
20
21/*
22 * void protected_mode_jump(u32 entrypoint, u32 bootparams);
23 */
324bda9e 24GLOBAL(protected_mode_jump)
7052fdd8 25 movl %edx, %esi # Pointer to boot_params table
c4d9ba6d
PA
26
27 xorl %ebx, %ebx
28 movw %cs, %bx
29 shll $4, %ebx
30 addl %ebx, 2f
2ee2394b
PA
31 jmp 1f # Short jump to serialize on 386/486
321:
7052fdd8 33
7052fdd8 34 movw $__BOOT_DS, %cx
88089519 35 movw $__BOOT_TSS, %di
7052fdd8
PA
36
37 movl %cr0, %edx
02a7b425 38 orb $X86_CR0_PE, %dl # Protected mode
7052fdd8
PA
39 movl %edx, %cr0
40
c4d9ba6d 41 # Transition to 32-bit mode
7052fdd8 42 .byte 0x66, 0xea # ljmpl opcode
c4d9ba6d 432: .long in_pm32 # offset
7052fdd8 44 .word __BOOT_CS # segment
324bda9e 45ENDPROC(protected_mode_jump)
c4d9ba6d
PA
46
47 .code32
be721696 48 .section ".text32","ax"
324bda9e 49GLOBAL(in_pm32)
c4d9ba6d
PA
50 # 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
88089519
PA
60 # Set up TR to make Intel VT happy
61 ltr %di
62
c4d9ba6d
PA
63 # 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
88089519
PA
71 # Set up LDTR to make Intel VT happy
72 lldt %cx
73
c4d9ba6d 74 jmpl *%eax # Jump to the 32-bit entrypoint
324bda9e 75ENDPROC(in_pm32)