]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/Library/LoadLinuxLib/X64/JumpToKernel.S
edc6e7bd707dd107a0b37b32b721c4166562eea6
[mirror_edk2.git] / OvmfPkg / Library / LoadLinuxLib / X64 / JumpToKernel.S
1 #------------------------------------------------------------------------------
2 #
3 # Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
4 #
5 # This program and the accompanying materials
6 # are licensed and made available under the terms and conditions of the BSD License
7 # which accompanies this distribution. The full text of the license may be found at
8 # http://opensource.org/licenses/bsd-license.php.
9 #
10 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 #
13 #------------------------------------------------------------------------------
14
15 ASM_GLOBAL ASM_PFX(JumpToKernel)
16
17 #------------------------------------------------------------------------------
18 # VOID
19 # EFIAPI
20 # JumpToKernel (
21 # VOID *KernelStart, // %rcx
22 # VOID *KernelBootParams // %rdx
23 # );
24 #------------------------------------------------------------------------------
25 ASM_PFX(JumpToKernel):
26
27 // Set up for executing kernel. BP in %esi, entry point on the stack
28 // (64-bit when the 'ret' will use it as 32-bit, but we're little-endian)
29 movq %rdx, %rsi
30 pushq %rcx
31
32 // Jump into the compatibility mode CS
33 pushq $0x10
34 leaq 1f(%rip), %rax
35 pushq %rax
36 .byte 0x48, 0xcb // retfq
37
38 1: // Now in compatibility mode
39 .code32
40 movl $0x18, %eax
41 movl %eax, %ds
42 movl %eax, %es
43 movl %eax, %fs
44 movl %eax, %gs
45 movl %eax, %ss
46
47 // Disable paging
48 movl %cr0, %eax
49 btcl $31, %eax
50 movl %eax, %cr0
51
52 // Disable long mode in EFER
53 movl $0x0c0000080, %ecx
54 rdmsr
55 btcl $8, %eax
56 wrmsr
57
58 // Disable PAE
59 movl %cr4, %eax
60 btcl $5, %eax
61 movl %eax, %cr4
62
63 // Zero registers and 'return' to kernel
64 xorl %ebp, %ebp
65 xorl %edi, %edi
66 xorl %ebx, %ebx
67 ret
68 .code64
69