1 ;------------------------------------------------------------------------------
3 ; Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
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.
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.
13 ;------------------------------------------------------------------------------
18 ;------------------------------------------------------------------------------
22 ; VOID *KernelStart, // rcx
23 ; VOID *KernelBootParams // rdx
25 ;------------------------------------------------------------------------------
26 global ASM_PFX(JumpToKernel)
27 ASM_PFX(JumpToKernel):
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)
34 ; Jump into the compatibility mode CS
41 ; Now in compatibility mode.
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
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
55 ; Disable long mode in EFER
56 DB 0xb9, 0x80, 0x0, 0x0, 0xc0 ; movl $0x0c0000080, %ecx
58 DB 0xf, 0xba, 0xf8, 0x8 ; btcl $8, %eax
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
66 DB 0x31, 0xed ; xor %ebp, %ebp
67 DB 0x31, 0xff ; xor %edi, %edi
68 DB 0x31, 0xdb ; xor %ebx, %ebx
71 ;------------------------------------------------------------------------------
75 ; EFI_HANDLE ImageHandle, // rcx
76 ; EFI_SYSTEM_TABLE *SystemTable, // rdx
77 ; VOID *KernelBootParams // r8
78 ; VOID *KernelStart, // r9
80 ;------------------------------------------------------------------------------
81 global ASM_PFX(JumpToUefiKernel)
82 ASM_PFX(JumpToUefiKernel):