]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/Library/LoadLinuxLib/X64/JumpToKernel.asm
bcf6260e1df1c6a636b5bea359b48c95c1799e6b
[mirror_edk2.git] / OvmfPkg / Library / LoadLinuxLib / X64 / JumpToKernel.asm
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 .code
16
17 ;------------------------------------------------------------------------------
18 ; VOID
19 ; EFIAPI
20 ; JumpToKernel (
21 ; VOID *KernelStart, // rcx
22 ; VOID *KernelBootParams // rdx
23 ; );
24 ;------------------------------------------------------------------------------
25 JumpToKernel PROC
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 mov rsi, rdx
30 push rcx
31
32 ; Jump into the compatibility mode CS
33 push 10h
34 lea rax, @F
35 push rax
36 DB 048h, 0cbh ; retfq
37
38 @@:
39 ; Now in compatibility mode.
40
41 DB 0b8h, 018h, 000h, 000h, 000h ; movl $0x18, %eax
42 DB 08eh, 0d8h ; movl %eax, %ds
43 DB 08eh, 0c0h ; movl %eax, %es
44 DB 08eh, 0e0h ; movl %eax, %fs
45 DB 08eh, 0e8h ; movl %eax, %gs
46 DB 08eh, 0d0h ; movl %eax, %ss
47
48 ; Disable paging
49 DB 00fh, 020h, 0c0h ; movl %cr0, %eax
50 DB 00fh, 0bah, 0f8h, 01fh ; btcl $31, %eax
51 DB 00fh, 022h, 0c0h ; movl %eax, %cr0
52
53 ; Disable long mode in EFER
54 DB 0b9h, 080h, 000h, 000h, 0c0h ; movl $0x0c0000080, %ecx
55 DB 00fh, 032h ; rdmsr
56 DB 00fh, 0bah, 0f8h, 008h ; btcl $8, %eax
57 DB 00fh, 030h ; wrmsr
58
59 ; Disable PAE
60 DB 00fh, 020h, 0e0h ; movl %cr4, %eax
61 DB 00fh, 0bah, 0f8h, 005h ; btcl $5, %eax
62 DB 00fh, 022h, 0e0h ; movl %eax, %cr4
63
64 DB 031h, 0edh ; xor %ebp, %ebp
65 DB 031h, 0ffh ; xor %edi, %edi
66 DB 031h, 0dbh ; xor %ebx, %ebx
67 DB 0c3h ; ret
68
69 JumpToKernel ENDP
70
71 END