Blame view

arch/x86/boot/pmjump.S 1.7 KB
7052fdd89   H. Peter Anvin   Code for actual p...
1
2
3
4
5
6
7
8
9
10
11
  /* ----------------------------------------------------------------------- *
   *
   *   Copyright (C) 1991, 1992 Linus Torvalds
   *   Copyright 2007 rPath, Inc. - All Rights Reserved
   *
   *   This file is part of the Linux kernel, and is made available under
   *   the terms of the GNU General Public License version 2.
   *
   * ----------------------------------------------------------------------- */
  
  /*
7052fdd89   H. Peter Anvin   Code for actual p...
12
13
14
15
   * The actual transition into protected mode
   */
  
  #include <asm/boot.h>
02a7b425e   H. Peter Anvin   x86 setup: use X8...
16
  #include <asm/processor-flags.h>
7052fdd89   H. Peter Anvin   Code for actual p...
17
  #include <asm/segment.h>
324bda9e4   Cyrill Gorcunov   x86: pmjump - use...
18
  #include <linux/linkage.h>
7052fdd89   H. Peter Anvin   Code for actual p...
19
20
  
  	.text
7052fdd89   H. Peter Anvin   Code for actual p...
21
22
23
24
25
  	.code16
  
  /*
   * void protected_mode_jump(u32 entrypoint, u32 bootparams);
   */
324bda9e4   Cyrill Gorcunov   x86: pmjump - use...
26
  GLOBAL(protected_mode_jump)
7052fdd89   H. Peter Anvin   Code for actual p...
27
  	movl	%edx, %esi		# Pointer to boot_params table
c4d9ba6da   H. Peter Anvin   x86 setup: make P...
28
29
30
31
32
  
  	xorl	%ebx, %ebx
  	movw	%cs, %bx
  	shll	$4, %ebx
  	addl	%ebx, 2f
2ee2394b6   H. Peter Anvin   x86: fix regressi...
33
34
  	jmp	1f			# Short jump to serialize on 386/486
  1:
7052fdd89   H. Peter Anvin   Code for actual p...
35

7052fdd89   H. Peter Anvin   Code for actual p...
36
  	movw	$__BOOT_DS, %cx
88089519f   H. Peter Anvin   x86 setup: initia...
37
  	movw	$__BOOT_TSS, %di
7052fdd89   H. Peter Anvin   Code for actual p...
38
39
  
  	movl	%cr0, %edx
02a7b425e   H. Peter Anvin   x86 setup: use X8...
40
  	orb	$X86_CR0_PE, %dl	# Protected mode
7052fdd89   H. Peter Anvin   Code for actual p...
41
  	movl	%edx, %cr0
c4d9ba6da   H. Peter Anvin   x86 setup: make P...
42
  	# Transition to 32-bit mode
7052fdd89   H. Peter Anvin   Code for actual p...
43
  	.byte	0x66, 0xea		# ljmpl opcode
c4d9ba6da   H. Peter Anvin   x86 setup: make P...
44
  2:	.long	in_pm32			# offset
7052fdd89   H. Peter Anvin   Code for actual p...
45
  	.word	__BOOT_CS		# segment
324bda9e4   Cyrill Gorcunov   x86: pmjump - use...
46
  ENDPROC(protected_mode_jump)
c4d9ba6da   H. Peter Anvin   x86 setup: make P...
47
48
  
  	.code32
be721696c   H. Peter Anvin   x86, setup: move ...
49
  	.section ".text32","ax"
324bda9e4   Cyrill Gorcunov   x86: pmjump - use...
50
  GLOBAL(in_pm32)
c4d9ba6da   H. Peter Anvin   x86 setup: make P...
51
52
53
54
55
56
57
58
59
  	# Set up data segments for flat 32-bit mode
  	movl	%ecx, %ds
  	movl	%ecx, %es
  	movl	%ecx, %fs
  	movl	%ecx, %gs
  	movl	%ecx, %ss
  	# The 32-bit code sets up its own stack, but this way we do have
  	# a valid stack if some debugging hack wants to use it.
  	addl	%ebx, %esp
88089519f   H. Peter Anvin   x86 setup: initia...
60
61
  	# Set up TR to make Intel VT happy
  	ltr	%di
c4d9ba6da   H. Peter Anvin   x86 setup: make P...
62
63
64
65
66
67
68
  	# Clear registers to allow for future extensions to the
  	# 32-bit boot protocol
  	xorl	%ecx, %ecx
  	xorl	%edx, %edx
  	xorl	%ebx, %ebx
  	xorl	%ebp, %ebp
  	xorl	%edi, %edi
88089519f   H. Peter Anvin   x86 setup: initia...
69
70
  	# Set up LDTR to make Intel VT happy
  	lldt	%cx
c4d9ba6da   H. Peter Anvin   x86 setup: make P...
71
  	jmpl	*%eax			# Jump to the 32-bit entrypoint
324bda9e4   Cyrill Gorcunov   x86: pmjump - use...
72
  ENDPROC(in_pm32)