]> git.proxmox.com Git - mirror_edk2.git/blame - 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
CommitLineData
3c0a051f 1#------------------------------------------------------------------------------\r
2#\r
a205121e 3# Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
3c0a051f 4#\r
5# This program and the accompanying materials\r
6# are licensed and made available under the terms and conditions of the BSD License\r
7# which accompanies this distribution. The full text of the license may be found at\r
8# http://opensource.org/licenses/bsd-license.php.\r
9#\r
10# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12#\r
13#------------------------------------------------------------------------------\r
14\r
15ASM_GLOBAL ASM_PFX(JumpToKernel)\r
dd71f6e2 16ASM_GLOBAL ASM_PFX(JumpToUefiKernel)\r
3c0a051f 17\r
18#------------------------------------------------------------------------------\r
19# VOID\r
20# EFIAPI\r
21# JumpToKernel (\r
22# VOID *KernelStart, // %rcx\r
23# VOID *KernelBootParams // %rdx\r
24# );\r
25#------------------------------------------------------------------------------\r
26ASM_PFX(JumpToKernel):\r
61a114ba 27\r
28 // Set up for executing kernel. BP in %esi, entry point on the stack\r
29 // (64-bit when the 'ret' will use it as 32-bit, but we're little-endian)\r
3c0a051f 30 movq %rdx, %rsi\r
61a114ba 31 pushq %rcx\r
32\r
33 // Jump into the compatibility mode CS\r
34 pushq $0x10\r
1bbb88c9 35 leaq 1f(%rip), %rax\r
61a114ba 36 pushq %rax\r
96cc1800 37 .byte 0x48, 0xcb // retfq\r
61a114ba 38\r
391: // Now in compatibility mode\r
40.code32\r
41 movl $0x18, %eax\r
42 movl %eax, %ds\r
43 movl %eax, %es\r
44 movl %eax, %fs\r
45 movl %eax, %gs\r
46 movl %eax, %ss\r
47\r
48 // Disable paging\r
49 movl %cr0, %eax\r
50 btcl $31, %eax\r
51 movl %eax, %cr0\r
52\r
53 // Disable long mode in EFER\r
54 movl $0x0c0000080, %ecx\r
55 rdmsr\r
56 btcl $8, %eax\r
57 wrmsr\r
58\r
59 // Disable PAE\r
60 movl %cr4, %eax\r
61 btcl $5, %eax\r
62 movl %eax, %cr4\r
63\r
64 // Zero registers and 'return' to kernel\r
65 xorl %ebp, %ebp\r
66 xorl %edi, %edi\r
67 xorl %ebx, %ebx\r
3c0a051f 68 ret\r
61a114ba 69.code64\r
3c0a051f 70\r
dd71f6e2 71#------------------------------------------------------------------------------\r
72# VOID\r
73# EFIAPI\r
74# JumpToUefiKernel (\r
75# EFI_HANDLE ImageHandle, // rcx\r
76# EFI_SYSTEM_TABLE *SystemTable, // rdx\r
77# VOID *KernelBootParams, // r8\r
78# VOID *KernelStart // r9\r
79# );\r
80#------------------------------------------------------------------------------\r
81ASM_PFX(JumpToUefiKernel):\r
82 movq %rcx, %rdi\r
83 movq %rdx, %rsi\r
84 movq %r8, %rdx\r
85 xor %rax, %rax\r
86 movl 0x264(%r8), %eax\r
87 addq %rax, %r9\r
88 addq $0x200, %r9\r
89 callq %r9\r
90 ret\r
91\r