]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Library/LoadLinuxLib/X64/JumpToKernel.asm
OvmfPkg LoadLinuxLib: Use kernel's EFI entry point where available
[mirror_edk2.git] / OvmfPkg / Library / LoadLinuxLib / X64 / JumpToKernel.asm
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
15 .code\r
16\r
17;------------------------------------------------------------------------------\r
18; VOID\r
19; EFIAPI\r
20; JumpToKernel (\r
21; VOID *KernelStart, // rcx\r
22; VOID *KernelBootParams // rdx\r
23; );\r
24;------------------------------------------------------------------------------\r
25JumpToKernel PROC\r
26\r
61a114ba 27 ; Set up for executing kernel. BP in %esi, entry point on the stack\r
28 ; (64-bit when the 'ret' will use it as 32-bit, but we're little-endian)\r
29 mov rsi, rdx\r
30 push rcx\r
31\r
32 ; Jump into the compatibility mode CS\r
33 push 10h\r
34 lea rax, @F\r
35 push rax\r
36 DB 048h, 0cbh ; retfq\r
37\r
38@@:\r
39 ; Now in compatibility mode.\r
40\r
41 DB 0b8h, 018h, 000h, 000h, 000h ; movl $0x18, %eax\r
42 DB 08eh, 0d8h ; movl %eax, %ds\r
43 DB 08eh, 0c0h ; movl %eax, %es\r
44 DB 08eh, 0e0h ; movl %eax, %fs\r
45 DB 08eh, 0e8h ; movl %eax, %gs\r
46 DB 08eh, 0d0h ; movl %eax, %ss\r
47\r
48 ; Disable paging\r
49 DB 00fh, 020h, 0c0h ; movl %cr0, %eax\r
50 DB 00fh, 0bah, 0f8h, 01fh ; btcl $31, %eax\r
51 DB 00fh, 022h, 0c0h ; movl %eax, %cr0\r
52\r
53 ; Disable long mode in EFER\r
54 DB 0b9h, 080h, 000h, 000h, 0c0h ; movl $0x0c0000080, %ecx\r
55 DB 00fh, 032h ; rdmsr\r
56 DB 00fh, 0bah, 0f8h, 008h ; btcl $8, %eax\r
57 DB 00fh, 030h ; wrmsr\r
58\r
59 ; Disable PAE\r
60 DB 00fh, 020h, 0e0h ; movl %cr4, %eax\r
61 DB 00fh, 0bah, 0f8h, 005h ; btcl $5, %eax\r
62 DB 00fh, 022h, 0e0h ; movl %eax, %cr4\r
63\r
64 DB 031h, 0edh ; xor %ebp, %ebp\r
65 DB 031h, 0ffh ; xor %edi, %edi\r
66 DB 031h, 0dbh ; xor %ebx, %ebx\r
67 DB 0c3h ; ret\r
3c0a051f 68\r
69JumpToKernel ENDP\r
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
81JumpToUefiKernel PROC\r
82\r
83 mov rdi, rcx\r
84 mov rsi, rdx\r
85 mov rdx, r8\r
86 xor rax, rax\r
87 mov eax, [r8 + 264h]\r
88 add r9, rax\r
89 add r9, 200h\r
90 call r9\r
91 ret\r
92\r
93JumpToUefiKernel ENDP\r
94\r
3c0a051f 95END\r