Commit | Line | Data |
---|---|---|
7052fdd8 PA |
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 | /* | |
7052fdd8 PA |
12 | * The actual transition into protected mode |
13 | */ | |
14 | ||
15 | #include <asm/boot.h> | |
02a7b425 | 16 | #include <asm/processor-flags.h> |
7052fdd8 PA |
17 | #include <asm/segment.h> |
18 | ||
19 | .text | |
20 | ||
21 | .globl protected_mode_jump | |
22 | .type protected_mode_jump, @function | |
23 | ||
24 | .code16 | |
25 | ||
26 | /* | |
27 | * void protected_mode_jump(u32 entrypoint, u32 bootparams); | |
28 | */ | |
29 | protected_mode_jump: | |
7052fdd8 | 30 | movl %edx, %esi # Pointer to boot_params table |
c4d9ba6d PA |
31 | |
32 | xorl %ebx, %ebx | |
33 | movw %cs, %bx | |
34 | shll $4, %ebx | |
35 | addl %ebx, 2f | |
2ee2394b PA |
36 | jmp 1f # Short jump to serialize on 386/486 |
37 | 1: | |
7052fdd8 | 38 | |
7052fdd8 | 39 | movw $__BOOT_DS, %cx |
88089519 | 40 | movw $__BOOT_TSS, %di |
7052fdd8 PA |
41 | |
42 | movl %cr0, %edx | |
02a7b425 | 43 | orb $X86_CR0_PE, %dl # Protected mode |
7052fdd8 PA |
44 | movl %edx, %cr0 |
45 | ||
c4d9ba6d | 46 | # Transition to 32-bit mode |
7052fdd8 | 47 | .byte 0x66, 0xea # ljmpl opcode |
c4d9ba6d | 48 | 2: .long in_pm32 # offset |
7052fdd8 PA |
49 | .word __BOOT_CS # segment |
50 | ||
51 | .size protected_mode_jump, .-protected_mode_jump | |
c4d9ba6d PA |
52 | |
53 | .code32 | |
54 | .type in_pm32, @function | |
55 | in_pm32: | |
56 | # Set up data segments for flat 32-bit mode | |
57 | movl %ecx, %ds | |
58 | movl %ecx, %es | |
59 | movl %ecx, %fs | |
60 | movl %ecx, %gs | |
61 | movl %ecx, %ss | |
62 | # The 32-bit code sets up its own stack, but this way we do have | |
63 | # a valid stack if some debugging hack wants to use it. | |
64 | addl %ebx, %esp | |
65 | ||
88089519 PA |
66 | # Set up TR to make Intel VT happy |
67 | ltr %di | |
68 | ||
c4d9ba6d PA |
69 | # Clear registers to allow for future extensions to the |
70 | # 32-bit boot protocol | |
71 | xorl %ecx, %ecx | |
72 | xorl %edx, %edx | |
73 | xorl %ebx, %ebx | |
74 | xorl %ebp, %ebp | |
75 | xorl %edi, %edi | |
76 | ||
88089519 PA |
77 | # Set up LDTR to make Intel VT happy |
78 | lldt %cx | |
79 | ||
c4d9ba6d PA |
80 | jmpl *%eax # Jump to the 32-bit entrypoint |
81 | ||
82 | .size in_pm32, .-in_pm32 |