]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/Library/LoadLinuxLib/X64/JumpToKernel.S
OvmfPkg LoadLinuxLib: Use kernel's EFI entry point where available
[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 ASM_GLOBAL ASM_PFX(JumpToUefiKernel)
17
18 #------------------------------------------------------------------------------
19 # VOID
20 # EFIAPI
21 # JumpToKernel (
22 # VOID *KernelStart, // %rcx
23 # VOID *KernelBootParams // %rdx
24 # );
25 #------------------------------------------------------------------------------
26 ASM_PFX(JumpToKernel):
27
28 // Set up for executing kernel. BP in %esi, entry point on the stack
29 // (64-bit when the 'ret' will use it as 32-bit, but we're little-endian)
30 movq %rdx, %rsi
31 pushq %rcx
32
33 // Jump into the compatibility mode CS
34 pushq $0x10
35 leaq 1f(%rip), %rax
36 pushq %rax
37 .byte 0x48, 0xcb // retfq
38
39 1: // Now in compatibility mode
40 .code32
41 movl $0x18, %eax
42 movl %eax, %ds
43 movl %eax, %es
44 movl %eax, %fs
45 movl %eax, %gs
46 movl %eax, %ss
47
48 // Disable paging
49 movl %cr0, %eax
50 btcl $31, %eax
51 movl %eax, %cr0
52
53 // Disable long mode in EFER
54 movl $0x0c0000080, %ecx
55 rdmsr
56 btcl $8, %eax
57 wrmsr
58
59 // Disable PAE
60 movl %cr4, %eax
61 btcl $5, %eax
62 movl %eax, %cr4
63
64 // Zero registers and 'return' to kernel
65 xorl %ebp, %ebp
66 xorl %edi, %edi
67 xorl %ebx, %ebx
68 ret
69 .code64
70
71 #------------------------------------------------------------------------------
72 # VOID
73 # EFIAPI
74 # JumpToUefiKernel (
75 # EFI_HANDLE ImageHandle, // rcx
76 # EFI_SYSTEM_TABLE *SystemTable, // rdx
77 # VOID *KernelBootParams, // r8
78 # VOID *KernelStart // r9
79 # );
80 #------------------------------------------------------------------------------
81 ASM_PFX(JumpToUefiKernel):
82 movq %rcx, %rdi
83 movq %rdx, %rsi
84 movq %r8, %rdx
85 xor %rax, %rax
86 movl 0x264(%r8), %eax
87 addq %rax, %r9
88 addq $0x200, %r9
89 callq %r9
90 ret
91