xref: /openbmc/linux/arch/x86/boot/pmjump.S (revision 643d1f7f)
1/* ----------------------------------------------------------------------- *
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>
18#include <asm/processor-flags.h>
19#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:
32	movl	%edx, %esi		# Pointer to boot_params table
33
34	xorl	%ebx, %ebx
35	movw	%cs, %bx
36	shll	$4, %ebx
37	addl	%ebx, 2f
38
39	movw	$__BOOT_DS, %cx
40	movw	$__BOOT_TSS, %di
41
42	movl	%cr0, %edx
43	orb	$X86_CR0_PE, %dl	# Protected mode
44	movl	%edx, %cr0
45	jmp	1f			# Short jump to serialize on 386/486
461:
47
48	# Transition to 32-bit mode
49	.byte	0x66, 0xea		# ljmpl opcode
502:	.long	in_pm32			# offset
51	.word	__BOOT_CS		# segment
52
53	.size	protected_mode_jump, .-protected_mode_jump
54
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
68	# Set up TR to make Intel VT happy
69	ltr	%di
70
71	# 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
79	# Set up LDTR to make Intel VT happy
80	lldt	%cx
81
82	jmpl	*%eax			# Jump to the 32-bit entrypoint
83
84	.size	in_pm32, .-in_pm32
85