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 DEFAULT REL 16 SECTION .text 17 18 ;------------------------------------------------------------------------------ 19 ; VOID 20 ; EFIAPI 21 ; JumpToKernel ( 22 ; VOID *KernelStart, // rcx 23 ; VOID *KernelBootParams // rdx 24 ; ); 25 ;------------------------------------------------------------------------------ 26 global ASM_PFX(JumpToKernel) 27 ASM_PFX(JumpToKernel): 28 29 ; Set up for executing kernel. BP in %esi, entry point on the stack 30 ; (64-bit when the 'ret' will use it as 32-bit, but we're little-endian) 31 mov rsi, rdx 32 push rcx 33 34 ; Jump into the compatibility mode CS 35 push 0x10 36 lea rax, [.0] 37 push rax 38 DB 0x48, 0xcb ; retfq 39 40 .0: 41 ; Now in compatibility mode. 42 43 DB 0xb8, 0x18, 0x0, 0x0, 0x0 ; movl $0x18, %eax 44 DB 0x8e, 0xd8 ; movl %eax, %ds 45 DB 0x8e, 0xc0 ; movl %eax, %es 46 DB 0x8e, 0xe0 ; movl %eax, %fs 47 DB 0x8e, 0xe8 ; movl %eax, %gs 48 DB 0x8e, 0xd0 ; movl %eax, %ss 49 50 ; Disable paging 51 DB 0xf, 0x20, 0xc0 ; movl %cr0, %eax 52 DB 0xf, 0xba, 0xf8, 0x1f ; btcl $31, %eax 53 DB 0xf, 0x22, 0xc0 ; movl %eax, %cr0 54 55 ; Disable long mode in EFER 56 DB 0xb9, 0x80, 0x0, 0x0, 0xc0 ; movl $0x0c0000080, %ecx 57 DB 0xf, 0x32 ; rdmsr 58 DB 0xf, 0xba, 0xf8, 0x8 ; btcl $8, %eax 59 DB 0xf, 0x30 ; wrmsr 60 61 ; Disable PAE 62 DB 0xf, 0x20, 0xe0 ; movl %cr4, %eax 63 DB 0xf, 0xba, 0xf8, 0x5 ; btcl $5, %eax 64 DB 0xf, 0x22, 0xe0 ; movl %eax, %cr4 65 66 DB 0x31, 0xed ; xor %ebp, %ebp 67 DB 0x31, 0xff ; xor %edi, %edi 68 DB 0x31, 0xdb ; xor %ebx, %ebx 69 DB 0xc3 ; ret 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 global ASM_PFX(JumpToUefiKernel) 82 ASM_PFX(JumpToUefiKernel): 83 84 mov rdi, rcx 85 mov rsi, rdx 86 mov rdx, r8 87 xor rax, rax 88 mov eax, [r8 + 0x264] 89 add r9, rax 90 add r9, 0x200 91 call r9 92 ret 93 94